mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-24 16:01:53 +08:00
feat(navigator): enable ROI tracking with vehicle yaw in Hold mode
ROI=Region of interest, also referred to as point of interest (POI). Add functionality that so far was constrained to Mission mode also to Hold (Loiter) flight mode. If MIS_MNT_YAW_CTL is 0, the vehicle yaws to the ROI in HOlD. A ROI set during a mission is carried over to Hold. Signed-off-by: Silvan <silvan@auterion.com>
This commit is contained in:
1 parent
d4d4c154dc
commit
8adc8f3ee9
4 files changed
+59
-4
No files matched your search
@@ -31,6 +31,12 @@ The vehicle will first ascend to [NAV_MIN_LTR_ALT](#NAV_MIN_LTR_ALT) if the mode
|
||||
|
||||
Stick movement will change the vehicle to [Position mode](../flight_modes_mc/position.md) (by [default](#MAN_OVERRIDE_SPD)).
|
||||
|
||||
If a region of interest (ROI) location is set, for example with [MAV_CMD_DO_SET_ROI_LOCATION](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_ROI_LOCATION), the vehicle yaws so that its nose points towards it.
|
||||
The heading keeps tracking the ROI while the vehicle holds or repositions, and stops updating when the vehicle is within the acceptance radius of the ROI.
|
||||
Clearing the ROI with [MAV_CMD_DO_SET_ROI_NONE](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_SET_ROI_NONE) leaves the vehicle at its last heading.
|
||||
A [MAV_CMD_DO_REPOSITION](https://mavlink.io/en/messages/common.html#MAV_CMD_DO_REPOSITION) with an explicit yaw sent after the ROI overrides ROI tracking until the next ROI command.
|
||||
Set [MIS_MNT_YAW_CTL](#MIS_MNT_YAW_CTL) to yaw a gimbal towards the ROI instead of the vehicle.
|
||||
|
||||
<!-- AUTO-GENERATED: mode_requirements_rotary_wing_auto_loiter -->
|
||||
|
||||
### Mode Requirements
|
||||
@@ -55,6 +61,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="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). |
|
||||
| <a id="MIS_MNT_YAW_CTL"></a>[MIS_MNT_YAW_CTL](../advanced_config/parameter_reference.md#MIS_MNT_YAW_CTL) | If disabled (default), the vehicle yaws towards an active ROI location. If enabled, the gimbal yaws towards the ROI and the vehicle keeps its heading. |
|
||||
|
||||
<!-- Code for this here: https://github.com/PX4/PX4-Autopilot/blob/main/src/modules/navigator/loiter.cpp#L61 -->
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ Loiter::on_activation()
|
||||
// an already-established loiter (used by set_loiter_position()).
|
||||
const position_setpoint_s previous_setpoint = _navigator->get_position_setpoint_triplet()->current;
|
||||
_navigator->reset_triplets();
|
||||
_reposition_yaw_timestamp = 0;
|
||||
|
||||
if (_navigator->get_reposition_triplet()->current.valid
|
||||
&& hrt_elapsed_time(&_navigator->get_reposition_triplet()->current.timestamp) < 500_ms) {
|
||||
@@ -89,6 +90,8 @@ Loiter::on_active()
|
||||
} else {
|
||||
_loiter_at_last_link_position_executed = false;
|
||||
}
|
||||
|
||||
updateHeadingToRoi();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -97,6 +100,42 @@ Loiter::on_inactive()
|
||||
_loiter_at_last_link_position_executed = false;
|
||||
}
|
||||
|
||||
void
|
||||
Loiter::updateHeadingToRoi()
|
||||
{
|
||||
// With mount yaw control enabled the gimbal yaws towards the ROI instead of the vehicle
|
||||
if (_param_mis_mnt_yaw_ctl.get()
|
||||
|| _navigator->get_vstatus()->vehicle_type != vehicle_status_s::VEHICLE_TYPE_ROTARY_WING
|
||||
|| _navigator->get_land_detected()->landed
|
||||
|| _navigator->get_vroi().mode != vehicle_roi_s::ROI_LOCATION) {
|
||||
return;
|
||||
}
|
||||
|
||||
position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();
|
||||
|
||||
if (!pos_sp_triplet->current.valid || pos_sp_triplet->current.type == position_setpoint_s::SETPOINT_TYPE_IDLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
// A reposition with an explicit yaw sent after the ROI takes precedence
|
||||
if (_reposition_yaw_timestamp > _navigator->get_vroi().timestamp) {
|
||||
return;
|
||||
}
|
||||
|
||||
const double lat = _navigator->get_global_position()->lat;
|
||||
const double lon = _navigator->get_global_position()->lon;
|
||||
const double roi_lat = _navigator->get_vroi().lat;
|
||||
const double roi_lon = _navigator->get_vroi().lon;
|
||||
|
||||
// Keep the last heading when close to the ROI to prevent excessive yawing
|
||||
if (get_distance_to_next_waypoint(lat, lon, roi_lat, roi_lon) <= _navigator->get_acceptance_radius()) {
|
||||
return;
|
||||
}
|
||||
|
||||
pos_sp_triplet->current.yaw = get_bearing_to_next_waypoint(lat, lon, roi_lat, roi_lon);
|
||||
_navigator->set_position_setpoint_triplet_updated();
|
||||
}
|
||||
|
||||
void
|
||||
Loiter::set_loiter_position(const position_setpoint_s &reference_setpoint)
|
||||
{
|
||||
@@ -162,6 +201,7 @@ Loiter::reposition()
|
||||
|
||||
if (rep->current.valid) {
|
||||
// set loiter position based on reposition command
|
||||
_reposition_yaw_timestamp = PX4_ISFINITE(rep->current.yaw) ? rep->current.timestamp : 0;
|
||||
|
||||
// convert mission item to current setpoint
|
||||
struct position_setpoint_triplet_s *pos_sp_triplet = _navigator->get_position_setpoint_triplet();
|
||||
|
||||
@@ -67,9 +67,17 @@ private:
|
||||
*/
|
||||
void set_loiter_position(const position_setpoint_s &reference_setpoint);
|
||||
|
||||
/**
|
||||
* Point the vehicle heading towards the ROI location (multicopter only).
|
||||
*/
|
||||
void updateHeadingToRoi();
|
||||
|
||||
bool _loiter_at_last_link_position_executed{false};
|
||||
|
||||
hrt_abstime _reposition_yaw_timestamp{0}; ///< time of the last reposition with an explicit yaw, 0 if none
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamInt<px4::params::NAV_LTR_LAST_DL>) _param_nav_ltr_last_dl
|
||||
(ParamInt<px4::params::NAV_LTR_LAST_DL>) _param_nav_ltr_last_dl,
|
||||
(ParamInt<px4::params::MIS_MNT_YAW_CTL>) _param_mis_mnt_yaw_ctl
|
||||
)
|
||||
};
|
||||
@@ -46,12 +46,12 @@ parameters:
|
||||
increment: 100
|
||||
MIS_MNT_YAW_CTL:
|
||||
description:
|
||||
short: Enable gimbal yaw control in missions
|
||||
short: Enable gimbal yaw control in missions and Hold
|
||||
long: |-
|
||||
Enable yaw control of the mount. (Only affects multicopters and ROI mission items)
|
||||
Enable yaw control of the mount. (Only affects multicopters with an active ROI)
|
||||
|
||||
If enabled, yaw commands will be sent to the mount and the vehicle will follow its heading towards the flight direction.
|
||||
If disabled, the vehicle will yaw towards the ROI.
|
||||
If disabled, the vehicle will yaw towards the ROI in Mission and Hold mode.
|
||||
type: enum
|
||||
values:
|
||||
0: Disable
|
||||
|
||||
Reference in new issue
Block a user