Rosbags In MATLAB
Sometimes you would rather analyze a rosbag in MATLAB rather than within the ROS environment. This page describes how to set up the Matlab infrastructure and includes a script example.
The following steps provide the parsing setup:
- Type roboticsAddons and install the Robotics System Toolbox Interface for ROS Custom Messages
- Copy custom package(s) to a standalone folder
- Check messages for redundant variables
- Run rosgenmsg(folderpath) where folderpath is the path to the standalone folder above our custom packages
- Follow directions in Matlab for editing javaclasspath.txt, adding the message to the path, restarting Matlab, and verifying success via rosmsg list
Basic rosbag parsing is as follows:
- Run
rosbag(filepath)
on the rosbag file of interest - Select only the topic of interest with
select(bag,'Topic','<topic name>')
- For straightforward values in a message, run
timeseries(bag_select,'<message element>')
- For more complicated messages, run
readMessages
This script parses Rosbags and creates a .mat
and .csv
file from it given a custom definition. The particular message referenced is an aggregation of multiple messages, hence the recursive structure.