Інжекція помилки системи
System failure injection allows you to induce different types of sensor and system failures, either programmatically using the MAVSDK failure plugin, or "manually" via a PX4 console like the MAVLink shell. This enables easier testing of safety failsafe behaviour, and more generally, of how PX4 behaves when systems and sensors stop working correctly.
Failure injection is disabled by default, and can be enabled using the SYS_FAILURE_EN parameter.
WARNING
Failure injection still in development. На момент написання (PX4 v1.14):
- Support may vary by failure type and between simulatiors and real vehicle.
- Потребує підтримки в симуляторі. Це підтримується в Gazebo Classic
- Багато типів відмов не широко реалізовані. У таких випадках команда повернеться з повідомленням "unsupported".
Команда системи збою
Failures can be injected using the failure system command from any PX4 console/shell (such as the QGC MAVLink Console or SITL pxh shell), specifying both the target and type of the failure.
Синтаксис
The full syntax of the failure command is:
sh
failure <component> <failure_type> [-i <instance_number>]де:
- component:
- Датчики:
gyro: Gyroscopeaccel: Accelerometermag: Magnetometerbaro: Barometergps: Global navigation satellite systemoptical_flow: Optical flow.vio: Visual inertial odometrydistance_sensor: Distance sensor (rangefinder).airspeed: Airspeed sensor
- Системи:
battery: Batterymotor: Motorservo: Servoavoidance: Avoidancerc_signal: RC Signalmavlink_signal: MAVLink data telemetry connection
- Датчики:
- failure_type:
ok: Publish as normal (Disable failure injection)off: Stop publishingstuck: Constantly report the same value which can happen on a malfunctioning sensorgarbage: Publish random noise. This looks like reading uninitialized memorywrong: Publish invalid values that still look reasonable/aren't "garbage"slow: Publish at a reduced ratedelayed: Publish valid data with a significant delayintermittent: Publish intermittently
- instance number (optional): Instance number of affected sensor. 0 (за замовчуванням) вказує на всі сенсори вказаного типу.
MAVSDK відлагоджувальний плагін
The MAVSDK failure plugin can be used to programmatically inject failures. It is used in PX4 Integration Testing to simulate failure cases (for example, see PX4-Autopilot/test/mavsdk_tests/autopilot_tester.cpp).
API плагіна - це пряме відображення команди збою, показаної вище, з деякими додатковими сигналами про помилки, пов'язані з підключенням.
Example: RC signal
Щоб симулювати втрату сигналу RC без вимкнення вашого пульта керування RC:
Enable the SYS_FAILURE_EN parameter.
Enter the following commands on the MAVLink console or SITL pxh shell:
sh# Fail RC (turn publishing off) failure rc_signal off # Restart RC publishing failure rc_signal ok
Example: Motor
To stop a motor mid-flight without the system anticipating it or excluding it from allocation effectiveness:
Enable the SYS_FAILURE_EN parameter.
Enable CA_FAILURE_MODE parameter to allow turning off motors.
Enter the following commands on the MAVLink console or SITL pxh shell:
sh# Turn off first motor failure motor off -i 1 # Turn it back on failure motor ok -i 1