ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I think I figured out what your mistake is. The 4th argument in the n.subscribe
method should be the context in which the callback should be called.
That is, instead of
ros::Subscriber ComPose_sub = n.subscribe("/RosAria/pose", 1000, &PioneerData::ComPoseCallback, PioneerData);
you should first instantiate the PioneerData class like this.
PioneerData pioneerData;
Then call the subscriber method with a pointer to the object instance.
ros::Subscriber ComPose_sub = n.subscribe("/RosAria/pose", 1000, &PioneerData::ComPoseCallback, &pioneerData);
It should work. Let me know if it doesn't.
2 | No.2 Revision |
I think I figured out what your mistake is. The 4th argument in the n.subscribe
method should be the context in which the callback should be called.
That is, instead of
ros::Subscriber ComPose_sub = n.subscribe("/RosAria/pose", 1000, &PioneerData::ComPoseCallback, PioneerData);
you should first instantiate the PioneerData class like this.
PioneerData pioneerData;
Then call the subscriber method with a pointer to the object instance.
ros::Subscriber ComPose_sub = n.subscribe("/RosAria/pose", 1000, &PioneerData::ComPoseCallback, &pioneerData);
It should work. Let me know if it doesn't.
EDIT
Also, your ComPoseCallback
method definition should be changed to
void PioneerData::ComPoseCallback(const nav_msgs::Odometry::ConstPtr& msg) { ...