From 25f51525834f922009b936dc62047d4238e928f3 Mon Sep 17 00:00:00 2001 From: Silvan Fuhrer Date: Tue, 1 Feb 2022 10:05:06 +0100 Subject: [PATCH] Tiltrotor: make sure tilt doesn't exceed the FW tilt angle Signed-off-by: Silvan Fuhrer --- src/modules/vtol_att_control/tiltrotor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/vtol_att_control/tiltrotor.cpp b/src/modules/vtol_att_control/tiltrotor.cpp index 5fd34e9ccb..fd4636c601 100644 --- a/src/modules/vtol_att_control/tiltrotor.cpp +++ b/src/modules/vtol_att_control/tiltrotor.cpp @@ -370,9 +370,9 @@ void Tiltrotor::update_transition_state() } else if (_vtol_schedule.flight_mode == vtol_mode::TRANSITION_FRONT_P2) { // the plane is ready to go into fixed wing mode, tilt the rotors forward completely - _tilt_control = _params_tiltrotor.tilt_transition + - fabsf(_params_tiltrotor.tilt_fw - _params_tiltrotor.tilt_transition) * time_since_trans_start / - _params_tiltrotor.front_trans_dur_p2; + _tilt_control = math::constrain(_params_tiltrotor.tilt_transition + + fabsf(_params_tiltrotor.tilt_fw - _params_tiltrotor.tilt_transition) * time_since_trans_start / + _params_tiltrotor.front_trans_dur_p2, _params_tiltrotor.tilt_transition, _params_tiltrotor.tilt_fw); _mc_roll_weight = 0.0f; _mc_yaw_weight = 0.0f;