Loss of altitude and crash when engaging LOITER

It happened to me few times, with two different drones, using firmware version 3.6.9-rc2, that when I engage loiter the copter stops the motors and falls to the ground.

The EKF position estimation is very good and the altitude correctly goes to the ground (like the drone :sweat_smile:), following the data from indoor positioning system through fakeGPS.
I’ve set EK2_ALT_NSE to an high value (12 meters) to reject barometer readings as the positioning altitude is more accurate.

There are only two suspicious things to me: the fact that the AHR2.Alt seems completely off and goes up after loiter is engaged and the fact that on arming there is an altitude drift and seems the same issue reported in the following discussion

Here’s the beginning of the crash flight, you can see a 50cm drift in POS.Alt (yellow).

(in both graphs POS.Alt and AHR2.Alt are not on same scale)

I’ve used loiter a lot of times without seeing this kind of problem.
Here’s a 7 minute flight with several loiter positions without any issue, AHR2.Alt is off anyway.

I hope it is only a misconfiguration problem and not a bug, by the way the copter is very well trimmed and tuned. Any hint?

Here the logs:
Crash on loiter engage 1

Loiter no problems

Crash on loiter engage 2

@tridge @peterbarker FYI

Unfortunately CTUN log was not enabled so I cannot read desired altitude, but I’m sure that that the throttle stick was centered as all the other times when I tested LOITER and everything was fine.

The RATE.ADes (target acceleration) goes down when loiter is engaged.

By the way I think this can be a vibration issue, I forgot to enable the notch filter on accelerometer.
If that’s the case, somewhat “proves” that this feature I’ve been working on could be very useful for small quadcopters even with a dampered IMU like mine.

No crashes after re-enabling the accel notch, I’ll continue to test and see if it happens again.

P.S. Here’s the pull