ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Here is my standard response:
There are two ways of communicating in ROS: publish/subscribe and services.
ROS is a publish/subscribe system. Think of it like watching live TV. If you tune in 5 minutes late, you miss the five minutes. There may be infinitely many subscribers, so a publisher can neither wait nor guarantee that every subscriber hears the message. In your program, the subscriber doesn't hear the message because it tunes in after your publisher publishes its first message.
In the ROS system, you are expect to either:
a) keep publishing a message at a certain rate
b) use 'latching', which, like a computer circuit, latches the value on the publisher until it publishes a new message.
If you wish to guarantee a single message is delivered, you should be using services. With services, the service client knows there is only a single service provider. Thus, there is a contract that the service request message will be delivered, or an error will be provided.