Skip to content

feat(failure_injection): Enable failure-injection on hardware, and through RC-switch#27832

Open
Claudio-Chies wants to merge 5 commits into
mainfrom
cch/failure-injection-followup
Open

feat(failure_injection): Enable failure-injection on hardware, and through RC-switch#27832
Claudio-Chies wants to merge 5 commits into
mainfrom
cch/failure-injection-followup

Conversation

@Claudio-Chies

Copy link
Copy Markdown
Member

Summary

Extends failure injection beyond the SITL simulators so failures can be injected on real hardware, triggered from an RC switch, and applied to multiple instances at once. All new apply-sites compile in only with the failure_injection_manager module and stay gated at runtime by SYS_FAILURE_EN.

Problem

Failure injection only worked through the SITL sensor/actuator sims. On real hardware failure <sensor> did nothing; failures could only be commanded over MAVLink/console with no RC trigger; and MAV_CMD_INJECT_FAILURE could target a single instance only.

Solution

  • Hardware sensor injection: Off/Stuck hooks in PX4Accelerometer/Gyroscope/Magnetometer/Barometer/Rangefinder via the shared failure_injection::process() helper.
  • GPS injection in all three GPS drivers (gps, septentrio, UAVCAN GNSS), addressable per uORB instance.
  • RC aux-switch trigger: SYS_FAIL_RC_SRC selects AUX1–6 (mapped via RC_MAP_AUXn), with SYS_FAIL_RC_UNIT/SYS_FAIL_RC_MODE/SYS_FAIL_RC_INST describing the failure;
  • MAV_CMD_INJECT_FAILURE instance bitmask (param4) support, plus a failure -m <mask> console option.
  • distance_sensor added to the capability catalogue; FAILURE_UNIT_SYSTEM_ESC (106) mirrored from MAVLink (reserved, not yet implemented).
  • SimulatorMavlink no longer re-applies accel/gyro/mag/baro failures, since the driver hooks now cover them in SITL too.

All new paths are gated by CONFIG_MODULES_FAILURE_INJECTION_MANAGER + SYS_FAILURE_EN.

@github-actions github-actions Bot added kind:feature Request or change that adds new functionality. kind:test Adds or improves tests. scope:build-system CMake, Kconfig, board config, or build tooling. scope:drivers Device drivers and hardware interfaces. scope:sensors Sensor pipeline, calibration, voting, or sensor validation. scope:offboard Offboard mode, external setpoints, companion-computer control, or offboard failsafe behavior. scope:mavlink MAVLink module, streams, commands, or protocol handling. scope:uorb uORB messages, generated interfaces, or message translation. scope:middleware DDS, ROS 2, Cyphal/UAVCAN, zenoh, or bridge layers. scope:simulation SITL, Gazebo, jmavsim, lockstep, or simulated sensors. scope:parameters Parameter definitions, metadata, migration, or defaults. scope:testing Unit, integration, fuzzing, or test data. scope:boards Board-specific changes or hardware definitions. scope:docs labels Jul 7, 2026
Claudio Chies added 2 commits July 7, 2026 15:48
…port and instance bitmasking

feat(failure_injection): add disabled failure injection manager and system command support for v5x and v6x boards
@Claudio-Chies Claudio-Chies force-pushed the cch/failure-injection-followup branch from 31a7540 to 6a3bf90 Compare July 7, 2026 13:48
@Claudio-Chies Claudio-Chies marked this pull request as ready for review July 7, 2026 13:54
@Claudio-Chies Claudio-Chies requested review from bkueng and dakejahl July 7, 2026 13:54
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 64 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +64  +0.0%     +64    .text
    +0.0%     +56  +0.0%     +56    g_cromfs_image
    +0.0%      +4  +0.0%      +4    [section .text]
     +44%      +4   +44%      +4    g_nullstring
  +0.0%    +114  [ = ]       0    .debug_abbrev
  +0.0%     +24  [ = ]       0    .debug_aranges
  +0.0%     +72  [ = ]       0    .debug_frame
  +0.0% +2.74Ki  [ = ]       0    .debug_info
  +0.0%    +261  [ = ]       0    .debug_line
   -42.9%      -3  [ = ]       0    [Unmapped]
    +0.0%    +264  [ = ]       0    [section .debug_line]
  +0.0%    +440  [ = ]       0    .debug_loclists
  +0.0%     +80  [ = ]       0    .debug_rnglists
    [DEL]      -1  [ = ]       0    [Unmapped]
    +0.0%     +81  [ = ]       0    [section .debug_rnglists]
  +0.0%    +356  [ = ]       0    .debug_str
  -0.6%     -64  [ = ]       0    [Unmapped]
  +0.0% +4.06Ki  +0.0%     +64    TOTAL

px4_fmu-v6x [Total VM Diff: 56 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +56  +0.0%     +56    .text
    +0.0%     +56  +0.0%     +56    g_cromfs_image
  +0.0%    +114  [ = ]       0    .debug_abbrev
  +0.0%     +24  [ = ]       0    .debug_aranges
  +0.0%     +72  [ = ]       0    .debug_frame
  +0.0% +2.71Ki  [ = ]       0    .debug_info
  +0.0%    +264  [ = ]       0    .debug_line
     +33%      +1  [ = ]       0    [Unmapped]
    +0.0%    +263  [ = ]       0    [section .debug_line]
  +0.0%    +376  [ = ]       0    .debug_loclists
  +0.0%     +80  [ = ]       0    .debug_rnglists
   -33.3%      -1  [ = ]       0    [Unmapped]
    +0.0%     +81  [ = ]       0    [section .debug_rnglists]
  +0.0%    +356  [ = ]       0    .debug_str
  -1.4%     -56  [ = ]       0    [Unmapped]
  +0.0% +3.96Ki  +0.0%     +56    TOTAL

Updated: 2026-07-08T14:18:12

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

No broken links found in changed files.

@Claudio-Chies Claudio-Chies changed the title feat(failure_injection): hardware sensor, GPS, and RC-switch failure injection feat(failure_injection):Enable failure-injection on hardware, and through RC-switch Jul 8, 2026
@Claudio-Chies Claudio-Chies changed the title feat(failure_injection):Enable failure-injection on hardware, and through RC-switch feat(failure_injection): Enable failure-injection on hardware, and through RC-switch Jul 8, 2026
Claudio Chies added 3 commits July 8, 2026 12:55
Add a value-mutating apply-site for FAILURE_UNIT_SYSTEM_BATTERY. On an
injected OFF the outgoing battery_status is reported as a depleted pack
(zero remaining, emergency warning) so the low-battery failsafe triggers.

The apply-site lives in the shared Battery library, covering the analog
ADC, INA power monitors, ESC battery and SITL in one place, plus the
UAVCAN battery driver which publishes battery_status directly. The
previous SITL-only hack in BatterySimulator is removed in favour of this
shared path so simulation and hardware behave identically.
@Claudio-Chies Claudio-Chies force-pushed the cch/failure-injection-followup branch from 8b91514 to 9ed50b4 Compare July 8, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:feature Request or change that adds new functionality. kind:test Adds or improves tests. scope:boards Board-specific changes or hardware definitions. scope:build-system CMake, Kconfig, board config, or build tooling. scope:docs scope:drivers Device drivers and hardware interfaces. scope:mavlink MAVLink module, streams, commands, or protocol handling. scope:middleware DDS, ROS 2, Cyphal/UAVCAN, zenoh, or bridge layers. scope:offboard Offboard mode, external setpoints, companion-computer control, or offboard failsafe behavior. scope:parameters Parameter definitions, metadata, migration, or defaults. scope:sensors Sensor pipeline, calibration, voting, or sensor validation. scope:simulation SITL, Gazebo, jmavsim, lockstep, or simulated sensors. scope:testing Unit, integration, fuzzing, or test data. scope:uorb uORB messages, generated interfaces, or message translation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant