Geofence - Change from "re-engage geofence failsafe every 10s when

outside the fence" to "engage geofence failsafe on transition". This
way, the pilot is not stucked in the non flight zone and can switch to
a manual mode and fly back or trigger RTL.
This commit is contained in:
bresch 2019-05-23 15:39:15 +02:00 committed by Julian Oes
parent 427b2e6636
commit f8f967f073
2 changed files with 34 additions and 38 deletions

View File

@ -1838,13 +1838,8 @@ Commander::run()
&& (geofence_result.geofence_action != geofence_result_s::GF_ACTION_NONE)
&& (_battery_warning < battery_status_s::BATTERY_WARNING_CRITICAL)) {
// check for geofence violation
if (geofence_result.geofence_violated) {
const hrt_abstime geofence_violation_action_interval = 10_s;
if (hrt_elapsed_time(&_last_geofence_violation) > geofence_violation_action_interval) {
_last_geofence_violation = hrt_absolute_time();
// check for geofence violation transition
if (geofence_result.geofence_violated && !_geofence_violated_prev) {
switch (geofence_result.geofence_action) {
case (geofence_result_s::GF_ACTION_NONE) : {
@ -1884,7 +1879,8 @@ Commander::run()
}
}
}
}
_geofence_violated_prev = geofence_result.geofence_violated;
// reset if no longer in LOITER or if manually switched to LOITER
_geofence_loiter_on = _geofence_loiter_on
@ -1905,7 +1901,7 @@ Commander::run()
_geofence_loiter_on = false;
_geofence_rtl_on = false;
_warning_action_on = false;
_last_geofence_violation = 0;
_geofence_violated_prev = false;
}
// revert geofence failsafe transition if sticks are moved and we were previously in a manual mode

View File

@ -167,7 +167,7 @@ private:
bool _geofence_loiter_on{false};
bool _geofence_rtl_on{false};
bool _warning_action_on{false};
hrt_abstime _last_geofence_violation{0};
bool _geofence_violated_prev{false};
FailureDetector _failure_detector;
bool _failure_detector_termination_printed{false};