From 44ebfb8c430b6e20e133c8e0f8c595b307b0e9cf Mon Sep 17 00:00:00 2001 From: Paul Riseborough Date: Wed, 2 Dec 2020 20:54:43 +1100 Subject: [PATCH] EKF: Don't report local position as valid when in a non-position mode --- EKF/ekf.h | 8 +++++++- EKF/estimator_interface.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/EKF/ekf.h b/EKF/ekf.h index 7b15bd6b68..e075b367ae 100644 --- a/EKF/ekf.h +++ b/EKF/ekf.h @@ -196,7 +196,13 @@ public: // and have not started using synthetic position observations to constrain drift bool global_position_is_valid() const { - return (_NED_origin_initialised && !_deadreckon_time_exceeded && !_using_synthetic_position); + return (_NED_origin_initialised && local_position_is_valid()); + } + + // return true if the local position estimate is valid + bool local_position_is_valid() const + { + return (!_deadreckon_time_exceeded && !_using_synthetic_position); } bool isTerrainEstimateValid() const { return _hagl_valid; }; diff --git a/EKF/estimator_interface.h b/EKF/estimator_interface.h index 45465477a3..2cd9a0ff67 100644 --- a/EKF/estimator_interface.h +++ b/EKF/estimator_interface.h @@ -159,7 +159,7 @@ public: int getNumberOfActiveHorizontalAidingSources() const; // return true if the local position estimate is valid - bool local_position_is_valid() const { return !_deadreckon_time_exceeded; } + bool local_position_is_valid() const { return local_position_is_valid(); } // return true if the EKF is dead reckoning the position using inertial data only bool inertial_dead_reckoning() const { return _is_dead_reckoning; }