SIM: refactor sensor-simulation and add faliure injection in SIH#25582
SIM: refactor sensor-simulation and add faliure injection in SIH#25582
Conversation
|
When/if this goes in, please update the docs to reflect this - suggest doing it in both the SIH and failure injection docs. Also add a release note in the /releases/main doc. |
dagar
left a comment
There was a problem hiding this comment.
- I'm not sure I agree with merging all the super simple little simulation modules. Most of these are pretty simple/crappy sensor models that were intended to fill in as a starting point with the intention that the actual simulator would takeover if you needed something better.
- Pushing the failure injection downstream would ultimately provide a lot more flexibility in testing across any simulator, real vehicles, and possibly unit tests. It could be build time conditional to fully strip it out of products that don't want it.
|
I infer @dagar means make the changes to simulate failure independent of the simulation code itself. |
* add failure type 'drift' and failure-unit 'gps_alt'
…nager. allows better failure handling * still all sensors can be enabled/disabled through parameters * check airspeed simulation (sih.cpp has seperate calc.)
* move sensor simulation from sih to SensorSimManager * fix failureInjection usage
* add AGP failure injection * add distance sensor failure injection
* fix gps-stuck-failure to actually be stuck
8a5f0c7 to
dec7f75
Compare
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: -60 byte (-0 %)]px4_fmu-v6x [Total VM Diff: 40 byte (0 %)]Updated: 2025-10-03T10:33:09 |
|
This pull request has been automatically closed due to 120 days of inactivity. If you would like to continue, please feel free to reopen it or submit a new PR. |
|
Not sure this one should go stale - even if the implementation isn't quite optimal, the use case is valid. |
Solved Problem
When developing and testing autonomous flight systems, failure simulation is crucial for robust system validation. The existing sensor simulation in PX4 was fragmented across multiple individual modules (
sensor_gps_sim,sensor_baro_sim,sensor_mag_sim, etc.), making it difficult to implement comprehensive failure injection scenarios. It was also difficult to maintain and extend the simulation capabilities.Additionally, there was no unified failure injection system for simulated sensors, limiting the ability to test failure modes like GPS altitude faults, sensor drift, and coordinated multi-sensor failures.
Solution
Unified Sensor Simulation Manager: Refactor multiple individual sensor simulation modules into a single
SensorSimManagerthat coordinates all simulated sensors (GPS, barometer, magnetometer, airspeed, AGP, distance sensor, IMU). SIH is now only responsible forthe simulation of the equations of motion, all sensor data is produced in
SensorSimManager.SimulatorMavlinkcan still use selectedsensors which are not covered by gazebo.
Comprehensive Failure Injection Framework: Add new
FailureInjectionclass that supports:GPS failures: blocked, stuck, wrong data, and drift
GPS altitude-specific failures: blocked, stuck, wrong data, and drift
IMU failures: accelerometer and gyroscope blocked/stuck per instance
Magnetometer failures: blocked/stuck per instance
Barometer failures: blocked/stuck
Airspeed sensor failures: disconnected, blocked (pitot tube simulation)
Visual-Inertial Odometry (VIO) failures: blocked
Auxiliary Global Position (AGP) failures: blocked, stuck, drift
Distance sensor failures: blocked, stuck, wrong readings
Extend
VEHICLE_CMD_INJECT_FAILUREsupport with new failure units (GPS_ALT,AGP) and failure type (DRIFT)Consolidate simulation configuration in startup scripts
Keep individual sensor enable/disable parameters for flexibility
Better integration with Gazebo and SIH simulation environments
All existing sensor simulation parameters (
SENS_EN_GPSSIM,SENS_EN_BAROSIM, etc.) continue to work as before.Changelog Entry
For release notes:
Testing
Tested in SIH / classic gazebo.
Further testing for each sensor and failure is not completed!
Draft:
Testing and dependent on #25552