How koide3/hdl_graph_slam works
Project type and purpose
• hdl_graph_slam is a ROS-based full-stack SLAM package for real-time 6DOF mapping with a 3D LiDAR.
• Its core function is to ingest raw point clouds (and optionally IMU, GPS), run odometry, floor detection, loop detection, optimize a pose graph, and produce a consistent 3D map.
File structure
• Top-level:
• apps/ – standalone demo nodelets
• / & src/ – core C++ & Python code under hdl_graph_slam and g2o extension
• launch/ – ROS launch files configuring parameters and nodelet loading
• msg/, srv/ – custom ROS messages (FloorCoeffs, ScanMatchingStatus) and services (DumpGraph, SaveMap)
• package.xml, CMakeLists.txt – ROS build/config
• docker/ – containerized build environments
• Patterns:
• Nodelet-based modular pipeline (four nodelets)
• Graph optimization via g2o library
• Python utilities (bag_player.py, ford2bag.py) for data playback/conversion
README for insights
• Four nodelets form a processing pipeline:
1) prefiltering_nodelet
2) scan_matching_odometry_nodelet
3) floor_detection_nodelet
4) hdl_graph_slam_nodelet (graph optimizer)
• Supported constraints: odometry, loop closures, GPS, IMU accel/orientation, floor plane
• Publishes optimized poses and map; offers services to dump/ save map.
a. Main components
• Sensors: 3D LiDAR, IMU, GPS
• Nodelets (processing modules)
• Graph Optimizer (g2o backend)
• ROS communication layer (topics, services)
• Output: optimized trajectory & 3D map
• External dependencies: ndt_omp/fast_gicp for scan matching, PCL, suitesparse
b. Relationships and interactions
• LiDAR → /velodyne_points (Topic) → prefiltering_nodelet
• Prefiltered cloud → scan_matching_odometry_nodelet → publishes odometry (Edge: odometry constraint)
• Same cloud → floor_detection_nodelet → publishes floor_coeffs (Edge: floor constraint)
• IMU → /imu_data → hdl_graph_slam_nodelet (accel/orientation constraints)
• GPS → /gps/* → hdl_graph_slam_nodelet (GPS constraint)
• scan_matching_odometry + floor_detection + loop detection → pose graph → g2o optimizer
• Optimizer → publishes corrected poses → map generator → /map → rviz / pcd file via SaveMap service
c. Architectural patterns/design principles
• Nodelet pipeline for zero-copy intra-process communication
• Modular constraint-based graph SLAM
• Separation of concerns: sensor filtering, odometry, environment feature detection, global optimization
• Extensibility via ROS messages/services and g2o edge definitions
d. Key technologies/frameworks/libraries
• ROS (nodelets, topics, services, launch files)
• PCL for point cloud processing
• ndt_omp / fast_gicp for scan matching
• g2o for graph optimization
• OpenMP, SuiteSparse for linear solvers