🧠 What is 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.


πŸ“¦ How it works

When you run a ROS 2 system, many nodes publish messages on topics such as:

ros2 bag records those messages into a .db3 file (SQLite database).

Later, you can replay or analyze them offline.


🧰 Basic commands

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: