Skip to content

Commit

Permalink
AutoSmoothVel - Handle NAN in velocity and position properly
Browse files Browse the repository at this point in the history
  • Loading branch information
bresch authored and LorenzMeier committed Jan 17, 2019
1 parent ef54bff commit a2e9d9f
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,6 @@ void FlightTaskAutoLineSmoothVel::_prepareSetpoints()
MPC_XY_TRAJ_P.get(); // Along-track setpoint + cross-track P controller
}

} else if (!PX4_ISFINITE(_velocity_setpoint(0)) &&
!PX4_ISFINITE(_velocity_setpoint(1))) {
// No position nor velocity setpoints available, set the velocity targer to zero

_velocity_setpoint(0) = 0.f;
_velocity_setpoint(1) = 0.f;
}

if (PX4_ISFINITE(_position_setpoint(2))) {
Expand All @@ -175,9 +169,6 @@ void FlightTaskAutoLineSmoothVel::_prepareSetpoints()
_velocity_setpoint(2) = vel_sp_z;
}

} else if (!PX4_ISFINITE(_velocity_setpoint(2))) {
// No position nor velocity setpoints available, set the velocity targer to zero
_velocity_setpoint(2) = 0.f;
}
}

Expand All @@ -204,6 +195,11 @@ void FlightTaskAutoLineSmoothVel::_updateTrajConstraints()

void FlightTaskAutoLineSmoothVel::_generateTrajectory()
{
if (!PX4_ISFINITE(_velocity_setpoint(0)) || !PX4_ISFINITE(_velocity_setpoint(1))
|| !PX4_ISFINITE(_velocity_setpoint(2))) {
return;
}

/* Slow down the trajectory by decreasing the integration time based on the position error.
* This is only performed when the drone is behind the trajectory
*/
Expand Down

0 comments on commit a2e9d9f

Please sign in to comment.