How to Convert ROS 2 Bag to ROS 1 Bag (for Foxglove Compatibility)

How to Convert ROS 2 Bag to ROS 1 Bag (for Foxglove Compatibility)

Overview

Foxglove does not currently support direct playback of ROS 2 .db3 bag files. To visualize ROS 2 data in Foxglove, you need to convert the ROS 2 bag to a ROS 1 .bag format.

This guide walks through the process of converting a ROS 2 bag file into a ROS 1 compatible format using the rosbags tool, so that it can be played in Foxglove or other ROS 1-based tools.

 

Prerequisites

  • Python 3.8+

  • rosbags Python package

    • Install via pip

    • pip3 install rosbags

 

Instructons

Step 1: Prepare the ROS 2 Bag Directory

Create a directory that includes both the ROS 2 .db3 file and the corresponding metadata.yaml file.

Sample metadata.yaml Structure

rosbag2_bagfile_information: version: 5 storage_identifier: sqlite3 duration: nanoseconds: 96723832439 starting_time: nanoseconds_since_epoch: 1751276554917484117 message_count: 4845 topics_with_message_count: - topic_metadata: name: /ouster_sensor_center/signal_image type: sensor_msgs/msg/Image serialization_format: cdr message_count: 969 - topic_metadata: name: /ouster_sensor_center/reflec_image type: sensor_msgs/msg/Image serialization_format: cdr message_count: 969 - topic_metadata: name: /ouster_sensor_center/range_image type: sensor_msgs/msg/Image serialization_format: cdr message_count: 969 - topic_metadata: name: /ouster_sensor_center/points type: sensor_msgs/msg/PointCloud2 serialization_format: cdr message_count: 969 - topic_metadata: name: /ouster_sensor_center/nearir_image type: sensor_msgs/msg/Image serialization_format: cdr message_count: 969 compression_format: "" compression_mode: "" relative_file_paths: - rosbag2_2025_06_30-11_42_32_0.db3 files: - path: rosbag2_2025_06_30-11_42_32_0.db3 starting_time: nanoseconds_since_epoch: 1751276554917484117 duration: nanoseconds: 96723832439 message_count: 484

 

Step 2: Run rosbag-convert

Use the following command to convert:

rosbag-convert /path/to/directory-containing-db3-and-metadata

This will generate a ROS 1-compatible .bag file that can be used in tools like Foxglove Studio.

 

Example as below:

image-20250722-071310.png

 

Now you can directly use the rosbag in Foxglove to see all the related topics for visualization.