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

Probably the biggest issue is that rosbag does not subscribe to your topics in time. When recording all topics (rosbag -a), rosbag has to poll the master periodically to discover new topics, so it may miss initial messages on any topic. In this case, you're publishing in a quick burst, so it may even miss all the messages on some topics.

Your hypothesis is also possible. rosbag uses an internal buffer of 256MB by default, which you might be filling up before rosbag can write everything to disk. You can use an infinite buffer instead (rosbag --buffize=0), though that's not recommended for any live system.

So in theory, you could make your setup work by giving rosbag an infinite buffer and explicitly telling it which topics to record. You'd probably also want your simulator to sleep for a couple seconds after creating the publishers, to give the socket connections the chance to form. Even then you're not 100% guaranteed to get a bag containing every single generated message.

Fortunately, there's a better way! Instead of using the rosbag command-line tool, generate your bag directly from your simulator using the rosbag API. No need to worry about network transport and buffering, you can just write data to a file.

Final note: when using the rosbag API, you don't need to write the /clock messages. When you write a message, you also give a time. On playback, use rosbag play --clock mydata.bag. The rosbag tool will set /use_sim_time=true and publish /clock for you.