From 5db41147ed6162b4166b22cccd1b59f767fe7afc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 27 Jul 2019 15:28:27 +1000 Subject: [PATCH] AP_NavEKF2: restrict setting of EKF origin only allow EKF origin to be set if EKx_GPS_TYPE is set to 3, which is used for indoor operation --- libraries/AP_NavEKF2/AP_NavEKF2.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/AP_NavEKF2/AP_NavEKF2.cpp b/libraries/AP_NavEKF2/AP_NavEKF2.cpp index 094e63f579..0ef9d9e4db 100644 --- a/libraries/AP_NavEKF2/AP_NavEKF2.cpp +++ b/libraries/AP_NavEKF2/AP_NavEKF2.cpp @@ -1096,6 +1096,13 @@ bool NavEKF2::getOriginLLH(int8_t instance, struct Location &loc) const // Returns false if the filter has rejected the attempt to set the origin bool NavEKF2::setOriginLLH(const Location &loc) { + if (_fusionModeGPS != 3) { + // we don't allow setting of the EKF origin unless we are + // flying in non-GPS mode. This is to prevent accidental set + // of EKF origin with invalid position or height + gcs().send_text(MAV_SEVERITY_WARNING, "EKF2 refusing set origin"); + return false; + } if (!core) { return false; }