-
Notifications
You must be signed in to change notification settings - Fork 0
Integrate WNN telemetry into DSM and implement immediate safety rollback #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,9 @@ | |
| #include <iostream> | ||
| #include <limits> | ||
|
|
||
| #include "raps/rollback_execution.hpp" | ||
| #include "itl/itl_manager.hpp" | ||
|
|
||
| // ===================================================== | ||
| // Deterministic Safety Monitor (DSM) | ||
| // ===================================================== | ||
|
|
@@ -25,8 +28,17 @@ constexpr double MAX_TCC_COUPLING_J = 1.0e+04; | |
| // Failsafe parameters | ||
| constexpr double MIN_RESONANCE_AMPLITUDE_CUTOFF = 0.10; | ||
|
|
||
| // WNN Constraints | ||
| constexpr double WNN_MAX_CURVATURE_PROXY = 5.0e-11; | ||
| constexpr double WNN_MIN_OSCILLATORY_PREFACTOR = 0.85; | ||
|
|
||
| } // namespace DSM_Config | ||
|
|
||
| struct WnnTelemetry { | ||
| double curvature_proxy; | ||
| double oscillatory_prefactor; | ||
| }; | ||
|
|
||
| // ===================================================== | ||
| // DSM Sensor Inputs (Independent Channels) | ||
| // ===================================================== | ||
|
|
@@ -55,6 +67,14 @@ class DeterministicSafetyMonitor { | |
|
|
||
| int evaluateSafety(const DsmSensorInputs& inputs); | ||
|
|
||
| bool pollWnnAndEnforce( | ||
| const WnnTelemetry& wnn_telem, | ||
| ITLManager& itl_manager, | ||
| const RollbackPlan* rollback_store, | ||
| uint32_t rollback_count, | ||
| PhysicsState& active_state_pointer | ||
| ); | ||
|
|
||
| private: | ||
| double last_estimated_Rmax_; | ||
| bool safing_sequence_active_; | ||
|
|
@@ -164,3 +184,26 @@ DeterministicSafetyMonitor::evaluateSafety( | |
|
|
||
| return ACTION_NONE; | ||
| } | ||
|
|
||
| inline bool | ||
| DeterministicSafetyMonitor::pollWnnAndEnforce( | ||
| const WnnTelemetry& wnn_telem, | ||
| ITLManager& itl_manager, | ||
| const RollbackPlan* rollback_store, | ||
| uint32_t rollback_count, | ||
| PhysicsState& active_state_pointer | ||
| ) { | ||
| if (wnn_telem.curvature_proxy > DSM_Config::WNN_MAX_CURVATURE_PROXY || | ||
| wnn_telem.oscillatory_prefactor < DSM_Config::WNN_MIN_OSCILLATORY_PREFACTOR) { | ||
|
Comment on lines
+196
to
+197
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When either WNN value is Useful? React with 👍 / 👎. |
||
|
|
||
| // Breach detected! Log to ITL and execute immediate rollback | ||
| itl_manager.log_wnn_rollback_event(wnn_telem.curvature_proxy, wnn_telem.oscillatory_prefactor); | ||
|
|
||
| return trigger_wnn_immediate_rollback( | ||
| rollback_store, | ||
| rollback_count, | ||
| active_state_pointer | ||
| ); | ||
|
Comment on lines
+199
to
+206
|
||
| } | ||
| return false; // No breach | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,16 @@ | |
| #include <optional> | ||
| #include <cstring> | ||
|
|
||
| #include "raps/telemetry/telemetry_ring_buffer.hpp" | ||
| #include "itl/itl_state_snapshot.hpp" | ||
|
|
||
| // Continuous, statically allocated snapshot buffer | ||
| inline raps::telemetry::TelemetryRingBuffer<PhysicsState, 64> StateSnapshotBuffer; | ||
|
|
||
| inline void store_state_snapshot_tick(const PhysicsState& state) { | ||
| StateSnapshotBuffer.try_push(state); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| inline void store_rollback_plan( | ||
| RollbackPlan* rollback_store, | ||
| uint32_t& rollback_count, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This helper commits a
ROLLBACK_COMMITbeforetrigger_wnn_immediate_rollbackhas run, so whenrollback_count == 0orexecute_rollback_planfails,pollWnnAndEnforcereturns false but the immutable ledger already contains a successful rollback commit. The reference rollback flow recordsrollback_commitonly after actuator success (reference/python/hlv_governance_reference.py:137-143), so this should be moved after a successful rollback or changed to a pending/failure event.Useful? React with 👍 / 👎.