Discrepancy between EKF altitude and barometric altitude in AltHold

I totally agree.

@angleman without tilt compensation the measured altitude should go up, not down, because the lidar is looking down the hypotenuse of a triangle. It follows the formula “real alt / cos(lean angle) = measured alt”. Since cos(lean angle) is always smaller than 1, the measured alt will always be bigger than the real alt.
What can lead to EKF height drops during horizontal flights are changes in the barometric readings due to air current.

I’m sorry, when the remote control controls the direction, the EKF height increases and the actual height decreases with the barometer height. I think it has nothing to do with the barometer. I do not install the rangefinder and optical flow, and the indoor height is very stable, but when the optical flow is connected and the height source is set as the barometer and the surface tracking is canceled, the reason is still not found