FlightTasks: remove unnecessary double precision floating point math

This commit is contained in:
Daniel Agar
2019-10-17 08:44:33 +02:00
committed by Julian Oes
parent 25aded36ec
commit e942d3a3b2
2 changed files with 3 additions and 3 deletions
@@ -72,7 +72,7 @@ void FlightTaskAutoLine::_setSpeedAtTarget()
if (Vector2f(&(_target - _next_wp)(0)).length() > 0.001f &&
(Vector2f(&(_target - _prev_wp)(0)).length() > _target_acceptance_radius)) {
// angle = cos(x) + 1.0
// angle = cosf(x) + 1.0f
angle =
Vector2f(&(_target - _prev_wp)(0)).unit_or_zero()
* Vector2f(&(_target - _next_wp)(0)).unit_or_zero()
@@ -202,8 +202,8 @@ float FlightTaskAutoLineSmoothVel::_getSpeedAtTarget()
yaw_align_check_pass) {
// Max speed between current and next
const float max_speed_current_next = _getMaxSpeedFromDistance(distance_current_next);
const float alpha = acos(Vector2f(&(_target - _prev_wp)(0)).unit_or_zero() *
Vector2f(&(_target - _next_wp)(0)).unit_or_zero());
const float alpha = acosf(Vector2f(&(_target - _prev_wp)(0)).unit_or_zero() *
Vector2f(&(_target - _next_wp)(0)).unit_or_zero());
// We choose a maximum centripetal acceleration of MPC_ACC_HOR * MPC_XY_TRAJ_P to take in account
// that there is a jerk limit (a direct transition from line to circle is not possible)
// MPC_XY_TRAJ_P should be between 0 and 1.