mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-07-26 16:28:06 +08:00
feat(FlightTaskAuto): manual control yaw override during Auto modes (#27691)
* feat(FlightTaskAuto): add RC yaw override during Auto modes * feat(FlightTaskAuto): disengage RC yaw nudge on flight-mode switch * docs: document MPC_AUTO_RC_YAW in MC Auto mode pages Describe the RC yaw nudge (MPC_AUTO_RC_YAW) on the Mission page. Add parameter rows to the Hold and Land pages where MPC_LAND_RC_HELP takes precedence over it for yaw, and document MPC_LAND_RC_HELP there too. * feat(FlightTaskAuto): updated param description to warn against COM_RC_OVERRIDE disabled The long description recommends to have a switch on the RC to change to Position mode * fix(FlightTaskAuto): unified yaw nudging with new MPC_AUTO_NUDGING parameter * docs(FlightTaskAuto): MPC_AUTO_RC_YAW and MPC_LAND_RC_HELP parameters were replaced by the unified MPC_AUTO_NUDGING bitmask * fix(parameters): migrate MPC_LAND_RC_HELP to MPC_AUTO_NUDGING bit 1 * docs(1.18): move stick override and add nudging changes --------- Co-authored-by: Matthias Grob <maetugr@gmail.com>
This commit is contained in:
@@ -39,6 +39,7 @@ Hold mode behaviour can be configured using the parameters below.
|
|||||||
| ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| <a id="NAV_MIN_LTR_ALT"></a>[NAV_MIN_LTR_ALT](../advanced_config/parameter_reference.md#NAV_MIN_LTR_ALT) | This is the minimum altitude above Home the system will always obey in Hold mode if switched into this mode without specifying an altitude (e.g. through switch on RC). |
|
| <a id="NAV_MIN_LTR_ALT"></a>[NAV_MIN_LTR_ALT](../advanced_config/parameter_reference.md#NAV_MIN_LTR_ALT) | This is the minimum altitude above Home the system will always obey in Hold mode if switched into this mode without specifying an altitude (e.g. through switch on RC). |
|
||||||
| <a id="MAN_OVERRIDE_SPD"></a>[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. <Badge type="tip" text="PX4 v1.18" /> |
|
| <a id="MAN_OVERRIDE_SPD"></a>[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. <Badge type="tip" text="PX4 v1.18" /> |
|
||||||
|
| <a id="MPC_AUTO_NUDGING"></a>[MPC_AUTO_NUDGING](../advanced_config/parameter_reference.md#MPC_AUTO_NUDGING) | Bitmask enabling stick nudging in Auto modes (multicopter). Bit 0 (yaw nudging) lets the yaw stick nudge heading in Hold, held when the stick is released; switching flight mode clears the held heading. Requires stick override to be disabled ([MAN_OVERRIDE_SPD](#MAN_OVERRIDE_SPD) = -1). |
|
||||||
|
|
||||||
<!-- Code for this here: https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/navigator/loiter.cpp#L61 -->
|
<!-- Code for this here: https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/navigator/loiter.cpp#L61 -->
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ Land mode behaviour can be configured using the parameters below.
|
|||||||
| <a id="MPC_LAND_SPEED"></a>[MPC_LAND_SPEED](../advanced_config/parameter_reference.md#MPC_LAND_SPEED) | The rate of descent during landing. This should be kept fairly low as the ground conditions are not known. |
|
| <a id="MPC_LAND_SPEED"></a>[MPC_LAND_SPEED](../advanced_config/parameter_reference.md#MPC_LAND_SPEED) | The rate of descent during landing. This should be kept fairly low as the ground conditions are not known. |
|
||||||
| <a id="COM_DISARM_LAND"></a>[COM_DISARM_LAND](../advanced_config/parameter_reference.md#COM_DISARM_LAND) | Time-out for auto disarm after landing, in seconds. If set to -1 the vehicle will not disarm on landing. |
|
| <a id="COM_DISARM_LAND"></a>[COM_DISARM_LAND](../advanced_config/parameter_reference.md#COM_DISARM_LAND) | Time-out for auto disarm after landing, in seconds. If set to -1 the vehicle will not disarm on landing. |
|
||||||
| <a id="MAN_OVERRIDE_SPD"></a>[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. <Badge type="tip" text="PX4 v1.18" /> |
|
| <a id="MAN_OVERRIDE_SPD"></a>[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. <Badge type="tip" text="PX4 v1.18" /> |
|
||||||
|
| <a id="MPC_AUTO_NUDGING"></a>[MPC_AUTO_NUDGING](../advanced_config/parameter_reference.md#MPC_AUTO_NUDGING) | Bitmask enabling stick nudging in Auto modes (multicopter). Bit 0 (yaw nudging) lets the yaw stick nudge heading during landing. Bit 1 (land nudging) additionally lets the pitch/roll sticks move the vehicle horizontally (within [MPC_LAND_RADIUS](#MPC_LAND_RADIUS)), the throttle stick amend the descent speed, and the yaw stick rotate the heading. Requires stick override to be disabled ([MAN_OVERRIDE_SPD](#MAN_OVERRIDE_SPD) = -1). |
|
||||||
|
|
||||||
## See Also
|
## See Also
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ The mission is typically created and uploaded with a Ground Control Station (GCS
|
|||||||
- RC control switches can be used to change flight modes on any vehicle.
|
- RC control switches can be used to change flight modes on any vehicle.
|
||||||
- Stick movement will [by default](#MAN_OVERRIDE_SPD) change the vehicle to [Position mode](../flight_modes_mc/position.md) unless prevented by the active failsafe state.
|
- Stick movement will [by default](#MAN_OVERRIDE_SPD) change the vehicle to [Position mode](../flight_modes_mc/position.md) unless prevented by the active failsafe state.
|
||||||
This is true for multicopters and VTOL in hover.
|
This is true for multicopters and VTOL in hover.
|
||||||
|
- The yaw stick can optionally nudge vehicle heading during the mission without changing mode (see [MPC_AUTO_NUDGING](#MPC_AUTO_NUDGING)).
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
@@ -109,6 +110,7 @@ General parameters:
|
|||||||
| ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| <a id="NAV_RCL_ACT"></a>[NAV_RCL_ACT](../advanced_config/parameter_reference.md#NAV_RCL_ACT) | RC loss failsafe mode (what the vehicle will do if it looses RC connection) - e.g. enter hold mode, return mode, terminate etc. |
|
| <a id="NAV_RCL_ACT"></a>[NAV_RCL_ACT](../advanced_config/parameter_reference.md#NAV_RCL_ACT) | RC loss failsafe mode (what the vehicle will do if it looses RC connection) - e.g. enter hold mode, return mode, terminate etc. |
|
||||||
| <a id="MAN_OVERRIDE_SPD"></a>[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. <Badge type="tip" text="PX4 v1.18" /> |
|
| <a id="MAN_OVERRIDE_SPD"></a>[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. <Badge type="tip" text="PX4 v1.18" /> |
|
||||||
|
| <a id="MPC_AUTO_NUDGING"></a>[MPC_AUTO_NUDGING](../advanced_config/parameter_reference.md#MPC_AUTO_NUDGING) | Bitmask enabling stick nudging in Auto modes (multicopter). Bit 0 (yaw nudging) lets the yaw stick nudge heading without switching modes; the heading is held when the stick is released. Switching flight mode (e.g. to Hold and back) clears the held heading and returns yaw to the mode default. Requires stick override to be disabled ([MAN_OVERRIDE_SPD](#MAN_OVERRIDE_SPD) = -1). |
|
||||||
|
|
||||||
Parameters related to [mission feasibility checks](#mission-feasibility-checks):
|
Parameters related to [mission feasibility checks](#mission-feasibility-checks):
|
||||||
|
|
||||||
|
|||||||
@@ -130,9 +130,18 @@ Please continue reading for [upgrade instructions](#upgrade-guide).
|
|||||||
### RC
|
### RC
|
||||||
|
|
||||||
- Parse ELRS Status and Link Statistics TX messages in the CRSF parser.
|
- Parse ELRS Status and Link Statistics TX messages in the CRSF parser.
|
||||||
|
- Merged the stick override parameters `COM_RC_OVERRIDE` and `COM_RC_STICK_OV` into a single [MAN_OVERRIDE_SPD](../advanced_config/parameter_reference.md#MAN_OVERRIDE_SPD) and made override reject erratic signal jumps. ([PX4-Autopilot#27041](https://github.com/PX4/PX4-Autopilot/pull/27041)).
|
||||||
|
|
||||||
### Multi-Rotor
|
### Multi-Rotor
|
||||||
|
|
||||||
|
- Removed parameters:
|
||||||
|
|
||||||
|
| Name | Notes |
|
||||||
|
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `MPC_LAND_RC_HELP` | Replaced by Bit 1 of [MPC_AUTO_NUDGING](../advanced_config/parameter_reference.md#MPC_AUTO_NUDGING). ([PX4-Autopilot#27691](https://github.com/PX4/PX4-Autopilot/pull/27691)) |
|
||||||
|
|
||||||
|
- Yaw stick nudging in auto modes ([MPC_AUTO_NUDGING](../advanced_config/parameter_reference.md#MPC_AUTO_NUDGING)). Bit 0 lets the yaw stick rotate vehicle heading during any auto mode (mission, RTL, hold, landing, takeoff) without switching modes. The heading is held when the stick is released and cleared on a flight mode switch. Requires stick override to be disabled ([MAN_OVERRIDE_SPD](../advanced_config/parameter_reference.md#MAN_OVERRIDE_SPD) = -1). ([PX4-Autopilot#27691](https://github.com/PX4/PX4-Autopilot/pull/27691))
|
||||||
|
|
||||||
### VTOL
|
### VTOL
|
||||||
|
|
||||||
- [Return mode VTOL Rally Point Approach Loiters](../flight_modes_vtol/return.md#vtol-rally-point-approach-loiters): VTOLs returning in fixed-wing mode can now use the approach loiter associated with the selected home/rally landing location (instead of home) to choose the most wind-aligned valid approach (if several are defined). ([PX4-Autopilot#27004: fix(navigator): rtl compute wind angle to select best land approach based on rally point location instead of home location](https://github.com/PX4/PX4-Autopilot/pull/27004))
|
- [Return mode VTOL Rally Point Approach Loiters](../flight_modes_vtol/return.md#vtol-rally-point-approach-loiters): VTOLs returning in fixed-wing mode can now use the approach loiter associated with the selected home/rally landing location (instead of home) to choose the most wind-aligned valid approach (if several are defined). ([PX4-Autopilot#27004: fix(navigator): rtl compute wind angle to select best land approach based on rally point location instead of home location](https://github.com/PX4/PX4-Autopilot/pull/27004))
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ Update these notes with features that are going to be in `main` (PX4 v1.18 or la
|
|||||||
|
|
||||||
## Read Before Upgrading
|
## Read Before Upgrading
|
||||||
|
|
||||||
- The RC override parameters `COM_RC_OVERRIDE` and `COM_RC_STICK_OV` are replaced by a single [MAN_OVERRIDE_SPD](../advanced_config/parameter_reference.md#MAN_OVERRIDE_SPD) (minimum stick speed to take over, default `1`; negative disables). `COM_RC_OVERRIDE=0` is migrated to `MAN_OVERRIDE_SPD=-1`. The `COM_RC_STICK_OV` value is not auto-migrated because its unit changed, so re-tune `MAN_OVERRIDE_SPD` if you had customized it.
|
|
||||||
|
|
||||||
Please continue reading for [upgrade instructions](#upgrade-guide).
|
Please continue reading for [upgrade instructions](#upgrade-guide).
|
||||||
|
|
||||||
## Major Changes
|
## Major Changes
|
||||||
@@ -82,7 +80,7 @@ Please continue reading for [upgrade instructions](#upgrade-guide).
|
|||||||
|
|
||||||
### RC
|
### RC
|
||||||
|
|
||||||
- Merged the RC override parameters `COM_RC_OVERRIDE` and `COM_RC_STICK_OV` into a single [MAN_OVERRIDE_SPD](../advanced_config/parameter_reference.md#MAN_OVERRIDE_SPD) and made override reject erratic signal jumps. ([PX4-Autopilot#27041](https://github.com/PX4/PX4-Autopilot/pull/27041)).
|
- TBD
|
||||||
|
|
||||||
### Multi-Rotor
|
### Multi-Rotor
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ This is done through the MAVLink protocol, specifically the [SET_POSITION_TARGET
|
|||||||
|
|
||||||
There are two things you want to setup on the firmware side before starting offboard development.
|
There are two things you want to setup on the firmware side before starting offboard development.
|
||||||
|
|
||||||
### Enable RC Override
|
### Enable Stick Override
|
||||||
|
|
||||||
In _QGroundControl_ the [MAN_OVERRIDE_SPD](../advanced_config/parameter_reference.md#MAN_OVERRIDE_SPD) parameter controls automatically switching from offboard (or autonomous) mode to Position mode when the remote sticks are moved. This is enabled by default; set it to -1 to disable.
|
In _QGroundControl_ the [MAN_OVERRIDE_SPD](../advanced_config/parameter_reference.md#MAN_OVERRIDE_SPD) parameter controls automatically switching from offboard (or autonomous) mode to Position mode when the remote sticks are moved. This is enabled by default; set it to -1 to disable.
|
||||||
This is the best way to ensure that an operator can easily take control of the vehicle and switch to the safest flight mode.
|
This is the best way to ensure that an operator can easily take control of the vehicle and switch to the safest flight mode.
|
||||||
@@ -23,7 +23,7 @@ In _QGroundControl_ you can set the [RC_MAP_OFFB_SW](../advanced_config/paramete
|
|||||||
This can be used to switch between offboard mode and the mode set by the mode switch ([RC_MAP_MODE_SW](../advanced_config/parameter_reference.md#RC_MAP_MODE_SW)).
|
This can be used to switch between offboard mode and the mode set by the mode switch ([RC_MAP_MODE_SW](../advanced_config/parameter_reference.md#RC_MAP_MODE_SW)).
|
||||||
You can also switch into offboard mode using a GCS/MAVLink so this is not "mandatory".
|
You can also switch into offboard mode using a GCS/MAVLink so this is not "mandatory".
|
||||||
|
|
||||||
Note also that this mechanism is not as "safe" as using [RC Override](#enable-rc-override) to switch out of offboard mode, because the mode you switch to is unpredictable.
|
Note also that this mechanism is not as "safe" as using [stick Override](#enable-stick-override) to switch out of offboard mode, because the mode you switch to is unpredictable.
|
||||||
|
|
||||||
### Enable the companion computer interface
|
### Enable the companion computer interface
|
||||||
|
|
||||||
|
|||||||
@@ -270,5 +270,21 @@ param_modify_on_import_ret param_modify_on_import(bson_node_t node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2026-06-29: MPC_LAND_RC_HELP replaced by the MPC_AUTO_NUDGING bitmask (landing nudging = bit 1).
|
||||||
|
// The old in-Hold yaw nudge is not migrated; it now lives in bit 0 (yaw nudging in all auto modes).
|
||||||
|
{
|
||||||
|
if ((node->type == bson_type_t::BSON_INT32) && (strcmp("MPC_LAND_RC_HELP", node->name) == 0)) {
|
||||||
|
if (node->i32 != 0) {
|
||||||
|
int32_t nudging = 0;
|
||||||
|
param_get(param_find("MPC_AUTO_NUDGING"), &nudging);
|
||||||
|
nudging |= (1 << 1);
|
||||||
|
param_set(param_find("MPC_AUTO_NUDGING"), &nudging);
|
||||||
|
}
|
||||||
|
|
||||||
|
PX4_INFO("migrating MPC_LAND_RC_HELP -> MPC_AUTO_NUDGING bit 1 (value=%" PRId32 ")", node->i32);
|
||||||
|
return param_modify_on_import_ret::PARAM_SKIP_IMPORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return param_modify_on_import_ret::PARAM_NOT_MODIFIED;
|
return param_modify_on_import_ret::PARAM_NOT_MODIFIED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ bool FlightTaskAuto::activate(const trajectory_setpoint_s &last_setpoint)
|
|||||||
_yaw_setpoint = _yaw;
|
_yaw_setpoint = _yaw;
|
||||||
_yawspeed_setpoint = 0.0f;
|
_yawspeed_setpoint = 0.0f;
|
||||||
|
|
||||||
|
_manual_yaw_active = false;
|
||||||
|
_triplet_yaw = NAN;
|
||||||
|
_nav_state_prev = _sub_vehicle_status.get().nav_state;
|
||||||
|
|
||||||
Vector3f vel_prev{last_setpoint.velocity};
|
Vector3f vel_prev{last_setpoint.velocity};
|
||||||
Vector3f pos_prev{last_setpoint.position};
|
Vector3f pos_prev{last_setpoint.position};
|
||||||
Vector3f accel_prev{last_setpoint.acceleration};
|
Vector3f accel_prev{last_setpoint.acceleration};
|
||||||
@@ -101,9 +105,6 @@ bool FlightTaskAuto::updateInitialize()
|
|||||||
_sub_vehicle_status.update();
|
_sub_vehicle_status.update();
|
||||||
_position_setpoint_triplet_sub.update();
|
_position_setpoint_triplet_sub.update();
|
||||||
_takeoff_status_sub.update();
|
_takeoff_status_sub.update();
|
||||||
#if defined(CONFIG_MODULES_VISION_TARGET_ESTIMATOR) && CONFIG_MODULES_VISION_TARGET_ESTIMATOR
|
|
||||||
_prec_land_status_sub.update();
|
|
||||||
#endif // CONFIG_MODULES_VISION_TARGET_ESTIMATOR
|
|
||||||
|
|
||||||
// require valid reference and valid target
|
// require valid reference and valid target
|
||||||
ret = ret && _evaluateGlobalReference() && _evaluatePositionSetpointTriplet();
|
ret = ret && _evaluateGlobalReference() && _evaluatePositionSetpointTriplet();
|
||||||
@@ -153,11 +154,6 @@ bool FlightTaskAuto::update()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WaypointType::loiter:
|
case WaypointType::loiter:
|
||||||
if (_param_mpc_land_rc_help.get() && _sticks.checkAndUpdateStickInputs()) {
|
|
||||||
rcHelpModifyYaw(_yaw_setpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FALLTHROUGH
|
|
||||||
case WaypointType::takeoff:
|
case WaypointType::takeoff:
|
||||||
case WaypointType::position:
|
case WaypointType::position:
|
||||||
default:
|
default:
|
||||||
@@ -222,7 +218,7 @@ bool FlightTaskAuto::update()
|
|||||||
_unsmoothed_velocity_setpoint = smoothed_setpoints.unsmoothed_velocity;
|
_unsmoothed_velocity_setpoint = smoothed_setpoints.unsmoothed_velocity;
|
||||||
_want_takeoff = smoothed_setpoints.unsmoothed_velocity(2) < -0.3f;
|
_want_takeoff = smoothed_setpoints.unsmoothed_velocity(2) < -0.3f;
|
||||||
|
|
||||||
if (!PX4_ISFINITE(_yaw_setpoint) && !PX4_ISFINITE(_yawspeed_setpoint)) {
|
if (!PX4_ISFINITE(_yaw_setpoint) && !PX4_ISFINITE(_yawspeed_setpoint) && !_manual_yaw_active) {
|
||||||
// no valid heading -> generate heading in this flight task
|
// no valid heading -> generate heading in this flight task
|
||||||
// Generate heading along trajectory if possible, otherwise hold the previous yaw setpoint
|
// Generate heading along trajectory if possible, otherwise hold the previous yaw setpoint
|
||||||
if (!_generateHeadingAlongTraj()) {
|
if (!_generateHeadingAlongTraj()) {
|
||||||
@@ -233,10 +229,34 @@ bool FlightTaskAuto::update()
|
|||||||
// update previous type
|
// update previous type
|
||||||
_type_previous = _type;
|
_type_previous = _type;
|
||||||
|
|
||||||
|
const uint8_t nav_state = _sub_vehicle_status.get().nav_state;
|
||||||
|
|
||||||
|
if (nav_state != _nav_state_prev) {
|
||||||
|
_manual_yaw_active = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_nav_state_prev = nav_state;
|
||||||
|
|
||||||
|
const bool rc_yaw_type = (_type == WaypointType::position || _type == WaypointType::takeoff
|
||||||
|
|| _type == WaypointType::loiter || _type == WaypointType::land);
|
||||||
|
const int nudging = _param_mpc_auto_nudging.get();
|
||||||
|
const bool yaw_nudge_enabled = ((nudging & 1) && rc_yaw_type) || ((nudging & 2) && _type == WaypointType::land);
|
||||||
|
|
||||||
|
if (yaw_nudge_enabled && _sticks.checkAndUpdateStickInputs()) {
|
||||||
|
if (fabsf(_sticks.getYawExpo()) > FLT_EPSILON) {
|
||||||
|
_manual_yaw_active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_manual_yaw_active) {
|
||||||
|
rcHelpModifyYaw(_yaw_setpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
_manual_yaw_active = false;
|
||||||
|
}
|
||||||
|
|
||||||
_smoothYaw();
|
_smoothYaw();
|
||||||
|
|
||||||
_constraints.want_takeoff = _checkTakeoff();
|
_constraints.want_takeoff = _checkTakeoff();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,13 +293,6 @@ void FlightTaskAuto::_prepareLandSetpoints()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_type_previous != WaypointType::land) {
|
if (_type_previous != WaypointType::land) {
|
||||||
// initialize yaw and xy-position
|
|
||||||
_land_heading = PX4_ISFINITE(_yaw_setpoint) ? _yaw_setpoint : _yaw_setpoint_previous;
|
|
||||||
|
|
||||||
if (!PX4_ISFINITE(_land_heading)) {
|
|
||||||
_land_heading = _yaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
_stick_acceleration_xy.resetPosition(Vector2f(_triplet_current));
|
_stick_acceleration_xy.resetPosition(Vector2f(_triplet_current));
|
||||||
_initial_land_position = Vector3f(_triplet_current(0), _triplet_current(1), NAN);
|
_initial_land_position = Vector3f(_triplet_current(0), _triplet_current(1), NAN);
|
||||||
}
|
}
|
||||||
@@ -287,37 +300,22 @@ void FlightTaskAuto::_prepareLandSetpoints()
|
|||||||
// Update xy-position in case of landing position changes (etc. precision landing)
|
// Update xy-position in case of landing position changes (etc. precision landing)
|
||||||
_land_position = Vector3f(_triplet_current(0), _triplet_current(1), NAN);
|
_land_position = Vector3f(_triplet_current(0), _triplet_current(1), NAN);
|
||||||
|
|
||||||
#if defined(CONFIG_MODULES_VISION_TARGET_ESTIMATOR) && CONFIG_MODULES_VISION_TARGET_ESTIMATOR
|
|
||||||
|
|
||||||
// Use the raw navigator/precland yaw command here. _yaw_setpoint can stay finite from
|
|
||||||
// generic land yaw logic even after precland clears current.yaw.
|
|
||||||
const uint8_t pld_state = _prec_land_status_sub.get().state;
|
|
||||||
const bool pld_ongoing = pld_state != prec_land_status_s::PREC_LAND_STATE_STOPPED
|
|
||||||
&& pld_state != prec_land_status_s::PREC_LAND_STATE_DONE;
|
|
||||||
|
|
||||||
if (_param_pld_yaw_en.get() && pld_ongoing) {
|
|
||||||
const float prec_land_yaw = _position_setpoint_triplet_sub.get().current.yaw;
|
|
||||||
_land_heading = PX4_ISFINITE(prec_land_yaw) ? prec_land_yaw : _yaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // CONFIG_MODULES_VISION_TARGET_ESTIMATOR
|
|
||||||
|
|
||||||
// User input assisted landing
|
// User input assisted landing
|
||||||
if (_param_mpc_land_rc_help.get() && _sticks.checkAndUpdateStickInputs()) {
|
if ((_param_mpc_auto_nudging.get() & 2) && _sticks.checkAndUpdateStickInputs()) {
|
||||||
// Stick full up -1 -> stop, stick full down 1 -> double the speed
|
// Stick full up -1 -> stop, stick full down 1 -> double the speed
|
||||||
vertical_speed *= (1 - _sticks.getThrottleZeroCenteredExpo());
|
vertical_speed *= (1 - _sticks.getThrottleZeroCenteredExpo());
|
||||||
|
|
||||||
Vector2f sticks_xy = _sticks.getPitchRollExpo();
|
Vector2f sticks_xy = _sticks.getPitchRollExpo();
|
||||||
|
|
||||||
if (sticks_xy.longerThan(FLT_EPSILON)) {
|
if (sticks_xy.longerThan(FLT_EPSILON)) {
|
||||||
// Ensure no unintended yawing when nudging horizontally during initial heading alignment
|
// Prevent unintended yaw during initial heading alignment when nudging horizontally
|
||||||
_land_heading = _yaw_setpoint_previous;
|
_yaw_setpoint = _yaw_setpoint_previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
rcHelpModifyYaw(_land_heading);
|
// Yaw nudging is handled by the unified block in update(); use current _yaw_setpoint for XY rotation
|
||||||
|
const float heading_for_xy = PX4_ISFINITE(_yaw_setpoint) ? _yaw_setpoint : _yaw;
|
||||||
Vector2f sticks_ne = sticks_xy;
|
Vector2f sticks_ne = sticks_xy;
|
||||||
Sticks::rotateIntoHeadingFrameXY(sticks_ne, _yaw, _land_heading);
|
Sticks::rotateIntoHeadingFrameXY(sticks_ne, _yaw, heading_for_xy);
|
||||||
|
|
||||||
float max_speed = INFINITY;
|
float max_speed = INFINITY;
|
||||||
|
|
||||||
@@ -344,7 +342,7 @@ void FlightTaskAuto::_prepareLandSetpoints()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_stick_acceleration_xy.setVelocityConstraint(max_speed);
|
_stick_acceleration_xy.setVelocityConstraint(max_speed);
|
||||||
_stick_acceleration_xy.generateSetpoints(sticks_xy, _yaw, _land_heading, _position,
|
_stick_acceleration_xy.generateSetpoints(sticks_xy, _yaw, heading_for_xy, _position,
|
||||||
_velocity_setpoint_feedback.xy(), _deltatime);
|
_velocity_setpoint_feedback.xy(), _deltatime);
|
||||||
_stick_acceleration_xy.getSetpoints(_land_position, _velocity_setpoint, _acceleration_setpoint);
|
_stick_acceleration_xy.getSetpoints(_land_position, _velocity_setpoint, _acceleration_setpoint);
|
||||||
|
|
||||||
@@ -356,7 +354,6 @@ void FlightTaskAuto::_prepareLandSetpoints()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_position_setpoint = _land_position; // The last element of the land position has to stay NAN
|
_position_setpoint = _land_position; // The last element of the land position has to stay NAN
|
||||||
_yaw_setpoint = _land_heading;
|
|
||||||
_velocity_setpoint(2) = vertical_speed;
|
_velocity_setpoint(2) = vertical_speed;
|
||||||
_gear.landing_gear = landing_gear_s::GEAR_DOWN;
|
_gear.landing_gear = landing_gear_s::GEAR_DOWN;
|
||||||
}
|
}
|
||||||
@@ -527,13 +524,29 @@ bool FlightTaskAuto::_evaluatePositionSetpointTriplet()
|
|||||||
_yaw_lock = false;
|
_yaw_lock = false;
|
||||||
_yaw_setpoint = NAN;
|
_yaw_setpoint = NAN;
|
||||||
_yawspeed_setpoint = 0.f;
|
_yawspeed_setpoint = 0.f;
|
||||||
|
_triplet_yaw = NAN; // force re-detection on recovery
|
||||||
} else if (PX4_ISFINITE(position_setpoint_triplet.current.yaw)) {
|
|
||||||
_yaw_setpoint = position_setpoint_triplet.current.yaw;
|
|
||||||
_yawspeed_setpoint = NAN;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_set_heading_from_mode();
|
const float triplet_yaw = position_setpoint_triplet.current.yaw;
|
||||||
|
|
||||||
|
if (PX4_ISFINITE(triplet_yaw)) {
|
||||||
|
// End of RTL changes yaw once, precision land can change it all the time
|
||||||
|
const bool yaw_changed = !PX4_ISFINITE(_triplet_yaw)
|
||||||
|
|| fabsf(wrap_pi(triplet_yaw - _triplet_yaw)) > 1e-4f;
|
||||||
|
|
||||||
|
if (!_manual_yaw_active || yaw_changed) {
|
||||||
|
_yaw_setpoint = triplet_yaw;
|
||||||
|
_yawspeed_setpoint = NAN;
|
||||||
|
_manual_yaw_active = false; // navigator published a different yaw, reset nudge latch
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (!_manual_yaw_active && (_type != WaypointType::land || _type_previous != WaypointType::land)) {
|
||||||
|
// Skip when manual yaw latch is active (nudge holds heading until mode switch) or
|
||||||
|
// during ongoing land (heading initialised on first cycle, only nudging/weathervane may change it).
|
||||||
|
_set_heading_from_mode();
|
||||||
|
}
|
||||||
|
|
||||||
|
_triplet_yaw = triplet_yaw; // NaN resets for future detection, finite value tracks last seen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,6 +699,10 @@ void FlightTaskAuto::_ekfResetHandlerHeading(const float delta_psi)
|
|||||||
{
|
{
|
||||||
_yaw_setpoint_previous = wrap_pi(_yaw_setpoint_previous + delta_psi);
|
_yaw_setpoint_previous = wrap_pi(_yaw_setpoint_previous + delta_psi);
|
||||||
_heading_smoothing.reset(wrap_pi(_heading_smoothing.getSmoothedHeading() + delta_psi));
|
_heading_smoothing.reset(wrap_pi(_heading_smoothing.getSmoothedHeading() + delta_psi));
|
||||||
|
|
||||||
|
if (PX4_ISFINITE(_yaw_setpoint)) {
|
||||||
|
_yaw_setpoint = wrap_pi(_yaw_setpoint + delta_psi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FlightTaskAuto::_checkEmergencyBraking()
|
void FlightTaskAuto::_checkEmergencyBraking()
|
||||||
|
|||||||
@@ -44,9 +44,6 @@
|
|||||||
#include <uORB/topics/position_setpoint.h>
|
#include <uORB/topics/position_setpoint.h>
|
||||||
#include <uORB/topics/home_position.h>
|
#include <uORB/topics/home_position.h>
|
||||||
#include <uORB/topics/manual_control_setpoint.h>
|
#include <uORB/topics/manual_control_setpoint.h>
|
||||||
#if defined(CONFIG_MODULES_VISION_TARGET_ESTIMATOR) && CONFIG_MODULES_VISION_TARGET_ESTIMATOR
|
|
||||||
#include <uORB/topics/prec_land_status.h>
|
|
||||||
#endif // CONFIG_MODULES_VISION_TARGET_ESTIMATOR
|
|
||||||
#include <uORB/topics/vehicle_status.h>
|
#include <uORB/topics/vehicle_status.h>
|
||||||
#include <uORB/topics/takeoff_status.h>
|
#include <uORB/topics/takeoff_status.h>
|
||||||
#include <lib/geo/geo.h>
|
#include <lib/geo/geo.h>
|
||||||
@@ -124,9 +121,6 @@ protected:
|
|||||||
WaypointType _type{WaypointType::idle}; /**< Type of current target triplet. */
|
WaypointType _type{WaypointType::idle}; /**< Type of current target triplet. */
|
||||||
|
|
||||||
uORB::SubscriptionData<position_setpoint_triplet_s> _position_setpoint_triplet_sub{ORB_ID(position_setpoint_triplet)};
|
uORB::SubscriptionData<position_setpoint_triplet_s> _position_setpoint_triplet_sub{ORB_ID(position_setpoint_triplet)};
|
||||||
#if defined(CONFIG_MODULES_VISION_TARGET_ESTIMATOR) && CONFIG_MODULES_VISION_TARGET_ESTIMATOR
|
|
||||||
uORB::SubscriptionData<prec_land_status_s> _prec_land_status_sub {ORB_ID(prec_land_status)};
|
|
||||||
#endif // CONFIG_MODULES_VISION_TARGET_ESTIMATOR
|
|
||||||
uORB::SubscriptionData<home_position_s> _sub_home_position {ORB_ID(home_position)};
|
uORB::SubscriptionData<home_position_s> _sub_home_position {ORB_ID(home_position)};
|
||||||
uORB::SubscriptionData<vehicle_status_s> _sub_vehicle_status{ORB_ID(vehicle_status)};
|
uORB::SubscriptionData<vehicle_status_s> _sub_vehicle_status{ORB_ID(vehicle_status)};
|
||||||
uORB::SubscriptionData<takeoff_status_s> _takeoff_status_sub{ORB_ID(takeoff_status)};
|
uORB::SubscriptionData<takeoff_status_s> _takeoff_status_sub{ORB_ID(takeoff_status)};
|
||||||
@@ -134,6 +128,9 @@ protected:
|
|||||||
float _target_acceptance_radius{0.0f}; /**< Acceptances radius of the target */
|
float _target_acceptance_radius{0.0f}; /**< Acceptances radius of the target */
|
||||||
|
|
||||||
float _yaw_setpoint_previous{NAN}; /**< Used because _yaw_setpoint is overwritten in multiple places */
|
float _yaw_setpoint_previous{NAN}; /**< Used because _yaw_setpoint is overwritten in multiple places */
|
||||||
|
float _triplet_yaw{NAN}; /**< Last yaw from position_setpoint_triplet, to detect navigator changes */
|
||||||
|
bool _manual_yaw_active{false};
|
||||||
|
uint8_t _nav_state_prev{0};
|
||||||
HeadingSmoothing _heading_smoothing;
|
HeadingSmoothing _heading_smoothing;
|
||||||
bool _yaw_sp_aligned{false};
|
bool _yaw_sp_aligned{false};
|
||||||
|
|
||||||
@@ -143,15 +140,11 @@ protected:
|
|||||||
StickAccelerationXY _stick_acceleration_xy{this};
|
StickAccelerationXY _stick_acceleration_xy{this};
|
||||||
StickYaw _stick_yaw{this};
|
StickYaw _stick_yaw{this};
|
||||||
matrix::Vector3f _land_position;
|
matrix::Vector3f _land_position;
|
||||||
float _land_heading;
|
|
||||||
WaypointType _type_previous{WaypointType::idle}; /**< Previous type of current target triplet. */
|
WaypointType _type_previous{WaypointType::idle}; /**< Previous type of current target triplet. */
|
||||||
bool _is_emergency_braking_active{false};
|
bool _is_emergency_braking_active{false};
|
||||||
bool _want_takeoff{false};
|
bool _want_takeoff{false};
|
||||||
|
|
||||||
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTask,
|
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTask,
|
||||||
#if defined(CONFIG_MODULES_VISION_TARGET_ESTIMATOR) && CONFIG_MODULES_VISION_TARGET_ESTIMATOR
|
|
||||||
(ParamInt<px4::params::PLD_YAW_EN>) _param_pld_yaw_en,
|
|
||||||
#endif // CONFIG_MODULES_VISION_TARGET_ESTIMATOR
|
|
||||||
(ParamFloat<px4::params::MPC_XY_CRUISE>) _param_mpc_xy_cruise,
|
(ParamFloat<px4::params::MPC_XY_CRUISE>) _param_mpc_xy_cruise,
|
||||||
(ParamFloat<px4::params::NAV_MC_ALT_RAD>)
|
(ParamFloat<px4::params::NAV_MC_ALT_RAD>)
|
||||||
_param_nav_mc_alt_rad, //vertical acceptance radius at which waypoints are updated
|
_param_nav_mc_alt_rad, //vertical acceptance radius at which waypoints are updated
|
||||||
@@ -168,7 +161,7 @@ protected:
|
|||||||
(ParamFloat<px4::params::MPC_Z_ERR_MAX>) _param_mpc_z_err_max,
|
(ParamFloat<px4::params::MPC_Z_ERR_MAX>) _param_mpc_z_err_max,
|
||||||
(ParamFloat<px4::params::MPC_LAND_SPEED>) _param_mpc_land_speed,
|
(ParamFloat<px4::params::MPC_LAND_SPEED>) _param_mpc_land_speed,
|
||||||
(ParamFloat<px4::params::MPC_LAND_CRWL>) _param_mpc_land_crwl,
|
(ParamFloat<px4::params::MPC_LAND_CRWL>) _param_mpc_land_crwl,
|
||||||
(ParamInt<px4::params::MPC_LAND_RC_HELP>) _param_mpc_land_rc_help,
|
(ParamInt<px4::params::MPC_AUTO_NUDGING>) _param_mpc_auto_nudging,
|
||||||
(ParamFloat<px4::params::MPC_LAND_RADIUS>) _param_mpc_land_radius,
|
(ParamFloat<px4::params::MPC_LAND_RADIUS>) _param_mpc_land_radius,
|
||||||
(ParamFloat<px4::params::MPC_LAND_ALT1>) _param_mpc_land_alt1,
|
(ParamFloat<px4::params::MPC_LAND_ALT1>) _param_mpc_land_alt1,
|
||||||
(ParamFloat<px4::params::MPC_LAND_ALT2>) _param_mpc_land_alt2,
|
(ParamFloat<px4::params::MPC_LAND_ALT2>) _param_mpc_land_alt2,
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ bool FlightTaskDescend::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Nudging
|
// Nudging
|
||||||
if (_param_mpc_land_rc_help.get() && _sticks.checkAndUpdateStickInputs()) {
|
if ((_param_mpc_auto_nudging.get() & 2) && _sticks.checkAndUpdateStickInputs()) {
|
||||||
_stick_yaw.generateYawSetpoint(_yawspeed_setpoint, _yaw_setpoint, _sticks.getYawExpo(), _yaw, _deltatime);
|
_stick_yaw.generateYawSetpoint(_yawspeed_setpoint, _yaw_setpoint, _sticks.getYawExpo(), _yaw, _deltatime);
|
||||||
_acceleration_setpoint.xy() = _stick_tilt_xy.generateAccelerationSetpoints(_sticks.getPitchRoll(), _deltatime, _yaw,
|
_acceleration_setpoint.xy() = _stick_tilt_xy.generateAccelerationSetpoints(_sticks.getPitchRoll(), _deltatime, _yaw,
|
||||||
_yaw_setpoint);
|
_yaw_setpoint);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ private:
|
|||||||
StickYaw _stick_yaw{this};
|
StickYaw _stick_yaw{this};
|
||||||
|
|
||||||
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTask,
|
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTask,
|
||||||
(ParamInt<px4::params::MPC_LAND_RC_HELP>) _param_mpc_land_rc_help,
|
(ParamInt<px4::params::MPC_AUTO_NUDGING>) _param_mpc_auto_nudging,
|
||||||
(ParamFloat<px4::params::MPC_LAND_SPEED>) _param_mpc_land_speed, ///< velocity for controlled descend
|
(ParamFloat<px4::params::MPC_LAND_SPEED>) _param_mpc_land_speed, ///< velocity for controlled descend
|
||||||
(ParamFloat<px4::params::MPC_THR_HOVER>) _param_mpc_thr_hover ///< thrust at hover equilibrium
|
(ParamFloat<px4::params::MPC_THR_HOVER>) _param_mpc_thr_hover ///< thrust at hover equilibrium
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,29 +2,32 @@ module_name: mc_pos_control
|
|||||||
parameters:
|
parameters:
|
||||||
- group: Multicopter Position Control
|
- group: Multicopter Position Control
|
||||||
definitions:
|
definitions:
|
||||||
MPC_LAND_RC_HELP:
|
MPC_AUTO_NUDGING:
|
||||||
description:
|
description:
|
||||||
short: Enable nudging based on user input during autonomous land routine
|
short: Enable stick nudging in autonomous modes
|
||||||
long: |-
|
long: |-
|
||||||
Using stick input the vehicle can be moved horizontally and yawed.
|
Bitmask to enable pilot override of heading and position during auto modes.
|
||||||
The descend speed is amended:
|
|
||||||
stick full up - 0
|
|
||||||
stick centered - MPC_LAND_SPEED
|
|
||||||
stick full down - 2 * MPC_LAND_SPEED
|
|
||||||
|
|
||||||
Manual override has to be disabled to use this feature (MAN_OVERRIDE_SPD -1).
|
Bit 0 - Yaw nudging: yaw stick rotates the heading in all auto types
|
||||||
type: enum
|
(takeoff, mission, RTL, hold, landing). The new heading is held until a
|
||||||
values:
|
mode switch resets it.
|
||||||
0: Nudging disabled
|
|
||||||
1: Nudging enabled
|
Bit 1 - Land nudging: during autonomous landing the pitch/roll sticks move
|
||||||
|
the vehicle horizontally, the throttle stick amends the descent speed
|
||||||
|
(stick full up: 0, centered: MPC_LAND_SPEED, full down: 2 * MPC_LAND_SPEED),
|
||||||
|
and the yaw stick rotates the heading.
|
||||||
|
|
||||||
|
Stick override must be disabled (set MAN_OVERRIDE_SPD = -1).
|
||||||
|
type: bitmask
|
||||||
|
bit:
|
||||||
|
0: Yaw nudging
|
||||||
|
1: Landing nudging
|
||||||
default: 0
|
default: 0
|
||||||
min: 0
|
|
||||||
max: 1
|
|
||||||
MPC_LAND_RADIUS:
|
MPC_LAND_RADIUS:
|
||||||
description:
|
description:
|
||||||
short: User assisted landing radius
|
short: User assisted landing radius
|
||||||
long: |-
|
long: |-
|
||||||
When nudging is enabled (see MPC_LAND_RC_HELP), this defines the maximum
|
When landing nudging is enabled (MPC_AUTO_NUDGING bit 1), this defines the maximum
|
||||||
allowed horizontal displacement from the original landing point.
|
allowed horizontal displacement from the original landing point.
|
||||||
- If inside of the radius, only allow nudging inputs that do not move the vehicle outside of it.
|
- If inside of the radius, only allow nudging inputs that do not move the vehicle outside of it.
|
||||||
- If outside of the radius, only allow nudging inputs that move the vehicle back towards it.
|
- If outside of the radius, only allow nudging inputs that move the vehicle back towards it.
|
||||||
|
|||||||
Reference in New Issue
Block a user