Ask Your Question
1

seeking in a bag file

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

brice rebsamen gravatar image

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

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: http://answers.ros.org/question/10852/playing-back-large-files-with-rosbag/

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

Comments

1

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 imageStephane.M ( 2013-06-11 21:52:22 -0600 )edit

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

brice rebsamen gravatar imagebrice rebsamen ( 2013-06-12 06:57:23 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

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

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
-1

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

tfoote gravatar image

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

edit flag offensive delete link more

Comments

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 imagebrice rebsamen ( 2013-05-16 09:37:12 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 937 times

Last updated: May 16 '13