Pure Pursuit PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

The pure pursuit path following algorithm

Juan Francisco Rascón Crespo

juan.rascon@eurecat.org

1 Introduction
This document is just a summary of some documents I have worked with when developing the
pure pursuit algorithm for a project in the company I work for, Eurecat. Given the general
success of this algorithm in literature and its simplicity, it is likely that it will be used again
in forthcoming land-based-navigation projects, so I decided to compile here my notes for future
reference.
This document aims to expose the geometric derivation for the path following algorithm called
pure pursuit for dierential drives.
This report also includes a geometric derivation of the method, and presents some insights into
the performance of the algorithm as a function of its parameters.

The pure pursuit algorithm is a tracking algorithm that works by calculating the curvature, γ ,
that will move a vehicle from its current position to some chosen path position . The
whole point of the algorithm is to choose a goal position that is some distance ahead of the

vehicle on the path (a waypoint). The name pure pursuit comes from the analogy that it
is used to describe the method. We tend to think of the vehicle as chasing a point on the path

some distance ahead of it, i.e., it is pursuing that moving point . That analogy is often used to
compare this method to the way humans drive . We tend to look some distance in front of the
car and head toward that spot. This lookahead distance, denoted as Lah , changes as we drive to
reect the twist of the road and vision occlusions.

1
2 Geometric derivation
The pure pursuit algorithm is a method of geometrically determining the curvature that will drive
the vehicle to a goal point. This goal point is a point on the path that is one lookahead distance,
Lah , from the current vehicle's position. An arc that joins the current vehicle's position and the
goal point is found out. The chord of this arc is the lookahead distance, and this is a constraint
in determining the unique arc that joins the two points. Consider the lookahead distance to be
analogous to the distance to a spot in front of a car that a human driver might look toward
to track the roadway. The result of the algorithm is the curvature, γ of the arc that joins the
vehicle's position to the chosen goal point and whose chord length is Lah

Figure 1: Geometric analysis for the pure pursuit algorithm.

2
q
Lah = (xg − xr )2 + (yg − yr )2 (1)
q
= x∗g 2 + yg∗ 2 (2)

θerr = α − θr (3)
 
yg − yr
= arctan − θr (4)
xg − xr

R = d + yg∗ (5)
R2 = d2 + x∗g 2 (6)
(7)
2
= R − yg∗ + x∗g 2

R2 = R2 − 2 R yg∗ + yg∗ 2 + x∗g 2 (8)

Since

q
Lah = x∗g 2 + yg∗ 2 (9)
yg∗ = Lah sin (θerr ) (10)
(11)

equation 8 becomes:

L2ah = 2 R yg∗ (12)


= 2 R Lah sin (θerr ) (13)
Lah = 2 R sin (θerr ) (14)

Finally:
1 2 sin (θerr )
γ = = (15)
R Lah

3
3 Implementation
The implementation of the pure pursuit algorithm is fairly straightforward. The pure pursuit
algorithm can be outlined as follows:

• Determine the robot's current location.

• Find the path's goal waypoint to navigate to. This action can be done in dierent ways.
The way I have implemented this now is that in the software I store the path's index for
the last goal waypoint the robot navigated to because this waypoint was one lookahead
distance from it. Next time the algorithm has to nd a goal point that is one lookahead
distance from the robot's position, it starts looking from this index onwards, selecting the
rst waypoint that satises this distance constraint.

• Calculate the curvature using the previous equations and request the vehicle to set the
steering to that curvature.

• Back to the rst step.

4 Eects of changing the lookahead distance


There is one parameter in the pure pursuit algorithm, the lookahead distance. The eects of
changing the parameter Lah are easy to imagine using the analogy to human driving.

4
Figure 2: Eect of Lah in the tracking behaviour.

Longer lookahead distances tend to converge to the path more gradually and with

less oscillation. The response of the pure pursuit tracker looks similar to the step response of
a second-order dynamic system and the value of Lah tends to act as a damping factor.
The longer the lookahead distance, the less curvy of a path that can be followed .
The algorithm is calculating a curvature so that the vehicle can drive an arc. If the path between
the vehicle and the goal point is suciently curvy then there might not be an arc that uses the
current value of Lah to join the two points; any driven arc will induce error.
Just a nal word about the lookahead distance. Try to make it at least equal to the dierential
base's track width (distance between wheels). That way, in the unusual case when θerr = π2 , the
radius R is half the distance between wheels and in that case the robot will turn around one of
the wheels, while the other will remain stopped. If the lookahead distance is less than the track
width, then in the weird case when θerr = π
2 the turning radius, R, will be less than half the
distance between wheels and then the robot will turn around a point that is located somewhere
in between one of the wheels and the robot's center, and even when this is not harmful it is not
very useful.

5
A video showing this: https://tinyurl.com/y6ox5zee

5 How to command the dierential drive to follow the curvature


Since we are commanding a dierential drive, we have to tell the low-level controller the linear
speed, v , and the angular speed, ω , for the robot to achieve the desired curvature. The pure
pursuit algorithm does not tell you what values are for these speeds; therefore, here you have to
be creative and design a strategy that ts your application and your platform. I'll show what I've
done in my particular case, but for yours, this might be inadequate. So feel free to experiment.
The only relationship we know that relates the curvature given by the pure pursuit controller
and the speeds we have to compute is:

v = Rω (16)
1
= ω (17)
γ

My strategy for the linear speed is this one:

• If the angular error, θerr , is within the interval dened by a small enough angle, [−θmin , θmin ],
then the robot will move in straigh line with speed Vmax . Let's say that θmin = 5◦ . So if
|θerr | ≤ θmin then, the heading error can be considered small enough to assume that the
robot can move in a straight line at maximum linear speed. Besides, the angular speed, ω ,
is forced to be 0 rad/s.

v = vmax |θerr | ≤ θmin


ω = 0 |θerr | ≤ θmin

• If the angular error is outside the interval dened by a large enough angle, [−θmax , θmax ],
then the robot will turn-in-place to correct its heading and to point to the proper goal
waypoint. Let's say, for instructional purposes, θmax = 70◦ . If the heading error is so
huge to be outside the interval [−θmax , θmax ], then there is no point in following the path.
Stop it and turn in place to recover the proper orientation. In this situation, v = 0 m/s
and ω is going to increase linearly with the heading error up to its maximum value. The

6
maximum angular speed, in the module, is achieved when the heading error, in absolute
value, exceeds the predened angle θrotmax = π
2 rad, for example.

v = 0 |θerr | ≥ θmax
 
−ωminrot
ω = ωmaxrot (θerr − θmax ) + ωminrot θerr ≥ θmax
 θrotmax −θrot 
−ωminrot
ω = ωmaxrot
θrotmax −θrot (θerr + θmax ) − ωminrot θerr ≤ −θmax

Figure 3: Linear speed and curvature (in cyan).

7
-
- -

Figure 4: Angular speed and curvature (in cyan).

• If the angular error, in absolute value, is within the interval [θmin , θmax ] then the robot
moves describing an arc with curvature γ . In this situation the linear speed and the angular
speed are describe by these expressions:

 
−Vmax
v = θmax −θmin (|θerr | − θmax ) θmin ≤ |θerr | ≤ θmax
v
ω = R = vγ θmin ≤ |θerr | ≤ θmax

Finally, the algorithm should check if the computed angular speed is below its maximum
level all the time the vehicle is in this interval, ωmax . To be clear, I'm considering a
maximum angular speed when the robot rotates in place, ωrotmax , also a minimum angular
speed when it rotates in place, ωrotmin , and also a dierent maximum angular speed when
the robot is traversing an arc, ωmax . I consider all these speeds to be as exible as possible.
Then you can merge those values as you want.
Two cases here. If the angular speed, ω is below its maximum level in this interval all the
time, then the algorithm has nished.

8
When (θmin ≤ |θerr | ≤ θmax ) −→ |ω| ≤ wmax

It might happen that the computed angular speed at any moment in this interval were,
in absolute value, |ω|, greater than its maximum level, ωmax , |ω| > ωmax . In that case,
you should truncate the angular speed's value to be below its maximum level. Now, as
you want the vehicle to follow the computed curvature, to traverse the found arc, then the
algorithm has to re-compute the linear speed, now with the truncated angular speed and
the curvature:

ω
v = Rω =
γ

Be careful to check if the curvature is zero before dividing.

Some images to show what I've just explained.

2 2 2 3

1.5 1.5 1.5


2.5

1 1 1

2
0.5 0.5 0.5

0 0 0 1.5

-0.5 -0.5 -0.5


1

-1 -1 -1

0.5
-1.5 -1.5 -1.5

-2 -2 -2 0
-200 -150 -100 -50 0 50 100 150 200 -200 -150 -100 -50 0 50 100 150 200

3 2

1.5
2.5

2
0.5

1.5 0

-0.5
1

-1

0.5
-1.5

0 -2
-200 -150 -100 -50 0 50 100 150 200

Figure 5: Truncated angular and linear speed.

9
6 References
Implementation of the Pure Pursuit Path Tracking Algorithm, R. Craig Coulter, CMU-RI-TR-
92-01.

10

You might also like