Ask Your Question

Revision history [back]

I dont know for sure what the best solution to your problem is. But just to brainstorm things you might try (I have not tried these myself): Perhaps you could use the filter functionality to make a new bag file containing only the messages you care about. Another option would be to use cut.py script from bag_tools (https://github.com/srv/srv_tools/blob/indigo/bag_tools/scripts/cut.py). Those would be more "direct" in that you would write fewer lines of codes, but I am not sure that it would be any faster than what you are doing now.

If you need a faster solution the bag file format supports random access. Assuming the bag file is in chronological order you could make a function that does a binary search to find the message you care about.