Main Content

Bag File Logging and Analysis

Import, visualize and analyze ROS bag and ROS 2 bag files

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 or ROS 2 bag log file, use ROS Bag Viewer app.

Apps

ROS Bag ViewerVisualize messages in ROS or ROS 2 bag file (Since R2023a)

Functions

expand all

ros2bagreaderAccess ROS 2 bag log file information (Since R2021a)
readMessagesRead messages from ros2bagreader object (Since R2021a)
selectSelect subset of messages in ros2bagreader (Since R2021a)
getTransformReturn transformation between two coordinate frames (Since R2023b)
canTransformVerify if transformation is available (Since R2023b)
ros2bagwriterCreate and write logs to ROS 2 bag log file (Since R2022b)
writeWrite logs to ROS 2 bag log file (Since R2022b)
deleteRemove ros2bagwriter object from memory (Since R2022b)
rosbagOpen and parse rosbag log file (Since R2019b)
readMessagesRead messages from rosbag (Since R2019b)
rosbagreaderAccess rosbag log file information (Since R2021b)
rosbagwriterCreate and write logs to rosbag log file (Since R2021b)
writeWrite logs to rosbag log file (Since R2021b)
selectSelect subset of messages in rosbag (Since R2019b)
timeseriesCreate time series object for selected message properties (Since R2019b)
BagSelection Object for storing rosbag selection (Since R2019b)

Blocks

expand all

Read DataPlay back data from ROS 2 log file (Since R2021b)
Read DataPlay back data from log file (Since R2019b)

Topics

Bag Logging in MATLAB

Bag Logging in Simulink

Bag File Analysis