Robotics StackExchange | Archived questions

Subscribe to topic with Tactile message

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 'mysensor' then the whole topic would be "~/mysensor/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?

Asked by K.G. on 2016-02-26 07:27:51 UTC

Comments

Answers

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
}

Asked by chapulina on 2016-02-26 13:15:18 UTC

Comments

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.

Asked by K.G. on 2016-02-26 13:42:08 UTC

Comments

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

Asked by K.G. on 2016-02-26 14:01:47 UTC