Hi,
I am writing a piece of code which uses the rosbag python API to parse a bag file. It crawls a directory and processes all found bags (searches for *.bag). Basically it looks like this
for filename in *.bag
bag = rosbag.Bag(filename)
for topic, msg, ts in bag.read_messages(...):
# do something
# output something
I am having the problem that I encounter splitted bag files.
splitted_2015-02-05-12-24-43_0.bag
splitted_2015-02-05-12-24-45_1.bag
splitted_2015-02-05-12-24-47_2.bag
As the crawling is done automatically (e.g. every night), I do not have the possibility to manually tell the system which bags belong together. I don't like the idea to add this data manually by e.g. adding another description file.
Skipping the once which end with a number different from 0 is easy. But identifying the next part is hard. With *rosbag play* the user defines all parts to join. A manual solution giving each sequence a different prefix is not suitable as I am working on existing files. Currently I am having a heuristic which looks like this:
1) split the filename into: prefix_dateAndTime_counter.bag
2) get the timestamp of the last message in the current bag
3) check if files exist with name
3.1) prefix_dateAndTime(last timestamp)_(counter+1).bag
3.2) add 1 second to "last timestamp" and retry 3.1
4) if 3.1or 3.2 succeed continue with this file otherwise stop parsing
**Question 1**: Has there been a reason to not include meta information about splitted bags into the bagfile? Some meta data telling e.g. the name of the next bagfile.
For the future I would love to have something like:
- an entry at the end of a bag "this bag continues in xyz.bag"
- or an option to tell *rosbag record* keep the timestamp of the first bag fixed and just change the counter, resulting in something like "date_1.bag date_2.bag ..."
**Question 2**: Anything planned like that for the future?
↧