Rule of thumb for topic queue size

Is there a rule of thumb for the queue/buffer size for topic messages during publishing? I see in the ROS Basics in 5 Days course that 1000 is used quite a bit. However, on Google I see 10 used frequently. I guess I could control the publishing frequency with ros::spinOnce in a ros::Rate applied while loop and make the queue size slightly bigger than the frequency. Is this the right way to go about it? Any suggestions? Thanks.

Hi,

There isn’t really a rule of thumb. Most of the cases it will work with either 1000 like the course says or 10 like online resources.

You should set a queue_size based on your publishing rate. If you publish faster than your queue size can handle, some messages will be dropped.

Here you can learn more about it:

http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers#Choosing_a_good_queue_size

2 Likes