lidar_localization_ros2

repository·main·Indexed 19 days ago

https://github.com/rsasaki0109/lidar_localization_ros2

A map-based 3D LiDAR localization system for ROS 2 and Nav2 supporting NDT/GICP algorithms against .pcd and .ply maps. It features a GLIL-style GLIM prior-map localizer with tightly coupled architecture, continuous-time deskewing, and guarded global initialization. The system supports sensors like the Livox MID-360 and includes advanced capabilities such as a scan-bounded dual IMU queue, an IMU seed consistency gate, and kidnap recovery using a deferred exact-coreset approach.

Tokens
57.5K
Snippets
107
Records
252
Agent score
68%

What's inside lidar_localization_ros2

  1. Understand the Global Localization Roadmap and Scope

    main

    The global localization feature is being developed in phases. Current development focuses on map-wide candidate generation and runtime services, but it is not yet intended for production-grade kidnapped-robot recovery or as part of the default bringup path.

    Current Non-Goals:

    • Production-grade kidnapped-robot recovery.
    • GPU-accelerated global search (current behavior is CPU-based using BBS/FPFH).
    • Integration into the default bringup path.
  2. Understand v1.0.0 features and capabilities

    main

    The v1.0.0 release of lidar_localization_ros2 includes the following core components:

    Core Localization

    • ROS 2 LiDAR localization node: Includes lifecycle support.
    • Registration Backends: Selectable backends including NDT, GICP, NDT_OMP, GICP_OMP, SMALL_GICP, and SMALL_VGICP.
    • Map Loading: Supports .pcd and .ply pointcloud-map loading with local-map cropping for large maps.
    • Prediction Paths: Includes odom, twist, and guarded IMU-preintegration prediction paths.

    Integration & Diagnostics

    • Nav2 Support: Includes localization-only and full Nav2 launch files.
    • Diagnostics: Alignment status is available on /alignment_status, and reinitialization requests are output on /reinitialization_requested.
    • Supervision: An optional external supervisor can republish /initialpose from the Nav2 wrapper.

    Hardware & Tools

    • MID-360 Support: Includes bringup launch, config, and check helpers for legged robots using Livox MID-360.
    • Testing Tools: Includes rosbag benchmarks, replay smoke tests, public/release regression helpers, and artifact-first experimental relocalization tools.
  3. Understand the current capabilities and limits of lidar_localization_ros2

    main

    The project provides a ROS 2 3D LiDAR map-based localization package with the following core features:

    • Lifecycle Support: ROS 2 localization node with lifecycle management.
    • Nav2 Integration: Launch helpers for localization-only or full navigation, including a recommended preset: param/nav2_ndt_urban.yaml.
    • Selectable Backends: Supports NDT, GICP, NDT_OMP, GICP_OMP, SMALL_GICP, and SMALL_VGICP.
    • Robustness Features: Local-map cropping, guarded update logic, recovery diagnostics, and reinitialization request outputs.
    • Benchmarking: Public replay/regression scripts and rosbag benchmark tooling.
    • Relocalization: An experimental artifact-first relocalization pipeline for validated dry-run /initialpose commands.

    Current Known Limits:

    • Global relocalization is not yet production-ready (v1.1 is an artifact-first evaluation path).
    • Covariance semantics are still being refined.
    • Real-world hardware behavior (e.g., Jetson + MID-360) requires separate validation for thermal, vibration, and extrinsics.
  4. Understand the IMU estimation layers

    main

    The package provides a layered set of IMU-aided estimation options. These are opt-in; the default configuration uses pure NDT/GICP tracking and does not use the IMU path. You can choose from the following layers based on your computational budget and accuracy requirements:

    1. Twist prediction: Uses use_twist_prediction and use_twist_prediction_use_angular_velocity. It performs constant-twist motion prediction between scans using IMU or odometry angular velocity to rotate the seed.
    2. Twist EKF: Uses use_twist_ekf. A small constant-velocity Extended Kalman Filter (EKF) on the twist that feeds both the prediction seed and the published covariance.
    3. IMU preintegration + smoother: Uses use_imu and use_imu_preintegration. This is the most advanced layer, implementing on-manifold IMU preintegration (Forster et al. 2017) within a sliding-window Gauss-Newton optimizer. It includes 6-DOF NDT priors and online gyro/accel bias estimation.
    4. Twist GTSAM smoother: Uses use_gtsam_smoother. A sliding-window odometry+NDT smoother that does not use raw IMU data.
  5. Runtime Contract for MID-360 Legged Robot Localization

    main

    When using the MID-360 legged robot configuration, the localization stack expects specific inputs and provides specific outputs. This stack acts as a localization boundary and does not manage walking control, motor estimation, or the MID-360 driver itself.

    Required Inputs

    • PointCloud2: From the MID-360. Default topic: /livox/points.
    • IMU (Optional): From the MID-360. Default topic: /livox/imu.
    • Body Twist (Optional): As TwistWithCovarianceStamped. Default topic: /twist.
    • Odometry: An odometry source must publish the odom -> base_link transform if enable_map_odom_tf:=true is set.
    • Initial Pose: An initial pose on /initialpose is required, unless set_initial_pose:=true is used to provide a known starting pose via parameters.
    • Map: A prebuilt .pcd or .ply pointcloud map.

    Published Outputs

    • /localization/pose_with_covariance
    • /path
    • /alignment_status
    • /reinitialization_requested
    • map -> odom TF (by default)
    • /initial_map
  6. Use NDT_OMP with 6-DoF Hessian diagnostics

    main
    The NDT_OMP backend supports 6-DoF Hessian diagnostics to evaluate localizability. This diagnostic is implemented as a default-off feature to avoid latency overhead. It provides metrics like weak ratio and condition numbers to help diagnose registration failures. Use this for offline analysis or debugging rather than real-time deployment unless latency requirements are met.
  7. How the IMU seed consistency gate works

    main

    The IMU seed consistency gate is a safety mechanism that validates an IMU-predicted pose against the currently accepted LiDAR pose before allowing the IMU prediction to seed the registration process.

    To pass the gate, the comparison must satisfy both translation and rotation thresholds for five consecutive accepted updates.

    Failure Conditions: Permission to use the IMU seed is revoked immediately if any of the following occur:

    • Missing updates
    • Non-finite values in the comparison
    • Failed evidence (exceeding thresholds)

    If the gate is not passed, the system remains in an open-loop state with respect to registration, meaning it does not use the IMU prediction as a seed.

  8. Understand the pose initialization order

    main

    The startup manager follows a strict hierarchy to determine the initial pose. It will use the first valid method found in this order:

    1. Explicit Pose: Provided via the --initial-pose flag. This disables both saved-pose publication and global search for that session.
    2. Saved Pose: The last verified pose associated with the exact SHA-256 hash and byte size of the current .pcd or .ply map.
    3. Global Search: Guarded BBS_2D search triggered when --occupancy-map is supplied.
    4. Manual Input: An operator-provided pose via the 2D Pose Estimate tool in RViz.

    Note: There is no implicit (0, 0, 0) fallback. If all methods fail, the system will not publish a pose.

    Saved Pose Details:

    • Location: ~/.local/state/lidar_localization_ros2/<map-name>.json
    • Safety: A pose is only saved after fresh diagnostics report stable tracking and acceptable fitness for a configured number of consecutive samples. It is rejected if the map content changes or if the NDT score gate fails to converge.
  9. Understand Multi-Criteria Measurement Acceptance

    main

    This mechanism allows the system to accept degraded-but-consistent registration results that a standard scalar fitness gate might reject. This prevents the system from entering long reject streaks when ground-truth poses have lower fitness scores than the hard threshold.

    Key variants include:

    • fixed_threshold: The runtime baseline using a scalar fitness threshold.
    • bounded_degraded: Uses a correction cross-check with a non-resetting degraded-accept budget.
    • correction_conditioned: Combines a fitness threshold with a correction/staleness cross-check.
    • score_ratio_budget: Uses a relative score cap with a gap/streak budget.
  10. Understand Koide GLIL-Style Prior-Map Localization

    main

    Koide GLIL-style localization uses a fixed-lag graph (GLIM) to jointly optimize three components:

    1. IMU preintegration
    2. Exact-coreset scan-to-scan GICP
    3. Exact-coreset scan-to-prior-map GICP

    This approach follows the sliding-window estimator structure from Koide et al. (ICRA 2024) and uses deferred exact point-cloud downsampling (ICRA 2025). Unlike legacy split methods, scan-to-map results are not solved independently; instead, each map observation constrains the same active pose states as scan-to-scan and IMU factors. This ensures continuous range-inertial odometry even if map overlap is lost.

  11. Understand the Global Localization Stack (G1, G2, G3)

    main

    The global localization stack is designed to recover a usable pose when the initial pose is unknown or lost, and to automatically re-seed tracking when divergence occurs. It consists of three distinct stages:

    1. G1 (Map-wide candidate generation): An offline/artifact-first stage that uses a BBS_2D branch-and-bound algorithm over an occupancy grid to find potential pose candidates. Entry point: scripts/make_bbs_relocalization_attempts.py.
    2. G2 (On-demand relocalization service): A runtime ROS 2 service that exposes G1 results. It allows users to query for ranked candidates based on the latest scan. Entry point: scripts/global_localization_node.py.
    3. G3 (Guarded automatic reinitialization): A supervisor that monitors for lost-tracking signals, queries G2, and automatically publishes an /initialpose only after passing several safety guards. Entry point: scripts/reinitialization_supervisor_node.py.

    Prerequisites:

    • G1 and G2 require an occupancy grid generated from a map PCD using scripts/generate_occupancy_map_from_pcd.py.
    • G3 requires both a running localization node and a running G2 node.
  12. Implement Odometry-Aware Guarded Recovery

    main

    To prevent catastrophic failures during global localization (kidnapping), the system uses an 'Odometry-aware guarded recovery' mechanism:

    1. Forward Propagation: When a global candidate is found, use the current odometry to forward-propagate the candidate's scan timestamp to the current publish time.
    2. Relative Calculation: Calculate the transform from map -> odom from the candidate pose, but do not immediately reset the odometry state.
    3. Probation Period: Monitor the candidate during a probation phase by checking:
      • Map score
      • Relative-motion consistency
      • Pose jump magnitude
      • Covariance
    4. Rollback: If the candidate fails the probation checks, perform an atomic rollback and enter a bounded cooldown period.