Gazebo | Ignition | Community
Ask Your Question

Cannot Declare Reference to tf2_msgs::TFMessage

asked 2016-11-02 09:22:54 -0500

ElizabethA gravatar image


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);


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.

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: image description

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-11-02 10:34:44 -0500

chapulina gravatar image

It looks like you're trying to mix gazebo transport with ROS. A Gazebo subscriber is not able to subscribe to ROS messages and vice-versa. You'll need a ROS node for that.

Here's an example of a ROS subscriber in a Gazebo plugin.

edit flag offensive delete link more



That was the problem! Thanks so much for the example. I also found this link to a Gazebo tutorial, once I knew what to look for, that also helped.

ElizabethA gravatar imageElizabethA ( 2016-11-04 08:31:41 -0500 )edit

Nice find, I looked a bit for a tutorial which mentioned it and couldn't find one. Feel free to accept this answer so others know it solved your issue ;)

chapulina gravatar imagechapulina ( 2016-11-04 12:06:24 -0500 )edit

Question Tools

1 follower


Asked: 2016-11-02 09:22:54 -0500

Seen: 1,187 times

Last updated: Nov 02 '16