ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Publishing commands to custom controller works with rqt_gui but not otherwise

asked 2022-03-17 11:13:36 -0600

Kopper29 gravatar image

Hi I’ve set up a custom position controller to a UR5e robot model based on this guide:

I’m using ROS melodic with Gazebo 9.

So far it has seemed to work when using rqt_gui for publishing commands to the different topics e.g. like “/shoulder_lift_joint_position_controller/command”using the Message Publisher. But when I try to publish manually, e.g. via terminal or via a python script, the robot in gazebo does not react, despite I can see the topic changing value (using the rqt_gui Topic Monitor).

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2022-03-18 03:36:41 -0600

Kopper29 gravatar image

I solved the problem, but I can’t say that I understand why it works, as I saw the data published to the correct topics. Still my solution was to wait (e.g. 5s), after setting up the publisher, before publishing.

# Setting up publishers
pSP = rospy.Publisher("/shoulder_pan_joint_position_controller/command", Float64, queue_size=1) 
# Test
MoveJnt([1.57, -1.57, 1.57, 0.0, 1.57, -1.57]) #move joints using the above publishers
MoveJnt([1.57, -1, 1, 0.0, 1.57, -1.57])
edit flag offensive delete link more


The explanation is: if you try to use a publisher object that has not yet established a connection to the topic subscriber(s), the message is discarded. In ROS, the policy is that message delivery is not guaranteed. In my experience, it often takes 10's of milliseconds to connect over wifi.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-03-18 06:34:56 -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: 2022-03-17 11:13:36 -0600

Seen: 94 times

Last updated: Mar 18 '22