Open Source Robotics

A curated collection of high-quality open source robotics projects, tools, and software to propel the robotics community forward.

rosbag

  • Also called: ROS bag, rosbag2, ros2 bag, bag file
  • Category: Software & tooling › Tools & formats
  • Tags: ros, data-logging, datasets, debugging, robot-software

The ROS tool and file format for recording timestamped messages from topics and replaying them later; in ROS 2 it is provided by rosbag2 through the ros2 bag command.

Definition

rosbag records the messages published on selected ROS topics, such as camera images, lidar scans, joint states, transforms and commands, into a file called a bag, together with their timestamps and message types. The same tool plays a bag back, republishing the messages on their original topics at the recorded rate or faster or slower, so that other nodes receive them as if the robot were running. Bags can be inspected for their topics, message counts and duration, filtered to selected topics or time ranges, and read directly from code through Python and C++ client libraries.

rosbag began in ROS 1, where rosbag record and rosbag play wrote and read the .bag format. ROS 2 replaced it with rosbag2, used through the ros2 bag command, which separates the recording logic from pluggable storage back ends. Early ROS 2 releases stored bags in SQLite3 databases, and more recent releases default to MCAP, an open container format designed for timestamped, multimodal robotics data. Bags from ROS 1 and ROS 2 are not directly interchangeable, although conversion tools exist. Recording options include compression, splitting files by size or duration, and quality-of-service settings to match publishers.

Bags are the usual way to capture field data for debugging, offline development and dataset creation. Replaying a bag lets engineers rerun perception or estimation code on identical inputs, compare algorithm versions and reproduce failures without the robot. A few points need care: playback can publish a clock topic, and nodes should then use simulated time; both dynamic and static transforms must be recorded; nodes that would publish the same topics as the bag must not run during playback; and high-rate sensor streams fill disks quickly. For learning at scale, bags are often converted to formats built for random access and batched loading, because the bag layout is designed for sequential recording and replay.

Why it matters

Nearly every ROS-based robot depends on recorded data for debugging and development. Bags make it possible to reproduce what the robot sensed and did, test changes offline against real sensor data, and build datasets, so recording, replaying and converting them is basic ROS practice.

Key applications

  • Debugging robot behavior by replaying recorded sensor data
  • Offline development and tuning of perception, localization and SLAM
  • Regression testing of algorithms on fixed real-world data
  • Collecting demonstration and sensor datasets for robot learning
  • Field logging for incident analysis
  • Sharing benchmark datasets in a ROS-native form

In practice

A team testing an outdoor mobile robot records a bag on every field run with lidar scans, camera images, IMU data, wheel odometry, transforms and the commands sent to the base, splitting files every few minutes and compressing them. When the robot's localization drifts during a run, an engineer back at the office replays the bag with simulated time, runs a modified localization node on the recorded sensor topics while leaving out the original localization output, and compares the two trajectories in a visualizer. Once the fix works on several bags, those bags become regression tests in continuous integration. For training a perception model, the team converts selected topics into a dataset format that allows random access by frame.

Common misconceptions

  • rosbag is a ROS 2 tool — it originated in ROS 1, and ROS 2 provides a redesigned version, rosbag2, used through the ros2 bag command
  • A replayed bag behaves like the live robot — playback is open loop, so changed nodes cannot affect the recorded sensor data or the robot's recorded motion
  • Recording every topic is always the safe choice — high-rate images and point clouds fill storage quickly and can cause dropped messages, so topics, compression and splitting should be chosen deliberately
  • Bag files are a ready-made training-data format — they are designed for sequential recording and replay, and large-scale learning usually converts them to formats with efficient random access

Who should know this

  • ROS developers and robotics software engineers
  • Perception and SLAM engineers
  • Field-test and validation engineers
  • Robot-learning engineers building datasets

Related technologies

  • ROS 2
  • rosbag2
  • MCAP
  • SQLite
  • RViz
  • tf2

Related terms

  • ROS
  • SLAM
  • Sensor Fusion
  • Extrinsic Calibration
  • Digital Twin

Related projects

  • LeRobot: HuggingFace ML library for real-world robotics in PyTorch
  • Rerun: Time-aware visualizer and data store for multimodal robotics data
  • Cartographer: Google's real-time 2D and 3D SLAM system for multi-platform robotics
  • OpenMower: Open-source project converting commercial mowers into autonomous RTK-GPS guided robots
  • ROS 2: Next-gen Robot Operating System for real-time production robotics
  • PlotJuggler: Fast time-series visualization tool for ROS topics, rosbags, and robot debugging

Videos

  • Rosbags | ROS Tutorial for Beginners: ROBOMECHTRIX
  • ROS2 Rosbag to Record Data And Playback Data: Kevin Wood | Robotics & AI

This website requires JavaScript to function properly. Please enable JavaScript to explore our collection of open source robotics projects.