Subscribing to global_costmap
I have been trying out the navigation stack with the turtlebot tutorial. My objective is to be able to write a node (ex: costmapsubscribernode.cpp) which subscribes to /movebase/globalcostmap/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 =
nh.subscribe("/move_base/global_costmap/costmap_update",100,occupancygrid_callback);
ros::Rate rate(60);
while(nh.ok()){
ros::spinOnce();
rate.sleep();
}
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.
Update
- 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)
Asked by gpldecha on 2016-11-12 13:14:16 UTC
Comments
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?Asked by 130s on 2016-11-14 07:14:18 UTC
I updated the description of the question to make it clear: I am writing my own node.
Asked by gpldecha on 2016-11-14 07:22:47 UTC
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 trailings
in the subscriber...Asked by mgruhler on 2016-11-15 02:15:42 UTC