Skip to content

Commit

Permalink
Copter: support FENCE_OPTIONS on copter
Browse files Browse the repository at this point in the history
  • Loading branch information
andyp1per committed Jul 17, 2024
1 parent 4c6ef82 commit 61f462b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ArduCopter/mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,20 @@ bool Copter::set_mode(Mode::Number mode, ModeReason reason)
return false;
}

#if AP_FENCE_ENABLED
// may not be allowed to change mode if recovering from fence breach
if (!ignore_checks &&
fence.enabled() &&
fence.option_enabled(AC_Fence::OPTIONS::DISABLE_MODE_CHANGE) &&
fence.get_breaches() &&
!flightmode->is_landing() &&
get_control_mode_reason() == ModeReason::FENCE_BREACHED &&
!ap.land_complete) {
mode_change_failed(new_flightmode, "in fence recovery");
return false;
}
#endif

if (!new_flightmode->init(ignore_checks)) {
mode_change_failed(new_flightmode, "init failed");
return false;
Expand Down

0 comments on commit 61f462b

Please sign in to comment.