MCPcopy Create free account
hub / github.com/RoboMaster/RoboRTS / InComingMap

Method InComingMap

roborts_costmap/src/static_layer.cpp:98–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98void StaticLayer::InComingMap(const nav_msgs::OccupancyGridConstPtr &new_map) {
99 unsigned int temp_index = 0;
100 unsigned char value = 0;
101 unsigned int size_x = new_map->info.width, size_y = new_map->info.height;
102 auto resolution = new_map->info.resolution;
103 auto origin_x = new_map->info.origin.position.x;
104 auto origin_y = new_map->info.origin.position.y;
105 auto master_map = layered_costmap_->GetCostMap();
106 if(!layered_costmap_->IsRolling() && (master_map->GetSizeXCell() != size_x || master_map->GetSizeYCell() != size_y ||
107 master_map->GetResolution() != resolution || master_map->GetOriginX() != origin_x || master_map->GetOriginY() != origin_y ||
108 !layered_costmap_->IsSizeLocked())) {
109 layered_costmap_->ResizeMap(size_x, size_y, resolution, origin_x, origin_y, true);
110 } else if(size_x_ != size_x || size_y_ != size_y || resolution_ != resolution || origin_x_ != origin_x || origin_y_ != origin_y) {
111 ResizeMap(size_x, size_y, resolution, origin_x, origin_y);
112 }
113
114 for (auto i = 0; i < size_y; i++) {
115 for (auto j = 0; j < size_x; j++) {
116 value = new_map->data[temp_index];
117 costmap_[temp_index] = InterpretValue(value);
118 ++temp_index;
119 }
120 }
121 map_received_ = true;
122 has_updated_data_ = true;
123 map_frame_ = new_map->header.frame_id;
124 staic_layer_x_ = staic_layer_y_ = 0;
125 width_ = size_x_;
126 height_ = size_y_;
127 if (first_map_only_) {
128 map_sub_.shutdown();
129 }
130}
131
132unsigned char StaticLayer::InterpretValue(unsigned char value) {
133 // check if the static value is above the unknown or lethal thresholds

Callers

nothing calls this directly

Calls 9

IsRollingMethod · 0.80
GetSizeXCellMethod · 0.80
GetSizeYCellMethod · 0.80
GetResolutionMethod · 0.80
GetOriginXMethod · 0.80
GetOriginYMethod · 0.80
IsSizeLockedMethod · 0.80
GetCostMapMethod · 0.45
ResizeMapMethod · 0.45

Tested by

no test coverage detected