loading/processgin rosbag takes too much time

Dear reader,
For some project, I need to process the contents of a bag-file in Matlab. For this I basically follow the proposed procedure of the Matlab-help pages:
  1. load bag-file using: bag_msgs = rosbag(...)
  2. extract all topics from bag-file: all_topics = bag_msgs.AvailableTopics.Row
  3. loop over all topics
  4. get all messages of some topic: topic_msg = select(bag_msgs,'topic',topic_name)
  5. extract all data of the topic into a timeseries data-structure: mat_data = timeseries(topic_msg)
I am, however, unpleasantly surprised by the time it takes to run this loop.
My bag-file has the following properties:
  • 12,777,785 bytes
  • recorded time-span: 122.65 seconds
  • 27313 messages, divided over only 4 topics
The above described loop of processing the bagfile data takes up 167.2 seconds, which I think is way too slow. In the near future I will work with much larger bag-files, containing much more than 4 topics.
My question: how can I improve the reading/processing speed of a bag-file in Matlab?

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Release

R2017b

Asked:

on 18 Mar 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!