From 89cfdb678ffa43b597b79b76cded4cae3364fb7e Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 10 Sep 2019 14:41:14 +1000 Subject: [PATCH] AC_WPNav: do not calculate NEU vector from invalid location --- libraries/AC_WPNav/AC_WPNav.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libraries/AC_WPNav/AC_WPNav.cpp b/libraries/AC_WPNav/AC_WPNav.cpp index e277b0dc31..8ff6bba6ae 100644 --- a/libraries/AC_WPNav/AC_WPNav.cpp +++ b/libraries/AC_WPNav/AC_WPNav.cpp @@ -603,16 +603,19 @@ bool AC_WPNav::set_spline_destination(const Location& destination, bool stopped_ return false; } - // make altitude frames consistent - if (!next_destination.change_alt_frame(destination.get_alt_frame())) { - return false; - } + Vector3f next_dest_neu; // left uninitialised for valgrind + if (seg_end_type == SEGMENT_END_STRAIGHT || + seg_end_type == SEGMENT_END_SPLINE) { + // make altitude frames consistent + if (!next_destination.change_alt_frame(destination.get_alt_frame())) { + return false; + } - // convert next destination to vector - Vector3f next_dest_neu; - bool next_dest_terr_alt; - if (!get_vector_NEU(next_destination, next_dest_neu, next_dest_terr_alt)) { - return false; + // convert next destination to vector + bool next_dest_terr_alt; + if (!get_vector_NEU(next_destination, next_dest_neu, next_dest_terr_alt)) { + return false; + } } // set target as vector from EKF origin