VTOL type and tiltrotor: use math::constrain() for constraining

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
Silvan Fuhrer
2020-02-07 16:43:44 +01:00
committed by Beat Küng
parent e3310796ce
commit 4c9dba8692
2 changed files with 2 additions and 5 deletions
+1 -3
View File
@@ -397,9 +397,7 @@ float Tiltrotor::thrust_compensation_for_tilt()
{
// only compensate for tilt angle up to 0.5 * max tilt
float compensated_tilt = _tilt_control;
compensated_tilt = compensated_tilt < 0.0f ? 0.0f : compensated_tilt;
compensated_tilt = compensated_tilt > 0.5f ? 0.5f : compensated_tilt;
float compensated_tilt = math::constrain(_tilt_control, 0.0f, 0.5f);
// increase vertical thrust by 1/cos(tilt), limmit to [0,1]
return math::constrain(_v_att_sp->thrust_body[2] / cosf(compensated_tilt * M_PI_2_F), 0.0f, 1.0f);