mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 10:53:34 +08:00
FlightTaskAuto: lock yaw once within acceptance radius
This commit is contained in:
committed by
ChristophTobler
parent
72f1fca55c
commit
1f1c9fde01
@@ -256,13 +256,20 @@ void FlightTaskAuto::_set_heading_from_mode()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (PX4_ISFINITE(v.length())) {
|
if (PX4_ISFINITE(v.length())) {
|
||||||
// We only adjust yaw if vehicle is outside of acceptance radius.
|
// We only adjust yaw if vehicle is outside of acceptance radius. Once we enter acceptance
|
||||||
|
// radius, lock yaw to current yaw.
|
||||||
// This prevents excessive yawing.
|
// This prevents excessive yawing.
|
||||||
if (v.length() > NAV_ACC_RAD.get()) {
|
if (v.length() > NAV_ACC_RAD.get()) {
|
||||||
_compute_heading_from_2D_vector(_yaw_setpoint, v);
|
_compute_heading_from_2D_vector(_yaw_setpoint, v);
|
||||||
|
_yaw_lock = false;
|
||||||
|
} else {
|
||||||
|
if (!_yaw_lock) {
|
||||||
|
_yaw_setpoint = _yaw;
|
||||||
|
_yaw_lock = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
_yaw_lock = false;
|
||||||
_yaw_setpoint = NAN;
|
_yaw_setpoint = NAN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
matrix::Vector2f _lock_position_xy{NAN, NAN}; /**< if no valid triplet is received, lock positition to current position */
|
matrix::Vector2f _lock_position_xy{NAN, NAN}; /**< if no valid triplet is received, lock positition to current position */
|
||||||
|
bool _yaw_lock = false; /**< if within acceptance radius, lock yaw to current yaw */
|
||||||
uORB::Subscription<position_setpoint_triplet_s> *_sub_triplet_setpoint{nullptr};
|
uORB::Subscription<position_setpoint_triplet_s> *_sub_triplet_setpoint{nullptr};
|
||||||
|
|
||||||
matrix::Vector3f
|
matrix::Vector3f
|
||||||
|
|||||||
Reference in New Issue
Block a user