Subscribing to global_costmap

asked 2016-11-12 12:14:16 -0500

gpldecha gravatar image

updated 2016-11-14 07:07:41 -0500

I have been trying out the navigation stack with the turtlebot tutorial. My objective is to be able to write a node (ex: costmap_subscriber_node.cpp) which subscribes to /move_base/global_costmap/costmap.

Example of node I am trying to write:

#include <ros/ros.h>

void occupancygrid_callback(const nav_msgs::OccupancyGrid::ConstPtr& msg){
      std::cout<< "occupancygrid_callback !! " << std::endl;

int main(int argc, char** argv)

    ros::init(argc, argv, "costmap_subscriber");
    ros::NodeHandle nh;
    ros::Subscriber sub =

    ros::Rate rate(60);


    return 0;

I checked first with the following command:

rostopic echo /move_base/global_costmap/costmap_updates

I get messages published every 5 seconds. The low frequency is the reason for the message:

rostopic hz /move_base/global_costmap/costmap
    subscribed to [/move_base/global_costmap/costmap]
    WARNING: may be using simulated time

However I am still unable to have my ros node callback pick up the messages. Similar problem here costmap-subscribe-problem-in-hydro.


  • I can subscribe to /map
  • Output of roswtf gives :
ERROR The following nodes should be connected but aren't:
* /move_base->/move_base (/move_base/global_costmap/footprint)
* /move_base->/move_base (/move_base/local_costmap/footprint)
edit retag flag offensive close merge delete


Can you be clear about "in my own node"? Do you mean rostopic by that (it's also a node when it's running)? Or are you writing a code for your node?

130s gravatar image 130s  ( 2016-11-14 06:14:18 -0500 )edit

I updated the description of the question to make it clear: I am writing my own node.

gpldecha gravatar image gpldecha  ( 2016-11-14 06:22:47 -0500 )edit

Maybe that is a typo in your question, but based on this, you are subscribing to "/move_base/global_costmap/costmap_update", whereas you are echoing /move_base/global_costmap/costmap_updates. Note the missing trailing s in the subscriber...

mgruhler gravatar image mgruhler  ( 2016-11-15 01:15:42 -0500 )edit