Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I got it to work using this code:

# -*- coding: utf-8 -*-
"""
Created on Mon Nov 24 19:23:30 2014

@author: morten
"""

import pygazebo
import pygazebo.msg.joint_cmd_pb2

import trollius
from trollius import From

#import pygazebo
#import pygazebo.msg.joint_cmd_pb2

@trollius.coroutine
def publish_loop():
    manager = yield From(pygazebo.connect())

    publisher = yield From(
    manager.advertise('/gazebo/default/my_robot/joint_cmd',
                      'gazebo.msgs.JointCmd'))

    message = pygazebo.msg.joint_cmd_pb2.JointCmd()
    message.name = 'my_robot::left_wheel_hinge'
    message.axis = 0
    message.force = 1.0

    while True:
    yield From(publisher.publish(message))
    yield From(trollius.sleep(1.0))

loop = trollius.get_event_loop()
loop.run_until_complete(publish_loop())