Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ROS2: Fast publisher, slow subscriber. Is it possible to slow down the publisher?

Suppose a scenario where a publisher is set to send data at a specific rate, e.g. 10Hz. The subscriber, however, is a slow processor; he might need 200ms to process the published data. It is necessary for the application that the subscriber is processing all messages from the publisher.

The default behaviour of ROS2 seems to be to loose messages, the subscriber will only get each 2nd message.

Is it possible at all to slow down the publisher to ensure that the subscriber will receive all published messages while not buffering messages infinitely? I'd like to set a queue size for the connection and the publisher should block if the queue is full. I played around with various QOS settings, but I did not succeed. It seems that KEEP_LAST is an indication that messages can be dropped. KEEP_ALL, however, buffers all the messages until at some point of time the publisher raises an exception.