Skip to content

Commit

Permalink
vtol_att_control: move handling of motor state and idle speed selection
Browse files Browse the repository at this point in the history
to VtolType class

Signed-off-by: Roman <[email protected]>
  • Loading branch information
RomanBapst authored and dagar committed Apr 12, 2018
1 parent bfb39b6 commit 48302f7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 39 deletions.
10 changes: 0 additions & 10 deletions src/modules/vtol_att_control/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,6 @@ void Standard::update_mc_state()
{
VtolType::update_mc_state();

// enable MC motors here in case we transitioned directly to MC mode
if (_motor_state != ENABLED) {
_motor_state = set_motor_state(_motor_state, ENABLED);
}

// if the thrust scale param is zero or the drone is on manual mode,
// then the pusher-for-pitch strategy is disabled and we can return
if (_params_standard.forward_thrust_scale < FLT_EPSILON ||
Expand Down Expand Up @@ -394,11 +389,6 @@ void Standard::update_mc_state()
void Standard::update_fw_state()
{
VtolType::update_fw_state();

// stop MC motors in FW mode
if (_motor_state != DISABLED) {
_motor_state = VtolType::set_motor_state(_motor_state, DISABLED);
}
}

/**
Expand Down
9 changes: 0 additions & 9 deletions src/modules/vtol_att_control/tailsitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,20 +257,11 @@ void Tailsitter::waiting_on_tecs()
void Tailsitter::update_mc_state()
{
VtolType::update_mc_state();

// set idle speed for rotary wing mode
if (!flag_idle_mc) {
flag_idle_mc = set_idle_mc();
}
}

void Tailsitter::update_fw_state()
{
VtolType::update_fw_state();

if (flag_idle_mc) {
flag_idle_mc = !set_idle_fw();
}
}

/**
Expand Down
20 changes: 0 additions & 20 deletions src/modules/vtol_att_control/tiltrotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,6 @@ void Tiltrotor::update_mc_state()

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

// enable rear motors
if (_motor_state != ENABLED) {
_motor_state = set_motor_state(_motor_state, ENABLED);
}

// set idle speed for rotary wing mode
if (!flag_idle_mc) {
flag_idle_mc = set_idle_mc();
}
}

void Tiltrotor::update_fw_state()
Expand All @@ -234,16 +224,6 @@ void Tiltrotor::update_fw_state()

// make sure motors are tilted forward
_tilt_control = _params_tiltrotor.tilt_fw;

// disable rear motors
if (_motor_state != DISABLED) {
_motor_state = set_motor_state(_motor_state, DISABLED);
}

// adjust idle for fixed wing flight
if (flag_idle_mc) {
flag_idle_mc = !set_idle_fw();
}
}

void Tiltrotor::update_transition_state()
Expand Down
16 changes: 16 additions & 0 deletions src/modules/vtol_att_control/vtol_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ bool VtolType::init()

void VtolType::update_mc_state()
{
if (!flag_idle_mc) {
flag_idle_mc = set_idle_mc();
}

if (_motor_state != ENABLED) {
_motor_state = VtolType::set_motor_state(_motor_state, ENABLED);
}

// copy virtual attitude setpoint to real attitude setpoint
memcpy(_v_att_sp, _mc_virtual_att_sp, sizeof(vehicle_attitude_setpoint_s));

Expand Down Expand Up @@ -143,6 +151,14 @@ void VtolType::update_mc_state()

void VtolType::update_fw_state()
{
if (flag_idle_mc) {
flag_idle_mc = !set_idle_fw();
}

if (_motor_state != DISABLED) {
_motor_state = VtolType::set_motor_state(_motor_state, DISABLED);
}

// copy virtual attitude setpoint to real attitude setpoint
memcpy(_v_att_sp, _fw_virtual_att_sp, sizeof(vehicle_attitude_setpoint_s));
_mc_roll_weight = 0.0f;
Expand Down

0 comments on commit 48302f7

Please sign in to comment.