Integrating a LiDAR in ROS2: Complete Guide
Step-by-step guide to integrate an Ouster, Hesai, Livox or SICK LiDAR into ROS2 (Humble/Iron/Jazzy): driver installation, network setup, PTP, QoS, launch files, RViz2 visualization, SLAM and sensor fusion.
1. Introduction
LiDAR has become essential in mobile robotics for autonomous navigation, SLAM mapping and perception. This guide covers integration of Ouster (ouster-ros), Hesai (hesai_ros_driver), Livox (livox_ros_driver2) and SICK (sick_scan_xd) drivers in ROS2 Humble, Iron and Jazzy.
2. Driver Installation
Ouster: git clone --branch ros2 https://github.com/ouster-lidar/ouster-ros.git, colcon build. Topics: /ouster/points (PointCloud2), /ouster/imu. Hesai: git clone https://github.com/HesaiTechnology/hesai_ros_driver.git. Topics: /hesai/pandar. Livox: git clone https://github.com/Livox-SDK/livox_ros_driver2.git. Topics: /livox/lidar. SICK: git clone https://github.com/SICKAG/sick_scan_xd.git. Topics: /scan (2D), /cloud (3D).
3. Network Configuration
Set a static IP on the same subnet as the LiDAR (e.g. 192.168.1.50/24). Enable PTP (IEEE 1588) via linuxptp for precise timestamping: sudo ptp4l -i eth0 -m -s. Use BEST_EFFORT QoS in ROS2 for point clouds to prevent DDS saturation.
4. Visualization and Advanced Processing
Visualize the point cloud in RViz2 (Add > PointCloud2). For 2D SLAM, use slam_toolbox after projection via pointcloud_to_laserscan. For 3D SLAM, use Cartographer. LiDAR/IMU fusion uses robot_localization. For clustering and obstacle detection, use PCL (pcl_ros).
5. Checklist and Conclusion
Verify: ROS2 sourced, driver built, static IP, ping OK, PTP active, BEST_EFFORT QoS, RViz2 working, TF published and SLAM validated. Key to successful integration: network config, ROS2 QoS and correct TF tree.