Gazebo | Ignition | Community
Ask Your Question
0

Subscribe from C++ external file

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

vcparedesc gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

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

vcparedesc gravatar image

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

`gazebo/<node_parent_name>/robot/JointState`

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

`gazebo/<another_node_name>/robot/JointState`

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

edit flag offensive delete link more

Comments

HI, I am trying to write a simple subscriber. I am pretty much a beginner with Gazebo and with C++. Here is my question. http://answers.gazebosim.org/question/2676/simple-subscribing-plugin/ Can you please help me with it. Any help is appreciated. Thanks

Bharadwaj Ramesh gravatar imageBharadwaj Ramesh ( 2013-05-07 15:34:44 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 317 times

Last updated: Feb 15 '13