ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
EDIT: If I add a small delay before the
goal_publisher.publish(goal)
line then the message gets published.
This is something that has come up many times and that makes me wonder whether we should add this to the wiki about Publishers and Subscibers in some form.
Setting up connections between publishers and subscibers takes time. Subscibers connect to publishers directly, not to the Master, nor does the Master buffer messages, so even if you start your subscriber before your publisher there is a non-zero amount of time needed for the two to connect.
If there are no connections, any message you publish will be dropped and won't reach anyone.
In your publisher program, you don't give any potentially interested subscribers any time to set up a connection, so it is most likely your PoseStamped
message is dropped.
You have two options:
edit
you've already done that, but you did it time based. It's always nicer to do things state based, which in this case means: look at the nr of subscribers and if there is at least one (or any other number) then publish your message. You can use Topic::get_num_connections for that in rospy
.