From 155f415168cef08dca2f5d85d2bc258b44a589ec Mon Sep 17 00:00:00 2001
From: Jonas Perolini <74473718+JonasPerolini@users.noreply.github.com>
Date: Wed, 4 Nov 2026 01:05:20 +0100
Subject: [PATCH] fix(navigator): circle instead of land for a fixed-wing on
RTL_TYPE 5 without a rally point (#29479)
Assisted-by: Claude:claude-opus-5-5
---
docs/en/flight_modes/return.md | 35 +++---
docs/en/flight_modes_fw/return.md | 16 +--
docs/en/flight_modes_mc/return.md | 14 +--
docs/en/flight_modes_vtol/return.md | 22 ++--
docs/en/releases/main.md | 3 +
src/modules/navigator/rtl.cpp | 5 +-
src/modules/navigator/rtl.h | 3 +-
src/modules/navigator/rtl_direct.cpp | 24 ++++-
src/modules/navigator/rtl_direct.h | 7 +-
src/modules/navigator/test/test_RTL.cpp | 136 ++++++++++++++++++++++++
10 files changed, 213 insertions(+), 52 deletions(-)
diff --git a/docs/en/flight_modes/return.md b/docs/en/flight_modes/return.md
index 0ca5e71b576..5ffb6f26cff 100644
--- a/docs/en/flight_modes/return.md
+++ b/docs/en/flight_modes/return.md
@@ -57,7 +57,7 @@ At high level these are:
- [Closest mission landing or reverse mission return](#rtl_type_4) (`RTL_TYPE=4`): Like `RTL_TYPE=2`, but chooses between mission landing and reverse mission path based on which requires fewer waypoints to traverse.
Rally points are not considered.
- [Rally point return](#rtl_type_5) (`RTL_TYPE=5`): Return directly to the closest rally point, ignoring home and mission landing.
- If no rally point is defined, land at the current position.
+ If no rally point is defined, land at the current position (a fixed-wing vehicle circles there instead).
- [Battery-aware home priority return](#rtl_type_6) (`RTL_TYPE=6`): Return to home if the estimated flight time is within the remaining battery time, otherwise return to the closest rally point.
Falls back to the closest safe point (home or rally) if the remaining battery time is unknown/unavailable.
@@ -71,7 +71,7 @@ In this return type the vehicle:
- Ascends to a safe [minimum return altitude](#minimum-return-altitude) (above any expected obstacles).
- Flies to the home position or a rally point (whichever is closest), preferring a [geofence-aware](#geofence_awareness) horizontal path over a direct path where possible.
-- On [arrival](#loiter-landing-at-destination) descends to "descent altitude" and waits for a configurable time.
+- On [arrival](#loiter-landing-at-destination) descends to "descent altitude" and waits for a configurable time (a multicopter with the default time of 0 lands directly).
This time may be used to deploy landing gear.
- Lands or waits (this depends on landing parameters),
By default an MC or VTOL in MC mode will land and a fixed-wing vehicle circles at the descent altitude.
@@ -188,6 +188,7 @@ In this return type, the vehicle ignores home and mission landing patterns entir
::: info
If no rally points are defined the vehicle will land at its current position instead of returning to home. There is a pre-flight check that prevents taking off without any rally point if this RTL_TYPE is selected.
+A fixed-wing vehicle does not land there: it circles over that position, because the altitude it is flying at is not a landing altitude.
This type is intended for use cases where only pre-approved rally points are acceptable landing destinations.
:::
@@ -314,7 +315,7 @@ If `RTL_LAND_DELAY=-1` it will loiter indefinitely.
The default landing configuration is vehicle dependent:
-- Multicopters are configured to hover for a short while, deploying landing gear if needed, and then land.
+- Multicopters are configured to land without waiting at the descent altitude.
- Fixed-wing vehicles use a return mode with a [mission landing pattern](#mission-landing-pattern), as this enables automated landing.
If not using a mission landing, the default configuration is to loiter indefinitely, so the user can take over and manually land.
- VTOLs in MC mode fly and land exactly as a multicopter.
@@ -333,17 +334,17 @@ For this reason fixed-wing vehicles are configured to use [Mission landing/reall
The Return parameters are listed in [Parameter Reference > Return Mode](../advanced_config/parameter_reference.md#return-mode) (and summarised below).
-| Parameter | Description |
-| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| [RTL_TYPE](../advanced_config/parameter_reference.md#RTL_TYPE) | Return mechanism (path and destination).
`0`: Return to a rally point or home (whichever is closest) via direct path.
`1`: Return to a rally point or the mission landing pattern start point (whichever is closest), via direct path. If neither mission landing or rally points are defined return home via a direct path. If the destination is a mission landing pattern, follow the pattern to land.
`2`: Use the mission path to landing while skipping DO_JUMP and other non-position mission items if a landing pattern is defined, otherwise fast-reverse to home with the same traversal rules. Ignore rally points. Fly direct to home if no mission plan is defined.
`3`: Return via direct path to closest destination: home, start of mission landing pattern or safe point. If the destination is a mission landing pattern, follow the pattern to land.
`4`: Like type 2, but selects between mission landing (fast-forward) and reverse mission path based on which requires fewer waypoints from the current position. Rally points not considered. Fly direct to home if no mission is defined.
`5`: Return via direct path to closest rally point. If no rally points are defined, land at current position.
`6`: Return to home if estimated flight time to home is less than remaining battery time, otherwise return to closest rally point. Falls back to closest safe point (home or rally) if battery time remaining is unavailable. |
-| [RTL_RETURN_ALT](../advanced_config/parameter_reference.md#RTL_RETURN_ALT) | Return altitude in meters (default: 60m) when [RTL_CONE_ANG](../advanced_config/parameter_reference.md#RTL_CONE_ANG) is 0. If already above this value the vehicle will return at its current altitude. |
-| [RTL_DESCEND_ALT](../advanced_config/parameter_reference.md#RTL_DESCEND_ALT) | Altitude above the destination used for the final descent before landing or loitering (default: 30m). |
-| [RTL_LAND_DELAY](../advanced_config/parameter_reference.md#RTL_LAND_DELAY) | Time to wait at `RTL_DESCEND_ALT` before landing (default: 0.5s) - by default this period is short so that the vehicle will simply slow and then land immediately. If set to -1 the system will loiter at `RTL_DESCEND_ALT` rather than landing. The delay is provided to allow you to configure time for landing gear to be deployed (triggered automatically). |
-| [RTL_MIN_DIST](../advanced_config/parameter_reference.md#RTL_MIN_DIST) | Within this distance from the return destination, the return altitude is calculated from the "cone" rather than directly from `RTL_RETURN_ALT`. |
-| [RTL_CONE_ANG](../advanced_config/parameter_reference.md#RTL_CONE_ANG) | Half-angle of the cone that defines the vehicle return altitude. Values (in degrees): `0`, `25`, `45`, `65`, `80`, `90`. Note that `0` is "no cone" (always return at `RTL_RETURN_ALT` or higher), while `90` indicates an almost vertical cone, so the vehicle generally returns at its current altitude when close to the destination. The return altitude may still be constrained to avoid flying too low while approaching the destination. |
-| [RTL_APPR_FORCE](../advanced_config/parameter_reference.md#RTL_APPR_FORCE) | [VTOL FW only] If set, home or rally-point return destinations are only considered when a valid VTOL approach loiter is defined for that landing location. Mission landing patterns are unaffected. |
-| [MAN_OVERRIDE_SPD](../advanced_config/parameter_reference.md#MAN_OVERRIDE_SPD) | Speed (normalized stick travel per second) above which moving the sticks controlling a multicopter (or VTOL in hover) gives control back to the pilot by switching to [Position mode](../flight_modes_mc/position.md) (or Altitude mode if position is unavailable). At the default 1 a half-stick movement in ~0.5 s triggers it; lower is more sensitive. A stick held statically has zero speed and will not trigger. Set to -1 to disable. |
-| [RTL_LOITER_RAD](../advanced_config/parameter_reference.md#RTL_LOITER_RAD) | [Fixed-wing Only] The radius of the loiter circle (at [RTL_LAND_DELAY](#RTL_LAND_DELAY)). |
-| [MIS_TKO_LAND_REQ](../advanced_config/parameter_reference.md#MIS_TKO_LAND_REQ) | Specify whether a mission landing or takeoff pattern is _required_. Generally fixed-wing vehicles set this to require a landing pattern but VTOL do not. |
-| [RTL_TIME_FACTOR](../advanced_config/parameter_reference.md#RTL_TIME_FACTOR) | Return time estimate safety factor. |
-| [RTL_TIME_MARGIN](../advanced_config/parameter_reference.md#RTL_TIME_MARGIN) | Return time estimate safety margin. |
+| Parameter | Description |
+| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| [RTL_TYPE](../advanced_config/parameter_reference.md#RTL_TYPE) | Return mechanism (path and destination).
`0`: Return to a rally point or home (whichever is closest) via direct path.
`1`: Return to a rally point or the mission landing pattern start point (whichever is closest), via direct path. If neither mission landing or rally points are defined return home via a direct path. If the destination is a mission landing pattern, follow the pattern to land.
`2`: Use the mission path to landing while skipping DO_JUMP and other non-position mission items if a landing pattern is defined, otherwise fast-reverse to home with the same traversal rules. Ignore rally points. Fly direct to home if no mission plan is defined.
`3`: Return via direct path to closest destination: home, start of mission landing pattern or safe point. If the destination is a mission landing pattern, follow the pattern to land.
`4`: Like type 2, but selects between mission landing (fast-forward) and reverse mission path based on which requires fewer waypoints from the current position. Rally points not considered. Fly direct to home if no mission is defined.
`5`: Return via direct path to closest rally point. If no rally points are defined, land at current position (a fixed-wing vehicle circles there).
`6`: Return to home if estimated flight time to home is less than remaining battery time, otherwise return to closest rally point. Falls back to closest safe point (home or rally) if battery time remaining is unavailable. |
+| [RTL_RETURN_ALT](../advanced_config/parameter_reference.md#RTL_RETURN_ALT) | Return altitude in meters (default: 60m) when [RTL_CONE_ANG](../advanced_config/parameter_reference.md#RTL_CONE_ANG) is 0. If already above this value the vehicle will return at its current altitude. |
+| [RTL_DESCEND_ALT](../advanced_config/parameter_reference.md#RTL_DESCEND_ALT) | Altitude above the destination used for the final descent before landing or loitering (default: 30m). |
+| [RTL_LAND_DELAY](../advanced_config/parameter_reference.md#RTL_LAND_DELAY) | Time to wait at `RTL_DESCEND_ALT` before landing (default: 0 s, -1 on fixed-wing airframes). If set to -1 the system will loiter at `RTL_DESCEND_ALT` rather than landing. The delay is provided to allow you to configure time for landing gear to be deployed (triggered automatically). |
+| [RTL_MIN_DIST](../advanced_config/parameter_reference.md#RTL_MIN_DIST) | Within this distance from the return destination, the return altitude is calculated from the "cone" rather than directly from `RTL_RETURN_ALT`. |
+| [RTL_CONE_ANG](../advanced_config/parameter_reference.md#RTL_CONE_ANG) | Half-angle of the cone that defines the vehicle return altitude. Values (in degrees): `0`, `25`, `45`, `65`, `80`, `90`. Note that `0` is "no cone" (always return at `RTL_RETURN_ALT` or higher), while `90` indicates an almost vertical cone, so the vehicle generally returns at its current altitude when close to the destination. The return altitude may still be constrained to avoid flying too low while approaching the destination. |
+| [RTL_APPR_FORCE](../advanced_config/parameter_reference.md#RTL_APPR_FORCE) | [VTOL FW only] If set, home or rally-point return destinations are only considered when a valid VTOL approach loiter is defined for that landing location. Mission landing patterns are unaffected. |
+| [MAN_OVERRIDE_SPD](../advanced_config/parameter_reference.md#MAN_OVERRIDE_SPD) | Speed (normalized stick travel per second) above which moving the sticks controlling a multicopter (or VTOL in hover) gives control back to the pilot by switching to [Position mode](../flight_modes_mc/position.md) (or Altitude mode if position is unavailable). At the default 1 a half-stick movement in ~0.5 s triggers it; lower is more sensitive. A stick held statically has zero speed and will not trigger. Set to -1 to disable. |
+| [RTL_LOITER_RAD](../advanced_config/parameter_reference.md#RTL_LOITER_RAD) | [Fixed-wing Only] The radius of the loiter circle (at [RTL_LAND_DELAY](#RTL_LAND_DELAY)). |
+| [MIS_TKO_LAND_REQ](../advanced_config/parameter_reference.md#MIS_TKO_LAND_REQ) | Specify whether a mission landing or takeoff pattern is _required_. Generally fixed-wing vehicles set this to require a landing pattern but VTOL do not. |
+| [RTL_TIME_FACTOR](../advanced_config/parameter_reference.md#RTL_TIME_FACTOR) | Return time estimate safety factor. |
+| [RTL_TIME_MARGIN](../advanced_config/parameter_reference.md#RTL_TIME_MARGIN) | Return time estimate safety margin. |
diff --git a/docs/en/flight_modes_fw/return.md b/docs/en/flight_modes_fw/return.md
index b2d0dc181e8..6bbbca7875a 100644
--- a/docs/en/flight_modes_fw/return.md
+++ b/docs/en/flight_modes_fw/return.md
@@ -69,14 +69,14 @@ The Return parameters are listed in [Parameter Reference > Return Mode](../advan
If using a mission landing, only the [RTL_RETURN_ALT](#RTL_RETURN_ALT) and [RTL_DESCEND_ALT](#RTL_DESCEND_ALT) are relevant.
The others are relevant if the destination is a rally point or the home location.
-| Parameter | Description |
-| ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| [RTL_TYPE](../advanced_config/parameter_reference.md#RTL_TYPE) | Return type. |
-| [RTL_RETURN_ALT](../advanced_config/parameter_reference.md#RTL_RETURN_ALT) | Return altitude in meters (default: 60m)If already above this value the vehicle will return at its current altitude. |
-| [RTL_DESCEND_ALT](../advanced_config/parameter_reference.md#RTL_DESCEND_ALT) | Minimum return altitude and altitude at which the vehicle will slow or stop its initial descent from a higher return altitude (default: 30m) |
-| [RTL_LAND_DELAY](../advanced_config/parameter_reference.md#RTL_LAND_DELAY) | Time to hover at `RTL_DESCEND_ALT` before landing (default: 0.5s) -by default this period is short so that the vehicle will simply slow and then land immediately. If set to -1 the system will loiter at `RTL_DESCEND_ALT` rather than landing. The delay is provided to allow you to configure time for landing gear to be deployed (triggered automatically). |
-| [RTL_LOITER_RAD](../advanced_config/parameter_reference.md#RTL_LOITER_RAD) | [Fixed-wing Only] The radius of the loiter circle (at [RTL_LAND_DELAY](#RTL_LAND_DELAY)). |
-| [MIS_TKO_LAND_REQ](../advanced_config/parameter_reference.md#MIS_TKO_LAND_REQ) | Specify whether a mission landing or takeoff pattern is required. Fixed wings generally require this. |
+| Parameter | Description |
+| ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| [RTL_TYPE](../advanced_config/parameter_reference.md#RTL_TYPE) | Return type. |
+| [RTL_RETURN_ALT](../advanced_config/parameter_reference.md#RTL_RETURN_ALT) | Return altitude in meters (default: 60m)If already above this value the vehicle will return at its current altitude. |
+| [RTL_DESCEND_ALT](../advanced_config/parameter_reference.md#RTL_DESCEND_ALT) | Minimum return altitude and altitude at which the vehicle will slow or stop its initial descent from a higher return altitude (default: 30m) |
+| [RTL_LAND_DELAY](../advanced_config/parameter_reference.md#RTL_LAND_DELAY) | Time to loiter at `RTL_DESCEND_ALT` before landing (default: -1 on fixed-wing airframes). If set to -1 the system will loiter at `RTL_DESCEND_ALT` rather than landing. The delay is provided to allow you to configure time for landing gear to be deployed (triggered automatically). |
+| [RTL_LOITER_RAD](../advanced_config/parameter_reference.md#RTL_LOITER_RAD) | [Fixed-wing Only] The radius of the loiter circle (at [RTL_LAND_DELAY](#RTL_LAND_DELAY)). |
+| [MIS_TKO_LAND_REQ](../advanced_config/parameter_reference.md#MIS_TKO_LAND_REQ) | Specify whether a mission landing or takeoff pattern is required. Fixed wings generally require this. |
## See Also
diff --git a/docs/en/flight_modes_mc/return.md b/docs/en/flight_modes_mc/return.md
index c2ca362a5ff..cd919e02785 100644
--- a/docs/en/flight_modes_mc/return.md
+++ b/docs/en/flight_modes_mc/return.md
@@ -5,7 +5,7 @@
The _Return_ flight mode is used to _fly a vehicle to safety_ on an unobstructed path to a safe destination, where it can land.
Multicopters use a [home/rally point return type](../flight_modes/return.md#rtl_type_0) by default.
-In this return type vehicles ascend to a safe altitude above obstructions if needed, fly to the closest safe landing point (a rally point or the home position) via the shortest horizontal [geofence-aware path](../flight_modes/return.md#geofence_awareness), descend to the "descent altitude", wait briefly, and then land.
+In this return type vehicles ascend to a safe altitude above obstructions if needed, fly to the closest safe landing point (a rally point or the home position) via the shortest horizontal [geofence-aware path](../flight_modes/return.md#geofence_awareness), and then land.
The return altitude, descent altitude, and landing delay are normally set to conservative "safe" values, but can be changed if needed.
Multicopter supports the [other PX4 return types](../flight_modes/return.md#return_types), including mission landing, mission path and closest safe destination.
@@ -35,9 +35,8 @@ For this return type the copter:
The vehicle maintains its initial altitude if that is higher than the minimum return altitude.
- Flies via a constant-altitude path to the safe landing point, which will be the nearest of any rally points and the home position.
The path is chosen to be the shortest horizontal [geofence-aware path](../flight_modes/return.md#geofence_awareness).
-- On arrival at its destination, it rapidly descends to the "descent altitude" ([RTL_DESCEND_ALT](#RTL_DESCEND_ALT)).
-- It waits for a configurable time ([RTL_LAND_DELAY](#RTL_LAND_DELAY)), which may be used for deploying landing gear.
-- Then lands.
+- On arrival at its destination, it lands.
+ If [RTL_LAND_DELAY](#RTL_LAND_DELAY) is not 0 (the default), it first descends to the "descent altitude" ([RTL_DESCEND_ALT](#RTL_DESCEND_ALT)) and waits there for that time, which may be used for deploying landing gear.
@@ -67,7 +66,8 @@ This is useful when there are few obstacles near the destination, as it may redu
The cone affects the minimum return altitude if return mode is triggered within the cylinder defined by the maximum cone radius ([RTL_MIN_DIST](#RTL_MIN_DIST)) and `RTL_RETURN_ALT`: outside this cylinder `RTL_RETURN_ALT` is used.
Inside the cone, the vehicle returns at an altitude calculated from the cone geometry, up to `RTL_RETURN_ALT`.
-After reaching the destination, it descends to `RTL_DESCEND_ALT` (if above that altitude) before landing or loitering.
+After reaching the destination, it lands directly with the default `RTL_LAND_DELAY` of 0.
+Otherwise it first descends to `RTL_DESCEND_ALT` (if above that altitude) to wait or loiter.
For more information on this return type see [Home/Rally Point Return Type (RTL_TYPE=0)](../flight_modes/return.md#rtl_type_0)
@@ -80,8 +80,8 @@ The parameters that are relevant to multicopter (assuming the [RTL_TYPE](../adva
| Parameter | Description |
| ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [RTL_RETURN_ALT](../advanced_config/parameter_reference.md#RTL_RETURN_ALT) | Return altitude in meters (default: 60m) when [RTL_CONE_ANG](../advanced_config/parameter_reference.md#RTL_CONE_ANG) is 0. If already above this value the vehicle will return at its current altitude. |
-| [RTL_DESCEND_ALT](../advanced_config/parameter_reference.md#RTL_DESCEND_ALT) | Altitude above the destination used for the final descent before landing or loitering (default: 30m). |
-| [RTL_LAND_DELAY](../advanced_config/parameter_reference.md#RTL_LAND_DELAY) | Time to hover at `RTL_DESCEND_ALT` before landing (default: 0.5s) - by default this period is short so that the vehicle will simply slow and then land immediately. If set to -1 the system will loiter at `RTL_DESCEND_ALT` rather than landing. The delay is provided to allow you to configure time for landing gear to be deployed (triggered automatically). |
+| [RTL_DESCEND_ALT](../advanced_config/parameter_reference.md#RTL_DESCEND_ALT) | Altitude above the destination at which the vehicle waits or loiters before landing when `RTL_LAND_DELAY` is not 0 (default: 30m). |
+| [RTL_LAND_DELAY](../advanced_config/parameter_reference.md#RTL_LAND_DELAY) | Time to hover at `RTL_DESCEND_ALT` before landing (default: 0 s). If set to -1 the system will loiter at `RTL_DESCEND_ALT` rather than landing. The delay is provided to allow you to configure time for landing gear to be deployed (triggered automatically). |
| [RTL_MIN_DIST](../advanced_config/parameter_reference.md#RTL_MIN_DIST) | Within this distance from the home position, the return altitude is calculated from the "cone" rather than directly from `RTL_RETURN_ALT`. |
| [RTL_CONE_ANG](../advanced_config/parameter_reference.md#RTL_CONE_ANG) | Half-angle of the cone that defines the vehicle return altitude. Values (in degrees): `0`, `25`, `45`, `65`, `80`, `90`. Note that `0` is "no cone" (always return at `RTL_RETURN_ALT` or higher), while `90` indicates an almost vertical cone, so the vehicle generally returns at its current altitude when close to the destination. The return altitude may still be constrained to avoid flying too low while approaching the destination. |
| [MAN_OVERRIDE_SPD](../advanced_config/parameter_reference.md#MAN_OVERRIDE_SPD) | Speed (normalized stick travel per second) above which moving the sticks controlling a multicopter (or VTOL in hover) gives control back to the pilot by switching to [Position mode](../flight_modes_mc/position.md) (or Altitude mode if position is unavailable). At the default value of 1 a half-stick movement in ~0.5 s triggers it; lower is more sensitive. A stick held statically has zero speed and will not trigger. Set to -1 to disable. |
diff --git a/docs/en/flight_modes_vtol/return.md b/docs/en/flight_modes_vtol/return.md
index 52f4a07912a..c9c83da8d94 100644
--- a/docs/en/flight_modes_vtol/return.md
+++ b/docs/en/flight_modes_vtol/return.md
@@ -54,7 +54,7 @@ If returning as a fixed-wing, the vehicle:
See [VTOL Rally Point Approach Loiter](#vtol-rally-point-approach-loiters) below for information on how to define approach loiters (using [MAV_CMD_NAV_LOITER_TO_ALT](https://mavlink.io/en/messages/common.html#MAV_CMD_NAV_LOITER_TO_ALT) items in your _rally plan_).
- Loiter/spiral down to the approach altitude, or to [RTL_DESCEND_ALT](#RTL_DESCEND_ALT) above the destination if no approach altitude is defined.
- - Circle for a short time, as defined by [RTL_LAND_DELAY](#RTL_LAND_DELAY).
+ - Circle for [RTL_LAND_DELAY](#RTL_LAND_DELAY) (0 s by default).
- Fly from the approach loiter to the return destination (the rally point or home location).
- Transition to MC mode at the destination and land.
@@ -103,16 +103,16 @@ The Return parameters are listed in [Parameter Reference > Return Mode](../advan
If using a mission landing, only the [RTL_RETURN_ALT](#RTL_RETURN_ALT) and [RTL_DESCEND_ALT](#RTL_DESCEND_ALT) are relevant.
The others are relevant if the destination is a rally point or the home location.
-| Parameter | Description |
-| ----------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| [RTL_TYPE](../advanced_config/parameter_reference.md#RTL_TYPE) | Return type. |
-| [RTL_APPR_FORCE](../advanced_config/parameter_reference.md#RTL_APPR_FORCE) | [VTOL FW only] If set, PX4 only considers home or rally-point return destinations when a valid VTOL approach loiter is defined for that landing location. Mission landing patterns are unaffected. |
-| [RTL_RETURN_ALT](../advanced_config/parameter_reference.md#RTL_RETURN_ALT) | Return altitude in meters (default: 60m)If already above this value the vehicle will return at its current altitude. |
-| [RTL_CONE_ANG](../advanced_config/parameter_reference.md#RTL_CONE_ANG) | Half-angle of the cone that defines the vehicle return altitude. Values (in degrees): 0, 25, 45, 65, 80, 90. Note that 0 is "no cone" (always return at `RTL_RETURN_ALT` or higher), while 90 indicates that the vehicle must return at the current altitude or `RTL_DESCEND_ALT` (whichever is higher). |
-| [RTL_DESCEND_ALT](../advanced_config/parameter_reference.md#RTL_DESCEND_ALT) | Minimum return altitude and altitude at which the vehicle will slow or stop its initial descent from a higher return altitude (default: 30m) |
-| [RTL_LAND_DELAY](../advanced_config/parameter_reference.md#RTL_LAND_DELAY) | Time to hover at `RTL_DESCEND_ALT` before landing (default: 0.5s) -by default this period is short so that the vehicle will simply slow and then land immediately. If set to -1 the system will loiter at `RTL_DESCEND_ALT` rather than landing. The delay is provided to allow you to configure time for landing gear to be deployed (triggered automatically). |
-| [RTL_LOITER_RAD](../advanced_config/parameter_reference.md#RTL_LOITER_RAD) | [Fixed-wing Only] The radius of the loiter circle (at [RTL_LAND_DELAY](#RTL_LAND_DELAY). |
-| [MIS_TKO_LAND_REQ](../advanced_config/parameter_reference.md#MIS_TKO_LAND_REQ) | Specify whether a mission landing or takeoff pattern is _required_. Generally fixed-wing vehicles set this to require a landing pattern but VTOL do not. |
+| Parameter | Description |
+| ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| [RTL_TYPE](../advanced_config/parameter_reference.md#RTL_TYPE) | Return type. |
+| [RTL_APPR_FORCE](../advanced_config/parameter_reference.md#RTL_APPR_FORCE) | [VTOL FW only] If set, PX4 only considers home or rally-point return destinations when a valid VTOL approach loiter is defined for that landing location. Mission landing patterns are unaffected. |
+| [RTL_RETURN_ALT](../advanced_config/parameter_reference.md#RTL_RETURN_ALT) | Return altitude in meters (default: 60m)If already above this value the vehicle will return at its current altitude. |
+| [RTL_CONE_ANG](../advanced_config/parameter_reference.md#RTL_CONE_ANG) | Half-angle of the cone that defines the vehicle return altitude. Values (in degrees): 0, 25, 45, 65, 80, 90. Note that 0 is "no cone" (always return at `RTL_RETURN_ALT` or higher), while 90 indicates that the vehicle must return at the current altitude or `RTL_DESCEND_ALT` (whichever is higher). |
+| [RTL_DESCEND_ALT](../advanced_config/parameter_reference.md#RTL_DESCEND_ALT) | Minimum return altitude and altitude at which the vehicle will slow or stop its initial descent from a higher return altitude (default: 30m) |
+| [RTL_LAND_DELAY](../advanced_config/parameter_reference.md#RTL_LAND_DELAY) | Time to wait at `RTL_DESCEND_ALT` before landing (default: 0 s). If set to -1 the system will loiter at `RTL_DESCEND_ALT` rather than landing. The delay is provided to allow you to configure time for landing gear to be deployed (triggered automatically). |
+| [RTL_LOITER_RAD](../advanced_config/parameter_reference.md#RTL_LOITER_RAD) | [Fixed-wing Only] The radius of the loiter circle (at [RTL_LAND_DELAY](#RTL_LAND_DELAY). |
+| [MIS_TKO_LAND_REQ](../advanced_config/parameter_reference.md#MIS_TKO_LAND_REQ) | Specify whether a mission landing or takeoff pattern is _required_. Generally fixed-wing vehicles set this to require a landing pattern but VTOL do not. |
## See Also
diff --git a/docs/en/releases/main.md b/docs/en/releases/main.md
index 96726670e48..65ae8890490 100644
--- a/docs/en/releases/main.md
+++ b/docs/en/releases/main.md
@@ -79,6 +79,9 @@ Please continue reading for [upgrade instructions](#upgrade-guide).
- Return mode now stops in the cycle it is left, not one cycle later. Before, a precision landing selected right after Return was partly reset, and Return selected again after one cycle of Hold hovered in place instead of returning. ([PX4-Autopilot#29444](https://github.com/PX4/PX4-Autopilot/pull/29444))
- If a mission-based Return cannot allocate its executor, it now flies directly to its destination, the mission landing point or Home, and tells the pilot "Return: cannot follow the mission; flying directly". Before, Return did nothing. ([PX4-Autopilot#29444](https://github.com/PX4/PX4-Autopilot/pull/29444))
- Return no longer reports a stale VTOL landing approach in `rtl_status`, for example one found before an [RTL_TYPE](../advanced_config/parameter_reference.md#RTL_TYPE) change. With [MIS_TKO_LAND_REQ](../advanced_config/parameter_reference.md#MIS_TKO_LAND_REQ) = 5, a mission without a landing, uploaded or started in the air, can therefore now be rejected where it passed before. ([PX4-Autopilot#29444](https://github.com/PX4/PX4-Autopilot/pull/29444))
+- With [RTL_TYPE](../advanced_config/parameter_reference.md#RTL_TYPE) = 5 and no rally point, a fixed-wing vehicle now circles where Return started, whatever [RTL_LAND_DELAY](../advanced_config/parameter_reference.md#RTL_LAND_DELAY) is.
+ It used to land there when `RTL_LAND_DELAY` was not -1, with the altitude it was flying at as the ground altitude.
+ VTOLs and multicopters still follow `RTL_LAND_DELAY`.
### Hardware Support
diff --git a/src/modules/navigator/rtl.cpp b/src/modules/navigator/rtl.cpp
index d565ae22cc2..180886a7bb7 100644
--- a/src/modules/navigator/rtl.cpp
+++ b/src/modules/navigator/rtl.cpp
@@ -426,7 +426,8 @@ void RTL::setRtlTypeAndDestination()
}
_rtl_direct.setRtlAlt(rtl_alt);
- _rtl_direct.setRtlPosition(destination, landing_loiter);
+ _rtl_direct.setRtlPosition(destination, landing_loiter,
+ destination_type == DestinationType::DESTINATION_TYPE_CURRENT_POSITION);
_rtl_type = new_rtl_type;
@@ -640,7 +641,7 @@ void RTL::findRtlDestination(DestinationType &destination_type, PositionYawSetpo
destination.alt = _global_pos_sub.get().alt;
destination.lat = _global_pos_sub.get().lat;
destination.lon = _global_pos_sub.get().lon;
- destination_type = DestinationType::DESTINATION_TYPE_SAFE_POINT;
+ destination_type = DestinationType::DESTINATION_TYPE_CURRENT_POSITION;
}
}
diff --git a/src/modules/navigator/rtl.h b/src/modules/navigator/rtl.h
index 9b6728fcad8..54b419063ef 100644
--- a/src/modules/navigator/rtl.h
+++ b/src/modules/navigator/rtl.h
@@ -98,7 +98,8 @@ private:
enum class DestinationType {
DESTINATION_TYPE_HOME,
DESTINATION_TYPE_MISSION_LAND,
- DESTINATION_TYPE_SAFE_POINT
+ DESTINATION_TYPE_SAFE_POINT,
+ DESTINATION_TYPE_CURRENT_POSITION
};
/**
diff --git a/src/modules/navigator/rtl_direct.cpp b/src/modules/navigator/rtl_direct.cpp
index 0b419fd5a22..01c3a63389c 100644
--- a/src/modules/navigator/rtl_direct.cpp
+++ b/src/modules/navigator/rtl_direct.cpp
@@ -150,13 +150,15 @@ void RtlDirect::on_inactive()
_vehicle_status_sub.update();
}
-void RtlDirect::setRtlPosition(const PositionYawSetpoint &rtl_position, const loiter_point_s &loiter_pos)
+void RtlDirect::setRtlPosition(const PositionYawSetpoint &rtl_position, const loiter_point_s &loiter_pos,
+ bool destination_is_current_position)
{
parameters_update();
// Only allow to set a new approach if the mode is not activated yet.
if (!isActive()) {
_destination = rtl_position;
+ _destination_is_current_position = destination_is_current_position;
_force_heading = false;
_land_approach = sanitizeLandApproach(loiter_pos);
@@ -402,9 +404,9 @@ void RtlDirect::set_rtl_item()
.yaw = !_param_wv_en.get() ? _destination.yaw : NAN, // set final yaw if weather vane is disabled
};
- setLoiterHoldMissionItem(_mission_item, pos_yaw_sp, _param_rtl_land_delay.get(), _land_approach.loiter_radius_m);
+ setLoiterHoldMissionItem(_mission_item, pos_yaw_sp, landDelay(), _land_approach.loiter_radius_m);
- if (_param_rtl_land_delay.get() < -FLT_EPSILON) {
+ if (landDelay() < -FLT_EPSILON) {
mavlink_log_info(_navigator->get_mavlink_log_pub(), "Return: completed, loitering\t");
events::send(events::ID("rtl_completed_loiter"), events::Log::Info, "Return: completed, loitering");
@@ -613,9 +615,9 @@ rtl_time_estimate_s RtlDirect::calc_rtl_time_estimate()
// FALLTHROUGH
case RTLState::LOITER_HOLD:
// Add land delay (the short pause for deploying landing gear)
- _rtl_time_estimator.addWait(_param_rtl_land_delay.get());
+ _rtl_time_estimator.addWait(landDelay());
- if (_param_rtl_land_delay.get() < -FLT_EPSILON) { // Set to loiter infinitely and not land. Stop calculation here
+ if (landDelay() < -FLT_EPSILON) { // Set to loiter infinitely and not land. Stop calculation here
break;
}
@@ -691,6 +693,18 @@ void RtlDirect::parameters_update()
}
}
+float RtlDirect::landDelay() const
+{
+ // The current airborne altitude is not a landing altitude. MC and VTOL can descend until touchdown,
+ // but a fixed-wing landing would use this altitude to trigger the flare and idle the throttle in flight.
+ if (_destination_is_current_position && !_vehicle_status_sub.get().is_vtol
+ && _vehicle_status_sub.get().vehicle_type == vehicle_status_s::VEHICLE_TYPE_FIXED_WING) {
+ return -1.f;
+ }
+
+ return _param_rtl_land_delay.get();
+}
+
loiter_point_s RtlDirect::sanitizeLandApproach(const loiter_point_s &land_approach) const
{
loiter_point_s sanitized_land_approach{land_approach};
diff --git a/src/modules/navigator/rtl_direct.h b/src/modules/navigator/rtl_direct.h
index b8a8f74014c..a609b428aa8 100644
--- a/src/modules/navigator/rtl_direct.h
+++ b/src/modules/navigator/rtl_direct.h
@@ -110,7 +110,8 @@ public:
void setReturnAltMin(bool min) { _enforce_rtl_alt = min; }
void setRtlAlt(float alt) {_rtl_alt = alt;};
- void setRtlPosition(const PositionYawSetpoint &position, const loiter_point_s &loiter_pos);
+ void setRtlPosition(const PositionYawSetpoint &position, const loiter_point_s &loiter_pos,
+ bool destination_is_current_position = false);
bool isLanding() { return (_rtl_state != RTLState::IDLE) && (_rtl_state >= RTLState::LOITER_DOWN);};
@@ -170,10 +171,14 @@ private:
*/
bool geofenceAvoidanceActive() const;
+ /** RTL_LAND_DELAY, or indefinite where a pure fixed-wing cannot land. */
+ float landDelay() const;
+
void setLoiterPosition();
bool _enforce_rtl_alt{false};
bool _force_heading{false};
+ bool _destination_is_current_position{false}; ///< No landing altitude is known for a stop at the current position.
position_setpoint_s _setpoint_on_activation{}; ///< snapshot of the current setpoint taken before reset on activation, used to continue an established loiter through the climb
RtlTimeEstimator _rtl_time_estimator;
diff --git a/src/modules/navigator/test/test_RTL.cpp b/src/modules/navigator/test/test_RTL.cpp
index 6b4e338b17b..02028f0b7e7 100644
--- a/src/modules/navigator/test/test_RTL.cpp
+++ b/src/modules/navigator/test/test_RTL.cpp
@@ -52,9 +52,11 @@
#include
#include
#include
+#include
#include
#include
#include
+#include
#include
#include
#include
@@ -203,6 +205,13 @@ struct ReadFailureCase {
uint8_t expected_count;
};
+struct StopAtCurrentPositionCase {
+ const char *test_name;
+ bool is_vtol;
+ uint8_t vehicle_type;
+ bool lands;
+};
+
} // namespace
class RTLTestPeer : public RTL
@@ -262,6 +271,9 @@ public:
_param_rtl_type.set(rtl_type);
run(true);
}
+
+ // the estimate RTL publishes while the return type is a direct Return
+ rtl_time_estimate_s directEstimateForTest() { return _rtl_direct.calc_rtl_time_estimate(); }
};
template
@@ -2642,3 +2654,127 @@ TEST_F(RTLTest, ArmingRechecksTheMissionWithTheLatestHome)
EXPECT_TRUE(_dataman_client.clearSync(DM_KEY_WAYPOINTS_OFFBOARD_0));
EXPECT_TRUE(_dataman_client.clearSync(DM_KEY_FENCE_POINTS_STATE));
}
+
+class RTLStopAtCurrentPositionTest :
+ public RTLTest,
+ public ::testing::WithParamInterface
+{
+};
+
+// WHY: RTL_TYPE 5 without a rally point stops where the vehicle is, so the destination altitude is the
+// airborne altitude. A fixed-wing landing there would flare in the air.
+// WHAT: A pure fixed-wing circles above the stop instead of landing; the other vehicles land there.
+TEST_P(RTLStopAtCurrentPositionTest, RallyPointReturnWithoutRallyPointLandsOnlyVehiclesThatCanHover)
+{
+ const StopAtCurrentPositionCase &test_case = GetParam();
+
+ auto setVehicleType = [&](bool is_vtol, uint8_t vehicle_type) {
+ publishVehicleStatus(is_vtol, vehicle_type, vehicle_status_s::NAVIGATION_STATE_AUTO_RTL);
+ _navigator.get_vstatus()->is_vtol = is_vtol;
+ _navigator.get_vstatus()->vehicle_type = vehicle_type;
+ };
+
+ auto setPosition = [&](double lat, double lon, float alt) {
+ publishGlobalPosition(lat, lon, alt);
+ _navigator.get_global_position()->lat = lat;
+ _navigator.get_global_position()->lon = lon;
+ _navigator.get_global_position()->alt = alt;
+ };
+
+ // GIVEN: RTL_TYPE 5 with no rally point and the default RTL_LAND_DELAY of 0, while flying 2 km from home
+ int32_t rtl_type = 5; // RTL_TYPE_SAFE_POINT_DIRECT
+ param_set(param_find("RTL_TYPE"), &rtl_type);
+ _rtl.updateParamsForTest();
+ loadSafePointsIntoRouteCache({});
+
+ const PositionYawSetpoint stop = makePositionYawSetpointFromOffset(kBaseLat, kBaseLon, 2000.f, 0.f, kAlt + 100.f);
+ setVehicleType(test_case.is_vtol, test_case.vehicle_type);
+ setPosition(stop.lat, stop.lon, stop.alt);
+ publishLandDetected(false);
+ _navigator.get_land_detected()->landed = false;
+
+ uORB::Subscription vehicle_command_sub{ORB_ID(vehicle_command)};
+ vehicle_command_s vehicle_command{};
+
+ while (vehicle_command_sub.update(&vehicle_command)) {}
+
+ // WHEN: Return starts and the vehicle reaches every setpoint it gets
+ _rtl.on_activation();
+ ASSERT_EQ(_rtl.rtlTypeForTest(), RTL::RtlType::RTL_DIRECT);
+ const position_setpoint_s ¤t = _navigator.get_position_setpoint_triplet()->current;
+
+ for (int cycle = 0; (cycle < 20) && (current.type != position_setpoint_s::SETPOINT_TYPE_LAND); ++cycle) {
+ ASSERT_TRUE(current.valid);
+ setPosition(current.lat, current.lon, current.alt);
+
+ // a VTOL completes the back transition it is commanded
+ while (vehicle_command_sub.update(&vehicle_command)) {
+ if (vehicle_command.command == vehicle_command_s::VEHICLE_CMD_DO_VTOL_TRANSITION) {
+ setVehicleType(true, vehicle_status_s::VEHICLE_TYPE_ROTARY_WING);
+ }
+ }
+
+ _rtl.on_active();
+ }
+
+ // THEN: Vehicles that can hover land at the stop, a pure fixed-wing circles above it indefinitely
+ EXPECT_NEAR(current.lat, stop.lat, 1e-7);
+ EXPECT_NEAR(current.lon, stop.lon, 1e-7);
+
+ if (test_case.lands) {
+ EXPECT_EQ(current.type, position_setpoint_s::SETPOINT_TYPE_LAND);
+
+ } else {
+ float descend_alt = NAN;
+ param_get(param_find("RTL_DESCEND_ALT"), &descend_alt);
+ navigator_mission_item_s mission_item{};
+ uORB::Subscription{ORB_ID(navigator_mission_item)}.copy(&mission_item);
+ EXPECT_EQ(current.type, position_setpoint_s::SETPOINT_TYPE_LOITER);
+ EXPECT_FLOAT_EQ(current.alt, stop.alt + descend_alt);
+ EXPECT_EQ(mission_item.nav_cmd, NAV_CMD_LOITER_UNLIMITED);
+ }
+}
+
+INSTANTIATE_TEST_SUITE_P(
+ RTL,
+ RTLStopAtCurrentPositionTest,
+ ::testing::Values(
+ StopAtCurrentPositionCase{"FixedWing", false, vehicle_status_s::VEHICLE_TYPE_FIXED_WING, false},
+ StopAtCurrentPositionCase{"Multicopter", false, vehicle_status_s::VEHICLE_TYPE_ROTARY_WING, true},
+ StopAtCurrentPositionCase{"VtolFixedWing", true, vehicle_status_s::VEHICLE_TYPE_FIXED_WING, true},
+ StopAtCurrentPositionCase{"VtolRotaryWing", true, vehicle_status_s::VEHICLE_TYPE_ROTARY_WING, true}),
+ [](const ::testing::TestParamInfo ¶m_info)
+{
+ return std::string(param_info.param.test_name);
+});
+
+// WHY: A stop that never lands must not count a landing in the remaining time estimate.
+// WHAT: The RTL_TYPE 5 stop of a pure fixed-wing has the same estimate with RTL_LAND_DELAY 0 as with -1.
+TEST_F(RTLTest, RallyPointReturnWithoutRallyPointEstimatesNoFixedWingLanding)
+{
+ // GIVEN: RTL_TYPE 5 with no rally point, while a pure fixed-wing flies 2 km from home
+ int32_t rtl_type = 5; // RTL_TYPE_SAFE_POINT_DIRECT
+ param_set(param_find("RTL_TYPE"), &rtl_type);
+ loadSafePointsIntoRouteCache({});
+
+ const PositionYawSetpoint stop = makePositionYawSetpointFromOffset(kBaseLat, kBaseLon, 2000.f, 0.f, kAlt + 100.f);
+ publishVehicleStatus(false, vehicle_status_s::VEHICLE_TYPE_FIXED_WING);
+ publishGlobalPosition(stop.lat, stop.lon, stop.alt);
+ publishLandDetected(false);
+
+ auto estimateWithLandDelay = [&](float land_delay) {
+ param_set(param_find("RTL_LAND_DELAY"), &land_delay);
+ RTLTestPeer rtl{&_navigator}; // reads the parameters on construction
+ rtl.on_inactive();
+ rtl.decideRtlTypeForTest();
+ return rtl.directEstimateForTest();
+ };
+
+ // WHEN: the inactive Return estimates its time with RTL_LAND_DELAY 0 and with -1
+ const rtl_time_estimate_s no_delay = estimateWithLandDelay(0.f);
+ const rtl_time_estimate_s hold = estimateWithLandDelay(-1.f);
+
+ // THEN: both end at the hold
+ ASSERT_TRUE(no_delay.valid && hold.valid);
+ EXPECT_FLOAT_EQ(no_delay.time_estimate, hold.time_estimate);
+}