Skip to content

Commit

Permalink
Merge pull request #6695 from iNavFlight/dzikuvx-do-not-slow-down-bef…
Browse files Browse the repository at this point in the history
…ore-wp

Do not slow down in WP mission when approaching a waypoint
  • Loading branch information
DzikuVx committed Mar 25, 2021
2 parents a0b243c + 7363df0 commit 48d6b6b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/navigation/navigation_multicopter.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,19 @@ static void updatePositionVelocityController_MC(const float maxSpeed)

// Scale velocity to respect max_speed
float newVelTotal = sqrtf(sq(newVelX) + sq(newVelY));
if (newVelTotal > maxSpeed) {

/*
* We override computed speed with max speed in following cases:
* 1 - computed velocity is > maxSpeed
* 2 - in WP mission when: slowDownForTurning is OFF, we do not fly towards na last waypoint and computed speed is < maxSpeed
*/
if (
(navGetCurrentStateFlags() & NAV_AUTO_WP &&
!isApproachingLastWaypoint() &&
newVelTotal < maxSpeed &&
!navConfig()->mc.slowDownForTurning
) || newVelTotal > maxSpeed
) {
newVelX = maxSpeed * (newVelX / newVelTotal);
newVelY = maxSpeed * (newVelY / newVelTotal);
newVelTotal = maxSpeed;
Expand Down

0 comments on commit 48d6b6b

Please sign in to comment.