Skip to content

模拟故障保护

Failsafes define the safe limits/conditions under which you can safely use PX4, and the action that will be performed if a failsafe is triggered (for example, landing, holding position, or returning to a specified point).

在 SITL 中,默认情况下会禁用某一些故障,以便方便模拟使用。 本主题说明如何在实际世界中尝试 SITL 仿真之前测试安全关键行为。

INFO

You can also test failsafes using HITL simulation. 这使得模拟仅适用于连接的 GCS,SDK 或其他 MAVLink 应用程序。

数据链路丢失

The Data Link Loss failsafe (unavailability of external data via MAVLink) is enabled by default. This makes the simulation only usable with a connected GCS, SDK, or other MAVLink application.

Set the parameter NAV_DLL_ACT to the desired failsafe action to change the behavior. For example, set to 0 to disable it.

INFO

All parameters in SITL including this one get reset when you do make clean.

RC 链接损失

The RC Link Loss failsafe (unavailability of data from a remote control) is enabled by default. 这可以在 GCS UI 中测试电池指示,而不会触发可能中断其他测试的低电池反应。

Set the parameter NAV_RCL_ACT to the desired failsafe action to change the behavior. For example, set to 0 to disable it.

INFO

All parameters in SITL including this one get reset when you do make clean.

Low Battery

为了模拟丢失和重新获取 GPS 全球定位系统信息,您可以停止/重新启动 GPS 驱动程序。 This enables testing of battery indication in GCS UIs without triggering low battery reactions that might interrupt other testing.

To change this minimal battery percentage value use the parameter SIM_BAT_MIN_PCT.

To control how fast the battery depletes to the minimal value use the parameter SIM_BAT_DRAIN.

TIP

By changing SIM_BAT_MIN_PCT in flight, you can also test regaining capacity to simulate inaccurate battery state estimation or in-air charging technology.

The simulated battery can be completely disabled by setting SIM_BAT_DRAIN to 0. This is useful, for example, if you provide an external battery simulation via MAVLink.

Multiple Batteries

By default only one battery is simulated. Additional batteries are simulated by enabling them like on a real vehicle: set the source of the battery to Power Module and configure it, e.g. BAT2_SOURCE and BAT2_N_CELLS for a second battery. Each simulated battery is published as its own battery_status instance.

All batteries deplete according to SIM_BAT_DRAIN and SIM_BAT_MIN_PCT unless overridden for an individual battery with SIM_BATx_DRAIN and SIM_BATx_MIN_PCT. Setting SIM_BATx_DRAIN to a non-positive value uses the shared drain time. Setting SIM_BATx_MIN_PCT to a negative value uses the shared minimum charge. This can be used to test multi-battery behaviour, for example one battery depleting faster than the others.

GPS 损失

Failure injection can be used to simulate different types of failures in many sensors and systems. For example, this can be used to simulate absent or intermittent GPS, RC signal that has stopped or got stuck on a particular value, failure of the avoidance system, and much more.

Failure injection is gated by the SYS_FAILURE_EN parameter.

For example, to simulate GPS failure, enter the following commands on the SITL instance pxh shell:

sh
# Turn (all) GPS off (no position reported, as for a dead receiver)
failure gps off

# Freeze (all) GPS on the last reported position (a "stuck" fix)
failure gps stuck

# Report a diverging position (offset by ~111 km, trips the GNSS redundancy checks)
failure gps wrong

# Restore normal GPS output
failure gps ok

TIP

To test the GNSS redundancy failsafe you can simulate a second GPS receiver: set the antenna-offset parameter SENS_GPS1_OFFX or SENS_GPS1_OFFY to a non-zero value, and the simulator publishes a second sensor_gps instance offset by that distance (in metres). You can then fail an individual receiver with the -i flag (-i 0 = all instances, -i 1 = first GPS, -i 2 = second), for example failure gps wrong -i 2.