Problem with simple subscriber in CPP [closed]
Hi,
I tried writing a simple subscriber to /amcl_pose in CPP following this tutorial <http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber(c++)>; but it doesn't work: the Callback function never seems to be called. I am setting AMCL poses through rviz, and I can see data if I use rostopic echo /amcl_pose, but not through the subscriber node. My code looks like this.
#include "ros/ros.h"
#include "geometry_msgs/PoseStamped.h"
#include "geometry_msgs/PoseWithCovariance.h"
void receiveAmcl(const boost::shared_ptr<const geometry_msgs::PoseWithCovariance> amcl_pose)
{
ROS_INFO("I heard something"); // This is never printed
//Some more code goes here, haven't included it yet
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "subscriber");
ros::NodeHandle n;
ros::Subscriber amcl_sub = n.subscribe<geometry_msgs::PoseWithCovariance>("amcl_pose", 100, receiveAmcl);
ros::spin();
return 0;
}
It'd be helpful if you can let me know what I'm missing/doing wrong.
Thanks, Sai