📖
Wiki
Back to my personal website
  • Home
  • Equipment and Devices
    • 3D Printer
    • Laser Cutter
    • Motion Capture System
    • Sensors
      • RGB-D Cameras
      • Velodyne LiDAR
      • Zed Camera
      • RealSense D435i
      • IMU
    • eGPU
    • Nvidia AGX Xavier
    • CPU Benchmark
    • Installation Checklist
  • Development
    • Linux
      • Shell
      • GDB
      • Git
      • Tmux
      • Network
      • Tricks
      • Debug FAQ
    • CMake
      • Catkin Tools
      • CMakeLists
      • CMake Variables
      • CMake Commands
      • CMake: find_package()
    • ROS
      • Gazebo
      • wstool
      • roslaunch
      • rosbag
      • multi-threaded spinner
    • ROS2
      • Convert ROS1 bag to ROS2 bag
    • C++
      • C++ 11
      • C++ Examples
      • C++ Debug
      • Factory Method
      • Timing
    • Google Tools
      • GLog
      • GFlags
      • GTest
      • Style Guide
      • Clang Format
    • PCL
      • Point Type
      • Methods
      • Architecture
      • Code Explained
    • Open3D
      • Python API
      • Registration
      • Visualization
      • Tools
    • OpenCV
      • Documentation
      • Modules
    • Other Libraries
      • Eigen
      • Ceres
      • g2o
      • GTSAM
    • Website
  • Algorithm
    • SLAM
      • K-D Tree
      • Octree
      • Bag of Words
      • Distance Measures
      • Coordinate Systems
      • LOAM
      • Iterative Closest Point
      • Generalized ICP
      • Mahalanobis Distance
    • Computer Science
      • Computational Model
      • Sorting
      • Analysis
      • Complexity Classes (P, NP)
      • Divide and Conquer
      • Greedy Algorithm
      • Dynamic Programming
      • Tree
      • Graph
    • Computer Vision
      • Camera Models
      • Distortion
      • Motion Models
      • Shutter
      • Image Sensors
      • Epipolar Geometry
      • Multiple-View Geometry
    • Datasets
      • RGB-D Datasets
      • Point Cloud Datasets
      • LiDAR SLAM Datasets
  • Math
    • Optimization
      • Convex Optimization
      • Descent Methods
    • Probability
      • Moment
      • Covariance Matrix
      • Stochastic Process
    • Topology
      • References
      • Concepts
      • Topological Spaces
      • Representation of Rotations
      • Representation of 3-sphere
    • Algebra
      • Linear Algebra
      • Matrix Factorization
      • Condition Number
      • Matrix Lie Group
    • Differential Geometry
      • Manifold
      • Submanifold
      • Quotient Manifolds
      • Tangent Space
  • Quadrotor
    • PX4 Development
    • Companion Computer
    • Drone Hardware
    • Propeller Lock
    • Debug
  • Favorites
    • Bookmarks
Powered by GitBook
On this page
  • Solution 1: Install rosbag_v2 plugin and ros1_bridge
  • Solution 2: Use rosbags to convert bag files (Recommended)

Was this helpful?

  1. Development
  2. ROS2

Convert ROS1 bag to ROS2 bag

PreviousROS2NextC++

Last updated 6 months ago

Was this helpful?

For rosbag files recorded in ROS1 environment, we cannot use them directly in ROS2 environment. There are some discussions on workarounds. In summary, there are two ways, as summarized in .

Solution 1: Install rosbag_v2 plugin and ros1_bridge

  • Requirement: Ubuntu 20 or below, where we have both ROS1 and ROS2 available.

  • Follow the instructions in and to install.

sudo apt-get install ros-$ROS2_DISTRO-ros2bag ros-$ROS2_DISTRO-rosbag2*
sudo apt install ros-$ROS2_DISTRO-rosbag2-bag-v2-plugins
  • We can then playback ros1 bag files in a ros2 environment.

source_ros1
source_ros2
ros2 bag play -s rosbag_v2 V1_01_easy.bag

Additional comments: For Ubuntu 22 or above environment, according to , it may be possible to install ros1_bridge alongside ros2, if ros2 is installed from source. In practice, I did not run through this successfully and got stuck at the ros-core-dev : Depends: catkin but it is not installable error.

References:

Solution 2: Use rosbags to convert bag files (Recommended)

  • This is a python package that does not depend on ros environment. We can convert a ros1 bag file into ros2 bag by running the following commands.

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

References:

this article
ros1_bridge
rosbag_v2
ros2 official docs
https://robotics.stackexchange.com/questions/101945/playback-ros1-bag-files-in-ros2
https://answers.ros.org/question/402302/playback-ros1-bag-files-in-ros2/
https://docs.ros.org/en/humble/How-To-Guides/Using-ros1_bridge-Jammy-upstream.html
https://gitlab.com/ternaris/rosbags
https://docs.ros.org/en/noetic/api/ov_core/html/dev-ros1-to-ros2.html