Repository navigation
Consume pure-payload occupancy, drop MAP1 header (RSDEV-14426) - #3568
Conversation
sysrsbuild-gh-agentic
left a comment
There was a problem hiding this comment.
Auto-generated review by rs-agentic bot.
Target branch: ros2-development ✓
Author: @nivgo (internal) — full review.
Two bugs flagged below; one enhancement note.
sysrsbuild-gh-agentic
left a comment
There was a problem hiding this comment.
Auto-generated review by rs-agentic bot.
Two bugs in the new pure-payload path — both can throw rs2::error at runtime if certain metadata keys are unsupported.
3126b39 to
3ec85a1
Compare
sysrsbuild-gh-agentic
left a comment
There was a problem hiding this comment.
Auto-generated review by rs-agentic bot
Clean removal of the MAP1 layer. A few issues worth addressing before merge:
| return (stream != RS2_STREAM_SAFETY && stream != RS2_STREAM_OCCUPANCY && stream != RS2_STREAM_LABELED_POINT_CLOUD); | ||
| } | ||
|
|
||
| bool BaseRealSenseNode::tryPublishPurePayloadOccupancy(const rs2::frame& f, |
There was a problem hiding this comment.
@nivgo was dropping the CRC check intentional? The old MAP1 path validated a CRC-32 over the payload; the pure-payload path has none. The SDK still exposes the payload CRC via RS2_FRAME_METADATA_CRC (md_occupancy::payload_crc32, d500-depth-mapping.cpp:404, flag bit 31). If FW populates it, should we verify it here (when supports_frame_metadata(RS2_FRAME_METADATA_CRC)) and drop on mismatch?
There was a problem hiding this comment.
Good catch, will verify that its populated and if so will add it
There was a problem hiding this comment.
🤖 [rs-agentic] CRC-32/ISO-HDLC verification was added in this commit — RS2_FRAME_METADATA_CRC is checked when present and frames with mismatched CRC are dropped. The crc32IsoHdlc helper lives in occupancy_grid_utils.h and is covered by unit tests. ✓
There was a problem hiding this comment.
Confirmed on a live D555-
fw populates RS2_FRAME_METADATA_CRC with a CRC-32/ISO-HDLC over the full payload. Added the check in new commit, verified when the metadata is present, frame dropped on mismatch, skipped otherwise.
sysrsbuild-gh-agentic
left a comment
There was a problem hiding this comment.
Auto-review of new commits (rs-agentic bot). All previously flagged issues are resolved. One minor logging bug found in the new code.
| switch (occupancy::computeGeometry(cols, rows, cell_size_cm, origin_x_mm, origin_y_mm, raw_size, geo)) | ||
| { | ||
| case occupancy::GeometryStatus::Ok: | ||
| break; |
There was a problem hiding this comment.
%dx%d is fed rows, cols but the standard convention is cols x rows (width × height). A 320×256 grid will be logged as "256×320 cells - dropped", inverting the dimensions and misleading debugging. Same issue on the SizeOverflow message two lines below.
Fix: swap the arguments:
"Occupancy frame reported %dx%d cells - dropped", cols, rowsand
"Occupancy frame geometry %dx%d overflows size_t - dropped", cols, rowsThere was a problem hiding this comment.
🤖 [rs-agentic] Still not fixed in this commit — log arguments remain rows, cols, so a 320×256 grid logs as "256×320 cells - dropped". This affects the NonPositiveDims, SizeOverflow, and PayloadTooSmall cases. Please swap to cols, rows.
FW >= 7.58 + librealsense#15691 removed the 52-byte MAP1 header from the occupancy stream: the frame is now a bare signed-cell grid, and the grid geometry and signed origin travel in the UVC metadata ABI instead of a MAP1 sub-header. - publishOccupancyFrame: add a pure-payload path that reads cols/rows/ cell_size/origin from the occupancy frame metadata and copies the cells straight through (already in nav_msgs row-major order, no axis flip), publishing both ~/occupancy and ~/occupancy_certainty. - Remove publishOccupancyFromMap1, the occupancy_map1.h parser and its unit test, and the corresponding ament_add_gtest hook in CMakeLists. - Other-device legacy paths are left untouched. Validated live on D555 (FW 7.59.35.15855): occupancy 320x256, 81920-byte pure payload, resolution 0.05 m, origin (0, -6.4) sourced from metadata. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
When neither the pure-payload nor the legacy path can read the grid geometry (device/driver delivers no occupancy metadata, e.g. an unpatched uvcvideo on Linux that drops the vendor blob), the legacy path called get_frame_metadata() unguarded and librealsense threw on every frame. Guard on supports_frame_metadata(GRID_COLUMNS/ROWS) - matching the existing guarded readers in this file - and, when absent, drop the frame after an RCLCPP_ERROR_THROTTLE (5s, pointing at librealsense2-dkms). The 5s throttle matches the sibling occupancy-drop logs; no per-frame throw or log spam, but the cause stays visible in recent logs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Code review found two frames-that-partially-populate-metadata paths that could still throw rs2::error out of the streaming callback: - Pure-payload branch was gated only on ORIGIN_X/Y but then read COLUMNS/ROWS/CELL_SIZE unguarded. A frame advertising origin but not those would throw. Require all five metadata fields to enter the branch. - The metadata-missing guard checked COLUMNS/ROWS but not CELL_SIZE, while the legacy path reads CELL_SIZE unguarded. Add CELL_SIZE to the guard. Both cases now fall through to the throttled metadata-missing error and drop the frame instead of throwing per frame. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The pure-payload path's geometry validation (rows/cols positivity, size_t overflow, raw_size < n) and unit conversions were inline in publishOccupancyFrame with no unit coverage - the MAP1 tests deleted in this branch used to be the only occupancy-geometry tests. Extract them into occupancy::computeGeometry (header-only, free of ROS/SDK types, same pattern as splitCells) and cover with gtests: - valid 320x256 grid converts cm->m and mm->m correctly (the live D555 case) - non-positive dims and payload-smaller-than-grid are rejected - output is left untouched on failure publishOccupancyFrame now calls the helper; no behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- computeGeometry now rejects a non-positive cell size (would publish resolution 0, a malformed OccupancyGrid) with a NonPositiveCellSize status; covered by a new unit test. - Move the pure-payload path out of publishOccupancyFrame into tryPublishPurePayloadOccupancy() so the frame handler is no longer one oversized function (234 -> 169 lines; the helper is self-contained). The pre-existing legacy paths are left untouched.
The MAP1 path validated a CRC-32 over the payload; the pure-payload path dropped that check. The FW now reports the same CRC-32/ISO-HDLC over the whole payload in RS2_FRAME_METADATA_CRC (confirmed on a live D555: metadata CRC matches the computed one on real frames). When RS2_FRAME_METADATA_CRC is supported, recompute it over the payload and drop the frame on mismatch (throttled warning). Skip the check when the metadata has no CRC. CRC helper is header-only and unit-tested (standard check value + single-byte corruption).
The drop warnings printed rows x cols, so a 320x256 grid logged as 256x320. The legacy path keeps rows x cols since its width is the firmware row count.
cb7d5d5 to
ce51f17
Compare
Occupancy now arrives as a plain signed-cell grid with no 52-byte MAP1 header — the grid size, cell size and origin moved into the UVC metadata (RSDEV-14426: FW ≥ 7.58 + librealsense#15691).
What changed
/occupancyand/occupancy_certainty.occupancy_map1.hand its test are gone).uvcvideoon Linux that drops the vendor blob), it's dropped with a throttled error instead of throwing per frame.Tested on a live D555 camera stream (FW 7.59.35): occupancy publishes correctly end-to-end through the ROS node — 320×256 grid, 0.05 m cells, origin (0, −6.4), all sourced from UVC metadata. Labeled point cloud (still MAP1) is unaffected.
Heads-up for Linux: the geometry rides in UVC metadata, so the host needs a metadata-capable
uvcvideo—librealsense2-dkmsor an equivalently patched kernel — otherwise occupancy is dropped (with that one throttled error).