Ask Your Question
0

republishing a Gazebo topic to a ROS topic

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

wonwon0 gravatar image

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

jayess gravatar image

Hi,

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
@trollius.coroutine
def publish_loop():
    manager = yield From(pygazebo.connect()) 

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

    subscriber = manager.subscribe('/gazebo/default/physics/contacts',
                     'gazebo.msgs.Contacts',
                     callback)

    yield From(subscriber.wait_for_connection())
    while(True):
        yield From(trollius.sleep(1.00))
        print('wait...')
    print(dir(manager))
    import logging

    logging.basicConfig()

    loop = trollius.get_event_loop()
    loop.run_until_complete(publish_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
0

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

wonwon0 gravatar image

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

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_con... Thank you for your input it made me rethink about my whole approach.

edit flag offensive delete link more

Comments

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 -0500 )edit
1

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

gvdhoorn gravatar image

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

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

Comments

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 -0500 )edit
1

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 -0500 )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 -0500 )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

Stats

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

Seen: 1,411 times

Last updated: Jan 24 '18