diff --git a/docs/en/config/safety.md b/docs/en/config/safety.md
index e042845851f..2d666e111bc 100644
--- a/docs/en/config/safety.md
+++ b/docs/en/config/safety.md
@@ -207,7 +207,7 @@ In its simplest form, the perimeter is set up as a cylinder centered around the
If the vehicle moves outside the radius or above the altitude the specified _Failsafe Action_ will trigger.
Note that the failsafe action will only trigger once the vehicle has already breached the geofence.
-If a boundary must not be crossed, for safety or legal reasons, configure a [Pre-Geofence](#pre-geofence).
+If a horizontal boundary must not be crossed, for safety or legal reasons, configure a [Pre-Geofence](#pre-geofence).
It triggers its own action, for example `Hold`, before the vehicle reaches the geofence.

@@ -240,7 +240,7 @@ The following settings also apply, but are not displayed in the QGC UI.
-A pre-geofence is a second set of limits inside the geofence, with its own failsafe action.
+A pre-geofence is a second boundary at a horizontal margin inside the geofence, with its own failsafe action.
The vehicle reaches it first, so it can for example hold at the pre-geofence, and only terminate if it still crosses the geofence.
Use it where the geofence must not be crossed, or where the geofence action has to be severe.
@@ -248,43 +248,43 @@ For example, under the [SORA](http://jarus-rpas.org/wp-content/uploads/2024/06/S
#### Pre-Geofence Setup
-Each geofence limit has a pre-geofence twin.
-A limit that is set to 0 is disabled, and the pre-geofence is off while all of them are disabled (the default).
+The pre-geofence is off while the margin is 0 (the default).
-| Setting | Parameter | Description |
-| ------------------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
-| Pre-geofence action | [GF_PRE_ACTION](../advanced_config/parameter_reference.md#GF_PRE_ACTION) | Warning, Hold mode (default), Return mode, or Land mode. |
-| Pre-geofence max radius | [GF_PRE_MAX_HDIST](../advanced_config/parameter_reference.md#GF_PRE_MAX_HDIST) | Horizontal distance from Home. Set it below `GF_MAX_HOR_DIST`. Disabled if 0. |
-| Pre-geofence max altitude | [GF_PRE_MAX_VDIST](../advanced_config/parameter_reference.md#GF_PRE_MAX_VDIST) | Altitude above Home. Set it below `GF_MAX_VER_DIST`. Disabled if 0. |
-| Pre-geofence margin | [GF_PRE_MARGIN](../advanced_config/parameter_reference.md#GF_PRE_MARGIN) | Distance from the polygons and circles of the Geofence Plan. Disabled if 0. |
+| Setting | Parameter | Description |
+| ------------------- | ------------------------------------------------------------------------ | -------------------------------------------------------- |
+| Pre-geofence action | [GF_PRE_ACTION](../advanced_config/parameter_reference.md#GF_PRE_ACTION) | Warning, Hold mode (default), Return mode, or Land mode. |
+| Pre-geofence margin | [GF_PRE_MARGIN](../advanced_config/parameter_reference.md#GF_PRE_MARGIN) | Horizontal distance from the geofence. Disabled if 0. |
+
+The margin applies to the maximum distance from Home ([GF_MAX_HOR_DIST](../advanced_config/parameter_reference.md#GF_MAX_HOR_DIST)) and to every inclusion and exclusion area of the [Geofence Plan](../flying/geofence.md#geofence-plan): the vehicle breaches the pre-geofence once it comes closer to one of them than `GF_PRE_MARGIN`.
+It is a single distance, so there is only one fence to draw and upload.
+The maximum altitude ([GF_MAX_VER_DIST](../advanced_config/parameter_reference.md#GF_MAX_VER_DIST)) has no pre-geofence.
-The margin applies to every inclusion and exclusion area of the [Geofence Plan](../flying/geofence.md#geofence-plan): the vehicle breaches the pre-geofence once it comes closer to one of them than `GF_PRE_MARGIN`.
-It is a single distance for the whole plan, so there is only one fence to draw and upload.
`GF_PRE_MARGIN` is only available on flight controllers that [check the mission flight path](#mission-feasibility-checks) against the geofence (not on `px4_fmu-v2`, for example).
+The others have no pre-geofence.

-Leave enough room between the pre-geofence and the geofence for the vehicle to stop or turn around.
-The gap should be at least:
+The margin has to leave the vehicle enough room to stop or turn around before the geofence.
+It should be at least:
- Fixed-wing: The loiter radius ([NAV_LOITER_RAD](../advanced_config/parameter_reference.md#NAV_LOITER_RAD)).
- Multicopter: The nominal stopping distance (`v^2 / 2a` with `v`=[MPC_XY_VEL_MAX](../advanced_config/parameter_reference.md#MPC_XY_VEL_MAX) and `a`=[MPC_ACC_HOR](../advanced_config/parameter_reference.md#MPC_ACC_HOR)).
Allow additional distance for the acceleration ramp ([MPC_JERK_AUTO](../advanced_config/parameter_reference.md#MPC_JERK_AUTO)).
-Use a gap above these nominal values to account for possible tailwind, position uncertainty, attitude tracking delay, etc.
+Use a margin above these nominal values to account for possible tailwind, position uncertainty, attitude tracking delay, etc.
::: info
PX4 does not check the setup:
-- A pre-geofence limit outside its geofence twin never comes first.
- The pre-geofence action should be the milder of the two.
- It has no `None`, because the pre-geofence is disabled through its limits, and no `Terminate`, which is left to the geofence.
-- Keep the Return altitude ([RTL_RETURN_ALT](../advanced_config/parameter_reference.md#RTL_RETURN_ALT)) below `GF_PRE_MAX_VDIST`.
- It is measured from the destination and the limit from Home, so allow for a rally point or landing that is higher than Home.
+ It has no `None`, because the pre-geofence is disabled through its margin, and no `Terminate`, which is left to the geofence.
+- If the margin leaves no room inside `GF_MAX_HOR_DIST` or inside an inclusion area, the pre-geofence is breached everywhere.
- As for the geofence limits, a mission that is already uploaded is not checked again when these parameters change, also not while it is being flown.
It is checked again when Mission mode is activated, or when the mission or the Geofence Plan is uploaded.
- A geofence plan is not rejected because of the pre-geofence, for example when Home or the vehicle lies within the margin.
If the vehicle is already outside the pre-geofence when the plan is uploaded or a parameter changes, the action is triggered at once.
+- Rally points are not checked against the pre-geofence.
+ Keep them inside it: a vehicle that returns to a rally point within the margin triggers the pre-geofence action on the way there.
:::
@@ -303,11 +303,10 @@ When the vehicle breaches the pre-geofence:
PX4 also keeps planned flight inside the pre-geofence:
-- A mission is rejected if one of its positions is outside the pre-geofence.
- It is also rejected if a leg between positions or a fixed-wing loiter circle comes closer to the plan than the margin.
+- A mission is rejected if one of its positions, a leg between positions or a fixed-wing loiter circle comes closer to the geofence than the margin.
- The target of a _Go to location_ ([reposition](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_REPOSITION)) or of an altitude change, and the centre of a fixed-wing orbit or figure-eight, is refused if it lies outside the pre-geofence (unless the action is `Warning`).
As for the geofence, only the target is checked, not the path to it or the loiter circle around it.
- An altitude change keeps the vehicle's position, so it is refused while the vehicle is horizontally outside the pre-geofence: send the vehicle back inside first.
+ An altitude change keeps the vehicle's position, so it is refused while the vehicle is outside the pre-geofence: send the vehicle back inside first.
- [Return mode](../flight_modes/return.md#geofence_awareness) plans its route around the Geofence Plan with the margin added.
## Position Estimation Failsafes
diff --git a/docs/en/flight_modes/return.md b/docs/en/flight_modes/return.md
index 0c458fee51c..31b84d2c4e1 100644
--- a/docs/en/flight_modes/return.md
+++ b/docs/en/flight_modes/return.md
@@ -291,9 +291,6 @@ The exception is when executing a [mission path return](#rtl_type_2) from _withi
In this case the vehicle follows mission waypoints, which we assume are planned to avoid any obstacles.
:::
-Keep the return altitude below the [geofence](../config/safety.md#geofence-failsafe) and [pre-geofence](../config/safety.md#pre-geofence) altitude limits ([GF_MAX_VER_DIST](../advanced_config/parameter_reference.md#GF_MAX_VER_DIST), [GF_PRE_MAX_VDIST](../advanced_config/parameter_reference.md#GF_PRE_MAX_VDIST)): a vehicle that climbs to it otherwise breaches them.
-The limits are measured from Home and the return altitude from the destination, which can be higher than Home.
-
The return altitude for a fixed-wing vehicle or a VTOL in fixed-wing mode is configured using the parameter [RTL_RETURN_ALT](#RTL_RETURN_ALT) (does not use the code described in the next paragraph).
The return altitude for a multicopter (or VTOL vehicle in MC mode) is configured using the parameters [RTL_RETURN_ALT](#RTL_RETURN_ALT), [RTL_CONE_ANG](#RTL_CONE_ANG), and [RTL_MIN_DIST](#RTL_MIN_DIST), which together define a half cone centered around the destination (home location or safety point).
diff --git a/docs/en/releases/main.md b/docs/en/releases/main.md
index a51886d6076..e817ae4eb50 100644
--- a/docs/en/releases/main.md
+++ b/docs/en/releases/main.md
@@ -145,9 +145,9 @@ Please continue reading for [upgrade instructions](#upgrade-guide).
### Safety
- [Geofence Aware Return mode](../flight_modes/return.md#geofence_awareness). ([PX4-Autopilot#27145: feat(navigator): Geofence Aware RTL](https://github.com/PX4/PX4-Autopilot/pull/27145), [PX4-Autopilot#28001: docs(navigator): [geofence] added some more warnings about limitations](https://github.com/PX4/PX4-Autopilot/pull/28001)).
-- [Pre-geofence](../config/safety.md#pre-geofence): a second set of limits inside the geofence, with its own action ([GF_PRE_ACTION](../advanced_config/parameter_reference.md#GF_PRE_ACTION)).
+- [Pre-geofence](../config/safety.md#pre-geofence): a second boundary at a horizontal margin inside the geofence ([GF_PRE_MARGIN](../advanced_config/parameter_reference.md#GF_PRE_MARGIN)), with its own action ([GF_PRE_ACTION](../advanced_config/parameter_reference.md#GF_PRE_ACTION)).
A vehicle can for example hold at the pre-geofence, and only terminate if it still crosses the geofence.
- It is set with a maximum distance and altitude from Home ([GF_PRE_MAX_HDIST](../advanced_config/parameter_reference.md#GF_PRE_MAX_HDIST), [GF_PRE_MAX_VDIST](../advanced_config/parameter_reference.md#GF_PRE_MAX_VDIST)) and with a margin to the Geofence Plan ([GF_PRE_MARGIN](../advanced_config/parameter_reference.md#GF_PRE_MARGIN)).
+ The margin applies to the maximum distance from Home and to the Geofence Plan.
Outside the pre-geofence arming is denied, missions are rejected, and _Go to location_ targets are refused unless its action is Warning.
Return mode plans its route with the margin added.
- [Flight termination](../advanced_config/flight_termination.md) can now be used instead of a Descent mode as a fallback failsafe mode, allowing safer landing for unpiloted vehicles that carry a parachute.
diff --git a/msg/GeofenceResult.msg b/msg/GeofenceResult.msg
index e6146ca1fc6..14460376570 100644
--- a/msg/GeofenceResult.msg
+++ b/msg/GeofenceResult.msg
@@ -10,7 +10,6 @@ bool geofence_max_dist_triggered # true the check for max distance from Home is
bool geofence_max_alt_triggered # true the check for max altitude above Home is triggered
bool geofence_custom_fence_triggered # true the check for custom inclusion/exclusion geofence(s) is triggered
bool pre_geofence_max_dist_triggered # true if the pre-geofence check for max distance from Home is triggered
-bool pre_geofence_max_alt_triggered # true if the pre-geofence check for max altitude above Home is triggered
bool pre_geofence_custom_fence_triggered # true if the pre-geofence check for custom inclusion/exclusion geofence(s) is triggered
uint8 geofence_action # action to take when the geofence is breached
diff --git a/src/modules/commander/HealthAndArmingChecks/checks/geofenceCheck.cpp b/src/modules/commander/HealthAndArmingChecks/checks/geofenceCheck.cpp
index 86564f70832..1387638b67a 100644
--- a/src/modules/commander/HealthAndArmingChecks/checks/geofenceCheck.cpp
+++ b/src/modules/commander/HealthAndArmingChecks/checks/geofenceCheck.cpp
@@ -48,7 +48,6 @@ void GeofenceChecks::checkAndReport(const Context &context, Report &reporter)
reporter.failsafeFlags().gf_breached = geofence_result.geofence_action != geofence_result_s::GF_ACTION_NONE && any_geofence_triggered;
const bool any_pre_geofence_triggered = geofence_result.pre_geofence_max_dist_triggered ||
- geofence_result.pre_geofence_max_alt_triggered ||
geofence_result.pre_geofence_custom_fence_triggered;
reporter.failsafeFlags().pre_gf_breached = geofence_result.pre_geofence_action != geofence_result_s::GF_ACTION_NONE
@@ -111,31 +110,15 @@ void GeofenceChecks::checkAndReport(const Context &context, Report &reporter)
/* EVENT
* @description
*
- * This check can be configured via GF_PRE_ACTION and GF_PRE_MAX_HDIST parameters.
+ * This check can be configured via GF_PRE_ACTION, GF_MAX_HOR_DIST and GF_PRE_MARGIN parameters.
*
*/
reporter.armingCheckFailure(NavModes::All, health_component_t::system,
events::ID("check_pre_gf_breach_max_hor_dist"),
- events::Log::Error, "Pre-geofence breach: exceeding maximum distance to Home");
+ events::Log::Error, "Pre-geofence breach: approaching the maximum distance to Home");
if (reporter.mavlink_log_pub()) {
- mavlink_log_critical(reporter.mavlink_log_pub(), "Pre-geofence: exceeding maximum distance to Home\t");
- }
- }
-
- if (geofence_result.pre_geofence_max_alt_triggered) {
- /* EVENT
- * @description
- *
- * This check can be configured via GF_PRE_ACTION and GF_PRE_MAX_VDIST parameters.
- *
- */
- reporter.armingCheckFailure(NavModes::All, health_component_t::system,
- events::ID("check_pre_gf_breach_max_alt"),
- events::Log::Error, "Pre-geofence breach: exceeding maximum altitude above Home");
-
- if (reporter.mavlink_log_pub()) {
- mavlink_log_critical(reporter.mavlink_log_pub(), "Pre-geofence: exceeding maximum altitude above Home\t");
+ mavlink_log_critical(reporter.mavlink_log_pub(), "Pre-geofence: approaching the maximum distance to Home\t");
}
}
diff --git a/src/modules/commander/HealthAndArmingChecks/geofenceCheckTest.cpp b/src/modules/commander/HealthAndArmingChecks/geofenceCheckTest.cpp
index 92fb96ff9d0..f80f4b9e22b 100644
--- a/src/modules/commander/HealthAndArmingChecks/geofenceCheckTest.cpp
+++ b/src/modules/commander/HealthAndArmingChecks/geofenceCheckTest.cpp
@@ -83,7 +83,6 @@ TEST_F(GeofenceChecksTest, PreGeofenceSetsItsOwnFlagAndDeniesArming)
{
bool geofence_result_s::*const triggers[] = {
&geofence_result_s::pre_geofence_max_dist_triggered,
- &geofence_result_s::pre_geofence_max_alt_triggered,
&geofence_result_s::pre_geofence_custom_fence_triggered,
};
@@ -125,7 +124,7 @@ TEST_F(GeofenceChecksTest, GeofenceAndPreGeofenceSetIndependentFlags)
EXPECT_FALSE(_failsafe_flags.pre_gf_breached);
EXPECT_FALSE(_can_arm_all_modes);
- result.pre_geofence_max_alt_triggered = true;
+ result.pre_geofence_custom_fence_triggered = true;
runCheck(result);
EXPECT_TRUE(_failsafe_flags.gf_breached);
EXPECT_TRUE(_failsafe_flags.pre_gf_breached);
diff --git a/src/modules/navigator/geofence.cpp b/src/modules/navigator/geofence.cpp
index fba0eec21dc..54465834dc6 100644
--- a/src/modules/navigator/geofence.cpp
+++ b/src/modules/navigator/geofence.cpp
@@ -705,18 +705,7 @@ bool Geofence::checkPathBatch(const PathCheck *paths, size_t num_paths, bool *re
bool Geofence::checkPaths(const PathCheck *paths, size_t num_paths, bool *results)
{
bool pieces_calculated = false;
- // A circle has to fit inside the tightest enabled Home distance limit.
- float max_home_distance = _param_gf_max_hor_dist.get();
- const float pre_max_home_distance = _param_gf_pre_max_hdist.get();
-
- if (pre_max_home_distance > FLT_EPSILON && (max_home_distance <= FLT_EPSILON || pre_max_home_distance < max_home_distance)) {
- max_home_distance = pre_max_home_distance;
- }
-
- if (!_navigator->home_global_position_valid()) {
- max_home_distance = 0.f;
- }
-
+ const float max_home_distance = _navigator->home_global_position_valid() ? _param_gf_max_hor_dist.get() : 0.f;
const home_position_s &home = *_navigator->get_home_position();
for (size_t i = 0; i < num_paths; ++i) {
@@ -730,9 +719,10 @@ bool Geofence::checkPaths(const PathCheck *paths, size_t num_paths, bool *result
return false;
}
- // The caller checks path ends against Home; a circle must keep its whole radius inside.
+ // The caller checks path ends against Home; a circle must keep its whole radius inside, and GF_PRE_MARGIN.
results[i] = paths[i].end_radius <= 0.f || max_home_distance <= FLT_EPSILON
- || get_distance_to_next_waypoint(home.lat, home.lon, end(0), end(1)) + paths[i].end_radius < max_home_distance;
+ || get_distance_to_next_waypoint(home.lat, home.lon, end(0), end(1)) + paths[i].end_radius
+ < max_home_distance - getPreGeofenceMargin();
}
for (int p = 0; p < _num_polygons; ++p) {
@@ -876,47 +866,32 @@ bool Geofence::checkCirclePaths(const PolygonInfo &polygon, const PathCheck *pat
return true;
}
-bool Geofence::isCloserThanMaxDistToHome(double lat, double lon, float altitude)
-{
- return isWithinHomeDistance(_param_gf_max_hor_dist.get(), lat, lon);
-}
-
-bool Geofence::isCloserThanPreMaxDistToHome(double lat, double lon)
-{
- return isWithinHomeDistance(_param_gf_pre_max_hdist.get(), lat, lon);
-}
-
-bool Geofence::isWithinHomeDistance(float max_distance, double lat, double lon)
+bool Geofence::isCloserThanMaxDistToHome(double lat, double lon, float altitude, float margin)
{
bool inside_fence = true;
- if (max_distance > FLT_EPSILON && _navigator->home_global_position_valid()) {
+ if (_param_gf_max_hor_dist.get() > FLT_EPSILON && _navigator->home_global_position_valid()) {
- const home_position_s &home = *_navigator->get_home_position();
- inside_fence = get_distance_to_next_waypoint(lat, lon, home.lat, home.lon) < max_distance;
+ float dist_xy = -1.0f;
+ float dist_z = -1.0f;
+
+ get_distance_to_point_global_wgs84(lat, lon, altitude, _navigator->get_home_position()->lat,
+ _navigator->get_home_position()->lon, _navigator->get_home_position()->alt, &dist_xy, &dist_z);
+
+ inside_fence = dist_xy < _param_gf_max_hor_dist.get() - margin;
}
return inside_fence;
}
bool Geofence::isBelowMaxAltitude(float altitude)
-{
- return isBelowHomeAltitude(_param_gf_max_ver_dist.get(), altitude);
-}
-
-bool Geofence::isBelowPreMaxAltitude(float altitude)
-{
- return isBelowHomeAltitude(_param_gf_pre_max_vdist.get(), altitude);
-}
-
-bool Geofence::isBelowHomeAltitude(float max_altitude, float altitude)
{
bool inside_fence = true;
- if (max_altitude > FLT_EPSILON && _navigator->home_alt_valid()) {
+ if (_param_gf_max_ver_dist.get() > FLT_EPSILON && _navigator->home_alt_valid()) {
const float dist_z = altitude - _navigator->get_home_position()->alt;
- inside_fence = dist_z < max_altitude;
+ inside_fence = dist_z < _param_gf_max_ver_dist.get();
}
return inside_fence;
@@ -924,8 +899,7 @@ bool Geofence::isBelowHomeAltitude(float max_altitude, float altitude)
uint8_t Geofence::getPreGeofenceAction() const
{
- if (_param_gf_pre_max_hdist.get() <= FLT_EPSILON && _param_gf_pre_max_vdist.get() <= FLT_EPSILON
- && getPreGeofenceMargin() <= FLT_EPSILON) {
+ if (getPreGeofenceMargin() <= FLT_EPSILON) {
return geofence_result_s::GF_ACTION_NONE;
}
@@ -1295,10 +1269,8 @@ error:
bool Geofence::isHomeRequired()
{
- bool max_horizontal_enabled = (_param_gf_max_hor_dist.get() > FLT_EPSILON)
- || (_param_gf_pre_max_hdist.get() > FLT_EPSILON);
- bool max_vertical_enabled = (_param_gf_max_ver_dist.get() > FLT_EPSILON)
- || (_param_gf_pre_max_vdist.get() > FLT_EPSILON);
+ bool max_horizontal_enabled = (_param_gf_max_hor_dist.get() > FLT_EPSILON);
+ bool max_vertical_enabled = (_param_gf_max_ver_dist.get() > FLT_EPSILON);
bool geofence_action_rtl = (getGeofenceAction() == geofence_result_s::GF_ACTION_RTL)
|| (getPreGeofenceAction() == geofence_result_s::GF_ACTION_RTL);
diff --git a/src/modules/navigator/geofence.h b/src/modules/navigator/geofence.h
index c3fa29fcb31..7a0234e87f0 100644
--- a/src/modules/navigator/geofence.h
+++ b/src/modules/navigator/geofence.h
@@ -109,7 +109,7 @@ public:
/**
* Check 1..MAX_PATH_CHECKS paths and optional circles at their ends against horizontal fences.
- * Circles are also checked against the maximum distance from Home.
+ * Circles are also checked against the maximum distance from Home, less GF_PRE_MARGIN.
* A path's margin makes coming closer than it to a polygon or circle boundary a breach too.
* Boundary contact is a breach, including contact by a circle. Callers choose the circles;
* a fixed-wing waypoint turned into a loiter to reach its altitude cannot be predicted here.
@@ -136,9 +136,10 @@ public:
/**
* @brief check if the horizontal distance to Home is greater than the maximum allowed distance
*
+ * @param margin distance in metres to keep from the maximum allowed distance
* @return true if the horizontal distance to Home is smaller than the maximum allowed distance
*/
- bool isCloserThanMaxDistToHome(double lat, double lon, float altitude);
+ bool isCloserThanMaxDistToHome(double lat, double lon, float altitude, float margin = 0.f);
/**
@@ -148,11 +149,12 @@ public:
*/
bool isBelowMaxAltitude(float altitude);
- /** Pre-geofence twin of isCloserThanMaxDistToHome(), with GF_PRE_MAX_HDIST. */
- bool isCloserThanPreMaxDistToHome(double lat, double lon);
-
- /** Pre-geofence twin of isBelowMaxAltitude(), with GF_PRE_MAX_VDIST. */
- bool isBelowPreMaxAltitude(float altitude);
+ /** True if the position keeps GF_PRE_MARGIN from the maximum distance to Home, or one of the two is disabled. */
+ bool isCloserThanPreMaxDistToHome(double lat, double lon)
+ {
+ const float margin = getPreGeofenceMargin();
+ return margin <= FLT_EPSILON || isCloserThanMaxDistToHome(lat, lon, 0.f, margin);
+ }
/** Check the altitude band from a loaded fence file, if configured. */
bool isWithinAltitudeBand(float altitude);
@@ -173,8 +175,9 @@ public:
bool isCircleInside(double lat, double lon, float radius);
/**
- * GF_PRE_MARGIN [m], the distance the pre-geofence keeps from the polygons and circles. Zero if disabled.
- * The margin is checked with the path checks, so boards built without them have no such parameter.
+ * GF_PRE_MARGIN [m], the horizontal distance the pre-geofence keeps from the geofence: from the maximum
+ * distance to Home and from the polygons and circles. Zero if disabled, which disables the pre-geofence.
+ * The polygons and circles need the path checks, so boards built without them have no such parameter.
*/
float getPreGeofenceMargin() const
{
@@ -346,10 +349,6 @@ private:
bool insideCircle(const PolygonInfo &polygon, double lat, double lon, float altitude);
bool checkPaths(const PathCheck *paths, size_t num_paths, bool *results);
-
- /** Limits relative to Home; a limit of zero is disabled. */
- bool isWithinHomeDistance(float max_distance, double lat, double lon);
- bool isBelowHomeAltitude(float max_altitude, float altitude);
bool _readFencePoint(unsigned index, mission_fence_point_s &point);
bool _fencePointValid(const mission_fence_point_s &point) const;
bool checkPolygonPaths(const PolygonInfo &polygon, const PathCheck *paths, const uint8_t *pieces, size_t num_paths,
@@ -386,11 +385,9 @@ private:
(ParamInt) _param_gf_source,
(ParamFloat) _param_gf_max_hor_dist,
(ParamFloat) _param_gf_max_ver_dist,
- (ParamInt) _param_gf_pre_action,
- (ParamFloat) _param_gf_pre_max_hdist,
#if defined(CONFIG_NAVIGATOR_GEOFENCE_PATH_CHECKS)
(ParamFloat) _param_gf_pre_margin,
#endif // CONFIG_NAVIGATOR_GEOFENCE_PATH_CHECKS
- (ParamFloat) _param_gf_pre_max_vdist
+ (ParamInt) _param_gf_pre_action
)
};
diff --git a/src/modules/navigator/geofence_params.yaml b/src/modules/navigator/geofence_params.yaml
index 139efb5520c..08286fb1ca7 100644
--- a/src/modules/navigator/geofence_params.yaml
+++ b/src/modules/navigator/geofence_params.yaml
@@ -66,23 +66,3 @@ parameters:
default: 2
min: 1
max: 5
- GF_PRE_MAX_HDIST:
- description:
- short: Pre-geofence max horizontal distance from Home
- long: Triggers GF_PRE_ACTION beyond this distance. Set it below GF_MAX_HOR_DIST. Disabled if 0.
- type: float
- default: 0.0
- unit: m
- min: 0
- max: 10000
- increment: 1
- GF_PRE_MAX_VDIST:
- description:
- short: Pre-geofence max vertical distance from Home
- long: Triggers GF_PRE_ACTION above this height over Home. Set it below GF_MAX_VER_DIST. Disabled if 0.
- type: float
- default: 0.0
- unit: m
- min: 0
- max: 10000
- increment: 1
diff --git a/src/modules/navigator/geofence_pre_margin_params.yaml b/src/modules/navigator/geofence_pre_margin_params.yaml
index 4725168fa84..2b6c5f9746a 100644
--- a/src/modules/navigator/geofence_pre_margin_params.yaml
+++ b/src/modules/navigator/geofence_pre_margin_params.yaml
@@ -4,9 +4,9 @@ parameters:
definitions:
GF_PRE_MARGIN:
description:
- short: Pre-geofence margin to the geofence plan
- long: Triggers GF_PRE_ACTION within this distance of a polygon or circle of the geofence plan.
- Disabled if 0.
+ short: Pre-geofence horizontal margin to the geofence
+ long: Triggers GF_PRE_ACTION within this distance of GF_MAX_HOR_DIST, or of a polygon or circle
+ of the geofence plan. Disabled if 0.
type: float
default: 0.0
unit: m
diff --git a/src/modules/navigator/mission_feasibility_checker.cpp b/src/modules/navigator/mission_feasibility_checker.cpp
index 1d5e5043a94..d58dc2c653d 100644
--- a/src/modules/navigator/mission_feasibility_checker.cpp
+++ b/src/modules/navigator/mission_feasibility_checker.cpp
@@ -218,10 +218,9 @@ MissionFeasibilityChecker::checkMissionAgainstGeofence(const mission_s &mission,
missionitem.altitude);
#endif // CONFIG_NAVIGATOR_GEOFENCE_PATH_CHECKS
- // On every board, as for the geofence in both branches above: the pre-geofence limits from Home are
- // checked at every position. Its margin to the plan is checked with the paths, see addGeofencePath().
- point_valid = point_valid && geofence.isCloserThanPreMaxDistToHome(missionitem.lat, missionitem.lon)
- && geofence.isBelowPreMaxAltitude(missionitem.altitude);
+ // As for the geofence in both branches above, the pre-geofence distance to Home is checked at every
+ // position. Its margin to the plan is checked with the paths, see addGeofencePath().
+ point_valid = point_valid && geofence.isCloserThanPreMaxDistToHome(missionitem.lat, missionitem.lon);
if (!point_valid) {
failure = Failure::Waypoint;
diff --git a/src/modules/navigator/navigator_main.cpp b/src/modules/navigator/navigator_main.cpp
index c3d241222bd..05b85762929 100644
--- a/src/modules/navigator/navigator_main.cpp
+++ b/src/modules/navigator/navigator_main.cpp
@@ -1299,7 +1299,6 @@ void Navigator::geofence_breach_check()
current_longitude, current_altitude);
_geofence_result.pre_geofence_max_dist_triggered |= !_geofence.isCloserThanPreMaxDistToHome(current_latitude,
current_longitude);
- _geofence_result.pre_geofence_max_alt_triggered |= !_geofence.isBelowPreMaxAltitude(current_altitude);
_geofence_result.pre_geofence_custom_fence_triggered |= !_geofence.isInsidePreGeofence(current_latitude,
current_longitude);
@@ -1311,7 +1310,6 @@ void Navigator::geofence_breach_check()
current_longitude, current_altitude);
_geofence_result.pre_geofence_max_dist_triggered = !_geofence.isCloserThanPreMaxDistToHome(current_latitude,
current_longitude);
- _geofence_result.pre_geofence_max_alt_triggered = !_geofence.isBelowPreMaxAltitude(current_altitude);
_geofence_result.pre_geofence_custom_fence_triggered = !_geofence.isInsidePreGeofence(current_latitude,
current_longitude);
}
@@ -1328,7 +1326,6 @@ void Navigator::geofence_breach_check()
|| _geofence_result.geofence_max_alt_triggered
|| _geofence_result.geofence_custom_fence_triggered;
const bool pre_breach = _geofence_result.pre_geofence_max_dist_triggered
- || _geofence_result.pre_geofence_max_alt_triggered
|| _geofence_result.pre_geofence_custom_fence_triggered;
// For the Hold action Navigator sets where to hold, once per breach. The geofence and the pre-geofence
@@ -1343,7 +1340,7 @@ void Navigator::geofence_breach_check()
if (geofence_hold || pre_geofence_hold) {
// A vehicle that already holds after the pre-geofence breach keeps that position. Holding where it
- // then breaches the geofence would move it out, for example up to the altitude of an overshoot.
+ // then breaches the geofence would move it out, for example when it overshoots while braking or turning.
if (_time_loitering_after_gf_breach == 0) {
const position_setpoint_s current = get_position_setpoint_triplet()->current;
@@ -1928,9 +1925,8 @@ bool Navigator::pre_geofence_allows_position(const vehicle_global_position_s &po
if ((_geofence.getPreGeofenceAction() != geofence_result_s::GF_ACTION_NONE) &&
(_geofence.getPreGeofenceAction() != geofence_result_s::GF_ACTION_WARN)) {
- if (PX4_ISFINITE(pos.lat) && PX4_ISFINITE(pos.lon) && PX4_ISFINITE(pos.alt)) {
- return _geofence.isCloserThanPreMaxDistToHome(pos.lat, pos.lon) && _geofence.isBelowPreMaxAltitude(pos.alt)
- && _geofence.isInsidePreGeofence(pos.lat, pos.lon);
+ if (PX4_ISFINITE(pos.lat) && PX4_ISFINITE(pos.lon)) {
+ return _geofence.isCloserThanPreMaxDistToHome(pos.lat, pos.lon) && _geofence.isInsidePreGeofence(pos.lat, pos.lon);
}
}
diff --git a/src/modules/navigator/test/test_geofence_margin.cpp b/src/modules/navigator/test/test_geofence_margin.cpp
index ea64e00a284..4f9d97fcc5f 100644
--- a/src/modules/navigator/test/test_geofence_margin.cpp
+++ b/src/modules/navigator/test/test_geofence_margin.cpp
@@ -265,14 +265,19 @@ TEST_F(GeofencePathMarginTest, LoiterCircleAddsTheMargin)
EXPECT_TRUE(pathClear({0.f, 0.f}, {0.f, 360.f}, 0.f, 80.f));
}
-// The distance from Home has its own pre-geofence limit; only a loiter circle is checked against it.
-TEST_F(GeofencePathMarginTest, MarginDoesNotApplyToTheHomeDistance)
+// A path's margin is not kept from the distance from Home. The caller checks the path ends against it,
+// and a loiter circle keeps GF_PRE_MARGIN from it.
+TEST_F(GeofencePathMarginTest, LoiterCircleKeepsTheParameterToTheHomeDistance)
{
setParam("GF_MAX_HOR_DIST", 500.f);
ASSERT_TRUE(loadFence({}));
EXPECT_TRUE(pathClear({0.f, 0.f}, {480.f, 0.f}, 80.f));
EXPECT_TRUE(pathClear({0.f, 0.f}, {400.f, 0.f}, 80.f, 80.f));
EXPECT_FALSE(pathClear({0.f, 0.f}, {440.f, 0.f}, 80.f, 80.f));
+
+ setParam("GF_PRE_MARGIN", 80.f);
+ EXPECT_TRUE(pathClear({0.f, 0.f}, {320.f, 0.f}, 0.f, 80.f));
+ EXPECT_FALSE(pathClear({0.f, 0.f}, {360.f, 0.f}, 0.f, 80.f));
}
TEST_F(GeofencePathMarginTest, InvalidMarginIsUnavailable)
diff --git a/src/modules/navigator/test/test_mission_feasibility_geofence.cpp b/src/modules/navigator/test/test_mission_feasibility_geofence.cpp
index 7e7d2956c34..d3de28333b3 100644
--- a/src/modules/navigator/test/test_mission_feasibility_geofence.cpp
+++ b/src/modules/navigator/test/test_mission_feasibility_geofence.cpp
@@ -290,7 +290,7 @@ INSTANTIATE_TEST_SUITE_P(MissionBatches, MissionGeofenceBatchTest, ::testing::Va
return test_info.param.name;
});
-enum class MissionScalarLimit { Horizontal, Vertical, AltitudeBand, PreHorizontal, PreVertical };
+enum class MissionScalarLimit { Horizontal, Vertical, AltitudeBand };
struct MissionScalarCase {
const char *name;
@@ -313,13 +313,9 @@ TEST_P(MissionGeofenceScalarTest, ChecksEveryPosition)
GeofenceTestPeer::setAltitudeBand(_fence, 450.f, 550.f);
} else {
- const bool pre = test.limit == MissionScalarLimit::PreHorizontal || test.limit == MissionScalarLimit::PreVertical;
- const bool horizontal = test.limit == MissionScalarLimit::Horizontal
- || test.limit == MissionScalarLimit::PreHorizontal;
- const char *name = horizontal ? (pre ? "GF_PRE_MAX_HDIST" : "GF_MAX_HOR_DIST")
- : (pre ? "GF_PRE_MAX_VDIST" : "GF_MAX_VER_DIST");
- const float maximum = horizontal ? 300.f : 150.f;
- ASSERT_EQ(param_set(param_find(name), &maximum), PX4_OK);
+ const float maximum = test.limit == MissionScalarLimit::Horizontal ? 300.f : 150.f;
+ ASSERT_EQ(param_set(param_find(test.limit == MissionScalarLimit::Horizontal ? "GF_MAX_HOR_DIST" : "GF_MAX_VER_DIST"),
+ &maximum), PX4_OK);
_navigator.updateParams();
}
@@ -338,10 +334,6 @@ INSTANTIATE_TEST_SUITE_P(MissionScalarLimits, MissionGeofenceScalarTest, ::testi
MissionScalarCase{"BeyondHomeDistance", MissionScalarLimit::Horizontal, 400.f, 500.f, false, false},
MissionScalarCase{"WithinRelativeAltitude", MissionScalarLimit::Vertical, 200.f, 100.f, true, true},
MissionScalarCase{"BeyondRelativeAltitude", MissionScalarLimit::Vertical, 200.f, 200.f, true, false},
- MissionScalarCase{"WithinPreHomeDistance", MissionScalarLimit::PreHorizontal, 200.f, 500.f, false, true},
- MissionScalarCase{"BeyondPreHomeDistance", MissionScalarLimit::PreHorizontal, 400.f, 500.f, false, false},
- MissionScalarCase{"WithinPreRelativeAltitude", MissionScalarLimit::PreVertical, 200.f, 100.f, true, true},
- MissionScalarCase{"BeyondPreRelativeAltitude", MissionScalarLimit::PreVertical, 200.f, 200.f, true, false},
MissionScalarCase{"BelowAltitudeBand", MissionScalarLimit::AltitudeBand, 200.f, 440.f, false, false},
MissionScalarCase{"AboveAltitudeBand", MissionScalarLimit::AltitudeBand, 200.f, 560.f, false, false},
MissionScalarCase{"AtAltitudeBandMinimum", MissionScalarLimit::AltitudeBand, 200.f, 450.f, false, true},
@@ -360,14 +352,22 @@ TEST_F(MissionFeasibilityGeofenceTest, EmptyFenceStillChecksHomeLimits)
EXPECT_TRUE(waypointEvent(events::ID("navigator_mis_geofence_violation"), 2));
}
-TEST_F(MissionFeasibilityGeofenceTest, FirstPositionMustKeepThePreGeofenceLimits)
+// Every position keeps the pre-geofence margin to the maximum distance from Home.
+TEST_F(MissionFeasibilityGeofenceTest, PositionsMustKeepTheMarginToTheHomeDistance)
{
- const float maximum = 300.f;
- ASSERT_EQ(param_set(param_find("GF_PRE_MAX_HDIST"), &maximum), PX4_OK);
+ const float maximum = 400.f;
+ const float margin = 100.f;
+ ASSERT_EQ(param_set(param_find("GF_MAX_HOR_DIST"), &maximum), PX4_OK);
_navigator.updateParams();
- EXPECT_TRUE(missionFeasible({waypoint({0.f, 200.f})}));
- EXPECT_FALSE(missionFeasible({waypoint({0.f, 400.f})}));
+ EXPECT_TRUE(missionFeasible({waypoint({0.f, 200.f}), waypoint({0.f, 350.f})}));
+
+ ASSERT_EQ(param_set(param_find("GF_PRE_MARGIN"), &margin), PX4_OK);
+ _navigator.updateParams();
+ EXPECT_TRUE(missionFeasible({waypoint({0.f, 200.f}), waypoint({0.f, 290.f})}));
+ EXPECT_FALSE(missionFeasible({waypoint({0.f, 350.f})}));
EXPECT_TRUE(waypointEvent(events::ID("navigator_mis_geofence_violation"), 1));
+ EXPECT_FALSE(missionFeasible({waypoint({0.f, 200.f}), waypoint({0.f, 350.f})}));
+ EXPECT_TRUE(waypointEvent(events::ID("navigator_mis_geofence_violation"), 2));
}
TEST_F(MissionFeasibilityGeofenceTest, EmptyFenceIgnoresStoredAltitudeBand)
@@ -757,29 +757,19 @@ TEST_F(MissionGeofenceLoiterTest, EmptyFenceStillChecksCircleDistanceFromHome)
expectLoiterViolation(1);
}
-TEST_F(MissionGeofenceLoiterTest, CircleMustFitTheTighterHomeDistanceLimit)
+TEST_F(MissionGeofenceLoiterTest, CircleMustKeepTheMarginToTheHomeDistance)
{
ASSERT_TRUE(configureVehicle());
- const auto setLimits = [this](float geofence, float pre_geofence) {
- ASSERT_EQ(param_set(param_find("GF_MAX_HOR_DIST"), &geofence), PX4_OK);
- ASSERT_EQ(param_set(param_find("GF_PRE_MAX_HDIST"), &pre_geofence), PX4_OK);
- _navigator.updateParams();
- };
+ const float maximum = 400.f;
+ ASSERT_EQ(param_set(param_find("GF_MAX_HOR_DIST"), &maximum), PX4_OK);
+ _navigator.updateParams();
- // The 60 m circle fits the geofence limit but not the pre-geofence limit.
- setLimits(400.f, 300.f);
+ // The 60 m circle fits the geofence limit, but with the margin only the 40 m circle does.
+ EXPECT_TRUE(missionFeasible({loiter(250.f, 60.f)}));
+ ASSERT_TRUE(setMargin(100.f));
EXPECT_TRUE(missionFeasible({loiter(250.f, 40.f)}));
EXPECT_FALSE(missionFeasible({loiter(250.f, 60.f)}));
expectLoiterViolation(1);
-
- // The pre-geofence limit alone.
- setLimits(0.f, 300.f);
- EXPECT_FALSE(missionFeasible({loiter(250.f, 60.f)}));
-
- // A pre-geofence limit outside the geofence limit changes nothing.
- setLimits(400.f, 500.f);
- EXPECT_TRUE(missionFeasible({loiter(330.f, 60.f)}));
- EXPECT_FALSE(missionFeasible({loiter(350.f, 60.f)}));
}
TEST_F(MissionGeofenceLoiterTest, PreGeofenceMarginAppliesToPositionsAndPaths)
diff --git a/src/modules/navigator/test/test_pre_geofence_breach.cpp b/src/modules/navigator/test/test_pre_geofence_breach.cpp
index 1a7b2708354..4a70d3f5b78 100644
--- a/src/modules/navigator/test/test_pre_geofence_breach.cpp
+++ b/src/modules/navigator/test/test_pre_geofence_breach.cpp
@@ -143,8 +143,7 @@ protected:
static bool preGeofenceBreached(const geofence_result_s &result)
{
- return result.pre_geofence_max_dist_triggered || result.pre_geofence_max_alt_triggered
- || result.pre_geofence_custom_fence_triggered;
+ return result.pre_geofence_max_dist_triggered || result.pre_geofence_custom_fence_triggered;
}
// A 1000 m square inclusion fence centred on Home.
@@ -232,7 +231,7 @@ TEST_F(PreGeofenceBreachTest, GeofenceHoldWithoutPreGeofenceIsUnchanged)
EXPECT_EQ(reposition().timestamp, second_hold);
}
-TEST_F(PreGeofenceBreachTest, PreGeofenceLimitsNeedHome)
+TEST_F(PreGeofenceBreachTest, PreGeofenceReturnNeedsHome)
{
EXPECT_FALSE(_fence.isHomeRequired());
@@ -240,20 +239,41 @@ TEST_F(PreGeofenceBreachTest, PreGeofenceLimitsNeedHome)
setParam("GF_PRE_ACTION", static_cast(geofence_result_s::GF_ACTION_RTL));
EXPECT_FALSE(_fence.isHomeRequired());
- setParam("GF_PRE_MAX_VDIST", 80.f);
- EXPECT_TRUE(_fence.isHomeRequired());
- setParam("GF_PRE_MAX_VDIST", 0.f);
- setParam("GF_PRE_MAX_HDIST", 400.f);
- EXPECT_TRUE(_fence.isHomeRequired());
-
- // The margin is relative to the plan, so only its Return action needs Home.
- setParam("GF_PRE_MAX_HDIST", 0.f);
+ // The margin is relative to the geofence, so only its Return action needs Home.
setParam("GF_PRE_MARGIN", 100.f);
EXPECT_TRUE(_fence.isHomeRequired());
setParam("GF_PRE_ACTION", static_cast(geofence_result_s::GF_ACTION_LOITER));
EXPECT_FALSE(_fence.isHomeRequired());
}
+// A margin that leaves no room inside the Home distance limit is breached everywhere, not disabled.
+TEST_F(PreGeofenceBreachTest, MarginWiderThanTheHomeDistanceLimit)
+{
+ setParam("GF_MAX_HOR_DIST", 100.f);
+ setParam("GF_PRE_MARGIN", 100.f);
+
+ const geofence_result_s at_home = checkAt({0.f, 0.f, kAltitude});
+ EXPECT_TRUE(at_home.pre_geofence_max_dist_triggered);
+ EXPECT_FALSE(geofenceBreached(at_home));
+ EXPECT_FALSE(targetAllowed({0.f, 0.f, kAltitude}));
+}
+
+// The pre-geofence is horizontal only: the maximum altitude has no margin.
+TEST_F(PreGeofenceBreachTest, MaximumAltitudeHasNoPreGeofence)
+{
+ setParam("GF_MAX_HOR_DIST", 500.f);
+ setParam("GF_MAX_VER_DIST", 100.f);
+ setParam("GF_PRE_MARGIN", 50.f);
+
+ const geofence_result_s below = checkAt({0.f, 0.f, kHomeAltitude + 80.f});
+ EXPECT_FALSE(preGeofenceBreached(below));
+ EXPECT_FALSE(geofenceBreached(below));
+
+ const geofence_result_s above = checkAt({0.f, 0.f, kHomeAltitude + 110.f});
+ EXPECT_FALSE(preGeofenceBreached(above));
+ EXPECT_TRUE(above.geofence_max_alt_triggered);
+}
+
#if CONFIG_NAVIGATOR_GEOFENCE_AVOIDANCE
// Return routes around the fences with the margin added, so that it does not trigger the pre-geofence action.
TEST_F(PreGeofenceBreachTest, ReturnKeepsTheMargin)
@@ -267,11 +287,10 @@ TEST_F(PreGeofenceBreachTest, ReturnKeepsTheMargin)
}
#endif // CONFIG_NAVIGATOR_GEOFENCE_AVOIDANCE
-// What triggers the pre-geofence. Each source has its geofence twin further out.
+// The geofence that GF_PRE_MARGIN, 100 m, is kept from.
enum class Source {
- HomeDistance, // GF_PRE_MAX_HDIST 400 m inside GF_MAX_HOR_DIST 500 m
- HomeAltitude, // GF_PRE_MAX_VDIST 80 m below GF_MAX_VER_DIST 100 m
- Margin, // GF_PRE_MARGIN 100 m inside a 1000 m square plan fence
+ HomeDistance, // GF_MAX_HOR_DIST 500 m
+ Plan, // a 1000 m square plan fence
};
static std::ostream &operator<<(std::ostream &os, Source source)
@@ -279,9 +298,7 @@ static std::ostream &operator<<(std::ostream &os, Source source)
switch (source) {
case Source::HomeDistance: return os << "HomeDistance";
- case Source::HomeAltitude: return os << "HomeAltitude";
-
- case Source::Margin: return os << "Margin";
+ case Source::Plan: return os << "Plan";
}
return os;
@@ -293,55 +310,27 @@ class PreGeofenceSourceTest : public PreGeofenceBreachTest, public ::testing::Wi
protected:
void enablePreGeofence()
{
- switch (GetParam()) {
- case Source::HomeDistance:
+ if (GetParam() == Source::HomeDistance) {
setParam("GF_MAX_HOR_DIST", 500.f);
- setParam("GF_PRE_MAX_HDIST", 400.f);
- break;
- case Source::HomeAltitude:
- setParam("GF_MAX_VER_DIST", 100.f);
- setParam("GF_PRE_MAX_VDIST", 80.f);
- break;
-
- case Source::Margin:
+ } else {
ASSERT_TRUE(loadFence(inclusionSquare()));
- setParam("GF_PRE_MARGIN", 100.f);
- break;
}
+
+ setParam("GF_PRE_MARGIN", 100.f);
}
// Inside both, outside the pre-geofence only, and outside both.
Place inside() const { return {0.f, 300.f, kAltitude}; }
-
- Place between() const
- {
- return GetParam() == Source::HomeAltitude ? Place{0.f, 300.f, kHomeAltitude + 90.f} : Place{0.f, 420.f, kAltitude};
- }
-
- Place outside() const
- {
- return GetParam() == Source::HomeAltitude ? Place{0.f, 300.f, kHomeAltitude + 110.f} : Place{0.f, 510.f, kAltitude};
- }
+ Place between() const { return {0.f, 420.f, kAltitude}; }
+ Place outside() const { return {0.f, 510.f, kAltitude}; }
// Only the source under test is reported.
bool sourceTriggered(const geofence_result_s &result) const
{
- switch (GetParam()) {
- case Source::HomeDistance:
- return result.pre_geofence_max_dist_triggered && !result.pre_geofence_max_alt_triggered
- && !result.pre_geofence_custom_fence_triggered;
-
- case Source::HomeAltitude:
- return result.pre_geofence_max_alt_triggered && !result.pre_geofence_max_dist_triggered
- && !result.pre_geofence_custom_fence_triggered;
-
- case Source::Margin:
- return result.pre_geofence_custom_fence_triggered && !result.pre_geofence_max_dist_triggered
- && !result.pre_geofence_max_alt_triggered;
- }
-
- return false;
+ return GetParam() == Source::HomeDistance
+ ? result.pre_geofence_max_dist_triggered && !result.pre_geofence_custom_fence_triggered
+ : result.pre_geofence_custom_fence_triggered && !result.pre_geofence_max_dist_triggered;
}
// Leave Hold and return inside, as if the pilot had taken over and flown back.
@@ -540,5 +529,5 @@ TEST_P(PreGeofenceSourceTest, CommandedTargetsMustStayInside)
}
INSTANTIATE_TEST_SUITE_P(Sources, PreGeofenceSourceTest,
- ::testing::Values(Source::HomeDistance, Source::HomeAltitude, Source::Margin),
+ ::testing::Values(Source::HomeDistance, Source::Plan),
::testing::PrintToStringParamName());