Skip to content

Commit 2a5e9d9

Browse files
tridgepeterbarker
authored andcommitted
Plane: on wp set or fence disable re-arm fence
allows for continue mission after fence breach with pilot command to change WP
1 parent f168d2f commit 2a5e9d9

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ArduPlane/fence.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void Plane::fence_check()
5252

5353
if (plane.previous_mode_reason == ModeReason::FENCE_BREACHED) {
5454
if (!armed || ((fence_breaches.new_breaches == 0 && orig_breaches == 0) && !plane.is_flying())) {
55-
plane.previous_mode_reason = ModeReason::UNKNOWN;
55+
plane.previous_mode_reason = ModeReason::FENCE_REENABLE;
5656
}
5757
}
5858

@@ -73,6 +73,16 @@ void Plane::fence_check()
7373
// No returning to a previous mode, unless our action allows it
7474
break;
7575
}
76+
/*
77+
clear mode reasons if they are FENCE_BREACHED to allow AUX
78+
switch fence disable/enable to re-enable the fence after a breach
79+
*/
80+
if (plane.previous_mode_reason == ModeReason::FENCE_BREACHED) {
81+
plane.previous_mode_reason = ModeReason::FENCE_REENABLE;
82+
}
83+
if (plane.control_mode_reason == ModeReason::FENCE_BREACHED) {
84+
plane.control_mode_reason = ModeReason::FENCE_REENABLE;
85+
}
7686
goto fence_check_complete;
7787
}
7888

@@ -193,6 +203,11 @@ bool Plane::fence_stickmixing(void) const
193203

194204
bool Plane::in_fence_recovery() const
195205
{
206+
if (control_mode == &mode_auto && !mission.get_in_landing_sequence_flag()) {
207+
// the user may have changed target WP to be outside the
208+
// landing sequence
209+
return false;
210+
}
196211
const bool current_mode_breach = plane.control_mode_reason == ModeReason::FENCE_BREACHED;
197212
const bool previous_mode_breach = plane.previous_mode_reason == ModeReason::FENCE_BREACHED;
198213
const bool previous_mode_complete = (plane.control_mode_reason == ModeReason::RTL_COMPLETE_SWITCHING_TO_VTOL_LAND_RTL) ||

0 commit comments

Comments
 (0)