Rosanswers logo


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!

Originally posted by wonwon0 on ROS Answers with karma: 73 on 2018-01-23

Post score: 0


2 Answers 2


Rosanswers logo

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?

Originally posted by gvdhoorn with karma: 86574 on 2018-01-24

This answer was NOT ACCEPTED on the original site

Post score: 1

Original comments

Comment by wonwon0 on 2018-01-24:
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?

Comment by gvdhoorn on 2018-01-24:
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.

Comment by wonwon0 on 2018-01-24:
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.


Rosanswers logo

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. https://github.com/wonwon0/gazebo_contact_republisher Thank you for your input it made me rethink about my whole approach.

Originally posted by wonwon0 with karma: 73 on 2018-01-30

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by gvdhoorn on 2018-01-30:
As this has solved your problem for you, I've made your answer the accepted one.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.