From a0634d8b5b20eab2d285a7056663c9ce31eb8320 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 24 Feb 2023 20:38:26 +1100 Subject: [PATCH] Plane: constrain tilt range for vectored yaw this prevents a case where we can demand unlimited vectored yaw, leading to loss of control this was particularly noticible before the fix in #23023 - if you armed for a 2nd time in QHOVER after moving the throttle above 10% so throttle_wait was cleared then the motors would try to tilt fully so one motor is in fwd flight position. This would cause a prop strike while on the ground --- ArduPlane/tiltrotor.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ArduPlane/tiltrotor.cpp b/ArduPlane/tiltrotor.cpp index 6e36d193e3..5591fb3b6d 100644 --- a/ArduPlane/tiltrotor.cpp +++ b/ArduPlane/tiltrotor.cpp @@ -581,7 +581,14 @@ void Tiltrotor::vectoring(void) // we need to use the same factor here to keep the same roll // gains when tilted as we have when not tilted const float avg_roll_factor = 0.5; - const float tilt_offset = (throttle_scaler * yaw_out * cos_tilt + avg_roll_factor * roll_out * sin_tilt) * yaw_range; + float tilt_scale = throttle_scaler * yaw_out * cos_tilt + avg_roll_factor * roll_out * sin_tilt; + + if (fabsf(tilt_scale) > 1.0) { + tilt_scale = constrain_float(tilt_scale, -1.0, 1.0); + motors->limit.yaw = true; + } + + const float tilt_offset = tilt_scale * yaw_range; float left_tilt = base_output + tilt_offset; float right_tilt = base_output - tilt_offset;