Gazebo | Ignition | Community
Ask Your Question

Subscribe from C++ external file

asked 2013-02-15 13:40:36 -0600

vcparedesc gravatar image


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,


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-02-15 16:21:19 -0600

vcparedesc gravatar image

My mistake!!, sorry, I realized that "~/robot/JointState" calls


However, I was in another node, so "~/robot/JointState" was pointing to:


Just in case, if some beginner as me gets confused by a simple error.

edit flag offensive delete link more


HI, I am trying to write a simple subscriber. I am pretty much a beginner with Gazebo and with C++. Here is my question. Can you please help me with it. Any help is appreciated. Thanks

Bharadwaj Ramesh gravatar imageBharadwaj Ramesh ( 2013-05-07 15:34:44 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2013-02-15 13:40:36 -0600

Seen: 293 times

Last updated: Feb 15 '13