Cannot Declare Reference to tf2_msgs::TFMessage
Background:
I had a great callback function in a Gazebo plugin. I declared it with
void OnMsg(ConstVector3dPtr &msg)
and subscribed-to by my plugin's Load function with
subscriber = node->Subscribe("~/eb/vel_cmd", &MyPlugin::OnMsg, this);
Problem:
Instead of subscribing to "~/eb/vel_cmd", I'm subscribing to "/tf", so I need to change the message type of the callback (MyPlugin::OnMsg) to tf2_msgs::TFMessage. I followed the convention of the question in the link below to create a constant pointer for a tf2_msgs::TFMessage message.
http://answers.ros.org/question/21481...
Following the positionCb callback declaration in that code, now my callback is declared with:
private: void OnMsg(const tf2_msgs::TFMessage::ConstPtr& &msg)
I'm getting all kinds of compiling errors, but the biggest problem appears to be "Cannot declare reference to tf2_msgs::TFMessage_<std::allocator<void> >::ConstPtr& {aka class boost::shared_ptr<const tf2_msgs::tfmessage_<std::allocator<void="">>&}' (picture below).
Any ideas on what I'm doing incorrectly?
Compiling Errors:
private: void OnMsg(const tf2_msgs::TFMessage::ConstPtr& &msg) Do you need two ampersands here? Cannot declare reference to ... which is not a typedef or a template type argument I'm no c++ wizard, but it sounds like that might not be a thing you can do because TFMessage doesn't support it?
Thanks for the idea! It turned out that I was using the wrong kind of subscribing options - I was using the Transport objects/methods to connect to ROS messages, when the two are separate communications channels.