使用ros2跑mid360的fastlio2算法详细教程

1、ROS2-Humble系统要求使用Ubuntu 22.04版本,所以需要先安装虚拟机。ubuntu镜像可以从这里下载:ubuntu-releases-22.04安装包下载_开源镜像站-阿里云

2、安装完Ubuntu后进入系统,按照ROS2的官方文档安装Humble版本:Ubuntu (deb packages) — ROS 2 Documentation: Humble documentation

3、编译并安装Livox-mid360的驱动库:Livox-SDK/Livox-SDK2: Drivers for receiving LiDAR data and controlling lidar, support Lidar HAP and Mid-360.

第一步:

  • 先安装CMAKE库$ sudo apt install cmake
  •  然后$ gcc -v 确认一下gcc版本大于4.8.1
  • 执行如下命令克隆、编译、安装库,安装完成后 .a和.so库在 /usr/local/lib目录下,头文件在/usr/local/include目录下。
$ git clone https://github.com/Livox-SDK/Livox-SDK2.git $ cd ./Livox-SDK2/ $ mkdir build $ cd build $ cmake .. && make -j $ sudo make install

 cmake .. && make -j:这一步如果报错

CMake Error at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.5 has been removed from CMake. Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier. Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway. 

解决办法:cmake -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .. && make -j
运行上面的指令,因为cmake版本过高

第二步

安装ROS2系统的编译工具colcon$ sudo apt install python3-colcon-common-extensions

第三步

新建ros_ws文件夹作为ROS2的工作目录,并在目录下新建src文件存放套件源码

$ mkdir -p ros_ws/src/ $ cd ros_ws/src/

4.克隆livox_ros_driver2 到src目录

git clone https://github.com/Livox-SDK/livox_ros_driver2.git

5编译驱动

source /opt/ros/humble/setup.sh ./build.sh humble

~/mid360/ros_ws/src/livox_ros_driver2一般在这个目录下可以找到build.sh

6.修改ros_ws/install/livox_ros_driver2/share/livox_ros_driver2/config/MID360_config.json中的本机ip和设备ip,然后执行下命令运行测试程序,成功后会在右侧显示雷达扫描的点云图。!!!!!!!!非常重要,参考下图的来修改

{ "lidar_summary_info" : { "lidar_type": 8 }, "MID360": { "lidar_net_info" : { "cmd_data_port": 56100, "push_msg_port": 56200, "point_data_port": 56300, "imu_data_port": 56400, "log_data_port": 56500 }, "host_net_info" : { "cmd_data_ip" : "192.168.1.50",//全部改成这个 "cmd_data_port": 56101, "push_msg_ip": "192.168.1.50", "push_msg_port": 56201, "point_data_ip": "192.168.1.50", "point_data_port": 56301, "imu_data_ip" : "192.168.1.50", "imu_data_port": 56401, "log_data_ip" : "", "log_data_port": 56501 } }, "lidar_configs" : [ { "ip" : "192.168.1.188",//最后俩位查看雷达的sn码来修改 "pcl_data_type" : 1, "pattern_mode" : 0, "extrinsic_parameter" : { "roll": 0.0, "pitch": 0.0, "yaw": 0.0, "x": 0, "y": 0, "z": 0 } } ] } 
source ../../install/setup.sh ros2 launch livox_ros_driver2 rviz_MID360_launch.py

运行之后就可以得到点云图

  • 将soruce命令加入到用户目录的.bashrc文件末尾,这样就不用每次运行ros launch都要source了source ~/ros_ws/install/setup.bash

跑fastlio2算法包

 cd ros_ws/src # cd into a ros2 workspace folder git clone https://github.com/Ericsii/FAST_LIO.git --recursive cd .. rosdep install --from-paths src --ignore-src -y colcon build --symlink-install //务必使用这个来编译,其他指令很容易报错 . ./install/setup.bash # use setup.zsh if use zsh

注意在    colcon build --symlink-install这个步骤,可能会产生一个编译错误

sky@sky:~/mid360/ros_ws$ colcon build --symlink-install Starting >>> livox_ros_driver2 --- stderr: livox_ros_driver2 CMake Warning (dev) at /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:146 (find_package): Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT variables. Run "cmake --help-policy CMP0144" for policy details. Use the cmake_policy command to set the policy and suppress this warning. CMake variable EIGEN_ROOT is set to: /usr/include/eigen3 For compatibility, find_package is ignoring the variable, but code in a .cmake module might still use it. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:299 (find_eigen) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:543 (find_external_library) /opt/ros/humble/share/pcl_conversions/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package) /opt/ros/humble/share/pcl_conversions/cmake/pcl_conversionsConfig.cmake:41 (include) /opt/ros/humble/share/ament_cmake_auto/cmake/ament_auto_find_build_dependencies.cmake:67 (find_package) CMakeLists.txt:225 (ament_auto_find_build_dependencies) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:128 (find_package): Policy CMP0167 is not set: The FindBoost module is removed. Run "cmake --help-policy CMP0167" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:297 (find_boost) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:543 (find_external_library) /opt/ros/humble/share/pcl_conversions/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package) /opt/ros/humble/share/pcl_conversions/cmake/pcl_conversionsConfig.cmake:41 (include) /opt/ros/humble/share/ament_cmake_auto/cmake/ament_auto_find_build_dependencies.cmake:67 (find_package) CMakeLists.txt:225 (ament_auto_find_build_dependencies) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at /usr/lib/x86_64-linux-gnu/cmake/pcl/Modules/FindFLANN.cmake:44 (find_package): Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT variables. Run "cmake --help-policy CMP0144" for policy details. Use the cmake_policy command to set the policy and suppress this warning. CMake variable FLANN_ROOT is set to: /usr For compatibility, find_package is ignoring the variable, but code in a .cmake module might still use it. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:256 (find_package) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:301 (find_flann) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:543 (find_external_library) /opt/ros/humble/share/pcl_conversions/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package) /opt/ros/humble/share/pcl_conversions/cmake/pcl_conversionsConfig.cmake:41 (include) /opt/ros/humble/share/ament_cmake_auto/cmake/ament_auto_find_build_dependencies.cmake:67 (find_package) CMakeLists.txt:225 (ament_auto_find_build_dependencies) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:128 (find_package): Policy CMP0167 is not set: The FindBoost module is removed. Run "cmake --help-policy CMP0167" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:297 (find_boost) /usr/lib/x86_64-linux-gnu/cmake/pcl/PCLConfig.cmake:543 (find_external_library) /opt/ros/humble/share/pcl_conversions/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package) /opt/ros/humble/share/pcl_conversions/cmake/pcl_conversionsConfig.cmake:41 (include) /opt/ros/humble/share/ament_cmake_auto/cmake/ament_auto_find_build_dependencies.cmake:67 (find_package) CMakeLists.txt:225 (ament_auto_find_build_dependencies) This warning is for project developers. Use -Wno-dev to suppress it. /usr/include/apr-1.0 apr-1 CMake Warning (dev) at /opt/ros/humble/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:20 (find_package): Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules are removed. Run "cmake --help-policy CMP0148" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include) /opt/ros/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions) CMakeLists.txt:241 (rosidl_generate_interfaces) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at /opt/ros/humble/share/python_cmake_module/cmake/Modules/FindPythonExtra.cmake:52 (find_package): Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules are removed. Run "cmake --help-policy CMP0148" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): /opt/ros/humble/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:23 (find_package) /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include) /opt/ros/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions) CMakeLists.txt:241 (rosidl_generate_interfaces) This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at /opt/ros/humble/share/python_cmake_module/cmake/Modules/FindPythonExtra.cmake:140 (find_package): Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules are removed. Run "cmake --help-policy CMP0148" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): /opt/ros/humble/share/rosidl_generator_py/cmake/rosidl_generator_py_generate_interfaces.cmake:23 (find_package) /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include) /opt/ros/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions) CMakeLists.txt:241 (rosidl_generate_interfaces) This warning is for project developers. Use -Wno-dev to suppress it. failed to create symbolic link '/home/sky/mid360/ros_ws/build/livox_ros_driver2/ament_cmake_python/livox_ros_driver2/livox_ros_driver2' because existing path cannot be removed: Is a directory gmake[2]: *** [CMakeFiles/ament_cmake_python_symlink_livox_ros_driver2.dir/build.make:70:CMakeFiles/ament_cmake_python_symlink_livox_ros_driver2] 错误 1 gmake[1]: *** [CMakeFiles/Makefile2:520:CMakeFiles/ament_cmake_python_symlink_livox_ros_driver2.dir/all] 错误 2 gmake[1]: *** 正在等待未完成的任务.... gmake: *** [Makefile:146:all] 错误 2 --- Failed <<< livox_ros_driver2 [2.74s, exited with code 2] Summary: 0 packages finished [2.91s] 1 package failed: livox_ros_driver2 1 package had stderr output: livox_ros_driver2 1 package not processed 

解决办法:这意味着 CMake 尝试创建一个符号链接,但目标路径已经存在并且是一个目录。你可以手动删除它:
rm -rf /home/sky/mid360/ros_ws/build/livox_ros_driver2/ament_cmake_python/livox_ros_driver2/livox_ros_driver2
把这个文件下的这个包删除就行

然后就可以运行fastlio2的算法包了

 ###下面三个是使用ros2启动mid360驱动包的,在同一个终端按顺序启动即可 cd ~/mid360/ros_ws source ~/mid360/ros_ws/install/setup.bash ros2 launch livox_ros_driver2 rviz_MID360_launch.py ###下面步骤是启动fastlio2算法包的(重新打开一个终端) cd ros_ws/src source ~/mid360/ros_ws/install/setup.bash ros2 launch fast_lio mapping.launch.py 

其他报错:运行雷达驱动包有点云数据,但是fastlio2算法包运行之后,显示黑屏,并且没有数据显示,这个问题是运行fastliio算法包崩溃了,大概率是包的冲突,

sky@sky:~/mid360/ros_ws$ source install/setup.bash sky@sky:~/mid360/ros_ws$ ros2 launch fast_lio mapping.launch.py [INFO] [launch]: All log files can be found below /home/sky/.ros/log/2025-08-18-21-27-52-585647-sky-144534 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [fastlio_mapping-1]: process started with pid [144535] [INFO] [rviz2-2]: process started with pid [144537] [rviz2-2] Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. [fastlio_mapping-1] /home/sky/mid360/ros_ws/install/fast_lio/lib/fast_lio/fastlio_mapping: symbol lookup error: /lib/x86_64-linux-gnu/libpcl_io.so.1.12: undefined symbol: libusb_set_option [ERROR] [fastlio_mapping-1]: process has died [pid 144535, exit code 127, cmd '/home/sky/mid360/ros_ws/install/fast_lio/lib/fast_lio/fastlio_mapping --ros-args --params-file /home/sky/mid360/ros_ws/install/fast_lio/share/fast_lio/config/mid360.yaml --params-file /tmp/launch_params_v46jnbq_']. [rviz2-2] [INFO] [1755523673.190659466] [rviz2]: Stereo is NOT SUPPORTED [rviz2-2] [INFO] [1755523673.190715080] [rviz2]: OpenGl version: 4.6 (GLSL 4.6) [rviz2-2] [INFO] [1755523673.201940923] [rviz2]: Stereo is NOT SUPPORTE

解决办法:

1. 修复 FAST-LIO 的库依赖问题 错误 undefined symbol: libusb_set_option 表明 libpcl_io 和 libusb 版本不兼容。尝试以下步骤: 方法 1:降级 libpcl bash sudo apt remove libpcl-dev sudo apt install libpcl-dev=1.12.1+dfsg-5ubuntu0.1 # Ubuntu 22.04 默认版本 sudo ldconfig 方法 2:更新 libusb bash sudo apt install libusb-1.0-0-dev sudo apt upgrade libusb-1.0-0 方法 3:手动编译 PCL 如果问题仍然存在,从源码编译 PCL: bash git clone https://github.com/PointCloudLibrary/pcl.git cd pcl && mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j$(nproc) sudo make install 

报错:

sky@sky:~/mid360/ros_ws$ ros2 launch fast_lio mapping.launch.py [INFO] [launch]: All log files can be found below /home/sky/.ros/log/2025-08-19-01-18-35-837053-sky-190899 [INFO] [launch]: Default logging verbosity is set to INFO [INFO] [fastlio_mapping-1]: process started with pid [190901] [INFO] [rviz2-2]: process started with pid [190903] [rviz2-2] Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. [fastlio_mapping-1] [INFO] [1755537515.950811500] [laser_mapping]: p_pre->lidar_type 2 [fastlio_mapping-1] Multi thread started [fastlio_mapping-1] ~~~~/home/sky/mid360/ros_ws/src/FAST_LIO/ file opened [fastlio_mapping-1] [INFO] [1755537515.955457193] [laser_mapping]: Node init finished. [fastlio_mapping-1] Failed to find match for field 'time'. [fastlio_mapping-1] Failed to find match for field 'ring'. [fastlio_mapping-1] Failed to find match for field 'time'. [fastlio_mapping-1] Failed to find match for field 'ring'. [rviz2-2] [INFO] [1755537516.123347654] [rviz2]: Stereo is NOT SUPPORTED [rviz2-2] [INFO] [1755537516.123411995] [rviz2]: OpenGl version: 4.6 (GLSL 4.6) [rviz2-2] [INFO] [1755537516.135036306] [rviz2]: Stereo is NOT SUPPORTED [fastlio_mapping-1] IMU Initial Done [fastlio_mapping-1] [WARN] [1755537516.165249588] [laser_mapping]: No point, skip this scan! [fastlio_mapping-1] [fastlio_mapping-1] Failed to find match for field 'time'. [fastlio_mapping-1] Failed to find match for field 'ring'. [fastlio_mapping-1] [INFO] [1755537516.266224533] [laser_mapping]: Initialize the map kdtree [fastlio_mapping-1] Failed to find match for field 'time'. [fastlio_mapping-1] Failed to find match for field 'ring'. 

原因:你贴出的代码正是 FAST-LIO 的 preprocess.cpp
问题的根源是:当 lidar_type = 2(PointCloud2)时,默认的 default_handler 不会给点云里的每个点填充 curvature(即时间信息),于是 Fast-LIO 直接丢弃整帧,rviz 黑屏。

解决方法:

 -------------------------------------------------- 1 分钟补丁(改 `mid360_handler()`) 打开文件 ```bash gedit ~/mid360/ros_ws/src/FAST_LIO/src/preprocess.cpp ``` 找到 `mid360_handler()` 函数,把下面 3 行替换进去: - 找到 ```cpp added_pt.curvature = 0.; ``` 替换为 ```cpp /* 用整帧 header.stamp 作为统一时间戳 (ms) */ added_pt.curvature = rclcpp::Time(msg->header.stamp).seconds() * 1000.0; ``` (其余代码不动,只需改这一处。) 保存后: ```bash cd ~/mid360/ros_ws colcon build --packages-select fast_lio source install/setup.bash ros2 launch fast_lio mapping.launch.py ``` 日志立即不再出现 `Failed to find match for field 'time'`,`/cloud_registered` 10 Hz 正常输出,rviz 即可看到实时点云。

Read more

Flutter 三方库 stream_channel 的鸿蒙化适配指南 - 实现具备跨端通讯抽象与协议分层治理的流通道架构、支持端侧多维异步指令流管道化实战

Flutter 三方库 stream_channel 的鸿蒙化适配指南 - 实现具备跨端通讯抽象与协议分层治理的流通道架构、支持端侧多维异步指令流管道化实战

欢迎加入开源鸿蒙跨平台社区:https://openharmonycrossplatform.ZEEKLOG.net Flutter 三方库 stream_channel 的鸿蒙化适配指南 - 实现具备跨端通讯抽象与协议分层治理的流通道架构、支持端侧多维异步指令流管道化实战 前言 在进行 Flutter for OpenHarmony 的复杂通讯系统(如实现自定义的二进制协议、跨进程 IPC 或与嵌入式设备进行长连接)开发时,如何将原始的、读写分离的 IO 映射为统一、双工的指令流?stream_channel 是一款专注于流通讯抽象的核心库。它将一个 Stream(入站)和一个 StreamSink(出站)封装为单一、可组合的对象。本文将探讨如何在鸿蒙端构建极致、清亮的流通讯底座。 一、原直观解析 / 概念介绍 1.1 基础原理 该库建立在“双工通道(

By Ne0inhk
Rust异步测试与调试的实践指南

Rust异步测试与调试的实践指南

Rust异步测试与调试的实践指南 一、异步测试的基础 1.1 异步测试的概念 💡异步测试是对异步代码的功能和性能进行验证的过程,确保异步操作能够正确、高效地执行。与同步测试相比,异步测试需要处理任务调度、I/O操作和资源管理等复杂问题。 在Rust中,异步测试通常使用tokio::test宏或async-std::test宏来标记测试函数,这些宏会自动创建异步运行时环境。 1.2 常用的异步测试框架 * Tokio测试框架:适用于使用Tokio异步运行时的项目,提供tokio::test宏和tokio::spawn函数。 * Async-std测试框架:适用于使用async-std异步运行时的项目,提供async-std::test宏和async-std::task::spawn函数。 * Proptest:用于属性测试,支持异步属性测试。 * Mockall:用于模拟依赖对象,支持异步模拟。 1.3 简单异步函数的测试 下面是一个简单的异步函数测试示例: // src/lib.rsusetokio::time::sleep;usestd::time::D

By Ne0inhk
Java Web 科研工作量管理系统系统源码-SpringBoot2+Vue3+MyBatis-Plus+MySQL8.0【含文档】

Java Web 科研工作量管理系统系统源码-SpringBoot2+Vue3+MyBatis-Plus+MySQL8.0【含文档】

摘要 科研工作量管理是高校和科研机构面临的重要课题,传统的纸质或Excel记录方式效率低下且难以实现数据共享与分析。随着信息技术的快速发展,构建一个高效、智能的科研工作量管理系统成为迫切需求。该系统旨在解决科研人员工作量统计不准确、审核流程繁琐、数据可视化不足等问题,通过数字化手段实现科研项目的全流程管理。系统设计需兼顾不同角色的需求,包括科研人员、院系管理员和校级管理员,确保数据安全性和操作便捷性。关键词:科研工作量管理、数字化、数据共享、全流程管理。 本系统采用SpringBoot2框架构建后端服务,结合Vue3前端框架实现响应式用户界面,数据库选用MySQL8.0并利用MyBatis-Plus简化数据操作。系统功能模块包括科研项目管理、工作量统计、审核流程、数据可视化及报表生成。技术亮点包括RBAC权限控制、动态表单配置、多维度数据分析和实时消息通知。系统通过RESTful API实现前后端分离,采用JWT进行身份验证,确保数据传输安全。关键词:SpringBoot2、Vue3、MyBatis-Plus、RBAC、JWT。 数据表设计 科研项目信息表(research_p

By Ne0inhk
Flutter 组件 ubuntu_service 适配鸿蒙 HarmonyOS 实战:底层系统服务治理,构建鸿蒙 Linux 子系统与守护进程交互架构

Flutter 组件 ubuntu_service 适配鸿蒙 HarmonyOS 实战:底层系统服务治理,构建鸿蒙 Linux 子系统与守护进程交互架构

欢迎加入开源鸿蒙跨平台社区:https://openharmonycrossplatform.ZEEKLOG.net Flutter 组件 ubuntu_service 适配鸿蒙 HarmonyOS 实战:底层系统服务治理,构建鸿蒙 Linux 子系统与守护进程交互架构 前言 在鸿蒙(OpenHarmony)生态迈向工业互联、智能车载及深度客制化终端的背景下,如何实现 Flutter 应用对底层 Linux 服务(如 Systemd/DBus)的受控访问、在端侧治理长驻守护进程,已成为提升应用系统级集成能力的“技术门槛”。在鸿蒙设备这类强调内核级安全防护与微内核分布式调度的环境下,如果应用仅能实现表层 UI 的交互,而无法感知、重启或监控底层硬件驱动相关的后台服务,就无法在大屏中控、工业看板或服务器管理设备中胜任“控制塔”的角色。 我们需要一种能够穿透沙箱壁垒、支持 DBus 通信协议且具备高可靠服务状态感知能力的系统治理方案。 ubuntu_service 为

By Ne0inhk