forked from Archive/PX4-Autopilot
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:
parent
427b2e6636
commit
f8f967f073
|
@ -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
|
||||
|
|
|
@ -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};
|
||||
|
|
Loading…
Reference in New Issue