Main Content

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

Apps

ROS Bag ViewerVisualize messages in ROS bag file

Functions

expand all

rosbagOpen and parse rosbag log file
readMessagesRead messages from rosbag
rosbagreaderAccess rosbag log file information
rosbagwriterCreate and write logs to rosbag log file
writeWrite logs to rosbag log file
selectSelect subset of messages in rosbag
timeseriesCreate time series object for selected message properties
BagSelection Object for storing rosbag selection
ros2bagreaderAccess ROS 2 bag log file information
readMessagesRead messages from ros2bagreader object
selectSelect subset of messages in ros2bagreader
ros2bagwriterCreate and write logs to ROS 2 bag log file
writeWrite logs to ROS 2 bag log file
deleteRemove ros2bagwriter object from memory

Blocks

Read DataPlay back data from log file

Topics

ROS Bag Logging in MATLAB

ROS and ROS 2 Bag Logging in Simulink

ROS Bag File Analysis