Copter: Handle always land mode

This commit is contained in:
Raouf 2018-07-24 13:41:27 +09:00 committed by Randy Mackay
parent e55369b1c8
commit f78ffefd66
1 changed files with 8 additions and 4 deletions

View File

@ -30,13 +30,17 @@ void Copter::fence_check()
// don't disarm if the high-altitude fence has been broken because it's likely the user has pulled their throttle to zero to bring it down
if (ap.land_complete || (flightmode->has_manual_throttle() && ap.throttle_zero && !failsafe.radio && ((fence.get_breaches() & AC_FENCE_TYPE_ALT_MAX)== 0))){
init_disarm_motors();
}else{
// if we are within 100m of the fence, RTL
if (fence.get_breach_distance(new_breaches) <= AC_FENCE_GIVE_UP_DISTANCE) {
} else {
// if always land option mode is specified, land
if (fence.get_action() == AC_FENCE_ACTION_ALWAYS_LAND) {
set_mode(LAND, MODE_REASON_FENCE_BREACH);
} else if (fence.get_breach_distance(new_breaches) <= AC_FENCE_GIVE_UP_DISTANCE) {
if (!set_mode(RTL, MODE_REASON_FENCE_BREACH)) {
set_mode(LAND, MODE_REASON_FENCE_BREACH);
// if we are within 100m of the fence, RTL
}
}else{
} else {
// if more than 100m outside the fence just force a land
set_mode(LAND, MODE_REASON_FENCE_BREACH);
}