feat(sensor_gps_sim): add GPS failure injection via VEHICLE_CMD_INJEC…#27396
Open
gguidone wants to merge 1 commit into
Open
feat(sensor_gps_sim): add GPS failure injection via VEHICLE_CMD_INJEC…#27396gguidone wants to merge 1 commit into
gguidone wants to merge 1 commit into
Conversation
…T_FAILURE Implements FAILURE_UNIT_SENSOR_GPS support in the SITL sensor_gps_sim module, mirroring the existing motor failure injection pattern in FailureInjector. Supported failure types per GPS instance (param3=0 all, 1=GPS0, 2=GPS1): - FAILURE_TYPE_OFF, stop publishing (simulates dead receiver) - FAILURE_TYPE_STUCK, freeze last known position (simulates frozen fix) - FAILURE_TYPE_WRONG, corrupt position by +1 deg (~111 km offset, triggers gpsRedundancyCheck divergence gate) - FAILURE_TYPE_OK, recover all active failures for that instance Requires SYS_FAILURE_EN=1. The enable gate is re-read every cycle so runtime parameter changes take effect without restarting the module.
Contributor
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 728 byte (0.04 %)]px4_fmu-v6x [Total VM Diff: 0 byte (0 %)]Updated: 2026-05-19T12:42:29 |
Contributor
|
Just remember to update https://docs.px4.io/main/en/debug/failure_injection#system-failure-injection with information about what is supported both on SIM and real hardware please. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solved Problem
PX4's SITL has no GPS failure injection.
Solution
Add a
SensorGpsFailureInjectorinsensor_gps_simthat handlesVEHICLE_CMD_INJECT_FAILUREwithfailure_unit == FAILURE_UNIT_SENSOR_GPSand exposes per-instance failure flags. Every publish is routed through apublishWithFailures()helper that applies one of:FAILURE_TYPE_OFF, suppress publish (dead receiver)FAILURE_TYPE_STUCK, republish last sample with refreshed timestamp (frozen fix)FAILURE_TYPE_WRONG, +1° lat/lon offset (~111 km) to tripgpsRedundancyCheck's divergence gateFAILURE_TYPE_OK, clear active failures for the targeted instance(s)param3targets instances (0 = all, 1 = GPS0, 2 = GPS1), matching the motor injector. Gated bySYS_FAILURE_EN, re-read every cycle so toggling at runtime takes effect immediately.The implementation mirrors
src/modules/commander/failure_detector/FailureInjector.{cpp,hpp}.Alternatives
Test coverage
Manual SITL testing.