Pure Pursuit Algorithm Autonomous Driving
Pure Pursuit Algorithm Autonomous Driving
net/publication/341216836
CITATIONS READS
0 3,338
1 author:
Edoardo Cocconi
University of Nottingham
1 PUBLICATION 0 CITATIONS
SEE PROFILE
All content following this page was uploaded by Edoardo Cocconi on 16 May 2020.
Faculty of Engineering
UNSW Sydney
by
Edoardo Cocconi
ORIGINALITY STATEMENT
‘I hereby declare that this submission is my own work and to the best of my knowledge it contains no
materials previously published or written by another person, or substantial proportions of material
which have been accepted for the award of any other degree or diploma at UNSW or any other
educational institution, except where due acknowledgement is made in the thesis. Any contribution
made to the research by others, with whom I have worked at UNSW or elsewhere, is explicitly
acknowledged in the thesis. I also declare that the intellectual content of this thesis is the product of
my own work, except to the extent that assistance from others in the project's design and conception or
in style, presentation and linguistic expression is acknowledged.’
Signed ……………………………………………..............
Date ……………………………………………..............
ii
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
Abstract
iii
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
Acknowledgements
Thanks to Dr Jay Katupitiya for his guidance, support and availability. I am thankful for
working side to side with such a brilliant professor and learning about such interesting
topics with him.
I want to thank Dr David Lyons for going an extra mile to let me start this amazing journey
and for supporting me before and throughout my stay here at UNSW.
iv
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
𝒌𝟏 = proportional gain
𝒌𝟐 = derivative gain
𝑷 = target point
𝑹𝟎 = look-ahead distance
𝒗𝟏 = tangential velocity
𝒗𝟐 = steering rate
𝒙𝒚 = fixed reference frame
𝑿𝒀 = vehicle reference frame
𝜹 = steering angle
𝜽 = angle offset
𝐞 𝓵𝐝 = offset error
𝒈𝒙 , 𝒈𝒚 = target point coordinates
𝒌 = tunable look-ahead constant
𝑳 = length of the vehicle
𝓵𝐝 = look-ahead distance
𝑹 = radius of curvature
𝜹 = steering angle
𝜿 = curvature
Stanley Method
𝜽𝒆 = orientation error
𝒆𝒇𝒂 = offset error
v
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
Contents
Acknowledgements.......................................................................................................... iv
Contents ............................................................................................................................. vi
Introduction ...................................................................................................................... 1
Background ....................................................................................................................... 4
vi
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
Conclusion ........................................................................................................................ 24
Bibliography .................................................................................................................... 26
Appendix 1 ...................................................................................................................... 28
vii
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
Chapter 1
Introduction
An autonomous vehicle uses sensors such as LIDAR, GPS, IMU, and cameras to detect the
surrounding environment and localize itself. As shown in Fig. 1, it will subsequently calculate
the most feasible, safe, legal, and efficient path that will lead it to destination, and use a control
system to try to move following this path [2]. The subject of this thesis is Pure Pursuit
Algorithm, which is a control algorithm that allows autonomous UGVs to compute the steering
angle necessary to follow the previously determined path. The advantage of using such an
algorithm instead of hard-coding a sequence of steering angles is that in the eventuality of
1
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
deviations due to errors and unpredictable circumstances the vehicle can automatically stir itself
to get back onto its original route.
This increase in flexibility comes at a cost: it is necessary to develop a mathematical model that
triggers the right behavior under a wide spectrum of circumstances. In high accuracy
applications like self-driving cars, control algorithms are automatically tuned by artificial neural
networks (ANN) [11]. However, artificial intelligence can be expensive for a company in terms
of time and high level of expertise needed for the collection of data and the creation of a model.
These costs are further exacerbated by the constant expenses due to retraining, maintenance, and
eventual upgrades that AI algorithms typically need[15]. Therefore, AI is not to be regarded as a
silver bullet, but as a last resort to be utilized when simpler alternatives fail. The aim of this
thesis is to improve the Pure Pursuit controller so it can be used without ANN in a wider range
of applications.
2
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
possibility to tune the system, the Pure Pursuit Algorithm suffers from an inherent geometrical
limitation. Since the vehicle is headed towards a point travelling on the path, it will detect a turn
as soon as the point starts turning, even though it is not time for the vehicle to turn yet. This
leads to the cutting of corners, which is the main obstacle that has to be overcome to make the
algorithm usable in a wider range of applications.
The different algorithms are tested with a MATLAB simulation of a kinematic model of a UGV
[5]. A kinematic model is a model in which it is assumed that the vehicle can instantly reach the
desired speed, and it is therefore only accurate at low speeds, typically under 5 m/s [6]. This
allows to neglect the effects of accelerations and consequent forces acting on the UGV. A
kinematic model is already suited to the design of controllers for agricultural applications,
characterized by low speeds and accelerations [16][17]. The effects of slip have been added to
the simulation in order to better mimic an off-road environment. In future studies the produced
code could be tested on dynamic models and hardware to extend its validity to other types of
vehicles.
Follow the Carrot, Pure Pursuit, and Stanley Method have been implemented with and without
the effects of slip. An original improvement of the Follow the Carrot Algorithm has been
completed and it is ready for more realistic testing. In this modified algorithm, the carrot doesn’t
travel on the path that the vehicle is required to follow. Instead, it travels on the path that will
lead the vehicle in the right position at all times, even during turns. This method and the
produced MATLAB code is to be considered the contribution of this thesis.
The upcoming sections of the report will guide the reader through the theory behind Pure
Pursuit Algorithm and show in detail how it has been modified for maximum performance.
3
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
Chapter 2
Background
Pure Pursuit Algorithm is the most common and effective geometric method to direct a vehicle
towards a moving point travelling a path. Pure Pursuit was first devised in a study published in
1969 regarding the pursuit of a missile to a target [7]. In 1985 the Pure Pursuit strategy was
applied to the field of robotics for the first time in an algorithm capable of estimating the
steering necessary to maintain the vehicle on the road [8][9]. In this section the existing variants
of the Pure Pursuit Algorithm are explored in depth. The first to be discussed will be a
simplified version commonly called Follow the Carrot Algorithm. Successively, the full Pure
Pursuit Algorithm will be explained alongside the assumptions on which it is based. Eventually,
this section will go over the most recent variants and improvements of the algorithm made in
recent years.
The Follow the Carrot Algorithm is based on a very simple idea. At every instant the algorithm
detects the point on the path ahead of the vehicle with distance 𝑅0 from the center of its front
axle. Then it sets the value of the steering angle 𝛿(𝑡) to be equal and opposite to the offset error,
until the vehicle is directed towards its moving goal and its trajectory converges with the path.
To simplify the mathematical aspect of the model, the path indicated in red in Fig. 3 coincides
with the x-axis of the fixed reference frame. However, the same principles can be applied to a
much wider spectrum of scenarios if the reference frame of the vehicle is adopted instead.
4
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
Steering Angle
Look-ahead
distance
Path
Carrot Point
.
Figure 3. Follow the Carrot geometry [4]
In Fig. 3 the orientation error of the UGV is given by the sum of 𝛼 and 𝜃.
𝛿(𝑡) = −( 𝛼 + 𝜃) (1)
Since the path coincides with the x-axis, it is possible to use the following geometric properties
to relate 𝛼 and 𝜃 to the distance of the vehicle from the path 𝑦:
𝑦 𝑑𝑦
𝛼= 𝜃= (2)
𝑅0 𝑑𝑥
1 𝑑𝑦
𝛿(𝑡) = − ( 𝑦+ ) (3)
𝑅0 𝑑𝑥
In control systems, the term containing 𝑦 is generally called Proportional Term and the term
containing its derivative is called Derivative Term. The Proportional Term allows to quickly
reduce the distance 𝑦 of the vehicle from the path, while the Derivative Term makes sure that
the vehicle reaches the path with the right steering angle and low velocity in the 𝑦 direction [10].
5
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
Tunable parameter 𝑘1 and 𝑘2 can be added to the equation to regulate the influence of these two
terms on the steering angle and on the trajectory of the UGV.
𝑘1 𝑑𝑦
𝛿(𝑡) = − ( 𝑦 + 𝑘2 ) (4)
𝑅0 𝑑𝑥
𝑘1 is called Proportional Gain, and 𝑘2 is called Derivative Gain. Increasing the Derivative Gain
too much will result in a very smooth trajectory, but it will keep the vehicle off the path for an
unacceptable amount of time. This is wat is commonly referred to as an Over-Damped System.
Instead, if the Proportional Gain is too high the system will steer abruptly, and it will oscillate
around the path before stabilizing. The same effect could be caused by a small look-ahead
distance 𝑅0 or by an increase of the
tangential velocity of the vehicle. This
type of system is called Under-
Damped System. When 𝑘1 and 𝑘2
and 𝑅0 are properly tuned it is
possible to achieve a Critically
Damped System, where the vehicle
quickly reaches the path without
incurring in overshooting as indicated
in green in Fig. 4 [10]. Figure 4. System damping.
The complete version of this algorithm can be better visualized by representing the vehicle
using the Bicycle Model. The Bicycle Model simplifies the four-wheel car by combining the
two front wheels together and the two rear wheels together to form a two-wheeled model, like a
bicycle. This results in a simple geometric relationship between the front wheel steering angle
and the curvature that the rear axle will follow [3].
6
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
𝐿
𝑡𝑎𝑛(𝛿) = (5)
𝑅
Where δ is the steering angle of the front wheel, 𝐿 is the length of the vehicle and 𝑅 is the radius
of the circle that the rear axle will travel along at the given steering angle.
7
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
The vehicle’s steering angle δ can be defined using the goal point location and the angle α
between the vehicle’s heading vector and the look-ahead vector. By applying the law of sines, it
is possible to derive the following equation [3]:
ℓd R
= 𝜋 (6)
sin (2α) sin ( − 𝛼)
2
ℓd R
= (7)
2 sin (α) cos (α) cos (α)
ℓd
= 2R (8)
sin (α)
2 sin (α)
κ= (9)
ℓd
where κ is the curvature of the circular arc. Using the properties of the geometry of the bicycle
model earlier described in Eq. (5), the steering angle can be written as follows:
Combining Eqs. (9) and (10), the Pure Pursuit control law can be expressed as:
2 𝐿 sin (α(t))
δ(t) = tan−1 ( ) (11)
ℓd
A better understanding of this control law can be gained by defining a new variable, 𝑒ℓ𝑑 to be
the offset error defined by the lateral distance between the heading vector and the goal point [3].
This results in the equation:
e ℓd
sin (α) = (12)
ℓd
2
𝜅 = e (13)
ℓ2𝑑 ℓd
8
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
Equation (13) demonstrates that Pure Pursuit is a Proportional Control of the steering angle with
a Proportional Gain of 2/ℓ2𝑑 [3].
To simplify tuning, the control law can be rewritten, scaling the look-ahead distance with the
longitudinal velocity of the vehicle. Additionally, the look-ahead distance is commonly limited
to a minimum and maximum value. This results in:
2 𝐿 sin (𝛼)
𝛿(𝑡) = 𝑡𝑎𝑛−1 ( ) (14)
𝑘 𝑣(𝑡)
As 𝑘 increases, the look-ahead distance is increased and the tracking becomes less and less
oscillatory. A short look-ahead distance provides more accurate tracking while a longer distance
provides smoother tracking. It is clear that a 𝑘 value that is too small will cause the system to be
unstable and under-damped, and a 𝑘 value that is too large will generate an Over-Damped
System with poor tracking. One must be careful not to over tune on a course and test a variety of
courses and speeds to find a 𝑘 that can perform well over the operating requirements of the
vehicle [3]. Another characteristic of Pure Pursuit is that a sufficient look-ahead distance will
result in cutting corners while executing turns on the path [4]. This is due to the fact that the
algorithm is looking several meters forward, so it will detect turns before the vehicle has
reached them it and will start steering accordingly.
The method is named after the self-driving car Stanley that is the first autonomous vehicle to
have ever completed the notorious DARPA Grand Challenge and used this very algorithm. The
Stanley Method have a base steering angle
equal to the orientation error 𝜃𝑒 and an
additional steering angle proportional to the
offset error 𝑒𝑓𝑎 . This intuitive control law
allows to minimize both errors and bring the
vehicle on the path. 𝑒𝑓𝑎 is equal to the
distance between the front axle of the vehicle
and its closest point on the path indicated by
the coordinates (𝑐𝑥 , 𝑐𝑦 ) (Fig. 7). Instead, 𝜃𝑒 Figure 7. Stanley Method [3].
9
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
is given by the angular difference between the direction of the vehicle and the direction of the
path at (𝑐𝑥 , 𝑐𝑦 ). The resulting control law assumes the following form [3]:
𝑘 ∙ 𝑒𝑓𝑎
𝛿(𝑡) = 𝜃𝑒 + 𝑡𝑎𝑛−1 ( ) (15)
𝑣𝑥 (𝑡)
Where 𝑘 is a tunable parameter and the tangential speed 𝑣𝑥 (𝑡) is situated at the denominator to
avoid overshoot at higher speeds. Indeed, approaching the course too fast could lead to
oscillations, but it can be avoided by minimizing the effects of the offset error term.
The major drawback of this method is that the path must be differentiable in order to calculate
its direction at (𝑐𝑥 , 𝑐𝑦 ), and no discontinuity points are allowed [11]. The algorithm also suffers
from the opposite problem of Pure Pursuit: without feed forward the algorithm cannot prevent
errors but only react to them. This means that in case of sharp corners the vehicle will find itself
off the path and a control effort will successively be generated to bring it back on track. This
causes wide turns.
As shown in this section there is plenty of algorithms and ideas to approach the path-tracking
issue. The subject topic covered in the next section is how to set up a system to test and improve
these solutions.
10
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
Chapter 3
Solution Method
In order to test a control system such as the Pure Pursuit Algorithm, it is necessary to implement
it into a source code and to set up an infrastructure to test the code produced. This can be done
in two ways.
Using a physical UGV: This method can be expensive and dangerous but gives an immediate
idea of the actual behavior of the vehicle.
Using a UGV model: This method is cheap and safe but needs the code of the simulation to be
written. It is not going to match completely the actual behavior because it is just a mathematical
simulation [13]. At the initial stages of a project, a simulation is usually preferred, and it is the
method that will be utilized throughout this thesis.
the state of the UGV model, however the user of the simulation will not have to manually
provide this information since they will be automatically outputted by the control system. The
model with tangential velocity and steering rate as inputs is referred to as Standard Model, while
the model with tangential velocity and steering angle as inputs is referred to as Reduced Model.
The Reduced model is based on the assumption that every possible steering angle can be
reached instantaneously. As suggested by the name, this is a simplified model and it has the
advantage of requiring less computational power and being easier to understand and visualize in
relation to the algorithms explained above. Both models have been successfully set up, but the
Reduced Model gave more results because it is easier to visualize, which facilitated control
algorithms modification.
In order to allow the reader to reproduce the tests that have been performed, the MATLAB code
of the Modified Follow the Carrot Reduced Model simulation with slip has been pasted below.
The comments explain its functioning. The base code of the simulation can be retrieved at [5].
% Simulation
tspan = 0.0:0.1:60; %start time : timestep : end time
options = odeset('RelTol',1e-4,'AbsTol',[1e-5 1e-5 1e-5]); % options of
the ODE-solving function
[t,x] = ode45(@UPDN_UGV_model, tspan,[0 2 2*pi/8.0], options);
% [result] = ode45(function to solve, [start-time, end-time],
% initial conditions [x, y, teta, delta], options)
% this will derivate [xdot(1) xdot(2) xdot(3) xdot(4)] and give [x, y,
% theta, delta] of the UGV at any given time
12
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
function Create_Path2()
global current_point;
current_point = 0;
slope1 = (yfinal-yinitial)/(xfinal-xinitial);
13
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
continue_loop = 1;
% The loop will continue as long as you are building the course
while continue_loop
xmemo = xfinal;
ymemo = yfinal;
slope2 = (yfinal-yinitial)/(xfinal-xinitial);
% The second segment of the carrot path is saved. However, the line
has
% new initial coordinates, different from the vehicle path
[sz3, sz4] = size(xx_equal_distance);
new_xinitial = xx_equal_distance(sz4);
new_yinitial = yy_equal_distance(sz4);
length1 = sqrt((xfinal-new_xinitial)^2+(yfinal-new_yinitial)^2);
n1 = length1 * 100;
x_path_coordinates_new = linspace (new_xinitial,xfinal, n1);
y_path_coordinates_new = linspace (new_yinitial,yfinal, n1);
x_path_calc_coordinates = [x_path_calc_coordinates,
x_path_coordinates_new];
y_path_calc_coordinates = [y_path_calc_coordinates,
y_path_coordinates_new];
15
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
xinitial_spline = xfinal;
yinitial_spline = yfinal;
slope1 = slope2;
end
return;
% Declarations
xdot = zeros(3,1);
inputs = zeros(2,1); %velocity and stiring angle
%control inputs
inputs = UPDN_UGV_control_carrot(t,x);
% the slip velocity is proportional to how fast the car is going, k, and
the steering angle
v_slip = k*inputs(1)*inputs(2);
slip_angle = atan(v_slip/inputs(1));
%state equations
xdot(1) = vtot*cos(x(3)-slip_angle);
xdot(2) = vtot*sin(x(3)-slip_angle);
xdot(3) = sin(inputs(2))/(L*cos(inputs(2)-slip_angle))*vtot;
return;
% State variables
% [x(1) x(2) x(3)]
% x(1) - global x coordinate (m.)
% x(2) - global y coordinate (m.)
% x(3) = \theta - UGV heading (rad.)
global current_point;
global x_path_calc_coordinates
global y_path_calc_coordinates
R0 = 4.0; % Fixed look-ahead distance
distance = sqrt(X_prime^2+Y_prime^2);
count = 0;
current_x = x_path_calc_coordinates(current_point);
current_y = y_path_calc_coordinates(current_point);
distance = sqrt(X_prime^2+Y_prime^2);
count = count + 1;
end
17
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
end
return;
plot(x_path_calc_coordinates(1,point_sequence(i,1)),y_path_calc_coordina
tes(1,point_sequence(i,1)),'r.')
%L is the length
%angle is alpha
x2=x(i,1)+(4*cos(x(i,4)+x(i,3)));
y2=x(i,2)+(4*sin(x(i,4)+x(i,3)));
plot([x(i,1) x2],[x(i,2) y2],'g') % Shows where the car is pointing
% Scale the axis
axis equal;
axis([min(x(:,1))-5.0, max(x(:,1))+5.0,min(x(:,2))-
5.0,max(x(:,2))+5.0]);
% Plot the axis
ax = gca;
ax.XAxisLocation = 'origin'; % Plot x axis
ax.YAxisLocation = 'origin'; % Plot y axis
pause(0.001); % Slow down the output so it can be seen
18
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
hold off % Cancels the effect of "hold on" and allows the new
position of the UGV to be plotted
end
return;
These five files need to be in the same directory to work properly. The interparc function can be
found at [18] and also needs to be saved in the same directory. The simulation can be started by
running main.m. Follow the instructions displayed on the screen. If you get an error, it is likely
that the time allocated for the simulation is too long. You can either increase the size of the
course by entering new values or decrease the simulation time by modifying tspan in the main
function. The graphs produced by the code have been analyzed in an iterative process to
evaluate and modify the different algorithms. The results of this process can be found in the
following section.
19
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
Chapter 4
In this section, the performance of the algorithms coded will be analyzed and compared. The
first algorithm is a Follow the Carrot Algorithm with the goal of following a path made out of
segments joined by splines.
Finish
Start
As is possible to observe from Fig. 8, the vehicle trail indicated in red smoothly converges with
the black path without overshooting or oscillating. The red and the black lines completely
overlap in the straightway, meaning that no steady state error is present. However, the typical
20
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
flaw of Pure Pursuit algorithms can be observed: the vehicle cuts corners. This issue is evident
especially on sharp corners and this algorithm is therefore non satisfactory in high accuracy
applications.
One way to tackle this issue is to come up with different error terms to use in the controller, but
there is an easier and more effective way to improve the algorithm. It is sufficient to calculate
the path that the carrot would have to follow for the vehicle to stay on the chosen path. At every
moment in time, the desired position of the carrot can be calculated by following these
procedures:
1. Find the closest point to the vehicle that is part of the path and call it point A.
2. Draw the tangent to the path that touches point A.
3. Find points B and C that lie on the tangent at distance 𝑅0 from A.
4. Discard point B on the back of the vehicle and keep point C.
5. Point C is where the carrot point should be to keep the vehicle on track.
If the direction of travel of the UGV is known in advance, it is possible to calculate beforehand
the path that the carrot has to follow. This is done by carrying out steps 1 to 5 for every point in
the chosen path. The result of this operation is illustrated in Fig. 9. The chosen path is presented
Start
Finish
21
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
This modification prevents the vehicle from cutting corners because it is allowed to go straight
until it actually reaches a turn. The results obtained by the Modified Follow the Carrot
Algorithm are shown in Fig. 10.
Finish
Start
22
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
The effects of slip can also be overcome by modifying the course travelled by the carrot. It is
just necessary to shorten the distance 𝐴𝐶 so that the vehicle starts to turn earlier. This expedient
allows to obtain results indistinguishable from the ones shown in Fig. 10.
Pure Pursuit Algorithm and Stanley Method have also been tested but did not produce results as
positive as the Follow the Carrot Algorithm. The Pure Pursuit Algorithm can also benefit from
the method explained above, but its greater complexity does not allow to calculate the specific
path that the carrot should follow. It can be obtained empirically but this places this algorithm
one step below the Follow the Carrot. The Stanley method has been successfully implemented,
but a way has not been found to improve it or mix it with the previous algorithms. The code for
both algorithms can be found in the Appendix along with a graphical representation of their
results.
The Modified Follow the carrot algorithm can be considered successful so and should be
brought forward to be tested in a dynamic model. None of the research papers that have been
examined for the creation of this thesis used this approach to improve path tracking algorithms.
Therefore, the method and the MATLAB code described above can be considered an original
contribution of this thesis.
23
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
Chapter 5
Conclusion
Pure Pursuit Algorithm is a powerful control system widely used in different fields like
aerospace engineering and autonomous driving. This thesis has started from the most basic
versions of the algorithm and expanded to a solution that could be a promising alternative to AI
in low-end applications. Being able to contrast the effects of slip it is also a good candidate for
farming vehicles. As stated in the results section, the Modified Follow the Carrot Algorithm can
be considered successful and ready to be tested in a dynamic model.
Future modifications could find a way to calculate the exact path that the carrot should follow
for the Pure Pursuit Algorithm to obtain similar results to the ones shown above.
The Pure Pursuit Algorithm could be improved by establishing an inverse relationship between
the tangential speed of the vehicle 𝑣 and the curvature 𝜅 to mimic the behavior of human drivers
that slow down before a sharp corner. The Follow the Carrot Algorithm could also be further
improved by reducing the look-ahead distance during turns and increase it during straightway.
This solution is again inspired to the behavior of human drivers.
When the algorithms will be applied to hardware, an Integral Term could be added to the
equation to detect if the vehicle is spending more time on one side or the other of the path. This
24
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
allows to take into account systematic errors due to defects in the hardware utilized and to
correct the steering angle accordingly. This would create a combination of three that is referred
to as PID Control (Proportional, Integral, Derivative Control) [10].
More complex algorithms could also be tested. Vector Pursuit is an algorithm that has been
developed in the attempt to not only have the vehicle arrive at the goal point, but to arrive also
with the correct orientation and curvature. This translates into the vehicle joining the course with
the proper steering angle [4].
25
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
Bibliography
[1] Association for Safe International Road Travel (ASIRT), URL: https://www.asirt.org/safe-travel/road-safety-
facts/ [cited 10 October 2018].
[2] D. Rose, “THE FOUR PILLARS OF SELF-DRIVING CARS,” STRATEGYWISE, Mar. 2018, URL:
https://strategywise.com/the-four-pillars-of-self-driving-cars/ [cited 14 October 2018].
[3] J. M. Snider, “Automatic Steering Methods for Autonomous Automobile Path Tracking,” Robotics Institute
Carnegie Mellon University, Pittsburgh, PE, 2009.
[4] M. Lundgren and T. Hellström, “Path Tracking for a Miniature Robot,” Excerpt from master’s thesis, Dept.
of Computing Science, Umeå University, Sweden, 2003.
[5] J. Katupitiya “Modelling and Simulation of a Kinematic Model of a Car-like UGV,” University of New
South Wales, Australia, 2014.
[6] P. Polack, F. Altché, B. D’Andréa-Novel, and A. De La Fortelle “The Kinematic Bicycle Model: a
Consistent Model for Planning Feasible Trajectories for Autonomous Vehicles?” HAL Polytechnique,
France, 11 May 2017.
[7] L. Scharf, W. Harthill, and P. Moose, "A comparison of expected flight times for intercept and pure pursuit
missiles," IEEE Transactions on Aerospace and Electronic Systems, vol. 4, pp. 672-673, 1969.
[8] M. Samuel, “A Review of some Pure-Pursuit based Path Tracking Techniques for Control of Autonomous
Vehicle,” International Journal of Computer Applications (0975 – 8887) Volume 135 – No.1, February
2016.
[9] R. Wallace, A. Stentz, C. E. Thorpe, H. Maravec, W. Whittaker, and T. Kanade, "First Results in Robot
Road Following," IJCAI, pp. 1089-1095, 1985.
[10] A. C. Ritchie, “Systems modelling and control,” Dynamics (MM2DYN), University of Nottingham, Dept. of
Mechanical, Materials and Manufacturing Engineering, 2018.
[11] Y. Shan, W. Yang, C. Chen, J. Zhou, L. Zheng and B. Li “CF-Pursuit: A Pursuit Method with a Clothoid
Fitting and a Fuzzy Controller for Autonomous Vehicles,” International Journal of Advanced Robotic
Systems, 12:134 doi: 10.5772/61391, 2015.
[12] T. Hellström and O. Ringdahl, “Autonomous Path Tracking Using Recorded Orientation and Steering
Commands,” Dept. of Computer Science Ume˚a University, Sweden, 2005.
[13] J. Katupitiya, “Computer Applications in Mechatronic Systems,” MTRN3500-S2 2018, University of New
South Wales, Australia.
[14] J. Katupitiya, “Computer Applications in Mechatronic Systems,” MTRN3500-S2 2018, University of New
South Wales, Australia.
[15] M. Yao, M Jia and A. Zhou “Applied Artificial Intelligence: A Handbook for Business Leaders,” 2017.
[16] J. Taghia, S. Lam and J. Katupitiya “Path Following Control of an Off-Road Track Vehicle Towing a
26
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
Steerable Driven Implement,” IEEE International Conference on Advanced Intelligent Mechatronics (AIM),
Busan, Korea, 2015.
[17] R. Werner, S. Muller, and K. Kormann, “Path tracking control of tractors and steerable towed implements
based on kinematic and dynamic modeling,” in 11th International Conference on Precision Agriculture,
Indianapolis, Indiana, USA, 2012.
[18] J. D'Errico, MathWorks File Exchange, URL: https://au.mathworks.com/matlabcentral/fileexchange/34874-
interparc [cited 10 October 2018].
27
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
Appendix 1
Create_Path2()
global x_path_calc_coordinates
global y_path_calc_coordinates
global x_path_coordinates
global y_path_coordinates
global point_sequence
global current_point
global data
[sz1,sz2] = size(x_path_calc_coordinates);
tfinal = sz2/270;
% Simulation
tspan = 0.0:0.1:60;
options = odeset('RelTol',1e-4,'AbsTol',[1e-5 1e-5 1e-5]); % options of
the ODE-solving function
[t,x] = ode45(@UPDN_UGV_model, tspan,[0 2 2*pi/8.0], options);
% [result] = ode45(function to solve, [start-time, end-time],
% initial conditions [x, y, teta, delta], options)
% this will derivate [xdot(1) xdot(2) xdot(3) xdot(4)] and give [x, y,
% theta, delta] of the UGV at any given time
28
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
for i = 1:N % Obtain the steering angles at each instant so they can be
plotted
inputs = UPDN_UGV_control_pure_pursuit(t(i,1),x(i,:));
point_sequence(i,1) = current_point;
steering_angle(i,1) = inputs(2);
end
backup = x;
clear x
x = [backup(:,1), backup(:,2), backup(:,3),steering_angle(:,1)];
global current_point;
global x_path_calc_coordinates
global y_path_calc_coordinates
distance = sqrt(X_prime^2+Y_prime^2);
count = 0;
29
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
current_x = x_path_calc_coordinates(current_point);
current_y = y_path_calc_coordinates(current_point);
distance = sqrt(X_prime^2+Y_prime^2);
count = count + 1;
end
return;
global x_path_calc_coordinates
global y_path_calc_coordinates
global x_path_coordinates
global y_path_coordinates
global point_sequence
figure; % Plot figure 1
UGV = [ 0 0 -0.9000 -0.9000 0 0
0 -0.2500 -0.2500 0.2500 0.2500 0]; % UGV
dimensions
30
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
%sz = size(point_sequence);
for i = 1:size(t)% Real time animation of UGV motion and trajectory
UGV_ugv = [cos(x(i,3)) -sin(x(i,3));sin(x(i,3)) cos(x(i,3))];
ugv = UGV_ugv* UGV;
plot(x(i,1)+ugv(1,:), x(i,2)+ugv(2,:)); hold on; % Plot the UGV
plot(x_path_coordinates(1,:),y_path_coordinates(1,:),'k') % Plot the
path
plot(x_path_calc_coordinates(1,:),y_path_calc_coordinates(1,:),'b')
plot(x(1:i,1),x(1:i,2),'r') % Plot the actual path already percurred
plot(x_path_calc_coordinates(1,point_sequence(i,1)),y_path_calc_coordina
tes(1,point_sequence(i,1)),'r.')
% Scale the axis
axis equal;
axis([min(x(:,1))-5.0, max(x(:,1))+5.0,min(x(:,2))-
5.0,max(x(:,2))+5.0]);
% Plot the axis
ax = gca;
ax.XAxisLocation = 'origin'; % Plot x axis
ax.YAxisLocation = 'origin'; % Plot y axis
pause(0.001); % Slow down the output so it can be seen
hold off % Cancels the effect of "hold on" and allows the new
position of the UGV to be plotted
end
return;
31
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
Create_Path2()
%global x_path_calc_coordinates
%global y_path_calc_coordinates
global x_path_coordinates
global y_path_coordinates
global slope_path
global point_sequence
global current_point
global data
% Simulation
32
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
tspan = 0.0:0.1:60;
options = odeset('RelTol',1e-4,'AbsTol',[1e-5 1e-5 1e-5]); % options of
the ODE-solving function
[t,x] = ode45(@UPDN_UGV_model, tspan,[0 2 2*pi/8.0], options);
% [result] = ode45(function to solve, [start-time, end-time],
% initial conditions [x, y, teta, delta], options)
% this will derivate [xdot(1) xdot(2) xdot(3) xdot(4)] and give [x, y,
% theta, delta] of the UGV at any given time
backup = x;
clear x
x = [backup(:,1), backup(:,2), backup(:,3),steering_angle(:,1)];
function Create_Path2()
global current_point;
current_point = 0;
slope1 = (yfinal-yinitial)/(xfinal-xinitial);
global slope_path
33
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
for i = 1:n
slope_path = [slope_path, slope1];
end
xinitial_spline = xfinal;
yinitial_spline = yfinal;
continue_loop = 1;
while continue_loop
xmemo = xfinal;
ymemo = yfinal;
slope2 = (yfinal-yinitial)/(xfinal-xinitial);
n = 100;
xx = linspace (xinitial_spline,xinitial, n);
yy = spline(spline_bounds_x, [slope1 spline_bounds_y slope2],xx);
[pt] = interparc(n_path,xx,yy,'spline');
xx_equal_distance = pt(:,1);
yy_equal_distance = pt(:,2);
length = sqrt((xfinal-xinitial)^2+(yfinal-yinitial)^2);
n = length * 100;
x_path_coordinates_new = linspace (xinitial,xfinal, n);
y_path_coordinates_new = linspace (yinitial,yfinal, n);
for i = 1:n
slope_path = [slope_path, slope2];
end
xinitial_spline = xfinal;
yinitial_spline = yfinal;
slope1 = slope2;
end
return;
global current_point
global x_path_coordinates
global y_path_coordinates
global slope_path
35
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
distancemem = sqrt(X_prime^2+Y_prime^2);
current_x = x_path_coordinates(current_point-1);
current_y = y_path_coordinates(current_point-1);
distance = sqrt(X_prime^2+Y_prime^2);
count = 0;
current_x = x_path_coordinates(current_point);
current_y = y_path_coordinates(current_point);
distance = sqrt(X_prime^2+Y_prime^2);
count = count + 1;
end
36
Edoardo Cocconi Enhanced Pure Pursuit Algorithm & Autonomous Driving
return;
plot(x_path_calc_coordinates(1,point_sequence(i,1)),y_path_calc_coordina
tes(1,point_sequence(i,1)),'r.')
%L is the length
%angle is alpha
x2=x(i,1)+(4*cos(x(i,4)+x(i,3)));
y2=x(i,2)+(4*sin(x(i,4)+x(i,3)));
plot([x(i,1) x2],[x(i,2) y2],'g') % Shows where the car is pointing
% Scale the axis
axis equal;
axis([min(x(:,1))-5.0, max(x(:,1))+5.0,min(x(:,2))-
5.0,max(x(:,2))+5.0]);
% Plot the axis
ax = gca;
ax.XAxisLocation = 'origin'; % Plot x axis
ax.YAxisLocation = 'origin'; % Plot y axis
pause(0.001); % Slow down the output so it can be seen
hold off % Cancels the effect of "hold on" and allows the new
position of the UGV to be plotted
37
Enhanced Pure Pursuit Algorithm & Autonomous Driving Edoardo Cocconi
end
return;
38