Skip to content

fix(mobile): clip occupancy updates to grid bounds - #928

Open
Afloat16 wants to merge 5 commits into
petercorke:mainfrom
Afloat16:fix/clip-occupancy-regions
Open

Afloat16 wants to merge 5 commits into
petercorke:mainfrom
Afloat16:fix/clip-occupancy-regions

Conversation

@Afloat16

@Afloat16 Afloat16 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

OccupancyGrid.set passes converted region bounds directly into NumPy slices. Negative grid coordinates therefore wrap around to the opposite edge or produce an empty slice. A partially overlapping region may update nothing, while a region entirely outside the map can change unrelated cells.

Change

Intersect the inclusive grid-coordinate bounds with the actual array bounds before assigning. A disjoint region has no effect. The method docstring now states this clipping behaviour.

The regression checks partial overlap and disjoint regions on all four edges, on both a unit grid and a translated grid with half-unit cells.

Original validation

  • Original source: 6 regression cases failed and 6 controls passed.
  • PYTHONPATH=src python -m pytest tests/test_mobile_maps.py tests/test_occgrid_bounds.py -q: 46 passed.
  • The regression module passes Ruff and formatting.
  • git diff --check passed.

Main-branch update

Updated with main at b53974345598f978d6e5040c46a25aa2788ea1da in merge commit c3302fa48b3fa4aae8b6b0565b6ac6d5d0650095. The original two-file PR patch is byte-for-byte unchanged relative to the updated base. All files brought in from main retain exactly their upstream blobs, including the coverage updates from #946 and the empty-ETS fallback fix from #949.

Validation on the merged tree:

  • PYTHONPATH=src python -m pytest tests/test_mobile_maps.py tests/test_occgrid_bounds.py --timeout=50 --timeout_method=thread -q: 46 passed on Python 3.12.
  • Staged and working-tree git diff --check passed.

CI for the updated head completed successfully. All 15 OS/Python combinations, test-core, both coverage jobs and the documentation build passed. The allowed-to-fail mypy job reports the same eight existing errors in blocks/mobile.py and blocks/arm.py; those files are outside this PR's two-file patch.

Primary contributor: Afloat16, who has reviewed the original submission.

AI assistance for this follow-up: ChatGPT (GPT-6 Astra Pro), used for main-branch synchronization and verification.

@Afloat16
Afloat16 marked this pull request as ready for review November 3, 2026 13:56
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 complexity · 0 duplication

Metric Results
Complexity 4
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Refresh the branch with main cee0023. The existing PR patch and all changed file blobs remain unchanged.

Co-Authored-By: ChatGPT (GPT-6 Astra Pro)
@Afloat16

Copy link
Copy Markdown
Contributor Author

The CI run for 8dfb97214c54a6f55cff26fe99e4b4cce65404ca has now completed with an overall success result. All 15 OS/Python test combinations, test-core, the required All tests passed aggregate, coverage, and the docs job passed. The real Node/Pyodide install check also passed and produced nine animation frames.

For completeness, the workflow's informational browser step timed out after a page fetch error; it is configured as non-blocking. The advisory mypy errors are the same eight errors already present on main, as linked in the description.

The branch includes main at cee0023535, and the original clipping fix and regression patch are unchanged. Could you review this focused boundary-clipping fix for merge?

Refresh the branch with main ea35e42. The existing PR patch and its two changed file blobs remain unchanged.

Validation: both complete occupancy-grid test files passed (46 tests); staged and working-tree diff checks passed.

Co-Authored-By: ChatGPT (GPT-6 Astra Pro)
Include upstream coverage and pure-Python test updates from main 1cd9bd7. The original two-file PR patch remains byte-for-byte unchanged relative to the updated base.

Validation: both complete relevant test files passed (46 tests); staged and working-tree diff checks passed.

Co-Authored-By: ChatGPT (GPT-6 Astra Pro)
Include main b539743 while preserving the original focused fix and regression patch unchanged.

Co-Authored-By: ChatGPT (GPT-6 Astra Pro)

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.

2 participants