From 119c8b73637c0408107843e6a607f459e286ce5f Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Tue, 23 Aug 2022 21:03:46 +0900 Subject: [PATCH] AP_Mount: get_angle_target_to_location checks for valid location --- libraries/AP_Mount/AP_Mount_Backend.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/AP_Mount/AP_Mount_Backend.cpp b/libraries/AP_Mount/AP_Mount_Backend.cpp index 70a09166f6..170bfe32f7 100644 --- a/libraries/AP_Mount/AP_Mount_Backend.cpp +++ b/libraries/AP_Mount/AP_Mount_Backend.cpp @@ -252,6 +252,11 @@ bool AP_Mount_Backend::get_angle_target_to_location(const Location &loc, MountTa return false; } + // exit immediate if location is invalid + if (!loc.initialised()) { + return false; + } + const float GPS_vector_x = Location::diff_longitude(loc.lng, current_loc.lng)*cosf(ToRad((current_loc.lat + loc.lat) * 0.00000005f)) * 0.01113195f; const float GPS_vector_y = (loc.lat - current_loc.lat) * 0.01113195f; int32_t target_alt_cm = 0;