Problem with subscribe and callback function
Hi everybody, since my code is really long I will try to keep it minimal
in my program I wrote a class which defines 2 storing variables:
geometry_msgs::PoseWithCovarianceStamped initial_pose_;
geometry_msgs::PoseWithCovarianceStamped pose;
and subscribes to the /initialpose
topic:
ros::topic::waitForMessage<geometry_msgs::PoseWithCovarianceStamped>( "initialpose", ros::Duration( 60.0 ) );
this->pose_sub_ = nh_.subscribe( "initialpose", 10, updateInitialPose );
the callback function has been defined as:
void updateInitialPose( const geometry_msgs::PoseWithCovarianceStamped::ConstPtr& pose )
{
initial_pose_ = pose;
}
but compiling I get all the time the following error:
/home/wilhem/workspace_ros/src/turtlebot_guide/src/main.cpp: In member function ‘void robotMovement::updateInitialPose(const ConstPtr&)’: /home/wilhem/workspace_ros/src/turtlebot_guide/src/main.cpp:45:17: error: no match for ‘operator=’ (operand types are ‘geometry_msgs::PoseWithCovarianceStamped’ and ‘const ConstPtr {aka const boost::shared_ptr<const geometry_msgs::posewithcovariancestamped_<std::allocator<void="">
}’) initial_pose_ = pose; ^ /home/wilhem/workspace_ros/src/turtlebot_guide/src/main.cpp:45:17: note: candidate is: In file included from /home/wilhem/workspace_ros/src/turtlebot_guide/src/main.cpp:10:0: /opt/ros/indigo/include/geometry_msgs/PoseWithCovarianceStamped.h:57:8: note: geometry_msgs::PoseWithCovarianceStamped_<std::allocator<void> & geometry_msgs::PoseWithCovarianceStamped_<std::allocator<void> ::operator=(const geometry_msgs::PoseWithCovarianceStamped_<std::allocator<void> &) struct PoseWithCovarianceStamped_ ^
Even the candidated definitions are to me not really clear. I have already searched through the API and class definitions but I couldnt find a solution. Any help? Thanks in advance