Skip to content

Commit

Permalink
VTOL tiltrotor: move compensation in thrust for tilt into seperate fu…
Browse files Browse the repository at this point in the history
…nction

Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
  • Loading branch information
sfuhrer committed Jan 15, 2020
1 parent f016aa5 commit c109985
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
22 changes: 19 additions & 3 deletions src/modules/vtol_att_control/tiltrotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,11 @@ void Tiltrotor::update_mc_state()
{
VtolType::update_mc_state();

// make sure motors are not tilted
_tilt_control = _params_tiltrotor.tilt_mc;

VtolType::pusher_assist();

_tilt_control = _hover_pusher_or_tilt_forward_actuation;

Tiltrotor::thrust_compensation_for_tilt();
}

void Tiltrotor::update_fw_state()
Expand Down Expand Up @@ -391,3 +390,20 @@ void Tiltrotor::fill_actuator_outputs()
_actuators_fw_in->control[actuator_controls_s::INDEX_YAW];
}
}

/*
* Increase combined thrust of MC propellers if motors are tilted. Assumes that all MC motors are tilted equally.
*/

void 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 thrust_new = _v_att_sp->thrust_body[2] / cosf(compensated_tilt * M_PI_2_F);

_v_att_sp->thrust_body[2] = thrust_new;
}
1 change: 1 addition & 0 deletions src/modules/vtol_att_control/tiltrotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Tiltrotor : public VtolType
void update_mc_state() override;
void update_fw_state() override;
void waiting_on_tecs() override;
void thrust_compensation_for_tilt();

private:

Expand Down
6 changes: 0 additions & 6 deletions src/modules/vtol_att_control/vtol_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,6 @@ void VtolType::pusher_assist()
_hover_pusher_or_tilt_forward_actuation = _hover_pusher_or_tilt_forward_actuation > 0.9f ? 0.9f :
_hover_pusher_or_tilt_forward_actuation;

// compensate in combined thrust for tilt (increase thrust with tilt)
if (static_cast<vtol_type>(_params->vtol_type) == vtol_type::TILTROTOR) {
float thrust_new = _v_att_sp->thrust_body[2] / cosf(_hover_pusher_or_tilt_forward_actuation * M_PI_2_F);
_v_att_sp->thrust_body[2] = thrust_new;
}

// return the vehicle to level position
float pitch_new = 0.0f;

Expand Down

0 comments on commit c109985

Please sign in to comment.