Skip to content

Fix GridMap cell indices wrapping across map edges - #1480

Draft
yunyv wants to merge 3 commits into
AtsushiSakai:masterfrom
yunyv:fix/gridmap-axis-bounds
Draft

yunyv wants to merge 3 commits into
AtsushiSakai:masterfrom
yunyv:fix/gridmap-axis-bounds

Conversation

@yunyv

@yunyv yunyv commented Oct 27, 2026

Copy link
Copy Markdown

Reference issue

No matching issue or competing fix found for GridMap's per-axis index bounds. The open polygon comparison change in #1350 touches a different operation.

What does this implement/fix?

GridMap currently checks only the flattened storage index. This permits invalid x/y cell coordinates to alias a valid cell: for a 3-column, 2-row grid, writing to (3, 0) changes (0, 1), and reading (-1, 1) reads (2, 0). Neighbor updates in expand_grid can consequently mark cells across the opposite edge of the map.

Check each numeric cell index against its own axis bounds in the cell-value getter and setter, in addition to the existing flattened storage bounds. Out-of-bounds reads return the documented None, occupancy checks therefore treat them as occupied, and rejected writes return False without changing storage. Existing behavior for None inputs is unchanged.

  • Preserve the existing flattened-index guard, value-type check, valid row-major indexing, and integer-valued float/NumPy integer inputs.
  • Preserve the expansion neighbor stencil; only clip invalid neighbors at the grid edges.
  • Add regressions for negative and upper-bound coordinates, coordinate pairs that cancel into valid flattened indices, valid cell storage, and expansion at opposite corners.
  • Update the existing coverage-planner documentation's boundary explanation.

No parameter, dependency, animation, or CI configuration changes. Separate position-conversion and polygon issues are outside this fix.

Additional information

Linux / Python 3.14.8, with the repository-pinned runtime and development requirements and BLAS/OMP threads limited to one:

  • Original source with the new regressions: 7 failed, 6 passed, 3 original tests deselected.
  • Focused GridMap and sweep coverage-planner tests: 19 passed with warnings as errors.
  • Scoped Ruff, Mapping mypy (25 source files), and git diff --check: passed.
  • Final full bash runtests.sh: 169 passed in 158.40s, including changed-file Ruff, all configured mypy checks, and warnings as errors.
  • Sphinx make html with -W -E -a (warnings as errors and full rebuild): passed. Generated boundary paragraph and parent navigation link verified. The pinned IPython emits its existing Python 3.14 SyntaxWarning during import.
  • Browser visual inspection could not run: Chromium startup was blocked by the execution environment's Unix socket restriction. No screenshot, hardware, GPU, macOS, or Windows verification is claimed.

AI assistance was used for implementation and test preparation; no human review is claimed.

CheckList

  • Did you add an unittest for your new example or defect fix?
  • Did you add documents for your new example? (Updated the existing official page.)
  • All CIs are green? (Hosted CI has not run for this draft.)

yunyv added 3 commits October 27, 2026 10:16
Reject invalid numeric cell coordinates before they alias valid storage. Preserve existing flattened-index checks and None behavior.
Cover invalid numeric coordinates, row-major storage, and expansion without cross-edge aliasing.
Explain per-axis cell bounds and clipping expanded neighbors at map edges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant