ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Gazebo & ROS Subscriber and Publisher C++

asked 2016-06-30 08:51:43 -0500

justinkgoh gravatar image

Hello all, I am new to ROS and I am trying to write a subscriber and publisher c++ code to talk with Gazebo. I want to get the states of each link and be able to publish to each link to control its joint angles.

I was successfully able to control my model in Gazebo via a rostopic pub command and am struggling to write a c++ code to do the same. Similarly, I have not been able to write any code to get the link states. I was able to get code working to subscribe to the /joint_states, but this does not reflect the link states in Gazebo.

Any help would be appreciated!

Ubuntu: 14.04 LTS ROS: Indigo Gazebo: 2.2.3

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-07-01 08:12:59 -0500

kramer gravatar image

It's not clear to me whether a gazebo plugin is necessary for what you want, so decide that before pursuing the following.

If it is, here are a couple gazebo plugin tutorial links (from the link above).

I'm leaving that sparse because I've found the gazebo tutorials to be, let's say, unhelpful -- call it information overload. What did work for me was to look at and learn from already written plugins as examples (like those from the ROS simulation github repository).

edit flag offensive delete link more


I apologize if what I wrote is confusing. I am not a computer science major. Is there anything I can provide that would be helpful in clearing whether I would need a gazebo plugin or not. I would like to stay away from plugins if possible since my programming knowledge is limited.

justinkgoh gravatar image justinkgoh  ( 2016-07-05 09:56:37 -0500 )edit

Update: I was able to get the subscriber working and now I am having issues with the publisher.

justinkgoh gravatar image justinkgoh  ( 2016-07-06 12:26:54 -0500 )edit

A plugin might be needed if the current topics don't provide needed functionality. If your issue is just duplicating CLI commands in code, then disregard my original answer, I mis-interpreted. If, OTOH, the sim isn't publishing link_states, then you might need a plugin.

kramer gravatar image kramer  ( 2016-07-09 09:08:05 -0500 )edit

I managed to get it working without using a plugin. Thanks for your time and help!

justinkgoh gravatar image justinkgoh  ( 2016-07-11 14:53:13 -0500 )edit

hello @jutinkgoh i have the issue, please can you tell me how you did to solve that?

samo gravatar image samo  ( 2018-06-26 08:21:22 -0500 )edit

Question Tools

1 follower


Asked: 2016-06-30 08:51:43 -0500

Seen: 2,131 times

Last updated: Jul 01 '16