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

When to use publisher queue size vs. subscriber queue size

asked 2015-11-23 03:08:01 -0600

updated 2015-11-23 03:08:43 -0600

Although most tutorials only discuss the publisher queue size, a subscriber has such a parameter as well. So I'm wondering: When to use which queue size?

Actually the subscriber seems to be the natural place for a queue: If new messages arrive and the handler hasn't finished processing the previous message, it decides whether to store or to discard the message.

But what is the purpose of a publisher queue? If I'm understanding the documentation correctly, it manages whether to publish or to discard a message if any subscriber is still busy.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-11-23 04:42:28 -0600

Dimitri Schachmann gravatar image

As far as I understand it, when you call publish it does not block until the message is actually sent, but places the message in the publish queue and returns immediately. When your function, in which you called publish returns, it is up to ROS (via ros::spin()) to decide what to call next. Possibly to actually serialize and send your message, but there could be other stuff to do, e.g. processing an incoming message or publishing other messages.

Hence you need a queue and published messages could be dropped if there is too much load, form receiving and/or publishing too many messages.

edit flag offensive delete link more



Publish queues may also help on low-bandwidth and high-latency communication channel, which is the last bottleneck before a message reach a subscriber.

Boris gravatar image Boris  ( 2015-11-23 10:13:22 -0600 )edit

Question Tools

1 follower


Asked: 2015-11-23 03:08:01 -0600

Seen: 2,614 times

Last updated: Nov 23 '15