How livox-sdk/livox_ros_driver works
Project type and purpose
• This is a ROS (Robot Operating System) driver package (“livox_ros_driver”) for Livox LiDAR devices (single‐unit LiDAR or multi‐port Hub).
• Purpose: establish communication with Livox hardware (via Livox‐SDK), parse raw LiDAR packets or files (LVX), publish point clouds and custom messages on ROS topics, and optionally synchronize timestamps via GPS.
File structure
• Top‐level: .gitignore, LICENSE, README.md, CMakeLists.txt, package.xml → standard ROS/Catkin package.
• livox_ros_driver/common → third‐party libraries (FastCRC for checksums; RapidJSON/RapidXML for config and XML parsing).
• livox_ros_driver/config → JSON configuration files (livox_lidar_config.json, livox_hub_config.json) and RViz view presets.
• livox_ros_driver/launch → ROS launch files orchestrating nodes, passing parameters, autoloading RViz or rosbag conversion.
• livox_ros_driver/livox_ros_driver → core C++ implementation: communication layers (comm_protocol, lds*, ldq, lddc), LVX file handling, node main entry point.
• livox_ros_driver/msg → ROS message definitions (CustomMsg, CustomPoint).
• livox_ros_driver/timesync → GPS‐based timestamp synchronization module (serial port interface).
Extract architecture insights from README
• The driver is a single ROS node (can be run in multiple instances via different launch files).
• It depends on Livox-SDK for low‐level device communication.
• Configuration is supplied via JSON files, loaded at startup by launch files.
• Publishes multiple topic types: standard sensor_msgs/PointCloud2, custom liveox formats, and can record to rosbag or feed RViz.
a. Main components
• Hardware layer:
– Livox LiDAR devices (over Ethernet or USB)
– Livox Hub (aggregates multiple LiDARs)
– GPS receiver + PPS signal (for timesync)
• Driver layer (livox_ros_driver node):
– Comm module (comm_protocol)
– Data unpackers (lds_lidar, lds_hub, lvx_file)
– Timestamp sync (timesync module)
– JSON/XML parser (RapidJSON/RapidXML)
– CRC checker (FastCRC)
– ROS publishers (PointCloud2, CustomPoint, CustomMsg)
• ROS core/services:
– Parameter server (for configs)
– Topics and message bus
• Client layer:
– rviz (visualization)
– rosbag (record/playback)
– Other ROS nodes subscribing to LiDAR data
b. Relationships and interactions
1. Launch file → loads parameters from JSON → ROS parameter server
2. livox_ros_driver node reads parameters → initializes Livox‐SDK
3. Comm module connects to devices (LiDAR/Hub) → receives raw packets
4. Raw data passes through CRC → protocol parser → data queues
5. timesync module optionally reads GPS serial → adjusts packet timestamps
6. Data converters produce ROS messages → publish on topics
7. Clients (rviz, rosbag recorders, downstream nodes) subscribe to topics
c. Architectural patterns & principles
• Modular separation: communication, parsing, publishing, timesync
• Dependency injection via launch-file and config parameters
• Single‐responsibility nodes (one livox_ros_driver instance per device type or conversion use case)
• Plugin-free but layered code organization under livox_ros_driver/
d. Key technologies & libraries
• ROS (catkin, topic/launch/parameter server)
• Livox-SDK (device API)
• C++17 (or C++11)
• RapidJSON / RapidXML for config parsing
• FastCRC for integrity checks
• PCL / sensor_msgs/PointCloud2 for cloud formats
Elements
• Components: LiDAR, Hub, GPS, livox_ros_driver node (with sub‐components), ROS Core, clients
• Hardware (green)
• Driver internals (blue)
• ROS infrastructure (orange)
• Clients (purple)
• From hardware → comm module → parser → publishers → clients
• From GPS → timesync → timestamp adjuster
• From JSON files → parameter server → driver
• Clear labels for message types (PointCloud2, CustomPoint), topic names, ports/protocols