Skip to content

Commit

Permalink
ManualSmoothVel - Split position lock condition and flag action
Browse files Browse the repository at this point in the history
  • Loading branch information
bresch committed Feb 25, 2019
1 parent db0283e commit f229444
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,28 @@ void FlightTaskManualPositionSmoothVel::_updateSetpoints()
if (Vector2f(_vel_sp_smooth).length() < 0.01f &&
Vector2f(_acceleration_setpoint).length() < .2f &&
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;
}

if (fabsf(_vel_sp_smooth(2)) < 0.01f &&
fabsf(_acceleration_setpoint(2)) < .2f &&
fabsf(_sticks_expo(2)) <= FLT_EPSILON) {
_position_setpoint_z_locked = pos_sp_smooth(2);
_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(1) = _position_setpoint_xy_locked(1);
_position_setpoint(2) = _position_setpoint_z_locked;
Expand Down

0 comments on commit f229444

Please sign in to comment.