fix(nav): preserve unknown cells in saved maps - #732
Draft
axelpey wants to merge 3 commits into
Draft
Conversation
Contributor
Greptile SummaryThis PR preserves unknown occupancy cells across map saves and reloads while correcting GPU localization scoring.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Sequence DiagramsequenceDiagram
participant MM as Mode Manager
participant Saver as Nav2 Map Saver
participant Disk as Map Files
participant Map as Map Server
participant GL as Grid Localizer
participant AMCL as AMCL
MM->>Saver: "Save map with free_thresh_default=0.196"
Saver->>Disk: Write image and YAML
MM->>Disk: Discover and repair exact legacy metadata
Disk->>Map: Reload trinary occupancy map
Map->>GL: Publish free, occupied, and unknown cells
GL->>GL: Score only in-bounds occupied endpoints
GL->>AMCL: Publish coarse initial pose
Reviews (3): Last reviewed commit: "style(nav): format map metadata helper" | Re-trigger Greptile |
axelpey
marked this pull request as draft
August 29, 2026 23:27
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.
Summary
free_thresh_default:=0.196so gray 205 remains unknown after reloadmode: trinary+free_thresh: 0.25signature during map discoveryWhy
Nav2 Humble writes unknown trinary cells as gray 205. With its default YAML
free_thresh: 0.25, that pixel reloads as free ((255 - 205) / 255 ≈ 0.1961), so the global planner sees unmapped space as free even withallow_unknown: false.Correcting the map metadata exposed a second bug:
grid_localizercollapsed unknown and occupied into the same binary value and clipped off-map endpoints onto map-edge cells. Unknown space could therefore produce false obstacle matches and near-zero scores at unrelated poses.Validation
ruff checkandruff formaton changed Python files — passedgit diff --check— passedcolcon build --symlink-install --packages-select mars_nav— passedmars-the-3rd.local: all 7 maps remain atfree_thresh: 0.196;OfficeClean.yamlpublishes 80,124 unknown cells;GridBased.allow_unknown=false(0.33, -1.13, 40°)with scores0.426–0.441; before the fix, repeated runs jumped between opposite map edges with falsely excellent scores0.002–0.013The live result is consistent but above the configured
0.3confidence threshold, so navigation still needs physical pose confirmation before being called healthy.