Robotics StackExchange | Archived questions

Access specific message in rosbag file

I can get all the messages in my rosbag file through this loop:

BOOST_FOREACH(rosbag::MessageInstance const m, view) {
   //...
}

My rosbag file is a record of images from the Kinect. And I'm trying to get the images from it.

Knowing the size of rosbag, how could I use rosbag::MessageInstance and view to get a specific message (or image) without going through all the messages.

EDIT:

I did a "mecanical" solution but I don't really like it:

I ask the user to choose a number which will correspond to his message (image) knowing the size of the rosbag file. then I run BOOST_FOREACH loop till I get to the message and extract it.

Asked by ROSkinect on 2016-06-21 09:08:43 UTC

Comments

I'd guess you can't, but maybe you can check the source code of rosbag play for how it treats the -s (start time) option. If you could jump to a certain timestamp, it probably would be done there.

Asked by Felix Endres on 2016-06-21 09:41:39 UTC

I'll check it out..

Asked by ROSkinect on 2016-06-22 04:51:51 UTC

Answers