Rosanswers logo

Hello :) i wanna edit costmap data manually. i have x and y location of map data given by hector_mapping. and my costmap_2d_ros_ data is runs ok like this:

costmap_2d_ros_ = new costmap_2d::Costmap2DROS("global_costmap", tfl_);

how can i do?

costmap_2d::Costmap2D costmap_temp;

int map_width = costmap_temp.getSizeInCellsX();
int map_height = costmap_temp.getSizeInCellsY();
int num_map_cells = map_width * map_height;

const unsigned char* occupancy_grid_array;
occupancy_grid_array = costmap_temp.getCharMap();

geometry_msgs::PoseStamped lethal_obstacle;

if(??? QUESTION1 ???)
    ??? QUESTION2 ???=costmap_2d::LETHAL_OBSTACLE;

??? QUESTION3 ??? now convert costmap_2d::Costmap2D (costmap_temp) to costmap_2d::Costmap2DROS.

Originally posted by Mohsen Hk on ROS Answers with karma: 139 on 2013-06-12

Post score: 0


1 Answer 1


Rosanswers logo

One solution is to format your incoming data as a PointCloud and go through existing channels for editing the costmap.

However, if you want to do it in code, you can edit the underlying charMap like this.

unsigned int mx, my;
costmap_temp.worldToMap(point.pose.position.x, point.pose.position.y, &mx, &my);
costmap_temp.setCost(mx, my, LETHAL_OBSTACLE);

Originally posted by David Lu with karma: 10932 on 2013-06-12

This answer was ACCEPTED on the original site

Post score: 3


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.