feat(px4): add failure injection setup page#14578
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #14578 +/- ##
==========================================
+ Coverage 25.47% 30.69% +5.22%
==========================================
Files 769 789 +20
Lines 65912 66887 +975
Branches 30495 30985 +490
==========================================
+ Hits 16788 20529 +3741
+ Misses 37285 32399 -4886
- Partials 11839 13959 +2120
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 436 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
|
@bkueng @hamishwillee FYI This would be the PR for the UI side of the Failure injection refactor. |
There was a problem hiding this comment.
Pull request overview
This PR adds a new PX4 Vehicle Setup page for injecting simulated failures using MAV_CMD_INJECT_FAILURE, gated by the presence of SYS_FAILURE_EN on the connected vehicle. It also updates MAVLink to a newer commit and extends the MAVLink-enum generator so QML can reflect the FAILURE_UNIT/FAILURE_TYPE catalogs directly from the MAVLink dialect.
Changes:
- Add a PX4 “Failure Injection” setup component + QML page (instance selection, activity log, reset-all).
- Add a QML singleton (
FailureInjection) which builds unit/type catalogs from MAVLink enum reflection and tracks session activity. - Update MAVLink git tag and adjust enum-generation to provide QML-reflectable
FAILURE_UNIT/FAILURE_TYPEenums, plus add unit/integration/UI tests.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/generators/mavlink_enums.py | Extends QML enum header generation to locally redeclare specific enums for QML reflection. |
| cmake/CustomOptions.cmake | Bumps the MAVLink repository commit/tag used by the build. |
| src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h | Adds the Failure Injection component member/include. |
| src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc | Conditionally adds the Failure Injection setup page when SYS_FAILURE_EN exists. |
| src/AutoPilotPlugins/PX4/FailureInjectionComponent.qml | Implements the full PX4 setup UI for injecting and resetting failures via MAVLink command. |
| src/AutoPilotPlugins/PX4/FailureInjectionInstances.js | Shared instance-selection logic for mapping selected instances to MAVLink params. |
| src/AutoPilotPlugins/PX4/FailureInjectionComponent.h | Declares the new Vehicle Setup component wrapper. |
| src/AutoPilotPlugins/PX4/FailureInjectionComponent.cc | Implements component metadata and QML source wiring. |
| src/AutoPilotPlugins/PX4/FailureInjection.h | Declares the QML singleton API and activity/catalog properties. |
| src/AutoPilotPlugins/PX4/FailureInjection.cc | Builds catalogs from Q_ENUM_NS metadata and manages activity + injected-unit tracking. |
| src/AutoPilotPlugins/PX4/CMakeLists.txt | Adds new C++ sources and QML/JS resources to the PX4 plugin build. |
| test/UnitTestFramework/QmlTesting/tests/tst_FailureInjectionInstances.qml | Unit tests for the shared JS instance-selection logic. |
| test/AutoPilotPlugins/PX4/FailureInjectionTest.h | Declares unit tests for the FailureInjection singleton model/logic. |
| test/AutoPilotPlugins/PX4/FailureInjectionTest.cc | Implements unit tests for catalog building and activity/injected tracking behavior. |
| test/AutoPilotPlugins/CMakeLists.txt | Registers the new FailureInjection unit test target. |
| test/QmlUITests/FailureInjectionUITest.h | Declares an integration UI test that drives injection/reset through the real UI. |
| test/QmlUITests/FailureInjectionUITest.cc | Implements the UI test using PX4 MockLink and QML objectName lookups. |
| test/QmlUITests/CMakeLists.txt | Adds the new FailureInjection UI test to the test build/ctest list. |
| property Fact _sysFailureEn: controller.getParameterFact(-1, "SYS_FAILURE_EN", true /* reportMissing */) | ||
| property bool _paramSet: _sysFailureEn && _sysFailureEn.value === 1 | ||
| property bool _pendingReboot: false // SYS_FAILURE_EN just toggled, reboot not yet triggered | ||
| property bool _armed: _paramSet // PX4 honors SYS_FAILURE_EN at boot; arm once the param reads 1 |
| property int _unitIndex: 4 // GPS | ||
| property int _typeIndex: 1 // Off | ||
| property var _selectedInstances: [1] // 1-based instance numbers | ||
| readonly property int _instanceCount: 8 // fixed number of selectable instances (not tied to the unit) |
| Q_PROPERTY(QVariantList units READ units CONSTANT) ///< [{ name, unit, max }] | ||
| Q_PROPERTY(QVariantList types READ types CONSTANT) ///< [{ name, type }] |
|
|
||
| // One ack arrived: resolve the matching log row (only one is pending at a time), then send the next. | ||
| function _onAck(ackResult) { | ||
| FailureInjection.resolveResult(ackResult) // no-op when the head was a reset (no pending row) |
- Introduced FailureInjection and FailureInjectionComponent classes to manage simulated sensor and system failures. - Updated CMakeLists.txt to include new source files and tests for Failure Injection. - Implemented QML interface for Failure Injection, allowing users to inject failures and view activity logs. - Enhanced MAVLink enums to support new FAILURE_UNIT and FAILURE_TYPE enums for failure injection. - Added unit tests for FailureInjection functionality to ensure proper behavior and integration.
e7f5ab2 to
b6b67e7
Compare
Build ResultsPlatform Status
All builds passed. Pre-commit
Pre-commit hooks: 0 passed, 0 failed, 0 skipped. Test Resultslinux-coverage-integration: 26 passed, 0 skipped Code Coverage
Artifact Sizes
Updated: 2026-07-07 06:20:51 UTC • Commit: 25bf70e • Triggered by: Android |
cb576ac to
01412ce
Compare
|
FYI: Since we are currently in Stable 5.1 lockdown this won't get merged until we create the 5.1 branch. |
Description
Failure injection support in PX4 is being refactored and expanded, with the eventual goal of using it for hardware flight testing — for example, validating system response to a motor-out scenario.
As part of that, this PR adds a PX4 Vehicle Setup page for injecting simulated failures via
MAV_CMD_INJECT_FAILURE, so failsafe and EKF response can be validated from the UI instead of hand-crafting MAVLink commands.Operators pick a failure unit, type, and instance(s) and inject them directly through the page. The page only appears when
SYS_FAILURE_ENis present on the vehicle, which depends on the firmware being built with thefailure-injection-managermodule included — if the module isn't built in, the parameter is absent and the page stays hidden. The unit/type dropdowns are populated directly from MAVLink'sFAILURE_UNIT/FAILURE_TYPEenums, so new entries appear automatically as they're added to MAVLink.Display
Screencast.From.2026-07-01.19-28-43.mp4
Type of Change
Testing
Platforms Tested
Flight Stacks Tested
Screenshots
Checklist
Related PR's
By submitting this pull request, I confirm that my contribution is made under the terms of the project's dual license (Apache 2.0 and GPL v3).