ROS1 to ROS2 Bag Conversion Guide

rosbags

rosbags is the simplest utility which does not depend on ROS installs at all. ROS bag conversion is a hard problem since you need to have both ROS1 and ROS2 dependencies. This is what was used to generate the converted ROS2 bag files for standard datasets. To do a conversion of a bag file we can do the following:

pip3 install rosbags>=0.9.11
rosbags-convert V1_01_easy.bag --dst <ros2_bag_folder>

If you need to create a bag from images, then we recommend using the Kalibr bagcreater utility. To convert a ROS2 bag recorded to a ROS1 bag one which can then be processed by Kalibr or a ROS1 codebase, the following can be run:

pip3 install rosbags>=0.9.12
rosbags-convert <ros2_bag_folder> --dst calib_01.bag --exclude-topic <non_img_and_imu_topics>

rosbag2 play

To do this conversion you will need to have both ROS1 and ROS2 installed on your system. Also ensure that you have installed all dependencies and backends required. The main rosbag2 readme has a lot of good details.

sudo apt-get install ros-$ROS2_DISTRO-ros2bag ros-$ROS2_DISTRO-rosbag2*
sudo apt install ros-$ROS2_DISTRO-rosbag2-bag-v2-plugins

From here we can do the following. This is based on this issue. You might run into issues with the .so files being corrupted (see this issue) Not sure if there is a fix besides building it from scratch yourself.

source_ros1
source_ros2
ros2 bag play -s rosbag_v2 V1_01_easy.bag

We don't recommend this method and instead suggest using the rosbags utility as standalone.



ov_core
Author(s): Patrick Geneva , Kevin Eckenhoff , Guoquan Huang
autogenerated on Mon Jan 22 2024 03:08:17