AP_NavEKF3: Don't allow range finder use to start if terrain state is stale

This commit is contained in:
Paul Riseborough 2022-11-21 20:26:30 +11:00 committed by Randy Mackay
parent c4425d51e1
commit 74ff64f440

View File

@ -1087,7 +1087,7 @@ void NavEKF3_core::selectHeightForFusion()
// determine if we are above or below the height switch region
ftype rangeMaxUse = 1e-4 * (ftype)_rng->max_distance_cm_orient(ROTATION_PITCH_270) * (ftype)frontend->_useRngSwHgt;
bool aboveUpperSwHgt = (terrainState - stateStruct.position.z) > rangeMaxUse;
bool belowLowerSwHgt = (terrainState - stateStruct.position.z) < 0.7f * rangeMaxUse;
bool belowLowerSwHgt = ((terrainState - stateStruct.position.z) < 0.7f * rangeMaxUse) && (imuSampleTime_ms - gndHgtValidTime_ms < 1000);
// If the terrain height is consistent and we are moving slowly, then it can be
// used as a height reference in combination with a range finder