From e0a8b64e084eb3440bd074f77ef290ef5cdec280 Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Sat, 16 Nov 2024 19:33:50 +0000 Subject: [PATCH] Plane: tailsitter: tidy tilt left and right handling --- ArduPlane/tailsitter.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ArduPlane/tailsitter.cpp b/ArduPlane/tailsitter.cpp index 33d111db3d..759fa3d1a4 100644 --- a/ArduPlane/tailsitter.cpp +++ b/ArduPlane/tailsitter.cpp @@ -289,9 +289,6 @@ void Tailsitter::output(void) return; } - float tilt_left = 0.0f; - float tilt_right = 0.0f; - // throttle 0 to 1 float throttle = SRV_Channels::get_output_scaled(SRV_Channel::k_throttle) * 0.01; @@ -341,6 +338,10 @@ void Tailsitter::output(void) // set AP_MotorsMatrix throttles for forward flight motors->output_motor_mask(throttle, motor_mask, plane.rudder_dt); + // No tilt output unless forward gain is set + float tilt_left = 0.0; + float tilt_right = 0.0; + // in forward flight: set motor tilt servos and throttles using FW controller if (vectored_forward_gain > 0) { // remove scaling from surface speed scaling and apply throttle scaling @@ -398,8 +399,11 @@ void Tailsitter::output(void) } // output tilt motors - tilt_left = 0.0f; - tilt_right = 0.0f; + + // No output unless hover gain is set + float tilt_left = 0.0; + float tilt_right = 0.0; + if (vectored_hover_gain > 0) { const float hover_throttle = motors->get_throttle_hover(); const float output_throttle = motors->get_throttle(); @@ -438,8 +442,10 @@ void Tailsitter::output(void) tailsitter_motors->set_min_throttle(0.0); } - tilt_left = 0.0f; - tilt_right = 0.0f; + // No tilt output unless hover gain is set + float tilt_left = 0.0; + float tilt_right = 0.0; + if (vectored_hover_gain > 0) { // thrust vectoring VTOL modes tilt_left = SRV_Channels::get_output_scaled(SRV_Channel::k_tiltMotorLeft);