Ask Your Question

republishing a Gazebo topic to a ROS topic

asked 2018-01-23 15:28:08 -0600

wonwon0 gravatar image

updated 2018-01-23 16:13:35 -0600

jayess gravatar image


I'm currently working on trying to get a gazebo topic into the ROS topic list so I can access it through the matlab interface with ROS.

Right now I managed to create a subscriber to the gazebo topic in question (gazebo/default/physics/contacts) but I can't figure out exactly what type of ROS message it is to allow me to publish it again in ROS.

Here is the code:

import trollius
from trollius import From

import pygazebo
import pygazebo.msg.contacts_pb2
def publish_loop():
    manager = yield From(pygazebo.connect()) 

    def callback(data):
        message = pygazebo.msg.contacts_pb2.Contacts.FromString(data)

    subscriber = manager.subscribe('/gazebo/default/physics/contacts',

    yield From(subscriber.wait_for_connection())
        yield From(trollius.sleep(1.00))
    import logging


    loop = trollius.get_event_loop()

So, my problem could be solved in two ways:

  1. Figuring out a way to find the corresponding essage type in ROS to publish it.
  2. Figuring out a simpler way to do what i want to do.

Currently I'm working on both possibilities but I'm having a hard time...

Thank you for your help!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-01-30 12:14:40 -0600

wonwon0 gravatar image

updated 2018-01-30 12:15:28 -0600

I have implemented a ros package that subscribes to gazebo and publishes a custom message with the wanted info. I use the transport library provided by gazebo. Thank you for your input it made me rethink about my whole approach.

edit flag offensive delete link more


As this has solved your problem for you, I've made your answer the accepted one.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-30 12:35:02 -0600 )edit

answered 2018-01-24 03:37:08 -0600

gvdhoorn gravatar image

updated 2018-01-24 03:37:23 -0600

I'm not sure, but I believe that if there are specific messages that could mirror the Gazebo message structures they would be in gazebo_msgs. Message/service documentation here.

For /gazebo/default/physics/contacts that could probably be the ContactsState message (but you'd have to verify that).

I'm again unsure, but aren't those already published as ROS messages by Gazebo, if you load have the gazebo_ros plugins?

edit flag offensive delete link more


thank you for your answer, I will look into the documentation you provided. I am new to ROS and gazebo so maybe my problem is just a misunderstanding of the tools at my disposal.

Anyway, I will post an update if I figure what is my error.

How may I verify that I started gazebo_ros and not gazebo?

wonwon0 gravatar image wonwon0  ( 2018-01-24 08:20:54 -0600 )edit

You can probably start here: wiki/gazebo_ros_pkgs.

Note: gazebo_ros is a package, not a different version of Gazebo. It just integrates Gazebo with ROS. In some ways similar to what you have done with your Python script.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-24 11:14:07 -0600 )edit

I see what you are talking about. But I actually have some gazebo topics in the ros topics list. The thing is I dont see all the topics listed in gazebo topic list. gazebo/default/physics/contacts is one of the topics i dont see published in the ros topics. All the example only use the basic topics.

wonwon0 gravatar image wonwon0  ( 2018-01-24 12:08:39 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-01-23 15:28:08 -0600

Seen: 1,584 times

Last updated: Jan 24 '18