Problem with simple subscriber in CPP
Hi,
I tried writing a simple subscriber to /amclpose 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 /amclpose, 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
Asked by SaiHV on 2013-09-03 13:29:48 UTC
Answers
Solved it, it was just a datatype conflict. The AMCL node was printing this: Client [/subscriber] wants topic /amcl_pose to have datatype/md5sum [geometry_msgs/PoseWithCovariance], but our version has [geometry_msgs/PoseWithCovarianceStamped]. Dropping connection.
Asked by SaiHV on 2013-09-03 14:14:24 UTC
Comments