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/velcmd", I'm subscribing to "/tf", so I need to change the message type of the callback (MyPlugin::OnMsg) to tf2msgs::TFMessage. I followed the convention of the question in the link below to create a constant pointer for a tf2_msgs::TFMessage message.
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 tf2msgs::TFMessagestd::allocator<void >::ConstPtr& {aka class boost::sharedptr<const tf2msgs::TFMessage_std::allocator<void>&}' (picture below).
Any ideas on what I'm doing incorrectly?
Compiling Errors:
Asked by ElizabethA on 2016-11-02 09:36:16 UTC
Answers
My question was answered on the Gazebo forum.
See http://answers.gazebosim.org/question/14768/cannot-declare-reference-to-tf2_msgstfmessage/
I ended up needing to use ROS subscribing methods, as used here: http://gazebosim.org/tutorials?tut=guided_i6
Asked by ElizabethA on 2016-11-04 08:51:59 UTC
Comments
I also had to update my CMakeLists and add SET(CMAKE_CXX_FLAGS "-std=c++11") to get the 'auto' and 'thread' stuff to compile.
Asked by ElizabethA on 2016-11-04 09:12:46 UTC
Comments
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?
Asked by Robot_Cpak on 2016-11-02 10:16:07 UTC
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.
Asked by ElizabethA on 2016-11-04 08:51:05 UTC