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

latch=True in rospy.Publisher() appears to have no effect

asked 2013-09-27 06:51:11 -0500

Jim Rothrock gravatar image

I have a joint which I want to move to a position when the robot is initialized. The joint is never moved again. Therefore, I do this:

self._pub = rospy.Publisher("joint/command", Float64, latch=True)
self._pub.publish(45.0)

However, the subscriber (a gazebo_ros_control joint position controller) does not move the joint unless I add a rospy.sleep(1) call between the two statements above. It is my understanding that latch=True should result in the 45.0 message being stored, ready for any future subscribers to joint/command. Is this a bug, or is there something about latching that I don't understand? I'm using ROS Hydro on Ubuntu 12.04 LTS.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-09-27 07:04:36 -0500

Publishers take a non-zero amount of time to register themselves with the master. Trying to publish on a publisher that isn't ready yet will simply result in nothing happening, as you have discovered.

This issue seems to come up fairly frequently here, so it might be worth submitting a ticket for a feature request to issue a warning if trying to use a publisher that isn't ready.

edit flag offensive delete link more

Comments

1

I have added issue #286 to ros/ros_comm.

Jim Rothrock gravatar image Jim Rothrock  ( 2013-09-28 10:08:15 -0500 )edit
1

It turns out that the subscriber is receiving the messages; the lack of joint motion is caused by another problem. For details, go to this issue: https://github.com/ros/ros_comm/issue...

Jim Rothrock gravatar image Jim Rothrock  ( 2013-09-29 19:17:52 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-09-27 06:51:11 -0500

Seen: 5,568 times

Last updated: Sep 27 '13