mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 10:46:33 +08:00
ManualSmoothVel - Split position lock condition and flag action
This commit is contained in:
+13
-3
@@ -180,18 +180,28 @@ void FlightTaskManualPositionSmoothVel::_updateSetpoints()
|
|||||||
if (Vector2f(_vel_sp_smooth).length() < 0.01f &&
|
if (Vector2f(_vel_sp_smooth).length() < 0.01f &&
|
||||||
Vector2f(_acceleration_setpoint).length() < .2f &&
|
Vector2f(_acceleration_setpoint).length() < .2f &&
|
||||||
sticks_expo_xy.length() <= FLT_EPSILON) {
|
sticks_expo_xy.length() <= FLT_EPSILON) {
|
||||||
_position_setpoint_xy_locked(0) = pos_sp_smooth(0);
|
|
||||||
_position_setpoint_xy_locked(1) = pos_sp_smooth(1);
|
|
||||||
_position_lock_xy_active = true;
|
_position_lock_xy_active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fabsf(_vel_sp_smooth(2)) < 0.01f &&
|
if (fabsf(_vel_sp_smooth(2)) < 0.01f &&
|
||||||
fabsf(_acceleration_setpoint(2)) < .2f &&
|
fabsf(_acceleration_setpoint(2)) < .2f &&
|
||||||
fabsf(_sticks_expo(2)) <= FLT_EPSILON) {
|
fabsf(_sticks_expo(2)) <= FLT_EPSILON) {
|
||||||
_position_setpoint_z_locked = pos_sp_smooth(2);
|
|
||||||
_position_lock_z_active = true;
|
_position_lock_z_active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set valid position setpoint while in position lock.
|
||||||
|
// When the position lock condition above is false, it does not
|
||||||
|
// mean that the unlock condition is true. This is why
|
||||||
|
// we are checking the lock flag here.
|
||||||
|
if (_position_lock_xy_active) {
|
||||||
|
_position_setpoint_xy_locked(0) = pos_sp_smooth(0);
|
||||||
|
_position_setpoint_xy_locked(1) = pos_sp_smooth(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_position_lock_z_active) {
|
||||||
|
_position_setpoint_z_locked = pos_sp_smooth(2);
|
||||||
|
}
|
||||||
|
|
||||||
_position_setpoint(0) = _position_setpoint_xy_locked(0);
|
_position_setpoint(0) = _position_setpoint_xy_locked(0);
|
||||||
_position_setpoint(1) = _position_setpoint_xy_locked(1);
|
_position_setpoint(1) = _position_setpoint_xy_locked(1);
|
||||||
_position_setpoint(2) = _position_setpoint_z_locked;
|
_position_setpoint(2) = _position_setpoint_z_locked;
|
||||||
|
|||||||
Reference in New Issue
Block a user