Skip to content

Commit

Permalink
Copter: fixed motor runup check for heli
Browse files Browse the repository at this point in the history
for all auto-throttle modes we should not allow a mode change to the
mode if the motor runup is not complete.

This moves the code to the set_mode() so it applies to all modes

fixes issue #6956
  • Loading branch information
tridge committed Sep 20, 2017
1 parent 8cf8f3a commit 22bfec4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
7 changes: 0 additions & 7 deletions ArduCopter/control_althold.cpp
Expand Up @@ -8,13 +8,6 @@
// althold_init - initialise althold controller
bool Copter::althold_init(bool ignore_checks)
{
#if FRAME_CONFIG == HELI_FRAME
// do not allow helis to enter Alt Hold if the Rotor Runup is not complete
if (!ignore_checks && !motors->rotor_runup_complete()){
return false;
}
#endif

// initialize vertical speeds and leash lengths
pos_control->set_speed_z(-g.pilot_velocity_z_max, g.pilot_velocity_z_max);
pos_control->set_accel_z(g.pilot_accel_z);
Expand Down
7 changes: 0 additions & 7 deletions ArduCopter/control_loiter.cpp
Expand Up @@ -7,13 +7,6 @@
// loiter_init - initialise loiter controller
bool Copter::loiter_init(bool ignore_checks)
{
#if FRAME_CONFIG == HELI_FRAME
// do not allow helis to enter Loiter if the Rotor Runup is not complete
if (!ignore_checks && !motors->rotor_runup_complete()){
return false;
}
#endif

if (position_ok() || ignore_checks) {

// set target to current position
Expand Down
7 changes: 0 additions & 7 deletions ArduCopter/control_poshold.cpp
Expand Up @@ -75,13 +75,6 @@ static struct {
// poshold_init - initialise PosHold controller
bool Copter::poshold_init(bool ignore_checks)
{
#if FRAME_CONFIG == HELI_FRAME
// do not allow helis to enter Pos Hold if the Rotor Runup is not complete
if (!ignore_checks && !motors->rotor_runup_complete()){
return false;
}
#endif

// fail to initialise PosHold mode if no GPS lock
if (!position_ok() && !ignore_checks) {
return false;
Expand Down
13 changes: 13 additions & 0 deletions ArduCopter/flight_mode.cpp
Expand Up @@ -24,6 +24,15 @@ bool Copter::set_mode(control_mode_t mode, mode_reason_t reason)
return true;
}


#if FRAME_CONFIG == HELI_FRAME
// do not allow helis to enter a non-manual throttle mode if the
// rotor runup is not complete
if (!ignore_checks && !mode_has_manual_throttle(mode) && !motors->rotor_runup_complete()){
goto failed;
}
#endif

switch (mode) {
case ACRO:
#if FRAME_CONFIG == HELI_FRAME
Expand Down Expand Up @@ -118,6 +127,10 @@ bool Copter::set_mode(control_mode_t mode, mode_reason_t reason)
break;
}

#if FRAME_CONFIG == HELI_FRAME
failed:
#endif

// update flight mode
if (success) {
// perform any cleanup required by previous flight mode
Expand Down

0 comments on commit 22bfec4

Please sign in to comment.