What is rosbag2?
rosbag2 is the data recording and playback framework built for ROS 2. While a robot runs, it subscribes to selected topics and writes every message, with its timestamp, into a bag file. Later that file can be replayed at full speed, slowed down, or stepped through, feeding the same messages back into the system as though the robot were running live.
Its defining change from the original rosbag is architectural: storage is a plugin, so the underlying file format is swappable rather than fixed.
Key takeaways
- rosbag2 records and replays ROS 2 topic data.
- Its storage layer is pluggable, and MCAP is now the default format.
- It is the ROS 2 successor to the original rosbag tool.
How it works
You record by specifying topics, and rosbag2 serializes each incoming message with its timestamp into the chosen storage backend. Because storage is pluggable, the same tool can write SQLite3 or MCAP, with MCAP now the default for its indexing and performance. Playback republishes messages on their original topics with original timing, which lets perception and planning code run against recorded data unchanged.
Why it matters
Replay is how robotics teams debug, since a bug that appears once in the field can be reproduced endlessly from a bag. rosbag2 is the standard capture point for ROS 2 systems, which means it is usually where physical AI datasets begin their life before curation, labeling, and training.
Frequently asked questions
What is the difference between rosbag and rosbag2?
rosbag is the original ROS 1 tool with a fixed format, while rosbag2 is the ROS 2 rewrite with a pluggable storage layer that defaults to MCAP.
What file format does rosbag2 use?
MCAP by default in current ROS 2 releases, with SQLite3 available as an alternative through the same pluggable interface.
What is the difference between ROS and ROS 2?
ROS refers to the Robot Operating System project as a whole. ROS 1 was the original generation, widely adopted in research but limited in real-time performance, multi-robot support, and production readiness. ROS 2 is the ground-up redesign that addresses those gaps and is the version under active development, so new projects generally start there.
Related terms
Go deeper