Rosanswers logo

I have several bags recorded of navigating through an environment, with pauses between each bag from configuring the system. I would like to playback the entire sequence as one smooth continuous sequence. I merged the bags using https://gist.github.com/NikolausDemmel/8944211#file-rosbag_merge-py but there are large time gaps with no ROS messages in the merged bag as seen in the rqt_bag screenshot below.

RQT Bag Screenshot

Is there any easy way to remove these timegaps?


Originally posted by vkee on ROS Answers with karma: 127 on 2017-08-17

Post score: 1

Original comments

Comment by gvdhoorn on 2017-08-17:
I think this would require rewriting the timestamps of all involved msgs across all topics.

Doable, but I'm not aware of a tool that can do this OoB.

The scripts you link by Nikolaus could offer some inspiration for how to approach this.

Comment by vkee on 2017-08-17:
Ah okay, I was hoping to not have to do this.

Comment by gvdhoorn on 2017-08-17:
Well it could be that someone already wrote something for this, but I'm just not aware of it. That's why I commented instead of answering.

Let's see if other board members can come up with something.

But I believe that whatever tool you end up using, it will involve rewriting timestamps.


1 Answer 1


Rosanswers logo

I would like to playback the entire sequence as one smooth continuous sequence.

rosbag play has an option --skip-empty. You specify a maximum gap length in seconds, and it will skip any gaps longer than that. So if you run rosbag play --skip-empty=1.0, rosbag will jump ahead in time instantly whenever it encounters a gap longer than 1 second.

Originally posted by Ed Venator with karma: 1185 on 2017-08-17

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by gvdhoorn on 2017-08-18:
--skip-empty does skip gaps, but I'm wondering whether it fulfils the

playback the entire sequence as one smooth continuous sequence

wish of the OP.

Comment by vkee on 2017-08-18:
@Ed Venator, thanks a lot, this works perfect for me! Strange that this is not in the documentation for rosbag though (http://wiki.ros.org/rosbag/Commandline)...

Comment by Ed Venator on 2017-08-18:
The ROS wiki is often out of date and incomplete. I found the option with rosbag play --help

Comment by gvdhoorn on 2017-08-19:
@vkee: the wiki is dependent on users like you to keep it up to date. It isn't an automatically generated resource.

It would be great if you could edit the page to include the --skip-empty option (and any other missing options).

Comment by vkee on 2017-08-21:
@Ed Venator, I am running into issues using this command. When I handle the messages in a node callback, I am getting the following issue which kills my node:

munmap_chunk(): invalid pointer: 0x00007fffd47a33f0

I am guessing this is related to skipping (as I never had this issue before). Any idea?

Comment by Ed Venator on 2017-08-22:
I've never run into that particular error. It looks like a memory corruption error. What node is throwing that?

Comment by vkee on 2017-08-23:
The node with the callback that handles messages from the bag. It never has that issue if I don't run it with the skip option so I'm wondering if it has to do with the skipping.

Comment by Ed Venator on 2017-08-23:
Without knowing what code's running in that node, I can't say. If it's doing something with time, it's possible that it can't handle large jumps in Ros Time.

Comment by vkee on 2017-08-23:
The only time based operations have to deal with tf lookups, do you think that might cause problems?

Comment by Ed Venator on 2017-08-23:
I don't know if TF can handle large time jumps like that. I wouldn't be surprised if it causes problems, but I wouldn't expect it to cause memory corruption.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.