grid_map icon indicating copy to clipboard operation
grid_map copied to clipboard

How to convert grid map from Elevation Mapping to CostMap2D?

Open Aishkrish18 opened this issue 2 years ago • 3 comments

Hello, I am new to this repository and I see that we can convert any kind of grid map to occupancy grids/costmap2D . I also see these convertors in many of the issues on how to do it. But I dont understand how exactly do I execute this? Do i write my own separate launch files to do this?

Aishkrish18 avatar Sep 20 '23 16:09 Aishkrish18

You can use the grid_map_visualization node to convert a grid map topic into several others including an occupancy grid. Most of the grid_map demos do this in their launch file.

Also, you can include grid_map_ros/GridMapRosConvertor.hpp to convert a grid_map to other ros representations including a costmap2d.

deweykai avatar Nov 10 '23 03:11 deweykai

Thank you for your reply. Honestly, I am quite versatile with python and ros and not with c ++ and im quite unsure how to use this node from the repo, could you please explain a bit elaborately so that I can try it out? I am currently working on my thesis and it would be really helpful for me to implement this.

Thanks!

Aishkrish18 avatar Nov 30 '23 10:11 Aishkrish18

Looking at it again, the toCostmap function is only available in the ros2 branch. You can use the grid_map_visualization node to output a occupancy grid like shown here (launch) for traversability. Then use a costmap_2d_node with a static layer listening to the occupancy grid topic.

Or if you want to directly output a costmap2d. I think you can use Costmap2DConverter. Pseudo code:

// variables
grid_map::GridMap map;
costmap_2d::Costmap2D outputMap;
grid_map::Costmap2DConverter<grid_map::GridMap> converter;

// initialize
converter.initializeFromGridMap(grid, costmap);

// create costmap
converter.setCostmap2DFromGridMap(grid, "layer name", costmap);

deweykai avatar Nov 30 '23 20:11 deweykai