subscribe to a message with a pointer
Hey there,
I have:
Header (snipped):
protected:
#include <geometry_msgs/PoseWithCovarianceStamped.h>
void inputPoseCb(const geometry_msgs::PoseWithCovarianceStampedConstPtr& msg);
geometry_msgs::PoseWithCovarianceStampedConstPtr input_pose_;
ros::Subscriber sub_pose1_;
Source code (snipped):
//..
sub_pose1_ = nh.subscribe("/cam_pose_in_world", 1, &SimpleKfNode::inputPoseCb, this);
//...
void SimpleKfNode::inputPoseCb(const geometry_msgs::PoseWithCovarianceStampedConstPtr& msg)
{
input_pose_ = msg;
ROS_INFO("Received a pose");
}
my code compiles fine however I get this runntime error:
/usr/include/boost/smart_ptr/shared_ptr.hpp:648: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = const geom
etry_msgs::PoseWithCovarianceStamped_<std::allocator<void> >; typename boost::detail::sp_member_access<T>::type = const geometry_msgs::PoseWithCovarianceStamped_<std::allocator
<void> >*]: Assertion `px != 0' failed.
However without pointers it works fine (no runtime error) Header (snipped):
protected:
#include <geometry_msgs/PoseWithCovarianceStamped.h>
void inputPoseCb(geometry_msgs::PoseWithCovarianceStamped msg);
geometry_msgs::PoseWithCovarianceStamped input_pose_;
ros::Subscriber sub_pose1_;
Source code (snipped):
//..
sub_pose1_ = nh.subscribe("/cam_pose_in_world", 1, &SimpleKfNode::inputPoseCb, this);
//...
void SimpleKfNode::inputPoseCb(geometry_msgs::PoseWithCovarianceStamped msg)
{
input_pose_ = msg;
ROS_INFO("Received a pose");
}
What is the problem here why do I get a runntime error using pointers to subscribe a message?