ros1 bag to ros2 bag play

有个问题是,ros1格式的bag需要转到ros2格式的bag,怎么弄?
需要注意的是,这里只能提供标准信息的rosbag转换,如果带有自定义msg的rosbag,应该是不可以的,请注意一下。

解决办法:

  1. 安装依赖
sudo apt install ros-foxy-rosbag2-bag-v2-plugins ros-foxy-ros1-bridge ros-foxy-ros1-rosbag-storage-vendor ros-foxy-rosbag2*
  1. 设置环境变量

这里一定要注意顺序。因为我们原有的rosbag是ros1格式,用的是ros2里面的bag工具,所以要先source ros1,再source ros2,否则可能出现问题。特别提示一下,在安装完依赖之后,请打开一个新的终端窗口进行操作,保证环境变量的干净。

. /opt/ros/noetic/setup.bash && . devel/setup.bash && . /opt/ros/foxy/setup.bash

中途可能会提示:

ROS_DISTRO was set to 'noetic' before. Please make sure that the environment does not mix paths from different distributions.

不用管。

  1. 查看rosbag信息
ros2 bag info -s rosbag_v2 src/localization/localization/bag/data_example.bag

如果带有自定义msg的话,这里就会提示你转换可能有问题:

[INFO] [1621995510.997956249] [rosbag2_bag_v2_plugins]: ROS 1 to ROS 2 type mapping is not available for topic '/vicon_xb/viconPoseTopic' which is of type 'vicon_xb/viconPoseMsg'. Skipping messages of this topic when replaying.
[INFO] [1621995510.997974022] [rosbag2_bag_v2_plugins]: ROS 1 to ROS 2 type mapping is not available for topic '/uwb_endorange_info' which is of type 'uwb_driver/UwbRange'. Skipping messages of this topic when replaying.

在这里插入图片描述

  1. play rosbag
ros2 bag play -s rosbag_v2 src/localization/localization/bag/data_example.bag

在这里插入图片描述

因为这里带了自定义msg,所以不成功,不过标准msg的rosbag还是可以使用的。

  1. 搞定
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
As an AI language model, I cannot perform any actions beyond providing information. However, I can provide you with some guidance on how to convert a ROS1 bag file to a ROS2 bag file. There are different approaches to converting ROS1 bag files to ROS2 bag files. One of the simplest ways is to use the ROS1-ROS2 bridge, which allows communication between ROS1 and ROS2 systems. To convert a ROS1 bag file to a ROS2 bag file using the bridge, you can follow these steps: 1. Install the ROS1-ROS2 bridge package on your ROS2 system. You can do this by running the following command in your terminal: ``` sudo apt-get install ros-<distro>-ros1-bridge ``` Make sure to replace `<distro>` with the ROS2 distribution you are using (e.g., foxy, galactic). 2. Source the ROS1 and ROS2 environments in separate terminal windows: ``` source /opt/ros/<distro>/setup.bash # for ROS1 source /opt/ros/<distro>/setup.bash # for ROS2 ``` 3. Launch the ROS1-ROS2 bridge node in one terminal window: ``` ros2 run ros1_bridge dynamic_bridge ``` 4. In another terminal window, use the rosbag tool to play the ROS1 bag file and publish its messages to the ROS2 bridge: ``` ros1bag play <ros1_bag_file> --clock --pause --loop ``` 5. In a third terminal window, use the ROS2 bag tool to record the messages published by the bridge: ``` ros2 bag record -a ``` This will record all the messages published by the ROS1-ROS2 bridge and save them to a ROS2 bag file. Note that the conversion process may take some time, depending on the size of the ROS1 bag file and the complexity of the messages it contains. Also, not all message types are currently supported by the ROS1-ROS2 bridge, so you may encounter some errors or limitations during the conversion process.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

晚餐男孩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值