diff --git a/docs/assets/config/safety/contingency_geofence_margin.svg b/docs/assets/config/safety/contingency_geofence_margin.svg index 55469103de4..6b529985166 100644 --- a/docs/assets/config/safety/contingency_geofence_margin.svg +++ b/docs/assets/config/safety/contingency_geofence_margin.svg @@ -1,16 +1,16 @@ Contingency geofence margin - Top view of a geofence, drawn as a solid line, with the contingency geofence drawn as a dashed line at the distance GF_CONT_H_MARGIN inside it and around an exclusion area. A fixed-wing vehicle flies from Home towards the boundary. Where it comes closer to the geofence than the margin, the contingency geofence action Hold is triggered, and the vehicle loiters around that position without reaching the geofence. + Top view of an emergency geofence, drawn as a solid line, with the contingency geofence drawn as a dashed line at the distance GF_CONT_H_MARGIN inside it and around an exclusion area. A fixed-wing vehicle flies from Home towards the boundary. Where it comes closer to the emergency geofence than the margin, the contingency geofence action Hold is triggered, and the vehicle loiters around that position without reaching the emergency geofence. diff --git a/docs/en/config/safety.md b/docs/en/config/safety.md index 782b2b6f6a0..3ca2e795417 100644 --- a/docs/en/config/safety.md +++ b/docs/en/config/safety.md @@ -243,17 +243,23 @@ The following settings also apply, but are not displayed in the QGC UI. A contingency 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 contingency 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. -For example, under the [SORA](http://jarus-rpas.org/wp-content/uploads/2024/06/SORA-v2.5-Main-Body-Release-JAR_doc_25.pdf) framework, which many countries use to approve complex operations, leaving the contingency volume typically requires the flight to be terminated. +The two geofences are named after the volumes of the [SORA](http://jarus-rpas.org/wp-content/uploads/2024/06/SORA-v2.5-Main-Body-Release-JAR_doc_25.pdf) framework, which many countries use to approve complex operations: + +- The **contingency geofence** is the horizontal boundary of the flight geography. + A vehicle that leaves it carries out a contingency procedure, for example it holds or returns. +- The **emergency geofence** is the geofence described above, with the action `GF_ACTION`. + It is the outer boundary of the contingency volume: a vehicle that leaves it carries out an emergency procedure, typically flight termination. + +Use a contingency geofence where the emergency geofence must not be crossed, or where its action has to be severe. #### Contingency Geofence Setup The contingency geofence is off while the margin is 0 (the default). -| Setting | Parameter | Description | -| --------------------------- | ------------------------------------------------------------------------------ | -------------------------------------------------------- | -| Contingency geofence action | [GF_CONT_ACTION](../advanced_config/parameter_reference.md#GF_CONT_ACTION) | Warning, Hold mode (default), Return mode, or Land mode. | -| Contingency geofence margin | [GF_CONT_H_MARGIN](../advanced_config/parameter_reference.md#GF_CONT_H_MARGIN) | Horizontal distance from the geofence. Disabled if 0. | +| Setting | Parameter | Description | +| --------------------------- | ------------------------------------------------------------------------------ | --------------------------------------------------------------- | +| Contingency geofence action | [GF_CONT_ACTION](../advanced_config/parameter_reference.md#GF_CONT_ACTION) | Warning, Hold mode (default), Return mode, or Land mode. | +| Contingency geofence margin | [GF_CONT_H_MARGIN](../advanced_config/parameter_reference.md#GF_CONT_H_MARGIN) | Horizontal distance from the emergency 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 contingency geofence once it comes closer to one of them than `GF_CONT_H_MARGIN`. It is a single distance, so there is only one fence to draw and upload. @@ -262,9 +268,9 @@ The maximum altitude ([GF_MAX_VER_DIST](../advanced_config/parameter_reference.m `GF_CONT_H_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 contingency geofence. -![Top view of a geofence with the contingency geofence at the distance GF_CONT_H_MARGIN inside it: a fixed-wing vehicle that comes closer to the geofence than the margin holds and loiters there, instead of flying on and breaching the geofence](../../assets/config/safety/contingency_geofence_margin.svg) +![Top view of an emergency geofence with the contingency geofence at the distance GF_CONT_H_MARGIN inside it: a fixed-wing vehicle that comes closer to the emergency geofence than the margin holds and loiters there, instead of flying on and breaching it](../../assets/config/safety/contingency_geofence_margin.svg) -The margin has to leave the vehicle enough room to stop or turn around before the geofence. +The margin has to leave the vehicle enough room to stop or turn around before the emergency geofence. It should be at least: - Fixed-wing: The loiter radius ([NAV_LOITER_RAD](../advanced_config/parameter_reference.md#NAV_LOITER_RAD)). @@ -277,9 +283,9 @@ Use a margin above these nominal values to account for possible tailwind, positi PX4 does not check the setup: - The contingency geofence action should be the milder of the two. - It has no `None`, because the contingency geofence is disabled through its margin, and no `Terminate`, which is left to the geofence. + It has no `None`, because the contingency geofence is disabled through its margin, and no `Terminate`, which is left to the emergency geofence. - If the margin leaves no room inside `GF_MAX_HOR_DIST` or inside an inclusion area, the contingency 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. +- As for the emergency geofence, 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 contingency geofence, for example when Home or the vehicle lies within the margin. If the vehicle is already outside the contingency geofence when the plan is uploaded or a parameter changes, the action is triggered at once. @@ -293,19 +299,19 @@ PX4 does not check the setup: When the vehicle breaches the contingency geofence: - The contingency geofence action is triggered, in all flight modes. - With `Hold` the vehicle holds where it breached the contingency geofence, in the same way as after a geofence breach (a fixed-wing vehicle loiters around that position). + With `Hold` the vehicle holds where it breached the contingency geofence, in the same way as after an emergency geofence breach (a fixed-wing vehicle loiters around that position). If already established on a loiter, it keeps the existing loiter centre. Switch to another mode to take over. The action is triggered again the next time the vehicle breaches the contingency geofence. - Arming is denied. -- If the vehicle breaches the geofence as well, the more severe of the two actions is taken, as for other failsafes. +- If the vehicle breaches the emergency geofence as well, the more severe of the two actions is taken, as for other failsafes. This also applies after you have taken over. PX4 also keeps planned flight inside the contingency geofence: -- 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. +- A mission is rejected if one of its positions, a leg between positions or a fixed-wing loiter circle comes closer to the emergency 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 contingency 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. + As for the emergency 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 outside the contingency 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. diff --git a/docs/en/releases/main.md b/docs/en/releases/main.md index 20992844b9d..92925f07ce2 100644 --- a/docs/en/releases/main.md +++ b/docs/en/releases/main.md @@ -97,8 +97,9 @@ Please continue reading for [upgrade instructions](#upgrade-guide). Limits raised or disabled to allow large tilts, for example roll on fixed-wing vehicles, are no longer needed. The check is disabled with `FD_TILT_ERROR` set to -1. The `fd_roll` and `fd_pitch` fields of [FailureDetectorStatus](../msg_docs/FailureDetectorStatus.md) are replaced by `fd_tilt`. -- **The failsafe flag `geofence_breached` is renamed to `gf_breached`.** - The field of [FailsafeFlags](../msg_docs/FailsafeFlags.md) (`failsafe_flags`) is shortened to make room for the new `gf_cont_breach` flag within the logger's format limit. +- **The failsafe flag `geofence_breached` is renamed to `gf_emer_breach`.** + The field of [FailsafeFlags](../msg_docs/FailsafeFlags.md) (`failsafe_flags`) now names the emergency geofence, next to the new `gf_cont_breach` flag of the contingency geofence. + Both names are short because the message is at the logger's format limit. ROS 2 applications and log analysis that read `geofence_breached` must use the new name. ## Other changes @@ -147,6 +148,7 @@ Please continue reading for [upgrade instructions](#upgrade-guide). - [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)). - [Contingency geofence](../config/safety.md#contingency-geofence): a second boundary at a horizontal margin inside the geofence ([GF_CONT_H_MARGIN](../advanced_config/parameter_reference.md#GF_CONT_H_MARGIN)), with its own action ([GF_CONT_ACTION](../advanced_config/parameter_reference.md#GF_CONT_ACTION)). A vehicle can for example hold at the contingency geofence, and only terminate if it still crosses the geofence. + The names follow the SORA framework: messages about a breach or a refused target now call the existing geofence the emergency geofence. The margin applies to the maximum distance from Home and to the Geofence Plan. Outside the contingency 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. diff --git a/msg/FailsafeFlags.msg b/msg/FailsafeFlags.msg index 429d516e615..70e623e67ca 100644 --- a/msg/FailsafeFlags.msg +++ b/msg/FailsafeFlags.msg @@ -53,8 +53,8 @@ bool fd_motor_stuck_failure # Motor-stuck failure during spool-up bool fd_alt_loss # Uncommanded altitude loss (rotary-wing, altitude-controlled flight) # Other -bool gf_breached # Geofence breached (one or multiple) -bool gf_cont_breach # Contingency geofence breached (one or multiple) +bool gf_emer_breach # Emergency geofence breached (one or multiple) +bool gf_cont_breach # Contingency geofence breached (one or multiple) bool mission_failure # Mission failure bool vtol_fixed_wing_system_failure # vehicle in fixed-wing system failure failsafe mode (after quad-chute) bool wind_limit_exceeded # Wind limit exceeded diff --git a/src/modules/commander/HealthAndArmingChecks/checks/geofenceCheck.cpp b/src/modules/commander/HealthAndArmingChecks/checks/geofenceCheck.cpp index 470c56e5585..a4e7b816a30 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/geofenceCheck.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/geofenceCheck.cpp @@ -45,7 +45,7 @@ void GeofenceChecks::checkAndReport(const Context &context, Report &reporter) geofence_result.geofence_max_alt_triggered || geofence_result.geofence_custom_fence_triggered; - reporter.failsafeFlags().gf_breached = geofence_result.geofence_action != geofence_result_s::GF_ACTION_NONE && any_geofence_triggered; + reporter.failsafeFlags().gf_emer_breach = geofence_result.geofence_action != geofence_result_s::GF_ACTION_NONE && any_geofence_triggered; const bool any_cont_geofence_triggered = geofence_result.geofence_cont_max_dist_triggered || geofence_result.geofence_cont_custom_fence_triggered; @@ -64,10 +64,10 @@ void GeofenceChecks::checkAndReport(const Context &context, Report &reporter) */ reporter.armingCheckFailure(NavModes::All, health_component_t::system, events::ID("check_gf_violation_max_hor_dist"), - events::Log::Error, "Geofence breach: exceeding maximum distance to Home"); + events::Log::Error, "Emergency geofence breach: exceeding maximum distance to Home"); if (reporter.mavlink_log_pub()) { - mavlink_log_critical(reporter.mavlink_log_pub(), "Geofence: exceeding maximum distance to Home\t"); + mavlink_log_critical(reporter.mavlink_log_pub(), "Emergency geofence: exceeding maximum distance to Home\t"); } } @@ -80,10 +80,10 @@ void GeofenceChecks::checkAndReport(const Context &context, Report &reporter) */ reporter.armingCheckFailure(NavModes::All, health_component_t::system, events::ID("check_gf_violation_max_alt"), - events::Log::Error, "Geofence breach: exceeding maximum altitude above Home"); + events::Log::Error, "Emergency geofence breach: exceeding maximum altitude above Home"); if (reporter.mavlink_log_pub()) { - mavlink_log_critical(reporter.mavlink_log_pub(), "Geofence: exceeding maximum altitude above Home\t"); + mavlink_log_critical(reporter.mavlink_log_pub(), "Emergency geofence: exceeding maximum altitude above Home\t"); } } @@ -96,10 +96,10 @@ void GeofenceChecks::checkAndReport(const Context &context, Report &reporter) */ reporter.armingCheckFailure(NavModes::All, health_component_t::system, events::ID("check_gf_violation_custom_gf"), - events::Log::Error, "Geofence breach: approaching or outside geofence"); + events::Log::Error, "Emergency geofence breach: approaching or outside the fence"); if (reporter.mavlink_log_pub()) { - mavlink_log_critical(reporter.mavlink_log_pub(), "Geofence: approaching or outside geofence\t"); + mavlink_log_critical(reporter.mavlink_log_pub(), "Emergency geofence: approaching or outside the fence\t"); } } } @@ -131,10 +131,10 @@ void GeofenceChecks::checkAndReport(const Context &context, Report &reporter) */ reporter.armingCheckFailure(NavModes::All, health_component_t::system, events::ID("check_gf_cont_breach_custom_gf"), - events::Log::Error, "Contingency geofence breach: approaching or outside contingency geofence"); + events::Log::Error, "Contingency geofence breach: approaching or outside the fence"); if (reporter.mavlink_log_pub()) { - mavlink_log_critical(reporter.mavlink_log_pub(), "Contingency geofence: approaching or outside contingency geofence\t"); + mavlink_log_critical(reporter.mavlink_log_pub(), "Contingency geofence: approaching or outside the fence\t"); } } } diff --git a/src/modules/commander/HealthAndArmingChecks/geofenceCheckTest.cpp b/src/modules/commander/HealthAndArmingChecks/geofenceCheckTest.cpp index 486e3a22a65..bb5c8af9aae 100644 --- a/src/modules/commander/HealthAndArmingChecks/geofenceCheckTest.cpp +++ b/src/modules/commander/HealthAndArmingChecks/geofenceCheckTest.cpp @@ -78,7 +78,7 @@ public: uORB::Publication _geofence_result_pub{ORB_ID(geofence_result)}; }; -// Each contingency geofence limit sets the contingency geofence flag and denies arming before the geofence is breached. +// Each contingency geofence trigger sets its own flag and denies arming before the emergency geofence is breached. TEST_F(GeofenceChecksTest, ContGeofenceSetsItsOwnFlagAndDeniesArming) { bool geofence_result_s::*const triggers[] = { @@ -90,13 +90,13 @@ TEST_F(GeofenceChecksTest, ContGeofenceSetsItsOwnFlagAndDeniesArming) geofence_result_s result = resultWithActions(geofence_result_s::GF_ACTION_TERMINATE, geofence_result_s::GF_ACTION_LOITER); runCheck(result); - EXPECT_FALSE(_failsafe_flags.gf_breached); + EXPECT_FALSE(_failsafe_flags.gf_emer_breach); EXPECT_FALSE(_failsafe_flags.gf_cont_breach); EXPECT_TRUE(_can_arm_all_modes); result.*trigger = true; runCheck(result); - EXPECT_FALSE(_failsafe_flags.gf_breached); + EXPECT_FALSE(_failsafe_flags.gf_emer_breach); EXPECT_TRUE(_failsafe_flags.gf_cont_breach); EXPECT_FALSE(_can_arm_all_modes); } @@ -109,7 +109,7 @@ TEST_F(GeofenceChecksTest, ContGeofenceWorksWithoutAGeofenceAction) result.geofence_cont_max_dist_triggered = true; result.geofence_max_dist_triggered = true; runCheck(result); - EXPECT_FALSE(_failsafe_flags.gf_breached); + EXPECT_FALSE(_failsafe_flags.gf_emer_breach); EXPECT_TRUE(_failsafe_flags.gf_cont_breach); EXPECT_FALSE(_can_arm_all_modes); } @@ -120,13 +120,13 @@ TEST_F(GeofenceChecksTest, GeofenceAndContGeofenceSetIndependentFlags) geofence_result_s::GF_ACTION_LOITER); result.geofence_custom_fence_triggered = true; runCheck(result); - EXPECT_TRUE(_failsafe_flags.gf_breached); + EXPECT_TRUE(_failsafe_flags.gf_emer_breach); EXPECT_FALSE(_failsafe_flags.gf_cont_breach); EXPECT_FALSE(_can_arm_all_modes); result.geofence_cont_custom_fence_triggered = true; runCheck(result); - EXPECT_TRUE(_failsafe_flags.gf_breached); + EXPECT_TRUE(_failsafe_flags.gf_emer_breach); EXPECT_TRUE(_failsafe_flags.gf_cont_breach); EXPECT_FALSE(_can_arm_all_modes); } @@ -151,7 +151,7 @@ TEST_F(GeofenceChecksTest, DisabledContGeofenceIgnoresStaleTrigger) geofence_result_s result = resultWithActions(geofence_result_s::GF_ACTION_NONE, geofence_result_s::GF_ACTION_NONE); result.geofence_cont_max_dist_triggered = true; runCheck(result, true); - EXPECT_FALSE(_failsafe_flags.gf_breached); + EXPECT_FALSE(_failsafe_flags.gf_emer_breach); EXPECT_FALSE(_failsafe_flags.gf_cont_breach); EXPECT_TRUE(_can_arm_all_modes); } diff --git a/src/modules/commander/failsafe/failsafe.cpp b/src/modules/commander/failsafe/failsafe.cpp index 5635c93d9b8..137438cae6f 100644 --- a/src/modules/commander/failsafe/failsafe.cpp +++ b/src/modules/commander/failsafe/failsafe.cpp @@ -663,7 +663,7 @@ void Failsafe::checkStateAndMode(const hrt_abstime &time_us, const State &state, ActionOptions(Action::Hold).clearOn(ClearCondition::OnModeChangeOrDisarm)); } - CHECK_FAILSAFE(status_flags, gf_breached, fromGfActParam(_param_gf_action.get()).cannotBeDeferred()); + CHECK_FAILSAFE(status_flags, gf_emer_breach, fromGfActParam(_param_gf_action.get()).cannotBeDeferred()); CHECK_FAILSAFE(status_flags, gf_cont_breach, fromContGeofenceActionParam(_param_gf_cont_action.get()).cannotBeDeferred()); diff --git a/src/modules/commander/failsafe/failsafe_test.cpp b/src/modules/commander/failsafe/failsafe_test.cpp index 7fdb26f2522..9fec29ad5ff 100644 --- a/src/modules/commander/failsafe/failsafe_test.cpp +++ b/src/modules/commander/failsafe/failsafe_test.cpp @@ -1308,7 +1308,7 @@ TEST_F(FailsafeTest, GnssRecoveryDoesNotAbortRtlWhenAnotherFailsafeStartsADelay) ASSERT_EQ(failsafe.selectedAction(), FailsafeBase::Action::RTL); } -// The geofence and the contingency geofence are two failsafes: the more severe action wins. +// The emergency and the contingency geofence are two failsafes: the more severe action wins. class GeofenceFailsafeTest : public FailsafeTest { public: @@ -1374,7 +1374,7 @@ TEST_F(GeofenceFailsafeTest, ContGeofenceUsesItsOwnAction) Action action; } cases[] = { {kWarning, Action::Warn}, {kHold, Action::Hold}, {kReturn, Action::RTL}, {kLand, Action::Land}, - {kNone, Action::Warn}, {kTerminate, Action::Warn}, // not offered: the contingency geofence never terminates + {kNone, Action::Warn}, {kTerminate, Action::Warn}, // not offered for the contingency geofence }; for (const auto &c : cases) { @@ -1401,11 +1401,11 @@ TEST_F(GeofenceFailsafeTest, MoreSevereActionWins) {kHold, Action::Hold, kLand, Action::Land, Action::Land}, {kReturn, Action::RTL, kTerminate, Action::Terminate, Action::Terminate}, {kLand, Action::Land, kHold, Action::Hold, Action::Land}, // a Land in progress is not downgraded - {kHold, Action::Hold, kWarning, Action::Warn, Action::Hold}, // a geofence Warning does not cancel the Hold + {kHold, Action::Hold, kWarning, Action::Warn, Action::Hold}, // an emergency Warning keeps the Hold {kHold, Action::Hold, kNone, Action::None, Action::Hold}, }; - // Contingency geofence first, geofence first, and both in the same update. + // Contingency geofence first, emergency geofence first, and both in the same update. for (int order = 0; order < 3; ++order) { SCOPED_TRACE(order); @@ -1422,19 +1422,19 @@ TEST_F(GeofenceFailsafeTest, MoreSevereActionWins) EXPECT_EQ(update(failsafe), c.cont_action); } else if (order == 1) { - _flags.gf_breached = true; + _flags.gf_emer_breach = true; EXPECT_EQ(update(failsafe), c.action); } _flags.gf_cont_breach = true; - _flags.gf_breached = true; + _flags.gf_emer_breach = true; EXPECT_EQ(update(failsafe), c.both); EXPECT_EQ(update(failsafe), c.both); } } } -// Taking over after the contingency geofence action must not disable the geofence action. +// Taking over after the contingency geofence action must not disable the emergency geofence action. TEST_F(GeofenceFailsafeTest, GeofenceBreachEndsContGeofenceTakeover) { const struct { @@ -1462,8 +1462,8 @@ TEST_F(GeofenceFailsafeTest, GeofenceBreachEndsContGeofenceTakeover) ASSERT_EQ(update(failsafe, true), Action::Warn); ASSERT_TRUE(failsafe.userTakeoverActive()); - // The pilot flies on and breaches the geofence - _flags.gf_breached = true; + // The pilot flies on and breaches the emergency geofence + _flags.gf_emer_breach = true; EXPECT_EQ(update(failsafe), c.action); EXPECT_EQ(failsafe.userTakeoverActive(), c.takeover); } @@ -1478,7 +1478,7 @@ TEST_F(GeofenceFailsafeTest, ContGeofenceHoldIsLeftByModeSwitch) _flags.gf_cont_breach = true; ASSERT_EQ(update(failsafe), Action::Hold); - // Stick movement -> denied, like for a geofence breach + // Stick movement -> denied, like for an emergency geofence breach ASSERT_EQ(update(failsafe, false, true), Action::Hold); ASSERT_FALSE(failsafe.userTakeoverActive()); diff --git a/src/modules/navigator/geofence.cpp b/src/modules/navigator/geofence.cpp index 1008a68b283..fa8daf952d8 100644 --- a/src/modules/navigator/geofence.cpp +++ b/src/modules/navigator/geofence.cpp @@ -719,7 +719,7 @@ 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, and GF_CONT_H_MARGIN. + // The caller checks path ends against Home; a circle must keep its radius and GF_CONT_H_MARGIN inside. 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 - getContGeofenceMargin(); diff --git a/src/modules/navigator/geofence.h b/src/modules/navigator/geofence.h index bb95bcee8eb..9144eb250b9 100644 --- a/src/modules/navigator/geofence.h +++ b/src/modules/navigator/geofence.h @@ -149,7 +149,7 @@ public: */ bool isBelowMaxAltitude(float altitude); - /** True if the position keeps GF_CONT_H_MARGIN from the maximum distance to Home, or one of the two is disabled. */ + /** True if the position keeps GF_CONT_H_MARGIN from the maximum distance to Home, or one of the two is 0. */ bool isCloserThanContMaxDistToHome(double lat, double lon) { const float margin = getContGeofenceMargin(); @@ -175,8 +175,8 @@ public: bool isCircleInside(double lat, double lon, float radius); /** - * GF_CONT_H_MARGIN [m], the horizontal distance the contingency geofence keeps from the geofence: from the maximum - * distance to Home and from the polygons and circles. Zero if disabled, which disables the contingency geofence. + * GF_CONT_H_MARGIN [m], the horizontal distance the contingency geofence keeps from the emergency geofence: + * from the maximum distance to Home and from the polygons and circles. Zero disables the contingency geofence. * The polygons and circles need the path checks, so boards built without them have no such parameter. */ float getContGeofenceMargin() const @@ -223,7 +223,10 @@ public: int getSource() { return _param_gf_source.get(); } int getGeofenceAction() { return _param_gf_action.get(); } - /** GF_CONT_ACTION as a GF_ACTION value: None while the contingency geofence is disabled, Warning for values it does not offer. */ + /** + * GF_CONT_ACTION as a GF_ACTION value: None while the contingency geofence is disabled, Warning for values + * it does not offer. + */ uint8_t getContGeofenceAction() const; float getMaxHorDistanceHome() { return _param_gf_max_hor_dist.get(); } diff --git a/src/modules/navigator/geofence_contingency_margin_params.yaml b/src/modules/navigator/geofence_contingency_margin_params.yaml index 2817162912a..103914ba727 100644 --- a/src/modules/navigator/geofence_contingency_margin_params.yaml +++ b/src/modules/navigator/geofence_contingency_margin_params.yaml @@ -4,9 +4,9 @@ parameters: definitions: GF_CONT_H_MARGIN: description: - short: Contingency geofence horizontal margin to the geofence - long: Triggers GF_CONT_ACTION within this distance of GF_MAX_HOR_DIST, or of a polygon or circle - of the geofence plan. Disabled if 0. + short: Contingency geofence horizontal margin + long: Triggers GF_CONT_ACTION within this horizontal 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/geofence_params.yaml b/src/modules/navigator/geofence_params.yaml index b26c1f87bf3..a30905d9531 100644 --- a/src/modules/navigator/geofence_params.yaml +++ b/src/modules/navigator/geofence_params.yaml @@ -4,7 +4,7 @@ parameters: definitions: GF_ACTION: description: - short: Geofence breach action + short: Emergency geofence breach action long: |- Note: Setting this value to 4 enables flight termination, which will kill the vehicle on a breach of the fence. @@ -56,7 +56,7 @@ parameters: GF_CONT_ACTION: description: short: Contingency geofence breach action - long: If the geofence is breached as well, the more severe of the two actions is taken. + long: If the emergency geofence is breached as well, the more severe of the two actions is taken. type: enum values: 1: Warning diff --git a/src/modules/navigator/mission_feasibility_checker.cpp b/src/modules/navigator/mission_feasibility_checker.cpp index 81ae200021d..951de0d21e8 100644 --- a/src/modules/navigator/mission_feasibility_checker.cpp +++ b/src/modules/navigator/mission_feasibility_checker.cpp @@ -218,8 +218,8 @@ MissionFeasibilityChecker::checkMissionAgainstGeofence(const mission_s &mission, missionitem.altitude); #endif // CONFIG_NAVIGATOR_GEOFENCE_PATH_CHECKS - // As for the geofence in both branches above, the contingency geofence distance to Home is checked at every - // position. Its margin to the plan is checked with the paths, see addGeofencePath(). + // As for the emergency geofence in both branches above, the contingency 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.isCloserThanContMaxDistToHome(missionitem.lat, missionitem.lon); if (!point_valid) { diff --git a/src/modules/navigator/navigator_main.cpp b/src/modules/navigator/navigator_main.cpp index 69f45eec001..a0e1dce5208 100644 --- a/src/modules/navigator/navigator_main.cpp +++ b/src/modules/navigator/navigator_main.cpp @@ -555,9 +555,9 @@ void Navigator::run() _time_loitering_after_gf_breach = 0; // a manual reposition unlatches the post-breach loiter state } else if (!fence_allows_position) { - mavlink_log_critical(&_mavlink_log_pub, "Reposition is outside geofence\t"); + mavlink_log_critical(&_mavlink_log_pub, "Reposition is outside the emergency geofence\t"); events::send(events::ID("navigator_reposition_outside_geofence"), {events::Log::Error, events::LogInternal::Info}, - "Reposition is outside geofence"); + "Reposition is outside the emergency geofence"); } else { mavlink_log_critical(&_mavlink_log_pub, "Reposition is outside the contingency geofence\t"); @@ -589,9 +589,9 @@ void Navigator::run() _course.set_altitude(new_alt); } else if (!fence_allows_position) { - mavlink_log_critical(&_mavlink_log_pub, "Altitude change is outside geofence\t"); + mavlink_log_critical(&_mavlink_log_pub, "Altitude change is outside the emergency geofence\t"); events::send(events::ID("navigator_course_change_altitude_outside_geofence"), {events::Log::Error, events::LogInternal::Info}, - "Altitude change is outside geofence"); + "Altitude change is outside the emergency geofence"); } else { mavlink_log_critical(&_mavlink_log_pub, "Altitude change is outside the contingency geofence\t"); @@ -668,9 +668,9 @@ void Navigator::run() _time_loitering_after_gf_breach = 0; // a manual reposition unlatches the post-breach loiter state } else if (!fence_allows_position) { - mavlink_log_critical(&_mavlink_log_pub, "Altitude change is outside geofence\t"); + mavlink_log_critical(&_mavlink_log_pub, "Altitude change is outside the emergency geofence\t"); events::send(events::ID("navigator_change_altitude_outside_geofence"), {events::Log::Error, events::LogInternal::Info}, - "Altitude change is outside geofence"); + "Altitude change is outside the emergency geofence"); } else { mavlink_log_critical(&_mavlink_log_pub, "Altitude change is outside the contingency geofence\t"); @@ -752,7 +752,7 @@ void Navigator::run() _time_loitering_after_gf_breach = 0; // a manual reposition unlatches the post-breach loiter state } else if (!fence_allows_position) { - mavlink_log_critical(&_mavlink_log_pub, "Orbit is outside geofence"); + mavlink_log_critical(&_mavlink_log_pub, "Orbit is outside the emergency geofence"); } else { mavlink_log_critical(&_mavlink_log_pub, "Orbit is outside the contingency geofence"); @@ -809,7 +809,7 @@ void Navigator::run() _time_loitering_after_gf_breach = 0; // a manual reposition unlatches the post-breach loiter state } else if (!fence_allows_position) { - mavlink_log_critical(&_mavlink_log_pub, "Figure 8 is outside geofence"); + mavlink_log_critical(&_mavlink_log_pub, "Figure 8 is outside the emergency geofence"); } else { mavlink_log_critical(&_mavlink_log_pub, "Figure 8 is outside the contingency geofence"); @@ -1328,9 +1328,9 @@ void Navigator::geofence_breach_check() const bool cont_breach = _geofence_result.geofence_cont_max_dist_triggered || _geofence_result.geofence_cont_custom_fence_triggered; - // For the Hold action Navigator sets where to hold, once per breach. The geofence and the contingency geofence - // each ask for their own breach: a pilot who takes over after the contingency geofence Hold and flies on is - // held again at the geofence. + // For the Hold action Navigator sets where to hold, once per breach. The emergency and the contingency + // geofence each ask for their own breach: a pilot who takes over after the contingency geofence Hold + // and flies on is held again at the emergency geofence. const bool can_hold = global_position_valid && _vstatus.arming_state == vehicle_status_s::ARMING_STATE_ARMED; const bool geofence_hold = breach && !_geofence_reposition_sent && can_hold && _geofence_result.geofence_action == geofence_result_s::GF_ACTION_LOITER; @@ -1339,8 +1339,9 @@ void Navigator::geofence_breach_check() if (geofence_hold || cont_geofence_hold) { - // A vehicle that already holds after the contingency geofence breach keeps that position. Holding where it - // then breaches the geofence would move it out, for example when it overshoots while braking or turning. + // A vehicle that already holds after the contingency geofence breach keeps that position. + // Holding where it then breaches the emergency 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; diff --git a/src/modules/navigator/test/test_contingency_geofence_breach.cpp b/src/modules/navigator/test/test_contingency_geofence_breach.cpp index 282a83d6247..8bab84a360f 100644 --- a/src/modules/navigator/test/test_contingency_geofence_breach.cpp +++ b/src/modules/navigator/test/test_contingency_geofence_breach.cpp @@ -204,8 +204,8 @@ TEST_F(ContGeofenceBreachTest, DisabledByDefault) EXPECT_FALSE(contGeofenceBreached(outside)); } -// Without a contingency geofence the Hold after a geofence breach works as before: at the breach position, latched -// while holding, again on the next breach, and once per breach. +// Without a contingency geofence the Hold after an emergency geofence breach works as before: at the breach +// position, latched while holding, again on the next breach, and once per breach. TEST_F(ContGeofenceBreachTest, GeofenceHoldWithoutContGeofenceIsUnchanged) { setParam("GF_MAX_HOR_DIST", 500.f); @@ -239,7 +239,7 @@ TEST_F(ContGeofenceBreachTest, ContGeofenceReturnNeedsHome) setParam("GF_CONT_ACTION", static_cast(geofence_result_s::GF_ACTION_RTL)); EXPECT_FALSE(_fence.isHomeRequired()); - // The margin is relative to the geofence, so only its Return action needs Home. + // The margin is relative to the emergency geofence, so only its Return action needs Home. setParam("GF_CONT_H_MARGIN", 100.f); EXPECT_TRUE(_fence.isHomeRequired()); setParam("GF_CONT_ACTION", static_cast(geofence_result_s::GF_ACTION_LOITER)); @@ -275,7 +275,7 @@ TEST_F(ContGeofenceBreachTest, MaximumAltitudeHasNoContGeofence) } #if CONFIG_NAVIGATOR_GEOFENCE_AVOIDANCE -// Return routes around the fences with the margin added, so that it does not trigger the contingency geofence action. +// Return routes around the fences with the margin added, so that it does not trigger GF_CONT_ACTION. TEST_F(ContGeofenceBreachTest, ReturnKeepsTheMargin) { const float without_margin = _navigator.geofence_avoidance_margin(); @@ -287,7 +287,7 @@ TEST_F(ContGeofenceBreachTest, ReturnKeepsTheMargin) } #endif // CONFIG_NAVIGATOR_GEOFENCE_AVOIDANCE -// The geofence that GF_CONT_H_MARGIN, 100 m, is kept from. +// The emergency geofence that GF_CONT_H_MARGIN, 100 m, is kept from. enum class Source { HomeDistance, // GF_MAX_HOR_DIST 500 m Plan, // a 1000 m square plan fence @@ -423,8 +423,8 @@ TEST_P(ContGeofenceSourceTest, OtherActionsDoNotReposition) } } -// Commander ranks the two actions. A geofence that only warns, or does nothing, leaves the contingency geofence -// Hold in place when both are breached at once. +// Commander ranks the two actions. An emergency geofence that only warns, or does nothing, leaves the +// contingency geofence Hold in place when both are breached at once. TEST_P(ContGeofenceSourceTest, GeofenceWarningDoesNotReplaceTheHold) { enableContGeofence(); @@ -438,7 +438,7 @@ TEST_P(ContGeofenceSourceTest, GeofenceWarningDoesNotReplaceTheHold) } } -// The geofence still gets its Hold when the contingency geofence only warns. +// The emergency geofence still gets its Hold when the contingency geofence only warns. TEST_P(ContGeofenceSourceTest, GeofenceHoldAfterAContGeofenceWarning) { setParam("GF_CONT_ACTION", static_cast(geofence_result_s::GF_ACTION_WARN)); @@ -451,7 +451,7 @@ TEST_P(ContGeofenceSourceTest, GeofenceHoldAfterAContGeofenceWarning) EXPECT_TRUE(repositionedAt(outside())); } -// A pilot who took over after the contingency geofence breach is still held at the geofence. +// A pilot who took over after the contingency geofence breach is still held at the emergency geofence. TEST_P(ContGeofenceSourceTest, GeofenceHoldAfterATakeover) { enableContGeofence(); @@ -469,12 +469,12 @@ TEST_P(ContGeofenceSourceTest, GeofenceHoldAfterATakeover) EXPECT_GT(reposition().timestamp, cont_geofence_hold); EXPECT_TRUE(repositionedAt(outside())); - // The geofence Hold stays latched while the vehicle is holding. + // The emergency geofence Hold stays latched while the vehicle is holding. setNavState(vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER); EXPECT_TRUE(geofenceBreached(checkAt(between()))); } -// Breaching the geofence while holding must not move the loiter out to the breach position. +// Breaching the emergency geofence while holding must not move the loiter out to the breach position. TEST_P(ContGeofenceSourceTest, HoldIsNotMovedByAGeofenceBreach) { enableContGeofence(); @@ -517,7 +517,7 @@ TEST_P(ContGeofenceSourceTest, CommandedTargetsMustStayInside) EXPECT_FALSE(targetAllowed(between())); EXPECT_FALSE(targetAllowed(outside())); - // A warning does not restrict targets, the geofence still does. + // A warning does not restrict targets, the emergency geofence still does. setParam("GF_CONT_ACTION", static_cast(geofence_result_s::GF_ACTION_WARN)); EXPECT_TRUE(targetAllowed(between())); EXPECT_FALSE(targetAllowed(outside()));