Rosanswers logo

Hi all,

Acording to http://wiki.ros.org/costmap_2d it takes in sensor data from the world and builds a 2D occupancy grid of the data. I have a published topic: /scan (sensor_msgs/LaserScan) and I want to use costmap_2d to provide a current occupancy grid. (sensor data --> [2d costmap] --> 2d occupancy grid)

But the same reference (http://wiki.ros.org/costmap_2d) says:

  • Subscribed Topics:
  1. /footprint (geometry_msgs/Polygon)
  • Published Topics:
  1. /grid (nav_msgs/OccupancyGrid)
  2. /grid_updates (nav_msgs/OccupancyGridUpdate)
  3. /voxel_grid (costmap_2d/VoxelGrid)

It seems the costmap_2d doesn't subscribe the (sensor_msgs/LaserScan) that I have it published. The only subscribed topic for costmap_2d is: /footprint (geometry_msgs/Polygon). What should I do to have /scan topic subscribed to costmap_2d node? (I'm trying to use standalone costmap_2d node)


Originally posted by AliAs on ROS Answers with karma: 63 on 2014-08-26

Post score: 2


1 Answer 1


Rosanswers logo

You can't run costmap_2d as a node, however you can write your own node that will contain a Costmap2DROS object and little else. As David points out below, you CAN run a costmap_2d node that does this for you.

Check out the API, as well as how the object is typically used in move_base.

Costmaps don't explicitly subscribe to any sensors, they delegate that to layers. Setting up an obstacle layer to subscribe to a laser sensor source is done using parameters, and is described here - http://wiki.ros.org/costmap_2d/Tutorials/Configuring%20Layered%20Costmaps

Originally posted by paulbovbel with karma: 4518 on 2014-08-26

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by AliAs on 2014-08-26:
Thanks Paul. It seems more complicated than I thought. I will proceed with the steps and share the result here.

Comment by David Lu on 2014-08-26:
You are incorrect on the first point, Paul. You can run it as its own node. https://github.com/ros-planning/navigation/blob/hydro-devel/costmap_2d/src/costmap_2d_node.cpp

The rest is correct.


Your Answer

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