Main Content

ROS Bag File Logging and Analysis

Import, visualize and analyze ROS 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.

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 visualize the messages in a ROS bag log file and view live ROS topics, use ROS Data Analyzer app.

Apps

ROS Data AnalyzerVisualize messages from live ROS or ROS 2 topics and bag files (Since R2023a)

Functions

rosbagreaderAccess rosbag log file information (Since R2021b)
selectSelect subset of messages in rosbag (Since R2019b)
timeseriesCreate time series object for selected message properties (Since R2019b)
timetableCreate timetable for selected message properties in ROS bag file (Since R2024a)
rosbagwriterCreate and write logs to rosbag log file (Since R2021b)
writeWrite logs to rosbag log file (Since R2021b)
rosbagOpen and parse rosbag log file (Since R2019b)
readMessagesRead messages from rosbag (Since R2019b)
BagSelection Object for storing rosbag selection (Since R2019b)

Blocks

Read DataPlay back data from log file (Since R2019b)

Topics

Bag Logging in MATLAB

Bag Logging in Simulink

Bag File Analysis