ROS Bag File Logging and Analysis
The message data in ROS topics are stored in log files called ROS bag files or rosbags. You can use MATLAB® functions, apps and Simulink® blocks to access, filter and execute offline analysis of ROS data in these rosbag files. These bags are often created by subscribing to one or more ROS topics, and storing the received message data in an efficient file structure. For an example of working with rosbags, see Work with rosbag Logfiles.
ROS toolbox also allows access to the message data in ROS 2 bag files or ros2bags. You can filter the ROS 2 data and execute offline analysis in these ros2bag files.
Use rosbagreader
to extract message data from a rosbag and rosbagwriter
to create a rosbag log file and write logs to it. You can
also use the ROS Logger app to record ROS messages during Simulink simulation. For more information, see Use ROS Logger App to Save ROS Messages from Simulink.
To extract massage data from a ros2bag log file, use the ros2bagreader
object. To write logs to a ros2bag log file, use the
ros2bagwriter
object. You can also record ROS 2 messages during a
Simulink simulation by using the ROS 2 Logger app. For more
information, see Use ROS 2 Logger App to Save ROS 2 Messages from Simulink.
To visualize the messages in a ROS bag log file, use ROS Bag Viewer app.
Apps
ROS Bag Viewer | Visualize messages in ROS bag file |
Functions
Blocks
Read Data | Play back data from log file |
Topics
ROS Bag Logging in MATLAB
- ROS Log Files (rosbags)
Summary of the structure of rosbags and the workflow for selecting subsets of messages in a rosbag. - Work with rosbag Logfiles
Load arosbag
, and learn how to select and retrieve the contained messages.
ROS and ROS 2 Bag Logging in Simulink
- Log ROS Messages from Simulink to a Rosbag Logfile
Save ROS message data from Simulink to a rosbag file. - Log ROS 2 Messages from Simulink to a ROS 2 Bag File
Save ROS 2 message data from Simulink to a ros2bag file.
ROS Bag File Analysis
- Get Started with ROS Bag Viewer App
The ROS Bag Viewer app enables you to load a ROS bag file into MATLAB and visualize all the message content in the bag file.
- STEP 1: Load and Play ROS Bag File
- STEP 2: Control ROS Bag File Playback