[Documentation] [TitleIndex] [WordIndex

A bag is a file format in ROS for storing ROS message data. Bags -- so named because of their .bag extension -- have an important role in ROS, and a variety of tools have been written to allow you to store, process, analyze, and visualize them.

Online use in a Computation Graph

Bags are typically created by a tool like rosbag, which subscribe to one or more ROS topics, and store the serialized message data in a file as it is received. These bag files can also be played back in ROS to the same topics they were recorded from, or even remapped to new topics.

Using bag files within a ROS Computation Graph is generally no different from having ROS nodes send the same data, though you can run into issues with timestamped data stored inside of message data. For this reason, the rosbag tool includes an option to publish a simulated clock that corresponds to the time the data was recorded in the file.

The bag file format is very efficient for both recording and playback, as messages are stored in the same representation used in the network transport layer of ROS.

Offline use and data migration

Bags are the primary mechanism in ROS for data logging, which means that they have a variety of offline uses. Researchers have used the bag file toolchain to record datasets, then visualize, label them, and store them for future use. Bag files have also been used to perform long-term hardware diagnostics logging for the PR2 robot.

Tools like rqt_bag allow you to visualize the data in a bag file, including plotting fields and displaying images. You can also quickly inspect bag file data from the console using the rostopic command. rostopic supports listing bag file topics as well as echoing data to screen.

There are also programmatic APIs in the rosrecord package that give C++ and Python packages the ability to iterate over stored messages. For quicker manipulations to bag files, the rosbag tool supports rebagging a bag file, which allows you to extract messages that match a particular filter to a new bag file.

The data stored within bag files is often very valuable, so bag files are also designed to be easily migrated when msg files are updated. The bag file format stores the msg file of the corresponding message data, and tools like rosbagmigration let you write rules to automatically update bag files when they become out of date.

Bag Tools

Older tools

The following tools have been superceded by rosbag, but are still supported:

Bag Format

The underlying format of a bag file should not be relevant to the average user. It is subject to change, but backwards compatibility will be maintained by the programmatic access libraries, or custom conversion libraries.


2024-12-21 12:14