Ask Your Question
0

Problem with simple subscriber in CPP [closed]

asked 2013-09-03 13:29:48 -0500

SaiHV gravatar image

updated 2013-09-03 13:44:50 -0500

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

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by SaiHV
close date 2013-09-03 14:15:15

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-09-03 14:14:24 -0500

SaiHV gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-09-03 13:29:48 -0500

Seen: 539 times

Last updated: Sep 03 '13