Multiple EKF Primary change => Large Pitch/Roll variation and HAGL reset to 0 in flight!

, ,

We’ve just had a flight with a large X8 running AC3.5 with some frightening errors.

During an AUTO mission, the EFK started to act strangely and quickly switched between source 0 and source 1.
This was probably caused by the fact that tht NKF5.rng went from 100m to 0m instantly while NKF5.HAGL and RFND.Dist1 stayed at 100m.
This happen at the EXACT moment NKF5.rng is at 99.5 and is supposed to go to 100.5m, instead it goes to 0.5m. Bug with the rng library or only ekf msg parsing ? I don’t know

The question is WHY ? This is scary !
When switching for EKF 0 to 1, Copter became very unstable in Pitch and Roll (following the Desired commands). It is logical because the Desired Climb rate changed with the altitude reading being false.

After a few second, the NKF5.HAGL, so basically the Ground Level Altitude seen by the drone, went from 100 to 0 as well. Fortunately, pilot already changed the flight mode to Stabilize otherwise I’m sure we would have seen a rocket drone.

I must precise that EK2_ALT_SOURCE is set to 1 (rangefinder) EK2_RNG_USE_HGT is set to 50% (so 50m of RNGFND_MAX_CM = 1000 cm = 100m).

Log is here :

This was caused by a combination of incorrect parameter settings and a vulnerability in the EKF’s on-ground/in-flight detector.

Using the range finder as the permanent primary height source by setting EK2_ALT_SOURCE = 1 is only suitable for low altitude and low speed operation over flat surfaces, not for up and away flight. The copter climbed above the max valid range specified for the finder (100m) which means the range measurement is then considered to be out of range. What happened then was an incorrect output from the in-air/on-ground motion check caused the range finder reading to be set to the RNGFND_GNDCLEAR value.

To use range finder at lower altitudes and baro for up and away flight, set EK2_ALT_SOURCE = 0. The RNG_USE_HGT param is currently set to 50% which would mean using range finder up to 50m given that RNGFND_MAX_CM = 10000. This is too high. Either reduce RNGFND_MAX_CM or reduce RNG_USE_HGT so that it switches at no more than 15m. The reason for this is that as height increases, attitude estimation and alignment errors and terrain gradient create larger height errors.

I will investigate the behaviour of the on-ground/in-flight motion check further.

1 Like

Thanks a lot Paul for this answer.

Thank you for finding this and updating the wiki! is now merged!