Repository navigation
Fix outlier gate to compare residual against sqrt(map_v + v) - #147
Open
shravankumargulvadi wants to merge 1 commit into
Open
shravankumargulvadi wants to merge 1 commit into
shravankumargulvadi wants to merge 1 commit into
Conversation
Author
|
Closing, opened prematurely, will resubmit after internal review. |
The outlier gate compared |map_h - z| (metres) against map_v * mahalanobis_thresh (square metres). As cells converge and map_v shrinks, the acceptance band collapses quadratically, so confident cells reject good measurements and each rejection inflates variance again. Compare against the residual standard deviation instead: for independent cell and measurement errors the residual variance is map_v + v, so the gate becomes sqrt(map_v + v) * thresh, matching what "Mahalanobis distance" means and keeping both sides in metres. Applied to the fusion gate, the edge-sharpen check, and the drift- compensation inlier counter. The same expressions are fixed in kk.py, which is currently dead code. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
shravankumargulvadi
force-pushed
the
fix/mahalanobis-residual-gate
branch
from
October 24, 2026 17:21
4e8021f to
89431b5
Compare
Author
|
@mktk1117 please take a look (I have used the AI coding agent to generate the test for my fix and have retained it as coauthor of the commit). The same issue seems to exist in the ROS1 (main) branch as well, I can back-port this fix if needed. |
Author
|
Tagging another potential reviewer to this PR, @Idate96 please take a look or tag the right person to review this PR, thanks |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The outlier gate compares a height difference (metres) against a scaled variance (square metres):
The units don't match, so the check only behaves sensibly when the variance happens to be near 1. The obvious fix is to compare against the cell's standard deviation,
sqrt(map_v). Since the residual also carries the measurement noise v (already computed just above),sqrt(map_v + v)seemed like the right step, that's the actual standard deviation ofmap_h - z, i.e. what "Mahalanobis distance" means here.Applied to all three places using this comparison: the fusion outlier gate, the edge-sharpen check, and the drift-compensation inlier counter.
kk.pyhad identical copies and is updated too, though it doesn't appear to be imported anywhere, happy to drop it instead.Also added
tests/test_outlier_gate.py: a confident cell receiving a point 1cm off now fuses it (stock code rejects it and inflates variance), and a 60cm residual is still rejected.