ros2 bag (rosbag)ros2 bag is the ROS 2 tool used to record and replay topic data β meaning it saves the actual messages being published (like positions, states, and sensor readings), not text logs.
Itβs mainly used for flight data analysis, replaying missions, or debugging how nodes communicated.
When you run a ROS 2 system, many nodes publish messages on topics such as:
/mavros/local_position/pose β drone position (PoseStamped)/mavros/state β PX4 mode & arming state/mavros/setpoint_position/local β position commandsros2 bag records those messages into a .db3 file (SQLite database).
Later, you can replay or analyze them offline.
Record specific topics:
ros2 bag record /mavros/local_position/pose /mavros/state /mavros/setpoint_position/local
This starts recording all messages published to those topics into a new folder like:
rosbag2_2025_11_12-00_25_00/
View info about a bag file:
ros2 bag info rosbag2_2025_11_12-00_25_00
Replay the recorded data: