# livox_ros_driver2启动报std::bad_alloc崩溃

> 原文链接：https://robotics.hellobike.com/pitfalls/2026-02-03-livox-ros-driver2-221
> 频道：pitfalls | 更新日期：2026-02-03 | 标签：auto, github-issue, livox_ros_driver2
> 核心摘要：ROS2启动livox_ros_driver2时因Domain ID冲突触发std::bad_alloc，修改ROS_DOMAIN_ID环境变量解决。

# livox_ros_driver2启动报std::bad_alloc崩溃

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[ROS2 launch with problems: [livox_ros_driver2_node-1] bad_alloc caught: std::bad_alloc](https://github.com/Livox-SDK/livox_ros_driver2/issues/221)（GitHub Livox-SDK/livox_ros_driver2 #221）

**状态**：已解决

## 问题

在Livox-SDK及livox_ros_driver2 v2.4运行正常前提下，执行launch文件时节点livox_ros_driver2_node-1抛出std::bad_alloc异常并崩溃。尝试切换tag至1.2.3或1.2.1无效，该问题与版本无关，系ROS2通信通道冲突导致内存分配失败。

## 环境

ROS2 Kilted，livox_ros_driver2 v2.4，Livox-SDK正常运行环境。

## 解决办法

1. 编辑用户配置文件 `~/.bashrc`，添加非默认域ID配置行 `export ROS_DOMAIN_ID=<your_domain_id>` 以隔离通信通道。
2. 执行 `source ~/.bashrc` 使环境变量生效，避免与后台进程共用默认Domain ID 0引发信号冲突。
3. 重新启动launch文件验证节点不再抛出 `std::bad_alloc` 异常。

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

## 原始参考来源 (Sources)

- [GitHub Livox-SDK/livox_ros_driver2 #221：ROS2 launch with problems: [livox_ros_driver2_node-1] bad_alloc caught: std::bad_alloc](https://github.com/Livox-SDK/livox_ros_driver2/issues/221)