Home | Tutorials | Wiki | Issues
Ask Your Question
0

Cannot control joint from pygazebo

asked 2015-07-02 10:39:24 -0500

Skylion gravatar image

updated 2015-07-02 10:44:02 -0500

So I am trying to control a joint from the following world file: exported.world

While I can move the joint with the following command via terminal

gz joint -m 'default_body' -j hingejoint0 -f 10000

I cannot move the same joint with the following python script using PyGazebo:

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/model/joint_cmd',
                          'gazebo.msgs.JointCmd'))

    message = pygazebo.msg.joint_cmd_pb2.JointCmd()
    message.name = 'default_bot::hingejoint0'
    #message.axis = 0
    message.force = 10000

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

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

What am I doing wrong? Am I sending the command to the wrong endpoint? is my message improperly formatted?

I am using Gazebo 4.1.0 on Ubuntu with the Simbody physics engine.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-07-02 10:50:00 -0500

nkoenig gravatar image

I believe you are advertising on the wrong topic. Try:

manager.advertise('/gazebo/world/default_body/joint_cmd', 'gazebo.msgs.JointCmd'))

The topic name is /gazebo/WORLDNAME/MODELNAME/joincmd. In your case WORLD_NAME="world", and MODEL_NAME="defaultbody", based on your SDF file.

edit flag offensive delete link more

Comments

Thank you, I just submitted a pull request to the repo to update their example code for those unfamiliar with how topics are generated.

Skylion gravatar imageSkylion ( 2015-07-02 12:07:43 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2015-07-02 10:39:24 -0500

Seen: 6,304 times

Last updated: Jul 02 '15