ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Publishing commands to custom controller works with rqt_gui but not otherwise

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

Kopper29 gravatar image

Hi I’ve set up a custom position controller to a UR5e robot model based on this guide: https://roboticscasual.com/ros-tutori...

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
0

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

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) 
...
time.sleep(5)
# Test
MoveJnt([1.57, -1.57, 1.57, 0.0, 1.57, -1.57]) #move joints using the above publishers
time.sleep(1.5)
MoveJnt([1.57, -1, 1, 0.0, 1.57, -1.57])
edit flag offensive delete link more

Comments

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

Question Tools

1 follower

Stats

Asked: 2022-03-17 11:13:36 -0500

Seen: 270 times

Last updated: Mar 18 '22