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

Revision history [back]

click to hide/show revision 1
initial version

The queue_size is specific to each subscriber. It only controls the 'number of incoming messages to queue up for processing (messages in excess of this queue capacity will be discarded).' (http://docs.ros.org/api/roscpp/html/classros_1_1NodeHandle.html).

You can have multiple subscribers using the same callback function but with different queue sizes.

e.g sub1 and sub2 both use myCallBack() and subscribe to "/mytopic1" and "/mytopic2" respectively, sub1 has queue_size=1, sub2 has queue_size=10

If I publish 15 identical messages "instantaneously" on both topics (faster than the time it takes to complete myCallBack()), you should see 2 calls to myCallBack() corresponding to sub1 for messages 1 (assuming sub1's callback is processed first) and 15, and 10 calls to myCallBack() corresponding to sub2 for messages 6-15.

Also remember that by default, all the callbacks within a node are invoked from a single global callback queue. You can assign separate callback queues for each of your subscribers if that is what you are looking for, but it takes a bit more work (http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning).