8000 GitHub - OTTFFIVE/FAST-LIO-GNSS-PGO: Robust FAST-LIO2 mapping with covariance-aware GNSS factors, Scan Context loop closure, ICP verification, and GTSAM iSAM2 pose-graph optimization. · GitHub
[go: up one dir, main page]

Skip to content

About

Robust FAST-LIO2 mapping with covariance-aware GNSS factors, Scan Context loop closure, ICP verification, and GTSAM iSAM2 pose-graph optimization.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FAST-LIO-GNSS-PGO

Robust LiDAR-inertial mapping with GNSS positioning, Scan Context loop detection, ICP loop verification, and GTSAM pose-graph optimization.

This repository is an engineering integration based on hku-mars/FAST_LIO and the pose-graph design of gisbi-kim/SC-A-LOAM. It focuses on reliable FAST-LIO + GPS operation and reproducible system testing. DCReg is not used and is not required.

1. Background

FAST-LIO2 provides high-rate, locally smooth LiDAR-inertial odometry and an incremental ikd-Tree map. Its local estimator is accurate over short distances, but it has no absolute position reference. Long trajectories may therefore accumulate drift, especially when the platform revisits an area, remains in a geometrically weak scene, or operates for a long time.

GNSS provides globally referenced position but is noisy, asynchronous, and may contain dropouts or outliers. Directly forcing every GNSS sample into the front-end can damage local smoothness and destabilize scan matching. This project keeps FAST-LIO as the real-time local estimator and adds a separate GTSAM/iSAM2 back-end. The back-end creates keyframes and combines:

  • relative odometry constraints from FAST-LIO;
  • covariance-aware GNSS position factors;
  • Scan Context loop candidates;
  • ICP-verified loop-closure constraints.

The result is a locally smooth front-end trajectory together with a globally consistent optimized path and map.

flowchart LR
    L[LiDAR] --> F[FAST-LIO front-end]
    I[IMU] --> F
    F --> O[Local odometry and registered cloud]
    O --> K[Keyframe manager]
    G[GNSS NavSatFix] --> S[Time, covariance and UTM validation]
    I --> H[Optional heading alignment]
    K --> P[GTSAM iSAM2 pose graph]
    S --> P
    H --> P
    K --> C[Scan Context]
    C --> V[ICP verification]
    V --> P
    P --> M[Optimized path and map]
    P --> U[Local or UTM PCD export]
Loading

2. Main contributions

This repository primarily contributes a complete integration and reliability layer rather than replacing the FAST-LIO estimator with a new registration algorithm.

2.1 FAST-LIO and GNSS pose-graph integration

  • Connects FAST-LIO odometry and registered body-frame clouds directly to the SC-PGO keyframe pipeline.
  • Adds GNSS factors in a common local/UTM coordinate system.
  • Supports GPS antenna lever-arm compensation in the IMU/body frame.
  • Supports absolute IMU heading alignment or a configured initial yaw when an absolute heading is unavailable.
  • Exports optimized maps in either the local map frame or absolute UTM coordinates.

2.2 GNSS quality control

  • Selects the nearest GNSS and IMU measurements within configurable timestamp tolerances instead of blindly using the newest sample.
  • Consumes each GNSS fix at most once, preventing one fix from constraining multiple keyframes.
  • Rejects invalid status, latitude/longitude, covariance and UTM-zone changes.
  • Applies independent covariance gates to horizontal and vertical axes.
  • Allows a fix with unavailable altitude to constrain only horizontal position.
  • Initializes the UTM origin only from a GNSS fix that passes the quality gates.

2.3 Loop-closure and back-end robustness

  • Uses Scan Context for place recognition and ICP for geometric verification.
  • Rejects failed, non-finite or low-quality ICP candidates.
  • Bounds loop, sensor and visualization queues to prevent unbounded memory use.
  • Protects shared keyframes, loop queues and graph state across worker threads.
  • Caches the visualization map and rebuilds it only after poses or keyframes change.

2.4 FAST-LIO safety fixes

  • Replaces fixed-size residual/selection arrays with scan-sized dynamic storage.
  • Handles empty scans, invalid ring indices and undersized point clouds in the Livox, Velodyne/RS32 and Ouster preprocessing paths.
  • Prevents division by zero when a frame contains no usable plane residuals.
  • Rejects non-finite ESKF states and restores the propagated IMU state and covariance.
  • Does not insert a rejected LiDAR update into the ikd-Tree map.
  • Validates IMU initialization, LiDAR-to-IMU extrinsics and critical parameters.
  • Drops scans that are not covered by IMU data instead of reusing an old undistorted cloud.
  • Detects timestamp rollback and shuts the node down safely to avoid combining a new bag timeline with an old map and filter state.

2.5 Runtime and maintenance improvements

  • Limits path history and debug arrays to prevent long-run overflow.
  • Corrects odometry covariance publication order and PCL in-place filtering.
  • Handles log-file failures safely and shuts worker threads down cleanly.
  • Keeps the legacy experimental FPFH back-end disabled by default so the main build does not require Ceres.

3. Repository structure

FAST_LIO_GNSS_PGO/
├── FAST-LIO/                 # LiDAR-IMU odometry and ikd-Tree local mapping
│   ├── config/rs32.yaml      # RS32 LiDAR/IMU configuration
│   ├── launch/mapping_rs32.launch
│   └── src/
├── SC-PGO/                   # GNSS and loop-constrained GTSAM back-end
│   ├── launch/fastlio_rs32_gps.launch
│   ├── launch/fastlio_rs32_gps_system.launch
│   ├── srv/SaveMap.srv
│   └── src/laserPosegraphOptimization_gps_pcd.cpp
└── README.md

ROS package names are fast_lio and aloam_velodyne.

4. Requirements

The recommended target is Ubuntu 20.04 with ROS Noetic. ROS Melodic can also be used if compatible versions of PCL, Eigen and GTSAM are available.

Required components:

  • ROS1 with catkin;
  • CMake 3.10 or newer;
  • a C++14/C++17-capable GCC compiler;
  • Eigen3 and PCL 1.8 or newer;
  • OpenCV;
  • GTSAM 4.x;
  • OpenMP and pthreads;
  • ROS packages geodesy, geographic_msgs, visualization_msgs, pcl_ros, pcl_conversions, tf, tf2, cv_bridge and image_transport;
  • livox_ros_driver because it is a declared FAST-LIO build dependency, even when an RS32 sensor is used.

Install the common ROS dependencies on Noetic:

sudo apt update
sudo apt install -y \
  build-essential cmake git \
  ros-noetic-pcl-ros ros-noetic-pcl-conversions \
  ros-noetic-geodesy ros-noetic-geographic-msgs \
  ros-noetic-visualization-msgs ros-noetic-tf ros-noetic-tf2 \
  ros-noetic-cv-bridge ros-noetic-image-transport \
  libeigen3-dev libpcl-dev libopencv-dev libgtsam-dev

Install livox_ros_driver in the same catkin workspace if it is not already available in the ROS environment.

5. Build procedure

5.1 Prepare a clean catkin workspace

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
cp -r /path/to/FAST_LIO_GNSS_PGO/FAST-LIO .
cp -r /path/to/FAST_LIO_GNSS_PGO/SC-PGO .

Install any remaining package dependencies:

cd ~/catkin_ws
rosdep install --from-paths src --ignore-src -r -y

5.2 Clean Release build

For the first verification, use a clean build so stale objects cannot hide header or message-generation problems:

cd ~/catkin_ws
rm -rf build devel
catkin_make -DCMAKE_BUILD_TYPE=Release
source devel/setup.bash

The normal build produces these main executables:

fast_lio/fastlio_mapping
aloam_velodyne/alaserPGO_gps

Confirm that ROS can locate both packages and executables:

rospack find fast_lio
rospack find aloam_velodyne
rosrun fast_lio fastlio_mapping --help
rosrun aloam_velodyne alaserPGO_gps --help

The two rosrun ... --help commands may start the nodes rather than print a traditional CLI help page; use Ctrl+C after ROS confirms that each executable can be launched.

5.3 Optional experimental back-end

The legacy FPFH/Ceres node is not required for FAST-LIO + GPS. To compile it, install Ceres and explicitly enable it:

catkin_make -DCMAKE_BUILD_TYPE=Release \
  -DBUILD_EXPERIMENTAL_PGO=ON

6. Sensor configuration

6.1 FAST-LIO

Edit FAST-LIO/config/rs32.yaml and verify:

  • LiDAR and IMU topic names;
  • LiDAR model, scan-line count and timestamp unit;
  • LiDAR-to-IMU translation and rotation;
  • accelerometer/gyroscope noise and bias random walk;
  • blind range and voxel-filter sizes.

The RS32 launch also exposes two safety parameters:

<param name="min_effective_features" type="int" value="5" />
<param name="max_path_poses" type="int" value="20000" />

min_effective_features is the minimum number of valid point-to-plane residuals required for a LiDAR correction. An undersupported frame is propagated with IMU only and is not inserted into the map.

6.2 GPS and pose graph

Edit SC-PGO/launch/fastlio_rs32_gps.launch:

<param name="gps_topic" value="/localization/gps/fix"/>
<param name="imu_topic" value="/localization/imu/data"/>
<param name="use_imu_heading" value="true"/>
<param name="initial_yaw_deg" value="0.0"/>
<rosparam param="gps_lever_arm_body">[0.0, 0.0, 0.0]</rosparam>

gps_lever_arm_body is the GPS antenna position expressed in the FAST-LIO IMU/body frame:

p_GPS_in_body = [x, y, z] metres

Replace the zero vector with a measured or calibrated value. Set use_imu_heading=true only if sensor_msgs/Imu.orientation contains a valid absolute orientation compatible with ENU. Otherwise set it to false and use initial_yaw_deg to specify the rotation from the initial FAST-LIO x-axis to UTM East.

Default GNSS gates are:

<param name="gps_time_tolerance" value="0.10"/>
<param name="sensor_sync_tolerance" value="0.03"/>
<param name="gps_min_variance" value="0.01"/>
<param name="gps_max_xy_variance" value="4.0"/>
<param name="gps_max_z_variance" value="9.0"/>

Covariance values are variances in square metres. Do not tune these thresholds until the GNSS driver is confirmed to publish meaningful NavSatFix.position_covariance values.

7. Run and test procedure

7.1 Pre-flight topic checks

Before starting SLAM, check the input rates and timestamps:

rostopic hz /rslidar_points
rostopic hz /localization/imu/data
rostopic hz /localization/gps/fix
rostopic echo -n 1 /localization/gps/fix
rostopic echo -n 1 /localization/imu/data

Confirm that:

  • all timestamps use the same clock domain;
  • IMU frequency is substantially higher than LiDAR frequency;
  • GNSS status is valid and covariance is nonzero;
  • the IMU quaternion is normalized if absolute heading is enabled;
  • the LiDAR and IMU frame conventions match the configured extrinsics.

7.2 Start the complete system

source ~/catkin_ws/devel/setup.bash
roslaunch aloam_velodyne fastlio_rs32_gps_system.launch rviz:=true

The same system can be started as two nodes for easier diagnosis:

roslaunch fast_lio mapping_rs32.launch rviz:=false
roslaunch aloam_velodyne fastlio_rs32_gps.launch rvizscpgo:=true

7.3 Verify the ROS graph

rosnode list
rostopic hz /Odometry
rostopic hz /cloud_registered_body
rostopic hz /aft_pgo_odom
rostopic echo -n 1 /GpsOdom

Expected outputs:

Topic Description
/Odometry high-rate FAST-LIO local odometry
/cloud_registered_body registered cloud consumed by the back-end
/aft_pgo_odom latest optimized keyframe pose
/aft_pgo_path optimized keyframe trajectory
/aft_pgo_map optimized local-frame point-cloud map
/GpsOdom GNSS constraint accepted in the local map frame

If /Odometry is healthy but /GpsOdom is absent, inspect GNSS status, covariance, timestamp tolerance, UTM zone and topic remapping before changing factor noise.

7.4 Repeatable rosbag test

Use simulated time and start the nodes before playing the bag:

rosparam set use_sim_time true
roslaunch aloam_velodyne fastlio_rs32_gps_system.launch rviz:=false
rosbag play --clock --pause /path/to/dataset.bag

Release pause after all subscribers are connected. For every replay from the beginning, restart the FAST-LIO node. A backward timestamp is intentionally treated as a safe shutdown condition because retaining the old ESKF/map state across a new bag timeline would corrupt the map.

Recommended test sequence:

  1. Run FAST-LIO with use_gps=false to verify LiDAR-IMU odometry and extrinsics.
  2. Enable GPS and verify that accepted fixes appear on /GpsOdom.
  3. Drive or replay a loop and confirm that Scan Context candidates are accepted only after ICP verification.
  4. Compare /Odometry and /aft_pgo_path: the former should remain locally smooth while the latter removes long-term drift.
  5. Repeat the same bag and configuration to check deterministic behavior.

7.5 Save and inspect the map

Local-frame map:

rosservice call /opt/save_map \
  "{utm: false, resolution: 0.2, destination: '$HOME/FAST_LIO_GNSS_PGO/maps/local_map.pcd'}"

Absolute UTM map:

rosservice call /opt/save_map \
  "{utm: true, resolution: 0.2, destination: '$HOME/FAST_LIO_GNSS_PGO/maps/utm_map.pcd'}"

UTM export becomes available only after a valid GNSS factor initializes the origin. The node prints the selected UTM zone and local origin.

8. Verification record for this revision

The source review for this revision covered the active FAST-LIO front-end, point-cloud preprocessing, ESKF measurement update, GNSS synchronization, GTSAM back-end, loop verification, visualization and map-export paths.

Completed in the available development environment:

Check Result
Changed-file review and whitespace validation Passed
ROS launch XML parsing Passed
Python syntax parsing Passed
Regression search for fixed-array, zero-residual division and in-place PCL filtering patterns Passed
Working-copy/original-tree SHA-256 comparison for all modified files Passed

The available development host was Windows without ROS, CMake, GCC/Clang or a configured WSL distribution. Consequently, a genuine catkin_make and sensor runtime test could not be executed on that host after the final source changes. Run Sections 5 and 7 on the target Ubuntu/ROS computer before deployment. This distinction is intentional: static validation is not reported as a successful ROS compilation.

For a release or field deployment, record at least:

  • Ubuntu and ROS versions;
  • GCC, PCL, Eigen and GTSAM versions;
  • the complete catkin_make output;
  • sensor topic rates and timestamp sources;
  • the exact YAML/launch configuration;
  • bag name, duration and trajectory length;
  • GNSS acceptance count, loop-closure count and saved-map resolution;
  • trajectory metrics such as ATE/RPE when ground truth is available.

9. Initial tuning guidance

  • Start with keyframe_meter_gap=0.5 for vehicle mapping; increase it to reduce memory and optimization load.
  • Keep sc_dist_thres near 0.10-0.20; a smaller value is stricter.
  • Start with loop_max_correspondence_distance=5.0 and increase it only if the expected loop drift is larger.
  • Diagnose timestamps, coordinate frames, lever arm and GNSS covariance before tuning graph weights.
  • If the LIO and GPS trajectories point in different directions, correct ENU heading alignment instead of compensating with larger noise.
  • Tune LiDAR/IMU 5372 noise only after time synchronization and extrinsic calibration are verified.

10. Credits

Please follow the licenses and citation requirements of the upstream projects.

About

Robust FAST-LIO2 mapping with covariance-aware GNSS factors, Scan Context loop closure, ICP verification, and GTSAM iSAM2 pose-graph optimization.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0