树莓派4B (Ubuntu 22.04) + Livox mid 360 激光雷达运行fast_lio (更新中)

一、Ubuntu 系统安装

1.系统烧录

本次使用树莓派官方镜像烧录器,系统选择 Ubuntu desktop 22.04.5 LTS(64位)。

2.基础配置

写入完成后,将TF卡装入树莓派,连接显示器、鼠标键盘,上电进入系统引导,完成常规设置和更新后进入Ubuntu桌面。

2.1 开启VNC(根据实际需求选择

设置 setting >分享 sharing >远程桌面 remote desktop,开启远程桌面和远程控制开关。

本次使用 xrdp 服务器进行远程桌面连接,打开 Windows系统自带远程桌面连接进行远程。

#1. 安装xrdp
sudo apt update
sudo apt install xrdp -y

#2.启动
sudo systemctl enable xrdp --now

 2.2 更换软件镜像源(根据实际系统版本和CPU架构,本次为 Ubuntu 22.04 LTS jammy arm64架构

打开 sources.list 

sudo nano /etc/apt/sources.list

 将原软件源注释掉(根据实际需求),添加国内源并保存。

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-proposed main restricted universe multiverse

编辑镜像站后,使用 sudo apt update ,更新软件源列表,检查编辑是否正确。

二、安装 ROS 

本次为 Ubuntu 22.04 LTS jammy 位系统,选择安装 ROS 2 Humble Hawksbill 版本。 

#1.手动设定区域选项以避免后续出现问题
locale  # check for UTF-8
 
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
 
locale  # verify settings
#2. 将 ROS2 apt存储库添加到系统中
sudo apt install software-properties-common

#3. 启用Ubuntu Universe 存储库
sudo add-apt-repository universe
#4. 使用 apt 添加 ROS2 GPG 密钥
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg

# 若运行后提示无法链接到网址 Failed to connect to raw.githubusercontent.com
# 在hosts文件种添加 raw.githubusercontent.com ip
 
185.199.108.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
185.199.110.133 raw.githubusercontent.com
185.199.111.133 raw.githubusercontent.com
#5. 将存储库添加到源列表
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
#6. 安装 ros2 桌面版
sudo apt update
sudo apt upgrade
sudo apt install ros-humble-desktop
#7. 添加环境变量
source /opt/ros/humble/setup.bash
#5. 分别打开两个终端,运行 listener 和 talker 示例,验证 ROS 安装结果
source /opt/ros/humble/setup.bash
ros2 run demo_nodes_cpp talker
 
source /opt/ros/humble/setup.bash
ros2 run demo_nodes_py listener

#6. 检查环境变量
printenv | grep -i ROS

三、驱动激光雷达 

 1.安装 Livox-SDK2 功能包

#1. 下载 SDK
git clone https://github.com/Livox-SDK/Livox-SDK2.git

#2. 创建编译空间
cd Livox-SDK2/
mkdir build && cd build

#3. 编译安装
cmake .. 
make -j
sudo make install

编译时可能会出现关于 rapidjson 这一文件的 warning,类似下面的提示:

/home/pi/Livox-SDK2/sdk_core/../3rdparty/rapidjson/rapidjson.h:542:29: warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]
542 | #define RAPIDJSON_PRAGMA(x) _Pragma(RAPIDJSON_STRINGIFY(x))                           
/home/pi/Livox-SDK2/sdk_core/../3rdparty/rapidjson/rapidjson.h:543:34: note: in #expansion of macro ‘RAPIDJSON_PRAGMA’
543 | #define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(GCC diagnostic x)

本次的解决方法 

找到文件 /home/Livox-SDK2/3rdparty/rapidjson/internal/dtoa.h ,将第36行:

RAPIDJSON_DIAG_OFF(array - bounds)  // some gcc versions generate wrong warnings

 修改为:

RAPIDJSON_DIAG_OFF(array-bounds)  // some gcc versions generate wrong warnings

清理后再次编译,完成安装。 

2. 安装 livox_ros_driver2 驱动功能包

#0. 安装必要工具
sudo apt update
sudo apt install git python3-colcon-common-extensions python3-rosdep python3-ament-package python3-pip -y
sudo rosdep init
rosdep update

#1. 创建工作空间
mkdir -p ~/livox_ws/src
cd ~/livox_ws/src

#2. 下载驱动
git clone https://github.com/Livox-SDK/livox_ros_driver2.git

# 如果反复出现网址未响应,可以考虑更换 GitHub 镜像网站(需确认镜像网址可用)
git config --global url."https://bgithub.xyz/".insteadOf https://github.com/
 
# 查看当前网址设置
git config --global -l
 
# 断开替代链接网址
git config --global --remove-section url."https://bgithub.xyz/"

#3. 安装依赖
cd ~/livox_ws
rosdep install --from-paths src --ignore-src -r -y

#4. 构建项目
cd ~/livox_ws/src/livox_ros_driver2
source /opt/ros/humble/setup.sh
./build.sh humble

#5. 设置环境变量
source ~/livox_ws/install/local_setup.sh 
echo "source ~/livox_ws/install/local_setup.sh" >> ~/.bashrc

3.修改 IP 地址

3.1 使用 LivoxViewer2 客户端,将雷达接入,查看设备IP。 

左侧红框内为雷达 S/N 码,对应下述 cmdline_bd_code

Points IPIMU IPLidar Infor IP 相同,对应下述 cmd_data_ippush_msg_ippoint_data_ipimu_data_ip

Lidar IP 值对应下述 ip

LivoxViewer2 下载地址:

LiDAR Sensors - Livoxhttps://www.livoxtech.com/cn/downloadshttps://www.livoxtech.com/cn/downloadshttps://www.livoxtech.com/cn/downloads

3.2 打开 Livox-SDK2/samples/livox_lidar_quick_start/mid360_config.json 文件。

 修改 host_ip 192.168.1.xx Points IPIMU IPLidar Infor IP

3.3 打开 livox_ws/src/livox_ros_driver2/launch_ROS2/msg_MID360_launch.py 文件、livox_ws/src/livox_ros_driver2/launch_ROS2/rviz_MID360_launch.py 文件。

msg_MID360_launch.pyrviz_MID360_launch.py 两个文件中的 cmdline_bd_code 值修改为 S/N 编码。

3.4 打开 livox_ws/src/livox_ros_driver2/config/MID360_config.json 文件。

打开 livox_ws/install/livox_ros_driver2/share/livox_ros_driver2/config/MID360_config.json 文件。

sudo nano /home/pi/livox_ws/install/livox_ros_driver2/share/livox_ros_driver2/config/MID360_config.json

sudo nano /home/pi/livox_ws/install/livox_ros_driver2/share/livox_ros_driver2/config/MID360_config.json

将 cmd_data_ippush_msg_ippoint_data_ipimu_data_ip 修改为192.168.1.xx Points IPIMU IPLidar Infor IP 值);将 ip 修改为192.168.1.xx Lidar IP 值)

4 雷达驱动确认

打开网络设置,启用有线连接,identity mac 地址填写选择 eth0

 IPv4方式选择 手动,地址填写雷达 Lidar Infor IP , DNS 自动

 将雷达与树莓派连接,确认雷达驱动情况。

cd ~/livox_ws
source /opt/ros/humble/setup.bash
ros2 launch livox_ros_driver2 msg_MID360_launch.py

在另一终端,运行rivz。

cd ~/livox_ws
source /opt/ros/humble/setup.bash
ros2 launch livox_ros_driver2 rviz_MID360_launch.py

四、运行 fast_lio 实现建图 

<think>好的,我现在需要帮用户解决在树莓派5上连接和配置Mid360激光雷达的问题。首先,用户提供的引用中提到了树莓派4B和香橙派5MAX的配置,可能需要参考这些步骤来适配树莓派5。 首先,用户需要安装Ubuntu系统。根据引用[2]和[3],树莓派4B和香橙派5MAX都用了Ubuntu系统,所以树莓派5可能也需要类似的步骤。用户可能需要从官网下载适合的Ubuntu镜像,比如22.0420.04版本,并使用烧录工具写入SD卡。这里需要确认树莓派5的兼容性,可能需要查看官方文档推荐的Ubuntu版本。 接下来是系统配置,特别是网络设置。引用[3]提到香橙派5MAX配置网络,这可能包括有线或无线连接,确保树莓派5能联网以下载必要的驱动和软件。用户可能需要通过命令行或形界面设置网络,这部分可以详细说明步骤,比如使用nmcli或修改网络配置文件。 然后安装依赖项。根据引用[2],Livox Mid360可能需要ROS和相关的驱动支持。需要安装CMake、Git、构工具等,可能还要安装ROS Noetic或Humble,取决于Ubuntu版本。用户需要根据所选Ubuntu版本选择合适的ROS发行版,并按照官方指南安装。 接下来是Livox SDK的安装。引用[2]提到在树莓派4B上运行Livox Mid360,可能需要克隆SDK仓库,编译安装。用户需要执行git clone,创build目录,cmake和make。这里要注意权限问题,可能需要将用户添加到dialout组以访问串口设备,如引用[2]中的步骤。 然后是配置udev规则,确保雷达设备被正确识别。引用[2]中的步骤提到复制rules文件并重新加载udev,这可能需要sudo权限,用户需要注意命令的正确性。 最后是测试连接,运行livox viewer。如果出现权限问题,可能需要使用sudo或者调整用户组权限。此外,用户可能想运行Fast-LIO等算法,需要安装相关软件包,如引用[2]中的步骤,克隆仓库并编译。 在过程中可能会遇到的问题包括:系统兼容性、驱动编译错误、权限不足、硬件连接问题(如USB端口不稳定)。需要提醒用户检查硬件连接,确认USB接口供电充足,查看日志信息排查错误。 生成的相关问题需要考虑用户可能的后续需求,比如如何集成到ROS、使用其他算法,或者优化性能。比如用户完成连接后,可能需要实际应用或与其他传感器融合,因此相关问题可以围绕这些主题展开。</think>### 树莓派5连接与配置Mid360激光雷达教程 #### 1. 系统准备 - **安装Ubuntu系统** 树莓派5议安装**Ubuntu 22.04 LTS**(兼容性较好)。使用树莓派官方烧录工具或`Raspberry Pi Imager`将镜像写入SD卡[^2][^3]。 - **系统配置** - 连接网络(有线/无线),议使用静态IP方便后续调试。 - 更新系统: ```bash sudo apt update && sudo apt upgrade -y ``` #### 2. 安装依赖项 - **基础工具** ```bash sudo apt install -y cmake git build-essential ``` - **ROS安装(可选)** 若需运行SLAM算法(如Fast-LIO),需安装ROSUbuntu 22.04对应ROS 2 Humble: ```bash sudo apt install ros-humble-desktop ``` #### 3. 配置Livox Mid360驱动 - **下载Livox SDK 2** ```bash git clone https://github.com/Livox-SDK/Livox-SDK2.git cd Livox-SDK2 mkdir build && cd build cmake .. make -j4 sudo make install ``` - **添加用户权限** 将用户加入`dialout`组以访问串口: ```bash sudo usermod -aG dialout $USER ``` - **配置udev规则** 复制设备规则文件并生效: ```bash cd Livox-SDK2/sdk_core/udev sudo cp 80-livox.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules sudo udevadm trigger ``` #### 4. 连接与测试 - **硬件连接** 将Mid360通过Type-C线接入树莓派5的USB 3.0接口,确保供电充足(议使用外接电源)。 - **运行Livox Viewer** 下载并编译Livox Viewer工具: ```bash git clone https://github.com/Livox-SDK/Livox-SDK2.git cd Livox-SDK2/samples/livox_viewer mkdir build && cd build cmake .. make ./livox_viewer ``` 若设备列表中显示Mid360,则连接成功[^1][^2]。 #### 5. 运行SLAM算法(以Fast-LIO为例) - **克隆仓库并编译** ```bash git clone https://github.com/hku-mars/FAST_LIO.git cd FAST_LIO mkdir build && cd build cmake .. make -j4 ``` - **启动算法** 修改配置文件`config/mid360.yaml`,指定话题名称,运行: ```bash source devel/setup.bash roslaunch fast_lio mapping.launch ``` #### 常见问题 - **权限问题**:重启树莓派或重新登录使`dialout`组生效。 - **设备未识别**:检查USB线是否支持数据传输,更换接口尝试。 - **驱动编译失败**:确保已安装完整依赖项(如`libudev-dev`)。
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值