# ROS1转ROS2 Bag中Livox点云类型不匹配导致无法读取

> 原文链接：https://robotics.hellobike.com/pitfalls/2024-12-28-fast-lio-373
> 频道：pitfalls | 更新日期：2024-12-28 | 标签：auto, github-issue, fast_lio
> 核心摘要：rosbags-converter转换后消息类型仍为旧版驱动格式，需手动修改metadata.yaml中的type字段适配livox_ros_driver2。

# ROS1转ROS2 Bag中Livox点云类型不匹配导致无法读取

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[Hi bag from ros1 to ros2 continue in type of livox ros driver](https://github.com/hku-mars/FAST_LIO/issues/373)（GitHub hku-mars/FAST_LIO #373）

**状态**：有绕过办法

## 问题

使用rosbags-converter将ROS1 bag转为ROS2 db3格式后，/livox/lidar话题消息类型仍保留为livox_ros_driver，导致适配livox_ros2_driver或livox_ros_driver2的程序无法正确解析点云数据，即使修改接收端接口为livox_interface也无效。

## 环境

Ubuntu 22.04，FAST_LIO ROS2版本，Livox Avia雷达，rosbags-converter工具，db3存储格式。

## 解决办法

1. 打开转换生成的rosbag目录下的metadata.yaml文件。
2. 定位topics_with_message_count列表中name为/livox/lidar的条目。
3. 将该条目下topic_metadata的type字段值由livox_ros_driver/msg/CustomMsg修改为livox_ros_driver2/msg/CustomMsg。
4. 保存yaml文件后重新使用ros2 bag play命令播放验证数据读取是否正常。
5. 若修改后仍报错，检查序列化格式serialization_format是否为cdr，并确认本地已安装对应版本的livox_ros_driver2功能包以支持该消息类型定义。

讨论原作者：@SuperQueen20010701 等，版权归原作者所有。
:::

## 原始参考来源 (Sources)

- [GitHub hku-mars/FAST_LIO #373：Hi bag from ros1 to ros2 continue in type of livox ros driver](https://github.com/hku-mars/FAST_LIO/issues/373)