From 96f7d8a969146262a46b0d933c08337b658eb8a6 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 24 Sep 2024 18:43:31 +1000 Subject: [PATCH] Plane: avoid calling quadplane methods if quadplane not available one block was guarded, the second not --- ArduPlane/ArduPlane.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/ArduPlane/ArduPlane.cpp b/ArduPlane/ArduPlane.cpp index a3775e1bbb..0181f392d8 100644 --- a/ArduPlane/ArduPlane.cpp +++ b/ArduPlane/ArduPlane.cpp @@ -514,16 +514,21 @@ void Plane::update_fly_forward(void) // wing aircraft. This helps the EKF produce better state // estimates as it can make stronger assumptions #if HAL_QUADPLANE_ENABLED - if (quadplane.available() && - quadplane.tailsitter.is_in_fw_flight()) { - ahrs.set_fly_forward(true); - return; - } + if (quadplane.available()) { + if (quadplane.tailsitter.is_in_fw_flight()) { + ahrs.set_fly_forward(true); + return; + } - if (quadplane.in_vtol_mode() || - quadplane.in_assisted_flight()) { - ahrs.set_fly_forward(false); - return; + if (quadplane.in_vtol_mode()) { + ahrs.set_fly_forward(false); + return; + } + + if (quadplane.in_assisted_flight()) { + ahrs.set_fly_forward(false); + return; + } } #endif