rosbag records a robot's message streams to a file and plays them back later — the tool that lets engineers capture real runs, debug offline, and test algorithms on identical data again and again.
rosbag is like a DVR for a robot. It records all the messages flowing through the robot — camera, lidar, commands — into a file, so you can replay the exact run later to debug or test, without the robot present.
Something went wrong on the robot at 3pm and you weren't watching. Or you want to test three different algorithms on the exact same sensor data. Both are jobs for rosbag — a recorder for everything flowing through a robot.
What it does
rosbag records the messages on chosen topics — camera images, lidar scans, commands, transforms — into a file, each stamped with its time. Later, ros2 bag play replays them with the original timing, so downstream nodes see the data exactly as it happened live. It's effectively a DVR for a robot's data.
Capture live, replay anytime
Record once from the real robot; replay endlessly on your laptop. Downstream nodes can't tell the difference between live and replayed data.
Why it's indispensable
Debug offline. Capture a rare failure once, then replay it as many times as you need — no reproducing the fault on hardware.
Repeatable testing. Run competing perception or planning algorithms against the identical recorded run for a fair comparison.
Data collection. Bags are how teams gather real-world datasets to train and evaluate models (part of the sim-to-real and learning pipeline).
Development without hardware. Work on the planner using yesterday's recorded sensor data while the robot is busy or unavailable.
Practical notes
ros2 bag record -a grabs everything (careful — camera and lidar bags get huge fast), or name specific topics to keep it small. ros2 bag info summarizes a recording. Replay pairs naturally with RViz to watch a past run. The ROS 2 version (rosbag2) supports pluggable storage formats and compression.
Why it matters
rosbag turns fleeting live data into a reusable asset. It's the backbone of debugging, testing, and dataset collection in robotics — the reason engineers can iterate on real-world behavior without the robot in front of them.