ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Hello,
As far as I know, there is no publication on a topic if no node has subscribed to it. When there is at least one, message are published depending on the rate of publishing node.
If there are two nodes publishing on the same topic, messages will come one after the other in a non-predictable order. The subscriber will get these messages as they come. It may be conflicting (if you have a movement control node and the teleop node publishing speeds to the low-level controller, your robot may move strangely).
About queues :
ros::Subscriber subscribe(const std::string& topic, uint32_t queue_size, <callback>, const ros::TransportHints& transport_hints = ros::TransportHints());
the queue_size argument tells the node how many messages it should keep before erasing the oldest one. A value of 1 will keep the last message received. I guess that all subscribers having a queue_size on 1 means that you have at most "Nb of Callbacks" messages to process when spinningOnce.
So for you two last questions : subscribing nodes handle their own callbackQueue that is being processed when spinning. It can overflow if publishers are faster that subscribers and callback processing.
I let someone more used to the precise mechanisms of ROS give more details.