Skip to content

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

Open
Afloat16 wants to merge 1 commit into
petercorke:mainfrom
Afloat16:fix/clip-occupancy-regions
Open

Afloat16 wants to merge 1 commit 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.

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.

@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.

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