Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Subscribe from C++ external file

Hi!,

I am a new user of Gazebo and maybe this is a trivial question but I was trying to subscribe a topic from a c++ file, so I basically followed the custom messages tutorial. If I have a plugin and want to subscribe a topic the line that I need is:

subJointStates = nodeController->Subscribe("~/robot/JointState",&UpdateJointState,this);

When I tried to subscribe from the c++ file, I can't use "this", since I don't have a class, I have tried replacing "this" with a boolean value, because the declaration of Subscribe wants a boolean.

I tried both of them

subJointStates = nodeController->Subscribe("~/robot/JointState",&UpdateJointState,true);
subJointStates = nodeController->Subscribe("~/robot/JointState",&UpdateJointState,false);

But, looks like it's not working, should I try a different way to subscribe from a C++ External File?

Thank you,

Victor