ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

Revision history [back]

As I mentioned in the answer to your other question, the problem is in the type of the callback argument. Thus, instead of

void handelerInitialPose(geometry_msgs::PoseWithCovarianceStamped msg)


use:

void handelerInitialPose(const geometry_msgs::PoseWithCovarianceStampedConstPtr& msg)


The PoseWithCovarianceStampedConstPtr is a typedef like this:

typedef boost::shared_ptr<geometry_msgs::PoseWithCovarianceStamped> geometry_msgs::PoseWithCovarianceStampedConstPtr


and is generated automagically by ROS message generator.

Also, if you use templated subscriber it will give you an error at compile time as opposed to runtime in your case. So it is better to create subscribers as follows:

subInitialPose = n.subscribe<geometry_msgs::PoseWithCovarianceStamped>("/initialpose", 1, &PublishOdometry::handelerInitialPose, this);


Sorry for my inattention. As @hendrik-_seveq_-wiese suspected, most probably uninitialized pubJointState publisher is causing the problem. Here is a similar question.

As I mentioned in the answer to your other question, the problem is in the type of the callback argument. Thus, instead of

void handelerInitialPose(geometry_msgs::PoseWithCovarianceStamped msg)


use:

void handelerInitialPose(const geometry_msgs::PoseWithCovarianceStampedConstPtr& msg)


The PoseWithCovarianceStampedConstPtr is a typedef like this:

typedef boost::shared_ptr<geometry_msgs::PoseWithCovarianceStamped> geometry_msgs::PoseWithCovarianceStampedConstPtr


and is generated automagically by ROS message generator.

Also, if you use templated subscriber it will give you an error at compile time as opposed to runtime in your case. So it is better to create subscribers as follows:

subInitialPose = n.subscribe<geometry_msgs::PoseWithCovarianceStamped>("/initialpose", 1, &PublishOdometry::handelerInitialPose, this);