Add Monte Carlo Localization with kidnapped-robot recovery (navigation/38)#14
Merged
Conversation
…n/38) Localization is one of the canonical "what happens after it fails" stories, and the repo had no particle filter. This adds a self-contained Augmented MCL on a landmark map (range + bearing sensing), staged as three acts on one run: global localization from a uniform prior, a scheduled kidnap (teleport), and recovery. The lesson is Thrun's Augmented_MCL (Probabilistic Robotics, Table 8.3) in one trick: track a fast and a slow running average of the measurement likelihood, and when the fast one drops below the slow one — the signature of a failure — inject random particles in proportion to the drop. A few land near the new pose and the cloud re-collapses there. The contrast is sharp and built into the same file via `--no-augment`: augmented: kidnapped x1 (recovers in ~1 step) plain MCL: kidnapped x1 + localization_lost x30 (stays lost the whole run) - self-contained MCLWorld (landmarks, range+bearing, one scheduled kidnap) and an AugmentedMCL particle filter (systematic resampling, w_slow/w_fast injection, weighted-mean pose estimate) with a References section - two smoke tests: augmented recovers (global-localizes, detects the kidnap via injection, re-localizes); plain MCL never injects, stays unsuccessful, and emits localization_lost while augmented on the same seed recovers cleanly - examples index + navigation README section; example 40->41, tests 113->115 Verified across seeds 0-9: augmented recovers 10/10 (final error < 0.21), plain MCL recovers 0/10; ~0.06s per run; matplotlib render path confirmed under Agg. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
A new example,
examples/navigation/38_monte_carlo_localization.py: a self-contained Augmented Monte Carlo Localization particle filter that recovers from the kidnapped-robot problem. The repo had no particle filter, and localization is one of the canonical "what happens after it fails" stories.The lesson
Three acts on one run: global localization from a uniform prior → a scheduled kidnap (teleport) → recovery.
Plain MCL converges beautifully and then fails the kidnapped-robot problem: once the cloud collapses onto the true pose, a teleport leaves no particles anywhere to recover with. Augmented MCL (Thrun et al., Probabilistic Robotics, Table 8.3) is the fix in one trick — track a fast and a slow running average of the measurement likelihood, and when the fast one drops below the slow one (the signature of a failure) inject random particles in proportion to the drop. A few land near the new pose and the cloud re-collapses there.
The contrast is built into the same file via
--no-augment, and it shows up directly in the failure log:Contents
MCLWorld(point landmarks, range + bearing sensing, one scheduled kidnap) and anAugmentedMCLfilter: systematic (low-variance) resampling,w_slow/w_fastinjection, and a weighted-mean pose estimate so a handful of freshly injected particles on the sharp likelihood peak snap the estimate to the recovered pose.inject_ratio > 0), and re-localizes; plain MCL never injects, stays unsuccessful, and emitslocalization_lostwhile augmented on the same seed recovers without ever reporting itself lost.examples/README.mdrow + a fullexamples/navigation/README.mdsection; example count 40→41 and test count 113→115 inREADME.md/docs/status.md.Why it works (design notes)
Three subtleties that took iterating to get right, all documented in-code:
w_fast/w_slow.Verification
128 passed); matplotlib render path confirmed underAgg.References
amclpackage implements this adaptive recovery.🤖 Generated with Claude Code