25namespace localization {
27namespace pyramid_map {
60 for (
unsigned int i = 0; i < resolutions_mr_.size(); ++i) {
97 if (create_map_cells) {
103 std::shared_ptr<PyramidMapMatrix> map_matrix =
104 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
105 map_matrix->BottomUpBase();
109 std::shared_ptr<PyramidMapMatrix> map_matrix =
110 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
111 map_matrix->BottomUpSafe();
115 unsigned char intensity,
116 unsigned int level) {
117 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
123 std::shared_ptr<PyramidMapMatrix> map_matrix =
124 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
125 map_matrix->AddSampleBase(
static_cast<float>(intensity),
126 static_cast<float>(coordinate[2]), y, x, level);
134 const std::vector<Eigen::Vector3d>& coordinates,
135 const std::vector<unsigned char>& intensity,
unsigned int level) {
136 if (coordinates.size() != intensity.size()) {
140 for (
unsigned int i = 0; i < coordinates.size(); i++) {
146 unsigned int level,
unsigned int* x,
147 unsigned int* y)
const {
148 std::shared_ptr<PyramidMapMatrix> map_matrix =
149 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
151 const float& current_resolution = resolutions_mr_[level];
153 unsigned int off_x =
static_cast<unsigned int>(
155 unsigned int off_y =
static_cast<unsigned int>(
157 if (off_x < map_matrix->GetCols(level) &&
158 off_y < map_matrix->GetRows(level)) {
168 unsigned int y)
const {
172 float current_resolution =
176 Eigen::Vector2d coord;
177 coord[0] =
left_top_corner_[0] + current_resolution *
static_cast<float>(x);
178 coord[1] =
left_top_corner_[1] + current_resolution *
static_cast<float>(y);
183 unsigned int* x,
unsigned int* y)
const {
187 unsigned int* x,
unsigned int* y)
const {
192 unsigned int y)
const {
197 unsigned int level)
const {
198 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
203 float intensity = 0.0;
205 std::shared_ptr<PyramidMapMatrix> map_matrix =
206 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
207 const float* intensity_ptr = map_matrix->GetIntensitySafe(y, x, level);
209 if (intensity_ptr !=
nullptr) {
210 intensity = *intensity_ptr;
218 unsigned int level)
const {
219 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
224 float intensity_var = 0.0;
226 std::shared_ptr<PyramidMapMatrix> map_matrix =
227 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
228 const float* intensity_var_ptr =
229 map_matrix->GetIntensityVarSafe(y, x, level);
231 if (intensity_var_ptr !=
nullptr) {
232 intensity_var = *intensity_var_ptr;
236 return intensity_var;
240 unsigned int level)
const {
241 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
246 float altitude = 0.0;
248 std::shared_ptr<PyramidMapMatrix> map_matrix =
249 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
250 const float* altitude_ptr = map_matrix->GetAltitudeSafe(y, x, level);
252 if (altitude_ptr !=
nullptr) {
253 altitude = *altitude_ptr;
261 unsigned int level)
const {
262 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
267 float altitude_var = 0.0;
269 std::shared_ptr<PyramidMapMatrix> map_matrix =
270 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
271 const float* altitude_var_ptr = map_matrix->GetAltitudeVarSafe(y, x, level);
273 if (altitude_var_ptr !=
nullptr) {
274 altitude_var = *altitude_var_ptr;
282 unsigned int level)
const {
283 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
288 float ground_altitude = 0.0;
290 std::shared_ptr<PyramidMapMatrix> map_matrix =
291 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
292 const float* ground_altitude_ptr =
293 map_matrix->GetGroundAltitudeSafe(y, x, level);
295 if (ground_altitude_ptr !=
nullptr) {
296 ground_altitude = *ground_altitude_ptr;
300 return ground_altitude;
304 unsigned int level)
const {
305 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
310 unsigned int count = 0;
312 std::shared_ptr<PyramidMapMatrix> map_matrix =
313 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
314 const unsigned int* count_ptr = map_matrix->GetCountSafe(y, x, level);
316 if (count_ptr !=
nullptr) {
325 const Eigen::Vector3d& coordinate,
unsigned int level)
const {
326 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
331 unsigned int ground_count = 0;
333 std::shared_ptr<PyramidMapMatrix> map_matrix =
334 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
335 const unsigned int* ground_count_ptr =
336 map_matrix->GetGroundCountSafe(y, x, level);
338 if (ground_count_ptr !=
nullptr) {
339 ground_count = *ground_count_ptr;
347 unsigned int level)
const {
348 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
353 float intensity = 0.0;
355 std::shared_ptr<PyramidMapMatrix> map_matrix =
356 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
357 const float* intensity_ptr = map_matrix->GetIntensity(y, x, level);
359 if (intensity_ptr !=
nullptr) {
360 intensity = *intensity_ptr;
368 unsigned int level)
const {
369 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
374 float intensity_var = 0.0;
376 std::shared_ptr<PyramidMapMatrix> map_matrix =
377 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
378 const float* intensity_var_ptr = map_matrix->GetIntensityVar(y, x, level);
380 if (intensity_var_ptr !=
nullptr) {
381 intensity_var = *intensity_var_ptr;
385 return intensity_var;
389 unsigned int level)
const {
390 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
395 float altitude = 0.0;
397 std::shared_ptr<PyramidMapMatrix> map_matrix =
398 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
399 const float* altitude_ptr = map_matrix->GetAltitude(y, x, level);
401 if (altitude_ptr !=
nullptr) {
402 altitude = *altitude_ptr;
410 unsigned int level)
const {
411 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
416 float altitude_var = 0.0;
418 std::shared_ptr<PyramidMapMatrix> map_matrix =
419 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
420 const float* altitude_var_ptr = map_matrix->GetAltitudeVar(y, x, level);
422 if (altitude_var_ptr !=
nullptr) {
423 altitude_var = *altitude_var_ptr;
431 unsigned int level)
const {
432 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
437 float ground_altitude = 0.0;
439 std::shared_ptr<PyramidMapMatrix> map_matrix =
440 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
441 const float* ground_altitude_ptr =
442 map_matrix->GetGroundAltitude(y, x, level);
444 if (ground_altitude_ptr !=
nullptr) {
445 ground_altitude = *ground_altitude_ptr;
449 return ground_altitude;
453 unsigned int level)
const {
454 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
459 unsigned int count = 0;
461 std::shared_ptr<PyramidMapMatrix> map_matrix =
462 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
463 const unsigned int* count_ptr = map_matrix->GetCount(y, x, level);
465 if (count_ptr !=
nullptr) {
474 unsigned int level)
const {
475 Eigen::Vector2d coord2d(coordinate[0], coordinate[1]);
480 unsigned int ground_count = 0;
482 std::shared_ptr<PyramidMapMatrix> map_matrix =
483 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
484 const unsigned int* ground_count_ptr =
485 map_matrix->GetGroundCount(y, x, level);
487 if (ground_count_ptr !=
nullptr) {
488 ground_count = *ground_count_ptr;
496 std::shared_ptr<PyramidMapMatrix> map_matrix =
497 std::dynamic_pointer_cast<PyramidMapMatrix>(
map_matrix_);
498 return map_matrix->ComputeMeanIntensity(level);
The options of the reflectance map.
std::vector< float > map_resolutions_
The pixel resolutions in the map in meters.
MapVersion GetMapVersion() const
Get map version.
std::string map_version_
The version of map.
std::shared_ptr< CompressionStrategy > compression_strategy_
@bried The compression strategy.
virtual bool GetCoordinate(const Eigen::Vector2d &coordinate, unsigned int *x, unsigned int *y) const
Given the global coordinate, get the local 2D coordinate of the map cell matrix.
const BaseMapConfig * map_config_
The map settings.
bool is_changed_
Has the map node been changed.
bool is_reserved_
If the node is reserved in map.
static Eigen::Vector2d ComputeLeftTopCorner(const BaseMapConfig &config, const MapNodeIndex &index)
std::shared_ptr< BaseMapMatrixHandler > map_matrix_handler_
The class to load and create map matrix binary.
std::shared_ptr< BaseMapMatrix > map_matrix_
The data structure of the map datas, which is a matrix.
Eigen::Vector2d left_top_corner_
The left top corner of the map node in the global coordinate system.
std::shared_ptr< BaseMapNodeConfig > map_node_config_
The map node config.
virtual void InitMapMatrix(const BaseMapConfig *map_config)
Initialize the map matrix.
unsigned int resolution_num_
unsigned int resolution_ratio_
static BaseMapMatrixHandler * AllocPyramidMapMatrixHandler(MapVersion version)
void BottomUpSafe()
Propagate the data to the coarse resolution by check.
float GetAltitudeVar(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell's variance of the altitude without check.
float GetIntensityVar(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell variance of the intensity without check.
bool GetCoordinate(const Eigen::Vector2d &coordinate, unsigned int level, unsigned int *x, unsigned int *y) const
Given the global coordinate, get the local 2D coordinate of the map cell matrix.
float GetAltitudeVarSafe(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell's variance of the altitude with check.
float GetIntensity(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell intensity without check.
void BottomUpBase()
Propagate the data to the coarse resolution.
unsigned int GetGroundCount(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell's count of the ground samples without check.
unsigned int GetCount(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell's count of the samples without check.
double ComputeMeanIntensity(unsigned int level=0)
Compute mean intensity.
float GetAltitudeSafe(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell's average altitude with check.
unsigned int GetGroundCountSafe(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell's count of the ground samples with check.
unsigned int GetCountSafe(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell's count of the samples with check.
float GetGroundAltitude(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell's average ground altitude without check.
float GetIntensitySafe(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell intensity with check.
float GetIntensityVarSafe(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell variance of the intensity with check.
bool AddValueIfInBound(const Eigen::Vector3d &coordinate, unsigned char intensity, unsigned int level=0)
Add the value of a pixel in the map node if the pixel in the node.
virtual void Init(const BaseMapConfig *map_config)
Initialize the map node.
float GetAltitude(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell's average altitude without check.
float GetGroundAltitudeSafe(const Eigen::Vector3d &coordinate, unsigned int level=0) const
Given the 3D global coordinate, get the map cell's average ground altitude with check.