Home | Tutorials | Wiki | Issues
Ask Your Question

Subscribe to topic with Tactile message

asked 2016-02-26 06:27:51 -0500

K.G. gravatar image

Hi there,

I have a problem when subscribing to the tactile message. I have used topics and messages and am able to subscribe to default messages or custom messages that I have defined. However, I want to subscribe to the Tactile message now - I have a contact sensor in my model that uses the PressurePlugin and I want to subscribe the Tactile message so that I can get the data from it, such as the pressure. From PressurePlugin.cc I saw that it will advertise the Tactile message on a topic that starts with the name of the sensor - if my sensor was called 'my_sensor' then the whole topic would be "~/my_sensor/tactile". This is what I am using in my plugin, but it fails compilation and the problem is the Subscribe method. How can I successfully subscribe to the tactile message from the PressurePlugin?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2016-02-26 12:15:18 -0500

Can you describe the compilation problem you're experiencing?

It should be able to setup a subscriber like this:

this->tactileSub = this->node->Subscribe("~/my_sensor/tactile", &MyClass::OnTactileMsg, this);

And the callback would be like this:

void MyClass::OnTactileMsg(ConstTactilePtr &_msg)
  // do something
edit flag offensive delete link more

answered 2016-02-26 12:42:08 -0500

K.G. gravatar image

This is exactly how I had done it and the compiler error was on the Subscribe method. I managed to fix it and get it running by defining the type of the message beforehand with:

typedef const boost::shared_ptr< const gazebo::msgs::Tactile> TactilePtr;

And then it was able to subscribe and receive the messages.

edit flag offensive delete link more


I had used just TacticlePtr in my callback instead of ConstTactilePtr, that was my mistake.

K.G. gravatar imageK.G. ( 2016-02-26 13:01:47 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-02-26 06:27:51 -0500

Seen: 116 times

Last updated: Feb 26 '16