Files
PX4-Autopilot/src/systemcmds
Gennaro GuidoneandMatthias Grob e816025c3d feat(failure_injection): add ESC failure unit (off/wrong) with correct MAVLink semantics (#28088)
* feat(failure_injection): add process_esc() telemetry helper

Add a shared helper that applies the active FAILURE_UNIT_SYSTEM_ESC (106)
failures to an esc_status before it is published, matched per ESC by
esc_report.actuator_function: Off reports the ESC offline (clears its
esc_online_flags bit) so it reads as "completely non-responsive"; Wrong keeps
the ESC online but reports consistently wrong values. Mirrors process_battery();
a no-op stub keeps builds without the failure injection manager zero-cost.
Unit tested here.

* feat(failure_injection): inject ESC failures at the esc_status producers

Call process_esc() where esc_status is produced (UAVCAN ESC driver and SIH) so
injected ESC failures reach every consumer. Wire the ESC unit end to end: add
the "esc" key to the failure CLI and mark FAILURE_UNIT_SYSTEM_ESC as supporting
Off and Wrong. Regroup MOTOR to Off-only (actuation): its stuck/wrong were
never implemented, so stop advertising them.

* refactor(failure_detector): drop the misplaced ESC telemetry injection masks

FailureInjector mapped FAILURE_UNIT_SYSTEM_MOTOR Stuck/Wrong to ESC-telemetry
masks consumed by manipulateEscStatus() -- on the wrong MAVLink unit (telemetry
belongs to FAILURE_UNIT_SYSTEM_ESC) and dead code: manipulateEscStatus() has had
no callers since the ESC checks moved into escCheck. The equivalent behaviour
now lives on the ESC unit in process_esc (Wrong directly; the old zero+offline
"Stuck" as esc off). Remove the masks and the dead method; the motor-stop (Off)
path ControlAllocator consumes is unchanged.

* refactor(failure_injection): do the copy for the amneded esc_status in the process_esc() function

This results in a clearer interface with less lines to call and the same overhead of copying once.

* fix(failure_injection): add esc telemetry failure support for all simulation interfaces

* fix(failure_injection): zero a disconnected ESCs telemetry

It's not entirely realistic because the value would go stale in a real disconnect but better than just flagging it offline but still reporting new telemetry.

---------

Co-authored-by: Matthias Grob <maetugr@gmail.com>
2026-07-31 15:50:49 +02:00
..
…
…
2025-02-24 16:02:46 +01:00
2026-06-24 15:32:44 +02:00
…
…
…