Crash Analysis
A crash occurred with a PX4 v1.11.3 custom version (with no changes to core flight control) multirotor was landing in a mission & had a crash due to the faulty distance sensor readings. Here’s the diagnosis:
- Vehicle was descending at 0.5 m/s (MPC_LAND_SPEED), and was closing in on the ground
- When the distance sensor data was coming in & got considered valid (
vehicle_local_position/dist_bottom_valid
) at around 436 seconds mark, EKF2 fused local position z value started to ‘decrease’ (indicating vertically upwards movement) - As the z position setpoint generated from the “FlightTaskAutoLineSmoothVel” with jerk limited trajectory continued increasing (as it integrated velocity setpoint), current fused z position & it’s setpoint started to diverge
- Due to P-gain in Multicopter Position Controller, the “vz” velocity setpoint increases significantly and saturated at 1.5 m/s (
MPC_Z_VEL_MAX_DN
) - Multirotor descends rapidly, overshooting the vz setpoint, and crashes (438.5 seconds mark, based on
gps0_alt_m
curve showing ground truth terrain at 144.755 meters AMSL)
Cause
There are multiple things that went wrong, but I wanted to focus on the estimator’s behavior regarding the distance sensor’s faulty readings.
As far as I can tell, estimator did provide kinematically inconsistent estimation of it’s z
coordinate value as the faulty distance sensor data came in.
Estimator fuse of Height Above Ground Level
When checking the HAGL test ratio & innovation, it is clear that it saturated at 0.15 & 0.1 respectively moments before the crash. Their values were:
- HAGL innovation variance: 0.02 - 0.03
- HAGL innovation test ratio: Saturated at 0.023
- HAGL test ratio: Saturated at 0.15
- HAGL innovation: Saturated at 0.10
Also, checking the estimator_status/control_mode_flags
value of “8389783” which got set after “vehicle_local_position/dist_bottom_valid” got set to true, indicating that the range finder is being fused as primary height reference.
Questions & Answers
I effectively answered my own questions, but may be incorrect in some places, open for feedback!
First, the “EKF2_HGT_MODE” was set to 1 (Primary source: GPS) (Link to v1.11 Parameters doc). Why did the distance sensor reading cause so much disturbance although it was not primary source?
To answer my own question, I think it’s this logic:
Second, is it possible to disable the range finder disturbance to the height fusion?
To do that, we need to make this condition false:
We can either:
- Set “EKF2_RNG_AID” to 0 (it was 1), to make sure range sensor never disturbs the estimate of height
- Set lower “EKF2_RNG_GATE” (e.g. to 1.0, as it was 5.0 before), or “EKF2_RNG_A_IGATE” (e.g. to 0.5, as it was 1.0 before)
Extra link to logic where range finder aid suitability is checked:
Third, given the obviously inconsistent distance sensor data (for sure kinematically, as distance was increasing when velocity was expected to be down, closing in on the ground), the kinematic gate added in the following PR (for v1.13 and onwards) seems to likely solve this issue (and will reject range finder appropriately). Is this true?
@bresch Do these diagnosis & solution make sense? I’m also curious if there’s any sane value that RNG_GATE and RNG_A_IGATE params should be set to, instead of lowering them arbitrarily.