From a56b1dadb9e7794bc92103e654ca1ab53779a640 Mon Sep 17 00:00:00 2001 From: Samuel Tabor Date: Sat, 8 Jun 2019 13:49:56 +0100 Subject: [PATCH] Plane: fix bug with headingLinedUp when loiter.sum_cd was negative. --- ArduPlane/mode_loiter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArduPlane/mode_loiter.cpp b/ArduPlane/mode_loiter.cpp index 9313cf379e..13decff8db 100644 --- a/ArduPlane/mode_loiter.cpp +++ b/ArduPlane/mode_loiter.cpp @@ -66,7 +66,7 @@ bool ModeLoiter::isHeadingLinedUp(const int32_t bearing_cd) */ // Use integer division to get discrete steps - const int32_t expanded_acceptance = 1000 * (plane.loiter.sum_cd / 36000); + const int32_t expanded_acceptance = 1000 * (labs(plane.loiter.sum_cd) / 36000); if (labs(heading_err_cd) <= 1000 + expanded_acceptance) { // Want to head in a straight line from _here_ to the next waypoint instead of center of loiter wp