Skip to content

Commit

Permalink
Plane: reset previous mode fence breach when disarmed
Browse files Browse the repository at this point in the history
when we are disarmed or we are not in fence breach and we are not
flying then reset the previous mode fence reason state so that a new
flight will get the correct fence breach action behaviour
  • Loading branch information
tridge authored and andyp1per committed Jul 19, 2024
1 parent f676d41 commit fdae0dd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ArduPlane/fence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,23 @@ void Plane::fence_check()
return;
}

const bool armed = arming.is_armed();

/*
if we are either disarmed or we are currently not in breach and
we are not flying then clear the state associated with the
previous mode breach handling. This allows the fence state
machine to reset at the end of a fence breach action such as an
RTL and autoland
*/
if (!armed || (new_breaches == 0 && !plane.is_flying())) {
plane.previous_mode_reason = ModeReason::UNKNOWN;
}

// we still don't do anything when disarmed, but we do check for fence breaches.
// fence pre-arm check actually checks if any fence has been breached
// that's not ever going to be true if we don't call check on AP_Fence while disarmed
if (!arming.is_armed()) {
if (!armed) {
return;
}

Expand Down

0 comments on commit fdae0dd

Please sign in to comment.