@@ -52,7 +52,7 @@ void Plane::fence_check()
52
52
53
53
if (plane.previous_mode_reason == ModeReason::FENCE_BREACHED) {
54
54
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 ;
56
56
}
57
57
}
58
58
@@ -73,6 +73,16 @@ void Plane::fence_check()
73
73
// No returning to a previous mode, unless our action allows it
74
74
break ;
75
75
}
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
+ }
76
86
goto fence_check_complete;
77
87
}
78
88
@@ -193,6 +203,11 @@ bool Plane::fence_stickmixing(void) const
193
203
194
204
bool Plane::in_fence_recovery () const
195
205
{
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
+ }
196
211
const bool current_mode_breach = plane.control_mode_reason == ModeReason::FENCE_BREACHED;
197
212
const bool previous_mode_breach = plane.previous_mode_reason == ModeReason::FENCE_BREACHED;
198
213
const bool previous_mode_complete = (plane.control_mode_reason == ModeReason::RTL_COMPLETE_SWITCHING_TO_VTOL_LAND_RTL) ||
0 commit comments