Skip to content

Commit

Permalink
FlightTasks: remove unnecessary double precision floating point math
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar authored and julianoes committed Oct 17, 2019
1 parent 25aded3 commit e942d3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/FlightTasks/tasks/AutoLine/FlightTaskAutoLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e942d3a

Please sign in to comment.