Repository navigation
fix(autoware_ekf_localizer): gate on squared Mahalanobis distance of the innovation covariance - #1465
JArmandoAnaya wants to merge 4 commits into
Conversation
|
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
45e9b42 to
cdc3b1b
Compare
ba829cd to
4afce3e
Compare
|
Reviewed One documentation correction: the README's “Tune gate parameters” section and the pose/twist schema descriptions still call these parameters limits on Mahalanobis distance. They now limit squared Mahalanobis distance. The README should also distinguish the unsquared diagnostic values from these configured thresholds. I have prepared a three-file wording-only patch; no threshold values or runtime behavior change. I also checked the downstream launch config. The required AI assistance: OpenAI Codex investigated the code, ran the checks and drafted this review and wording patch. |
b9ccaac to
9b26bd1
Compare
|
Thanks for the review. I've pushed an update (head The gate also now uses the full innovation covariance ( Could a maintainer add the |
Some numbers that support doing fix 1 and fix 2 together. With the default parameters the two issues in the current gate happen to cancel, so the current gate width in metres is close to the intended one, and either fix alone moves it by a factor of about 7. Size of a purely lateral position residual at which rejection starts,
Direct check of the first row: for a 2.03 m lateral residual the current gate reported a distance of 41.2 against the limit 49.5, and none of the 333 gate evaluations rejected it. Because the current gate uses
With Setup: AI usage: I wrote this with Claude Code (Claude Fable 5.2), from my direction. The agent ran the replays, added the logging and computed the table. I read the comment and did not re-run ROS myself; a separate AI review (GPT-6.1-sol) re-computed the rejection counts and the first gate distance of each condition from the saved logs, and they matched. |
…t the unsquared value pose_gate_dist and twist_gate_dist are chi-square quantiles (e.g. 49.5 for 3 dof at significance 1e-10), which are thresholds on the squared Mahalanobis distance. measurement_update_pose/measurement_update_twist were comparing the unsquared distance (sqrt of the squared value) directly against these thresholds, making the gate reject only at ~7x the documented distance (squared-distance acceptance region ~49.5x larger than intended). Fixes the comparison to use squared_mahalanobis() against the existing config defaults, unchanged. distance (unsquared) is kept for the diagnostic field and warning message, with the printed threshold adjusted to sqrt() of the gate_dist param so both operands share units. Same fix applied to the diagnostics array construction in ekf_localizer_node.cpp, which reported the same unsquared/squared mismatch. Fixes autowarefoundation#1464 Signed-off-by: Jesus Armando Anaya <armando@robomous.ai>
…halanobis gate The pose and twist gates normalized the innovation by the predicted state covariance block only (H P H^T), while the Kalman update that follows uses the innovation covariance S = H P H^T + R. The gate therefore ignored the measurement's own uncertainty: a noisy measurement with a large reported covariance could be rejected even though the filter would weight it lightly, and the chi-square thresholds (which assume the innovation is distributed with covariance S) were applied to the wrong statistic. Build R once with pose_measurement_covariance/twist_measurement_covariance (message covariance scaled by the smoothing steps), form S = C P C^T + R from the same C and R passed to updateWithDelay, and gate on the squared Mahalanobis distance under S. The gate and the update now agree on the innovation covariance. Signed-off-by: Jesus Armando Anaya <armando@robomous.ai>
…obis limits pose_gate_dist and twist_gate_dist are chi-square quantiles and limit the squared Mahalanobis distance of the innovation, normalized by the innovation covariance (predicted state covariance plus measurement covariance). Update the "Tune gate parameters" section and the schema descriptions accordingly, and note that diagnostics report the unsquared distance against the square root of the parameter. Wording only; threshold values are unchanged. Signed-off-by: Jesus Armando Anaya <armando@robomous.ai>
… covariance and diagnostics threshold The existing RejectsOnMahalanobisGate tests use gate distances (1e-6, 10000.0) extreme enough that neither squaring the distance nor including the measurement covariance changes their verdict. Add pose and twist tests at the shipped defaults (49.5, 46.1): - RealisticGateRejects/Accepts: the unsquared distance under the innovation covariance lies between sqrt(gate_dist) and gate_dist, so only the squared comparison rejects it; the warning reports sqrt(gate_dist). - GateAcceptsOffsetCoveredByMeasurementCovariance: an offset that a state-covariance-only gate rejects is accepted once the large measurement covariance R is included in S = H P H^T + R. - GateRejectsSameOffsetWithTightMeasurementCovariance: the same offset with a tight R is rejected. - Node integration: the published pose/twist mahalanobis_distance_threshold diagnostics equal sqrt(pose_gate_dist)/sqrt(twist_gate_dist). Checked locally that the Realistic*/tight-R/diagnostics tests fail against an unsquared comparison and that the Realistic*/large-R tests fail against a gate built from the state covariance only. Signed-off-by: Jesus Armando Anaya <armando@robomous.ai>
6cce6a0 to
466e380
Compare
|
Thanks @DWatabe for the analysis. Your table is independent evidence that the gate fix and the process-noise fix belong together: with default parameters the two bugs cancel, and fixing only the gate shrinks it to roughly 0.34–0.43 m. This PR is intentionally the gate fix only (squared distance on the innovation covariance S = C P C^T + R). The x/y process-noise change is kept separate and will be positioned against #1548 before it is proposed. I rebased the branch onto current Could a maintainer add the |
|
This pull request comes from a fork, so its documentation site is built but not published.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1465 +/- ##
==========================================
- Coverage 82.36% 82.32% -0.05%
==========================================
Files 421 413 -8
Lines 23857 23230 -627
Branches 147 0 -147
==========================================
- Hits 19650 19124 -526
+ Misses 4177 4106 -71
+ Partials 30 0 -30
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Fixes the Mahalanobis gating in
autoware_ekf_localizerfor pose and twist measurements. This PR was originally two changes; the x/y process-noise change has been split out and will be proposed separately (see "Notes for reviewers").1. Gate on the squared Mahalanobis distance (closes #1464)
pose_gate_distandtwist_gate_distare chi-square quantiles on the squared Mahalanobis distance (e.g.49.5for 3 dof at significance1e-10), butmeasurement_update_pose/measurement_update_twistcompared the unsquared distance (mahalanobis(), thesqrtof the squared value) against them. The deployed gate therefore rejected only at aboutsqrt(49.5) ≈ 7.04x further out than the documented significance level implies.The comparison now uses the squared distance against the unchanged config values. The unsquared distance is still used for the diagnostic field and the warning message, whose printed threshold is now
sqrt(gate_dist)so both numbers share units. The same mismatch in the diagnostics array inekf_localizer_node.cppis fixed the same way.2. Gate on the innovation covariance
The gate statistic used only the state covariance block
P. The chi-square interpretation requires the innovation covarianceS = C P C^T + R, with the sameCandRthat are passed toupdateWithDelay. The gate now usesS, so the gate and the update agree. Without this, tightening the gate (fix 1) makes it reject measurements whose own noise explains the residual.3. Documentation
The README "Tune gate parameters" section and the
pose_gate_dist/twist_gate_distschema descriptions now state that these limit the squared Mahalanobis distance, and that the diagnostics report the unsquared distance. No threshold values change.Related links
Parent Issue:
How was this PR tested?
autoware_ekf_localizergtests in an offline container (Jazzy, CUDA devel image) on this exact branch: all pass exceptxmllint, which needs network access to fetch its schema. The launch test was not run.Rthat the state-only distance would reject is accepted, a tight-Rmeasurement is rejected, and the diagnostics report the square root of the threshold. The existingRealisticGateRejects*tests fail without fix 1; removingRfrom the gate or reverting to the unsquared comparison makes the new tests fail.Notes for reviewers
R(fix 2) is what keeps the statistic bounded by the measurement noise.P, whereas the update usesPat the delayed step; the two coincide only when there is no delay. Making them consistent needs a new getter inautoware_kalman_filter, so it is left out of this PR.process_noise.proc_stddev_xy_c, which stops the stationary position covariance from collapsing) is intentionally not part of this PR. It adds a required parameter and needs a pairedautoware_launchchange, so it will be proposed on its own after this one.Interface changes
No ROS parameter, topic or message changes.
Effects on system behavior
sqrt(gate_dist).