How mourams/livox_ros_driver2 works
Project Type and Purpose
• This is a full-stack robotics driver package (“Livox ROS Driver 2”), providing a bridge between Livox LiDAR hardware and ROS/ROS2.
• It configures LiDAR devices over the network, ingests raw data packets, parses and queues them, then publishes point-cloud messages to ROS topics for visualization or recording.
File Structure
• Top-level directories:
• 3rdparty/rapidjson → JSON parser library for config files
• config/ → JSON config templates for HAP, MID360, mixed setups
• launch_ROS1/launch_ROS2 → ROS1 XML launch files and ROS2 Python launch scripts
• msg/ → Custom ROS message definitions
• src/parse_cfg_file → Code to read and interpret JSON configs
• src/comm/ → Communication utilities (queues, semaphores, packet handlers)
• src/call_back/ → Callbacks for different LiDAR models
• src/… .cpp/.h → Driver node entrypoint, util modules, SDK integration
README for Additional Insights
• Core flow:
1) Read JSON config (via rapidjson)
2) Use Livox-SDK2 to send configuration commands
3) Open UDP ports to receive point and IMU data
4) Parse raw packets → CustomMsg/CustomPoint or standard PointCloud2
5) Publish to ROS topics
6) Optionally launch RViz or rosbag record
Main Components & Interactions
a. Hardware & External Services
• LiDAR devices (HAP, MID360) on network
• ROS1/ROS2 middleware (roscore or ROS2 DDS)
• RViz visualization
• rosbag (optional)
b. Internal Driver Components
• Config Parser (src/parse_cfg_file + rapidjson)
• Network Interface (Livox-SDK2 + sockets)
• Comm Layer (src/comm: cache_index, data_queue, pub_handler)
• Callback Layer (src/call_back: model-specific packet handlers)
• Driver Node (livox_ros_driver2_node entrypoint)
• Message Definitions (msg/CustomMsg.msg, CustomPoint.msg)
c. Data Flows & Relationships
1) Launch file passes parameters → Driver Node
2) Driver Node loads JSON via Config Parser
3) Driver Node calls Livox-SDK2 to configure devices
4) Driver Node opens UDP sockets to receive data
5) Raw packets → Comm Layer → Callback Layer
6) Processed point clouds → ROS topics
7) Topics → RViz / rosbag
8) Optionally multiple instances (multi-topic)
Architectural Patterns & Design Principles
• Publisher–Subscriber (ROS topics)
• Modular layering:
• Separation of concerns (config, network, parsing, publishing)
• Extensibility (callback modules per LiDAR type)
• Use of industry libraries: rapidjson for config, Livox-SDK2 for low-level comms, PCL for optional data types
Final Checklist
• All src subdirectories represented (parse_cfg_file, comm, call_back)
• JSON config files feeding into parser
• Launch file layer feeding parameters
• Network flow from devices to node
• ROS topics as central bus
• Visualization & recording as sinks