Skip to content

Update safety flash tables structs and tests to flash v0.95#14967

Merged
remibettan merged 8 commits into
realsenseai:developmentfrom
remibettan:sc-flash-095-updates
May 3, 2026
Merged

Update safety flash tables structs and tests to flash v0.95#14967
remibettan merged 8 commits into
realsenseai:developmentfrom
remibettan:sc-flash-095-updates

Conversation

@remibettan
Copy link
Copy Markdown
Contributor

@remibettan remibettan commented Apr 23, 2026

Tracked by: RSDEV-6640

Summary

Updates the D585S Safety Camera C++ struct definitions, JSON API, version constants, and unit tests to match the flash memory layout changes introduced in flash spec v0.95 (from v0.93).

Changes

Safety Interface Config (0xC0DC) - version 0x0301 ? 0x0400

  • occupancy_grid_params: Replaced the three quorum threshold fields (close_range_quorum, mid_range_quorum, long_range_quorum) and renamed grid_cell_seed ? grid_cell_size. Added three new float fields: cell_threshold_factor, polynomial_bias, and surface_height (moved here from the Safety Preset table).
  • safety_interface_config: Grew reserved tail from 17 ? 324 bytes to match the expanded table size (148 ? 464 bytes).
  • set_safety_interface_config(): version constant updated to 0x04 0x00.

Safety Preset (0xC0DB) - Safety Zones version 0x0300 ? 0x0302

  • safety_environment: surface_height (float) transferred to Safety Interface Config. The 4-byte slot is now a reserved array (m_reserved_surface_height[4]). Removed from JSON API and validation.

Application Config (0xC0DE) - version 0x0100 ? 0x0102

  • application_config: Added hw_configuration_setup (uint8_t, Feat Frame pointer ownership? #16) for Pixter/RVP HW platform selection (0 = nominal, 1 = Pixter MIPI injection, 2 = RVP dev board). reserved3 shrunk from 265 ? 264 bytes.
  • set_application_config(): version constant updated to 0x01 0x02.

New Table IDs (d500-private.h)

  • Added frame_sequence_id = 0xc0e0 (ctFrameSequence, new in v0.95 for SC1.2)
  • Added projector_laser_id = 0xc0e8 (ctProjectorLaser, Laser Projector calibration GOLD)

Tests

  • test-interface-config-get-set.py: Updated occupancy_grid_params JSON fields to match new layout.
  • test-app-config-get-set-hwm-cmd.py: Added hw_configuration_setup byte, reduced reserved3 to 264, updated version to [1, 2].
  • test-preset-get-set.py: Removed surface_height from environment section.

Test plan

  • Build passes: realsense-viewer compiles without errors (verified locally)
  • Run test-interface-config-get-set.py against D585S device with flash v0.95
  • Run test-app-config-get-set-hwm-cmd.py against D585S device with flash v0.95
  • Run test-preset-get-set.py against D585S device with flash v0.95
  • Verify SIC get/set round-trip with new occupancy_grid_params fields
  • Verify AppConfig get/set round-trip with hw_configuration_setup field

Copilot AI review requested due to automatic review settings April 23, 2026 13:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates D500/D585S safety flash table structs, JSON serialization, and live unit tests to align with flash spec v0.95 layout/version changes.

Changes:

  • Updated safety_interface_config / occupancy_grid_params JSON + struct layout (new float fields, larger reserved tail) and bumped write version to 0x0400.
  • Updated application_config layout to include hw_configuration_setup, adjusted reserved sizing, and bumped write version to 0x0102.
  • Removed surface_height from Safety Preset environment JSON and repurposed its slot as reserved bytes; added new D500 table IDs; updated corresponding live tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
unit-tests/live/d500/safety/test-preset-get-set.py Removes surface_height from environment JSON used in preset get/set test.
unit-tests/live/d500/safety/test-interface-config-get-set.py Updates SIC JSON schema to new occupancy_grid_params fields and modifies test mutation logic.
unit-tests/live/d500/safety/test-app-config-get-set-hwm-cmd.py Inserts hw_configuration_setup into generated binary app-config payload; bumps version bytes.
src/ds/d500/d500-types/safety-preset.h Removes surface_height from JSON mapping/validation; keeps 4-byte reserved placeholder in struct.
src/ds/d500/d500-types/safety-interface-config.h Reworks occupancy_grid_params struct/JSON fields and expands SIC reserved tail.
src/ds/d500/d500-types/application-config.h Adds hw_configuration_setup field, adjusts reserved sizing, updates version comment, and JSON mapping/validation.
src/ds/d500/d500-safety.cpp Bumps SIC and AppConfig write-version constants used in table headers.
src/ds/d500/d500-private.h Adds new calibration table IDs for frame sequence and projector laser calibration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ds/d500/d500-types/safety-interface-config.h
Comment thread src/ds/d500/d500-types/safety-interface-config.h
Comment thread src/ds/d500/d500-types/application-config.h
Comment thread src/ds/d500/d500-types/safety-preset.h
@remibettan remibettan requested a review from Nir-Az April 26, 2026 07:09
@Nir-Az
Copy link
Copy Markdown
Collaborator

Nir-Az commented Apr 26, 2026

See:

Review of PR #14967 vs. v0.95 spec

I read the xlsx and cross-checked every changed field. Authoritative sources used:

  • changes tab v0.95 row
  • Safety Interface Config tab (header + per-row offsets)
  • Application_Config(Dynamic) tab
  • Safety_Zones_Table tab
  • Table Id summary tab is stale for v0.93–v0.95 — ignored in favor of per-tab specs.

✅ Verified correct against spec

Area Spec (v0.95) PR Status
SIC (0xC0DC) version 0x04 0x00 0x04 0x00
SIC table size 464 (payload) static_assert(sizeof == 464) ✓ math: 34+1+48+14+11+32+324 = 464
occupancy_grid_params uint16 grid_cell_size + 3× float32 (cell_threshold_factor, polynomial_bias, surface_height) at offsets 99/101/105/109 exact match
AppConfig (0xC0DE) version 0x01 0x02 0x01 0x02
hw_configuration_setup (Feat #16) uint8 at payload offset 167 inserted between peripherals_sensors_disable_mask and reserved3[264]
AppConfig payload size 464 unchanged (1 byte moved from reserved3 → new field)
New IDs ctFrameSequence = 0xC0E0, ctProjectorLaser = 0xC0E8 match
Safety Preset (0xC0DB) surface_height "Transferred to SafetyInterfaceCfg" — 4-byte reserved slot m_reserved_surface_height[4]
HWM-cmd test tail size 302 bytes (1+1+1+2+1+264+32) matches

Outer Safety_Zones_Table (0xC0DA) is bumped to 0x03 0x02 per spec, and surface_height is removed from the preset content per spec.

🔴 Concerns to address before merging

1. Safety Preset (0xC0DB) version bump — likely incorrect.
PR changes d500-safety.cpp:459 from 0x03010x0302. But the v0.95 changes tab is explicit:

Safetty Zones (0xC0DA:0x0302) - transferring SurfaceHeight to SafetyInterfaceCfg
Safety Interface Config (0xC0DC:0x0400): Update occupancy scan parameters

Only 0xC0DA (the outer table) is bumped to 0x0302. 0xC0DB is not listed. And the per-tab spec at Safety_Zones_Table!A479 still shows the inner dtSafetyPreset (0xC0DB) header version as 0x3 0x1.

set_safety_preset() writes a single inner preset (0xC0DB) — not the outer 0xC0DA container. So the version byte being written here corresponds to the inner-preset row in the spec, which says 0x0301.

The PR description ("Safety Preset (0xC0DB) - Safety Zones version 0x0300 → 0x0302") appears to conflate the outer 0xC0DA bump with the inner 0xC0DB writer. Recommend reverting that one line back to 0x0301 unless the spec author confirms the inner header should also move.

2. PR description typo. It says preset went 0x0300 → 0x0302, but the base in master is actually 0x0301. Minor — but worth fixing for the merge commit message.

🟡 Nice-to-have

3. Add static_assert(sizeof(application_config) == 464, ...). Same drift risk that motivated the SIC assert (now added per Copilot's #2 comment). The AppConfig diff already shifts a byte in/out of reserved3 — a static guard prevents silent re-drift.

4. The class-level docblock for application_config still says "according to flash0.92 specs" / "Version: 0x01 0x01" at application-config.h:331-332. The PR diff shows lines 331-332 were updated to v0.95 / 0x01 0x02, so this is fixed in the PR ✓ — confirmed via the diff. (Skip.)

Status of Copilot review threads

Recommendation

Request changes with one ask: have remibettan confirm with the spec author whether the inner Safety Preset (0xC0DB) version should remain 0x0301 in v0.95, and either revert the d500-safety.cpp:459 line or get the spec sheet's row 479 corrected. Optional: add a static_assert for application_config size while we're here.

@remibettan remibettan force-pushed the sc-flash-095-updates branch 2 times, most recently from 7d812a4 to be76cb5 Compare April 29, 2026 13:38
remibettan and others added 5 commits April 29, 2026 16:38
- Add static_assert(sizeof(safety_interface_config) == 464) to catch layout regressions at compile time
- Fix Safety Preset write version from 0x0301 to 0x0302 per flash v0.95 spec
- Update application_config docblock to document hw_configuration_setup field

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Added missing hw_configuration_setup field to the test JSON to match
the updated application_config struct from flash v0.95.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@remibettan remibettan force-pushed the sc-flash-095-updates branch from be76cb5 to 0d15aa6 Compare April 29, 2026 13:38
@remibettan remibettan merged commit 3c576e4 into realsenseai:development May 3, 2026
29 of 30 checks passed
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.

3 participants