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

seeking in a bag file

asked 2013-03-30 15:34:29 -0500

brice rebsamen gravatar image

updated 2013-03-30 15:39:52 -0500

I am going to work with large bag files, offline. I am going to have to seek back and forth in the bag to find the data I need, i.e. some sort of random access. Before I start working on a hack of my own, I'd like to know if there is any standard approach implemented out there. Let say the goal is to be able to retrieve a message on topic X, at or near time T.

Note: this question is related:

I am thinking that I could open a new View with the proper query (X,T). But I am wondering how long will it take. i.e. when opening a view, is it reading an index to open it in a constant time, or is it going to scan through the bag until it finds it?

edit retag flag offensive close merge delete



Did you finally found a solution ? Because I could be very interesting (for me, but also for everyone) if you could share what you found/did :-) Thanks !

Stephane.M gravatar image Stephane.M  ( 2013-06-11 21:52:22 -0500 )edit

It's still on my todo list. Once done i'll post my solution here (probably a couple of months)

brice rebsamen gravatar image brice rebsamen  ( 2013-06-12 06:57:23 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-05-16 12:42:15 -0500

It looks to me like most of the work in a view query happens in View::updateQueries. In particular, it uses std::lower_bound and std::upper_bound to find the desired ranges by searching over a timestamp index. My C++ reference states that these are binary searches, with O(log N) complexity. If you look in Bag::doWrite, you can see this index being updated as new data is written to the bag file.

The other question you reference addresses time to load a bag-file from disk, but not time to seek within that bag file once loaded. I haven't tested it, but (at first glance) it looks like view queries should be fairly quick, even in large bag files.

edit flag offensive delete link more

answered 2013-05-16 09:13:01 -0500

tfoote gravatar image

There's an API for both C++ and Python Rosbag Code API Documentation

edit flag offensive delete link more


yes I know, I am asking for the implementation details of the API. I guess I am left with experimenting by myself...

brice rebsamen gravatar image brice rebsamen  ( 2013-05-16 09:37:12 -0500 )edit

Question Tools



Asked: 2013-03-30 15:34:29 -0500

Seen: 1,797 times

Last updated: May 16 '13