When working with OpenVINS under ROS 2, you will often need to replay datasets that were originally recorded or distributed as ROS 1Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rpng/open_vins/llms.txt
Use this file to discover all available pages before exploring further.
.bag files. The two common conversion approaches are the standalone rosbags Python package (recommended) and the rosbag2 bridge that requires both ROS 1 and ROS 2 to be installed simultaneously. This page covers both methods, along with known issues and workarounds.
Option 1: rosbags (Recommended)
Therosbags library is the simplest and most reliable approach. It operates as a pure Python package with no ROS installation required, making it easy to use in any environment.
This is the tool used to generate the converted ROS 2 bag files for all standard OpenVINS-compatible datasets (e.g., EuRoC MAV, TUM-VI).
ROS 1 → ROS 2 Conversion
Install rosbags
Install the
rosbags package via pip. Version 0.9.11 or newer is required for ROS 1 → ROS 2 conversion.Convert the bag file
Run the The
rosbags-convert command, pointing it at your source .bag file and specifying a destination folder for the ROS 2 bag:--dst argument specifies the output directory for the new ROS 2 bag. The tool will create this directory and populate it with the converted metadata and data files.ROS 2 → ROS 1 Conversion
If you have a ROS 2 bag (e.g., recorded from a live ROS 2 system) and need to convert it back to a ROS 1.bag for use with Kalibr or a ROS 1 pipeline, use version 0.9.12 or newer:
--exclude-topic to drop any topics that are not needed (e.g., pointcloud or lidar topics that may have no equivalent ROS 1 message type).
Creating a Bag from Images
If you need to create a ROS bag from a folder of images (e.g., to calibrate cameras with Kalibr), use the Kalibr bagcreater utility rather thanrosbags-convert.
Option 2: rosbag2 Play Bridge
This method uses therosbag2 ROS 2 package with the rosbag_v2 storage plugin to play ROS 1 bags directly inside ROS 2. It requires both ROS 1 and ROS 2 installed on the same machine.
Install Dependencies
$ROS2_DISTRO with your ROS 2 distribution name (e.g., foxy, galactic, humble).
Play a ROS 1 Bag Under ROS 2
Source both ROS environments
Source ROS 1 first, then ROS 2 in the same shell. The exact source commands depend on your installation paths:
Comparison of Methods
| rosbags (Option 1) | rosbag2 play (Option 2) | |
|---|---|---|
| ROS install required | No | Yes (both ROS 1 and ROS 2) |
| Reliability | High | Low (known .so issues) |
| Bidirectional conversion | Yes | ROS 1 → ROS 2 only |
| Recommended | Yes | No |
Common Issues
Timestamp or topic type mismatches after conversion
Timestamp or topic type mismatches after conversion
Some message types changed between ROS 1 and ROS 2 (e.g.,
sensor_msgs/Image headers). The rosbags library handles most standard types automatically. If a topic fails to convert, it is usually because the message type is not supported. You can exclude those topics using --exclude-topic.rosbags-convert command not found
rosbags-convert command not found
Ensure the pip install target is on your
PATH. If you installed with pip3 install --user, add ~/.local/bin to your shell’s PATH:Corrupted .so files with rosbag2-bag-v2-plugins
Corrupted .so files with rosbag2-bag-v2-plugins
This is a known upstream issue (rosbag2 #94). The
.so files for the rosbag_v2 storage plugin can be malformed in the binary apt packages. The only reliable fix is to build rosbag2 and its plugins from source. It is simpler to use the rosbags Python package instead.Bag recorded at >100 Hz fails to convert cleanly
Bag recorded at >100 Hz fails to convert cleanly
Very high-rate IMU bags may produce large output files. Ensure the destination has sufficient disk space before converting. Typical IMU-camera datasets are a few GB; allocate at least 2× the source file size.