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

There are two ways you can improve the behavior of your processing:

Play the bag file slower

rosbag has this functionnality, check rosbag play --help

  -r FACTOR, --rate=FACTOR
                        multiply the publish rate by FACTOR

This will play your bag file 2 times slower than the original timings:

rosbag play -r 0.5 large_bag_file.bag

Increase the queue size of your subscriber

http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29#roscpp_tutorials.2BAC8-Tutorials.2BAC8-WritingPublisherSubscriber.The_Code_Explained-1

Each subscriber has a fixed queue size, when a message arrives it is put in the queue and processed whenever your subscriber callback is available (the callback cannot be run in parallel). If you process messages slower than the rate of incoming messages the queue will grow. If it reaches it's limit messages will start being thrown away.


If you tweak the publish rate and queue size you will be able to process all the messages, as fast as your machine can. Unfortunately there seems to be no easy way to detect that a subscriber is throwing away messages (= checking the queue size).