Skip to content

refactor: add generated occupancy value helpers with legacy primitive reuse - #4669

Closed
TomCC7 wants to merge 2 commits into
cc/feat/cdr-depth-cloudfrom
cc/feat/cdr-occupancy-core
Closed

TomCC7 wants to merge 2 commits into
cc/feat/cdr-depth-cloudfrom
cc/feat/cdr-occupancy-core

Conversation

@TomCC7

@TomCC7 TomCC7 commented Oct 20, 2026

Copy link
Copy Markdown
Member

Add plain generated OccupancyGrid helpers for array/file input, read-only row-major views, rotated map coordinates and explicit Header timestamps. This prepares the mapping/navigation cutover without replacing the existing grid class or changing existing consumers yet.

Parent: #4668. Part of the message encoding refactor.

Area Change
Generated occupancy helper Validated ROS cells/resolution, safe NumPy loading, PNG unknown-cell mapping, independent input copies, rotated coordinate conversion
Legacy grid module Move the existing CostValues and identical block_max_reduce implementation into the shared helper; retain their old import names and the legacy grid class
Tests/workflow Actual CDR/MCAP round trips, complete embedded schema closure, zero/negative/epoch timestamps, input ownership and current legacy regression coverage
Navigation doc link Disambiguate an existing filename label after adding the new occupancy helper

From an installed main-package wheel for this proposal, the generated value workflow is:

import numpy as np
from dimos_cdrgen.registry import decode, encode
from dimos.messages.builtin_interfaces.msg import Time
from dimos.messages.nav_msgs.msg import OccupancyGrid
from dimos.messages.std_msgs.msg import Header
from dimos.msgs.occupancy import occupancy_from_array, occupancy_view

grid = occupancy_from_array(
    np.array([[-1, 0, 100]], dtype=np.int8), resolution=0.25,
    header=Header(frame_id="map", stamp=Time(sec=0, nanosec=1)),
)
received = decode(encode(grid), OccupancyGrid)
assert occupancy_view(received).tolist() == [[-1, 0, 100]]
assert received.header.stamp.nanosec == 1

For a prepared checkout, run the focused checks with python -m pytest --noconftest -o addopts='' -q dimos/msgs/test_occupancy.py dimos/msgs/nav_msgs/test_OccupancyGrid.py.

Validation: 41 source cases pass, including the retained historical pointcloud fixture case. That project LFS archive was fetched once, SHA256 verified against its pointer (245395d0c3e200fcfcea8de5de217f645362b145b200c81abc3862e0afc1aa7e,327201 bytes), and safely extracted (898117 bytes). Installed-main-wheel checks pass 40 cases with the generated production helper asserted to come from site-packages; the source-only fixture lookup case is deselected in that installed run. One production helper passes strict typing, applicable hooks pass, normal main wheel builds and the default 198-package environment passes pip check. Wheel SHA256 ea88584c175a0fcb4735ba1133b7ae58abb9683491cdc86f788e933943d756bd.

This layer does not switch mapping/navigation producers, default encoding or remove legacy recording/classes. No hardware, benchmark investigation or CI polling performed.

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