Rosanswers logo


It is not clear to me what the difference between costmap2d and OccupancyGrid is.

From what I learned in Tutorials, OccupancyGrid will be formed using gmapping and it will have three values: 0 for free space, 100 for obstacle, and -1 for unknown. This map will be used later for navigation.

But in navigation stack, it says that global planner uses costmap2d to make a plan and not the occupancyGrid and that costmap2D has also three values for free, occupied and unknown.

So, may questions are: 1- What is the difference between Costmap2D and OccupancyGrid 2- How to convert from one to another and where this is done? 3- Why Global Planner does not use OccupancyGrid, which seems to provide similar information to Costmap2D

Any clarification of these will be appreciated.



Originally posted by Anis on ROS Answers with karma: 253 on 2013-04-04

Post score: 4

Original comments

Comment by joq on 2013-04-05:
I agree that the names are confusing.


1 Answer 1


Rosanswers logo

nav_msgs/OccupancyGrid is a ROS message. This is a map that can be passed around between tools, namely gmapping/karto, amcl, and move_base.

costmap2d is a ROS package, which offers a costmap generation tool, which in fact is really 2.5D. That is, it does raytracing from sensor data into a 3d-voxel map, but it outputs a 2d costmap. It is mainly used via a C++ api, not the ROS message api. When used over ROS messages, it posts nav_msgs/GridCells on a variety of topics corresponding to obstacles, inflated obstacles, and unknown space.

Now, in the context of global planner, all planners use the C++ costmap2d interface. And thus, the global costmap2d is typically initialized from some map, which is typically received over a latched topic using nav_msgs/OccupancyGrid. The costmap2d then can do things needed for planning, like inflating obstacles or adding sensor data to the costmap if desired/configured as such.

Originally posted by fergs with karma: 13902 on 2013-04-05

This answer was ACCEPTED on the original site

Post score: 9


Your Answer

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