SlideShare a Scribd company logo
1
Design of an intelligent fuzzy logic controller for a
quadrotor helicopter
by
Angel J Francos
School of Marine Science and Engineering
Faculty of Science and Technology
University of Plymouth
Honours project submitted in partial fulfilment of the
requirements for the degree of
BEng (Hons) in Mechanical Engineering
Projects co-ordinators:
Dr Sanjay Sharma, Room 104, Reynolds Building
Dr Asiya Khan, Room 009, Reynolds Building
May 2016
2
Abstract
In this project a black-box model for the attitude pitch dynamics of a quadrotor
helicopter is obtained. And two fuzzy logic controllers are design using different
number of rules and tuning methods. Then the fuzzy logic controller with the best
performance is compared against a proportional integral derivative controller. The
results shows a better performance was achieve by the fuzzy logic controller
containing a greater number of rules. And the fuzzy logic controller has a better
performance than the proportional integral derivative controller.
3
Acknowledgements
I am grateful to: Mrs Maria Aurora Cagigas, Mr Angel Francos, Mrs Ana Laura
Francos, Mr Angel R Francos, Mrs Mari Carmen Cagigas, Dr Rafel Orozco, Mr
Rafael Orozco, Mr Fermin Orozco and Miss Dulce Orozco for all their support and
for being my one and only source of motivation.
I would like to thank: Dr Asiya Khan, Dr Sanjay Sharma and Dr Jian Wan for their
guidance throughout this project and for introducing me to a very interesting topic
that made work, an enjoyable action.
I would also like to thank: Mr Avinash Sithale, Mr Alesh Obornik and Mr Matthew H
Morris for their companionship through this project.
4
1. Table of Contents
2. Nomenclature....................................................................................................6
3. List of Figures....................................................................................................9
4. List of tables....................................................................................................11
5. Introduction .....................................................................................................12
5.1. Aim...........................................................................................................13
5.2. Objectives ................................................................................................13
6. Literature review..............................................................................................13
6.1. Modelling the dynamics of the system......................................................13
6.1.1. Mathematical models or white box models........................................13
6.1.2. Black-Box Models .............................................................................13
6.1.3. Grey Box Models...............................................................................14
6.2. Proportional Integral Derivative Controllers ..............................................14
6.3. Fuzzy Logic systems and Fuzzy logic ......................................................15
6.4. Fuzzy logic controllers..............................................................................15
6.4.1. The Mamdani fuzzy model ................................................................16
6.4.2. Takagi-Sugeno-Kang fuzzy model.....................................................16
6.4.3. Adaptive fuzzy PID controller ............................................................16
6.4.4. Signed distance method....................................................................16
6.4.5. Membership functions .......................................................................16
6.4.6. Type-2-fuzzy logic controllers............................................................16
6.4.7. Adaptive fuzzy logic controllers .........................................................17
7. Project specification ........................................................................................17
8. Modelling the quadrotor dynamics...................................................................17
8.1. Quadrotor dynamics.................................................................................18
8.2. ARX-Model...............................................................................................19
8.2.1. Determining the model orders of the ARX model...............................20
8.2.2. Estimating the ARX model parameters..............................................21
8.2.3. Validating the ARX model .................................................................21
9. PID Controller..................................................................................................23
10. Fuzzy Logic Controller .................................................................................25
10.1. Fuzzification..........................................................................................25
10.2. Defuzzification ......................................................................................25
10.3. Inference Mechanism ...........................................................................25
10.4. Rule-base .............................................................................................25
10.5. Design of the first fuzzy logic controller.................................................26
5
10.5.1. Rules used for the first controller .......................................................26
10.5.2. Fuzzy sets parameters used for the first controller.............................27
10.6. Design of the second fuzzy logic controller............................................28
10.7. Tuning the FLC controller......................................................................30
11. Results & Discussion ...................................................................................31
11.1. FLC comparison results ........................................................................31
11.2. FLC and PID controller comparison of results .......................................32
11.2.1. Settling time comparison ...................................................................34
11.2.2. Rise time comparison ........................................................................34
11.2.3. Steady state error comparison...........................................................34
11.2.4. Mean square error comparison..........................................................35
11.2.5. Equivalent energy..............................................................................35
11.2.6. Critical analysis..................................................................................36
12. Conclusion and recommendations ...............................................................37
13. References...................................................................................................38
14. Appendix A: Code used to arrange the data.................................................44
15. Appendix B: Data analysis ...........................................................................46
16. Appendix C: Mathematical model of the quadrotor.......................................49
17. Appendix D: Interim report ...........................................................................53
6
2. Nomenclature
AI Artificial Intelligence
ANN Artifical neural networks
APD AR Parrot Drone 2.0
AR Autoregressive model
ARMA Autoregressive model with moving avarage
ARX Autoregressive model with exogenous input
FLC Fuzzy Logic Controller
Hz Hertz
IV Instrumental variable method
LSM Least square method
MATLAB MATLAB Sotware
MISO Multiple-Input Single Output
MLE Maximun Likehood method
MSE Mean square error
na Number of poles
nb Number of zeros
nk Delay
PID Proportional Integral Derivative
PWM Pulse width Modulation
Quadrotor Quadrotor-Helicopter
SISO Single-Input Single-Output
TSK Takagi-Sugeno-Kang
UAV Unmanned aerial vehicle
VTOL Vertical take off and landing
Ω𝑖 Angular velocity of corresponding motor
𝐾 𝑑 Derivative gain
7
𝐾𝑖 Integral gain
𝐾 𝑝 Proportional gain
𝑇⃗ Total thrust vector
𝑇𝑖 Thrust in corresponding frame
𝑍 𝑛 Data set containing inputs and outputs
𝑍 𝑡−1 Past observations
𝑘 𝑑 Friction constant
𝑛 𝑎 Number of poles
𝑛 𝑏 Number of zeros plus 1
𝑛 𝑘 Number of samples before input affect the output
𝑥̈ Inertial frame acceleration
𝜏𝑖 Torques in corresponding axis
𝐼 Inertial matrix quadrotor
𝑏 Drag coefficient
𝑏 Motor constant
𝑐 Output
𝑒(𝑡) White noise disturbance value
𝑒𝑟𝑟𝑜𝑟 𝑒𝑟𝑟𝑜𝑟 = 𝑦(𝑡) − 𝑟(𝑡)
𝑔 Gravity
𝑙 Distance from the centre of a quadcopter to propeller centre
𝑚 Mass of the quadrotor
𝑞 Forward shift operator
𝑟(𝑡) Reference signal
𝑡 Time
𝑢(𝑡) Input signal
𝑢(𝑡) Input
𝑦(𝑡) Output signal
8
𝑦(𝑡) Prediction for the next output
𝜃 Dimensional vector
𝜔 Angular velocity vector inertial frame
9
3. List of Figures
Figure 1……………………………… Representation of a closed loop control
system
Figure 2……………………………… Solid works drawing of a symmetrical
quadrotor with the same rotor blade
configuration as the Parrot AR Drone 2.0
Figure 3……………………………… Block-scheme of the global control system
of an UAV
Figure 4……………………………… Graph of the fit of the multi-input ARX model
when comparing to the validation data,
Rotational angle in degrees vs Time. The
red line is the ARX model and the black line
is the recorded output
Figure 5……………………………… Cross correlation of residuals between input
one and output
Figure 6……………………………… Cross correlation of residuals between input
two and output
Figure 7……………………………… Autocorrelation of residuals for the output
Figure 8……………………………… Simulink structure for the PID controller
Figure 9……………………………… Input signal to the black-box model
Figure 10……………………………. Illustration of a FLC
Figure 11……………………………. Simulink structure used to design the FLC
Figure 12……………………………. Fuzzy sets used for input variable one
“Error”
Figure 13……………………………. Fuzzy sets used for input variable two
“Derivative Error”
Figure 14……………………………. Fuzzy sets used for the output variable one
(Error)
Figure 15……………………………. Fuzzy sets used for input variable one
Figure 16……………………………. Fuzzy sets used for input variable two
Figure 17……………………………. Fuzzy sets used for output variable one
Figure 18……………………………. Sketches showing the states of the system
Figure 19……………………………. Step response graph of the FLC’s the pink
line is the first fuzzy logic controller and the
10
blue line is the second fuzzy logic controller
Figure 20……………………………. step response graph of the FLC and PID
controllers to a step input, blue colour is
used to indicate the FLC and red colour is
used indicate the PID controller
Figure 21……………………………. Angular Velocity in degrees second vs Time
in seconds
Figure 22……………………………. Output of the FLC
Figure 23……………………………. Output of the PID controller
Figure 24……………………………. Critical evaluation sketch
Figure 25……………………………. Code used to arrange the data obtained
from the experiment
Figure 26……………………………. PWM signal to motor one vs Sample
number
Figure 27……………………………. PWM signal to three vs Sample number
Figure 28……………………………. Rotation in the y-axis vs Number of samples
Figure 29……………………………. Linear velocity in the x-axis vs Number of
samples
Figure 30……………………………. Showing the pictorial representation of the
inertial and body frame coordinates
11
4. List of tables
Table 1………………………………….... List of commonly used Black-Box
models
Table 2………………………………….... List of commonly used System
Identification methods
Table 3………………………………….... Parameters used to record the data
during the test-flight
Table 4………………………………….... Range of data used to estimate and
validate the ARX model
Table 5………………………………….... Table of the multi-input ARX model
orders as well as the options used to
estimate the model
Table 6………………………………….... List of parameters for the tuned PID
controller
Table 7………………………………….... Rules used for the first FLC
Table 8………………………………….... Fuzzy sets parameters for input variable
one “Error”
Table 9………………………………….... Fuzzy sets parameters for input variable
two “Derivative of Error”
Table 10………………………………….. Fuzzy sets parameters for output one
Table 11………………………………….. Rules used for the second FLC
controller
Table 12………………………………….. Fuzzy sets parameters for input variable
one “Error”
Table 13………………………………….. Fuzzy sets parameters for input variable
two “Derivative of error”
Table 14………………………………….. Fuzzy set parameters for output variable
one “Output”
Table 15………………………………….. Performance measurement values for
the FLC’s
Table 16………………………………….. Performance measurement for FLC and
PID controller
Table 17………………………………….. Data range used for estimation of the
ARX model
Table 18………………………………….. Data range used to validate the ARX
model
12
5. Introduction
Unmanned aerial vehicles (UAVs) have gained a lot of popularity in the past years.
UAVs can fly autonomously or remotely controlled therefore they are becoming
increasingly popular in military and civil applications. (Ali and Gueaieb, 2010)
A particular UAV has gained significant attention; that is the quadrotor helicopter or
quadrotor, because of its vertical take-off and landing (VTOL) capabilities, excellent
manoeuvrability and the available payload capacity. The quadrotor helicopter was
the first helicopter to complete the first-kilometre long helicopter flight. (Sharma,
2012)(Pallet, 1979) (Ali and Gueaieb, 2010) (Coza and Macnab, 2006) (Sikorsky,
1935)
Controlling a quadrotor is a highly complex task because; a quadrotor has open loop
unstable and highly non-linear dynamics the system is under-actuated, the spinning
rotor blades produce a torque that has to be counteracted and there are complex
aerodynamics and gyroscopic effects in the rotor blades. But technological
advances in; Computational power, sensor measurement and micro electrical
systems have endorsed a new helicopter; the electronically actuated and controlled
quadrotor. In this quadrotor the angular velocity of the rotor blades is varied to
control it, therefore, there is no need to use complex mechanical systems to control
the helicopter; this makes this type of helicopters low-cost and easy to Manufacture.
Furthermore, these types of helicopters can have more sophisticated and intelligent
control algorithms. (Coza et al., 2011) (Ryll, Bulthoff, and Giordano, 2012) (Sharma,
2012) (Pallet, 1979)
Using UAV’s to overcome logistic problems is an application that is becoming
increasingly popular. And multi-billion dollar companies like Google Inc. and
Amazon.com, Inc. are a few of the many companies in the pursuit of this dream.
(Soundarajan and Agrawal, 2016) (Santos, Lopez, and Morata, 2010) (Sharma,
2012) (Piskorski et al., 2012)
The use of UAV’s in logistic can help to tackle a major societal problem; that is the
problem faced by individuals living in remote areas that are difficult or too expensive
to access and they are in need of medicine. UAV medicine delivery is a feasible way
of solving this problem, as Raffaello D’Andrea suggested in his paper “Can drones
deliver?” (D’Andrea, 2014); D’Andrea also suggested that research in autonomous
vehicle coordination is needed to make the UAV medicine delivery system a feasible
concept. Therefore the use of an intelligent controller could be a viable method to
increase the autonomous coordination of UAV’s like the quadrotor helicopter.
(Editors et al., 2014) (Andrea, 2016)(D’Andrea, 2014)
A Fuzzy Logic Controller (FLC) attempts to mimic the decision making ability of
humans hence this intelligent controller offers an alternative to traditional control
methods used to control quadrotors like Proportional Integral Derivative (PID)
controllers. (Hema, Scientific, and Publishing, 2013) (Mendel, 1995)
13
5.1. Aim
The aim of this project is to compare the performance of a FLC compared to a PID
controller for a quadrotor as to increase the research in autonomous vehicle
coordination.
5.2. Objectives
1. The pitch dynamics of the quadrotor obtained using a black-box model
2. A PID controller is design
3. A FLC is design
4. The controllers are compared and analysed in a simulation
6. Literature review
This literature review is divide into four sections; section 6.1, 6.2, 6.3 and 6.4 which
correspond to modelling the dynamics of a system, PID controllers, Artificial
Intelligence and Fuzzy Logic Controllers respectively.
6.1. Modelling the dynamics of the system
White-box, black box and grey box models can be used to obtain the pitch dynamics
of the quadrotor, as explained below:
6.1.1. Mathematical models or white box models
The forces that affect the controllability of the system can be derived using a set of
equations that describe the system dynamics, known as white box modelling. This
approach is usually used in well understood models. Appendix C shows the
derivation of the equations used to derive a white box model. (Chao et al., 2010)
(Ahmad, Chipperfield, and Tokhi, 2002)(Wu et al., 2014) (Babuška and Verbruggen,
1996)
6.1.2. Black-Box Models
The use of input-output data with the combination of System Identification
techniques is used to get a model of the system dynamics, known as black-box
modelling. This approach is generally used in poorly understood models. Table 1
shows some common model structures used to obtain a black-box model. (Ahmad,
Chipperfield, and Tokhi, 2002) (Babuška and Verbruggen, 1996) (Ljung, 2007)
Table 1: List of commonly used Black-Box models. (Ljung, 2007) (Forssell and Ljung,
1999) (BILLINGS and VOON, 1987)
Model type Model structure
Linear models Autoregressive model with exogenous
input model (ARX)
Autoregressive model with moving
average model (ARMA)
Box-Jenkins model
Autoregressive model (AR)
Non Linear model Artificial Neural Networks (ANN)
14
However, System Identification methods have to be used to fit the model to the data
set. Table 2 shows a list of some commonly used system identification methods.
(Ahmad, Chipperfield, and Tokhi, 2002)
Table 2: List of commonly used System Identification methods. (Chao et al., 2010)
(Ahmad, Chipperfield, and Tokhi, 2002) (Ljung, 2007)(Wu et al., 2014)
System Identification methods
Least square method (LSM)
Instrumental variable method (IV)
Maximum Likelihood method (MLE)
Prediction error method (PEM)
The black-box model used in this project is obtained using a similar methodology as
(Kugelberg, 2016); in which he used a closed-loop configuration to acquire observed
data of the system dynamics consequently the least square method is used to fit the
data to the ARX model ignoring the correlation between the input and the
disturbances present when the data was recorded.
(Ahmad, Chipperfield, and Tokhi, 2002) used an open loop approach when
recording the data, this was done to eliminate the undesirable correlation between
the input and the disturbances present when the data was logged, and a rig
configuration was used to overcome the open-loop instability of helicopters.
6.1.3. Grey Box Models
This approach is a combination of black box modelling and white box modelling
where prior information about the system is known but there are certain unknown
parameters that can be determined from experimental data; this is known as grey
box modelling or hybrid-modelling. This approach is usually used in partly known
models. (Kugelberg, 2016) (Ljung, 2007) (Ahmad, Chipperfield, and Tokhi, 2002)
(Babuška and Verbruggen, 1996)
6.2. Proportional Integral Derivative Controllers
PID controllers are linear regulators. Type A, Type B and Type C PID structures are
some commonly used structures as shown in Equations (1), (2) and (3) respectively.
These controllers use a proportional constant, a derivative constant and an integral
constant to control the system, the value of these constants can be modified in order
to achieve a desire performance. (Hema, Scientific, and Publishing, 2013) (Stojković,
Rodić, and Stevanović, 2012)
Type A
𝑢(𝑡) = 𝐾 𝑝 𝑒(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡
𝑡
0
+ 𝐾 𝑑 𝑑𝑒(𝑡)/𝑑𝑡 (1)
Type B
15
𝑢(𝑡) = 𝐾 𝑝 𝑒(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡
𝑡
0
− 𝐾 𝑑 𝑑𝑦(𝑡)/𝑑𝑡 (2)
Type C`
𝑢(𝑡) = −𝐾 𝑝 𝑦(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡
𝑡
0
− 𝐾 𝑑 𝑑𝑦(𝑡)/𝑑𝑡 (3)
The PID controller chosen in this project is a Type-A PID controller as to make the
comparison between controllers clearer. (Hema, Scientific, and Publishing, 2013)
Further study could be done by comparing a Type-C PID controller with a FLC, as
Type-C controller tends to give smoother control. The use of a Type-B PID
controlled is not considered in this project because the advantages of this controller
are seen when the structure is implemented in hardware and because none of the
controllers designed here are going to be implemented in hardware this controller
structure is not taken into account. (Hema, Scientific, and Publishing, 2013)
6.3. Fuzzy Logic systems and Fuzzy logic
A Fuzzy logic controller derives from Fuzzy logic systems and fuzzy set theory, in
which a Fuzzy logic system is a well-known methodology in artificial intelligence.
(Mendel, 1995) (Zadeh, 1973) (Fukuda and Arakawa, 1998)
Lotfi A. Zadeh proposed fuzzy logic in 1965 where he describes a “methodological
framework which is tolerant of imprecision and partial truths” (Zadeh, 1973).
And Artificial Intelligence System (AI) can be though as the process of mimicking an
intelligent system by using human knowledge. In which (Fukuda and Arakawa, 1998)
defines an intelligent system as “a system that has the ability to adapt to changing
environments”. And perhaps Alan Turing is the father of artificial intelligence.
(Mendel, 1995) (Zadeh, 1973) (Fukuda and Arakawa, 1998)
If the functions of an intelligent system are understood, can these functions be
replicated through the use of machinery? Similar questions to this where asked by
Alan Turing as he was trying to find a way to imitate an adult humans mind. “In
considering the functions of the mind or the brain we find certain operations which
we can explain in purely mechanical terms” (TURING, 1950). However, he argued
that the nervous system cannot be mimicked through a discrete time machine.
(TURING, 1950)
6.4. Fuzzy logic controllers
The introduction to the Fuzzy logic controller (FLC) starts with understanding of the
fuzzy inference mechanism. The inference mechanism is the process of going from
input fuzzy sets to output fuzzy sets or singleton function with use of knowledge in
the form of rules.
Two famous inference systems are used in the FLC literature and that is the
Mamdani fuzzy model and the Takagi-Sugeno-Kang fuzzy model as explained
below. (Babuška and Verbruggen, 1996)(Jang, 1993)
16
6.4.1. The Mamdani fuzzy model
The Mamdani fuzzy model; was proposed by Mamdani and Assilian in 1974. This is
the first example of fuzzy logic control where they design a controller for an
industrial steam engine. (Ali Raza and Gueaieb, 2009)(Mamdani and Assilian, 1975)
(Zadeh, 1988)
6.4.2. Takagi-Sugeno-Kang fuzzy model
The Takagi-Sugeno-Kang (TSK) fuzzy model; was proposed by Takagi and Sugeno
in 1985. (Ali Raza and Gueaieb, 2009) (Babuška and Verbruggen, 1996)
(Syed, Raza, and Gueaieb, 2012) paper compares the Mamdani and TSK fuzzy
inference systems by implementing both inference systems to a Fuzzy Logic flight
controller and found that the Mamdani inference system converges to the desire
state faster than the TSK inference system and that FLC’s are very good at handling
external disturbances.
Both (Syed, Raza, and Gueaieb, 2012) and (Ali Raza and Gueaieb, 2009) results
concur that the TSK inference system uses less computational power when
compared to the Mamdani inference system.
6.4.3. Adaptive fuzzy PID controller
FLC can also be used to aid controllers. (Gautam and H, 2013b) designed Fuzzy
PID controller in which the gains of the PID controller are the outputs of the Fuzzy
Logic Controller the results showed an increase in the PID controller performance.
6.4.4. Signed distance method
(Ishaque et al., 2011) Designed a Single Input Single Output (SISO) FLC for an
underwater vehicle using the signed distance method. The rule table is a one-
dimensional table, therefore; it uses less computational power. However, the author
believes that the main advantage of using the signed distance method is the
simplification of the tuning process of the rules and membership functions.
6.4.5. Membership functions
(Sasaki et al., 1998) Used Gaussian membership functions to build a FLC for a
helicopter and he found that these functions are very good at stabilizing it. The
author considers that using a Gaussian membership functions can make the tuning
process harder than it already is. Therefore, triangular functions are utilized in the
FLC designed in this project.
6.4.6. Type-2-fuzzy logic controllers
(Raju and Pillai, 2016) and (Sabahi, Ghaemi, and Badamchizadeh, 2016) used a
type-2-fuzzy logic controller in which the membership functions of this controller
consist of a combination of a two membership functions; a primary and a secondary
function.
The type-2 membership functions allow the modelling of uncertainty in the system.
However the model used in this project is a simulated model hence sensors are not
used to feed-back the state of the system therefore the uncertainty of the state of
the system is minimal and this type of controller is not considered in this project.
(Raju and Pillai, 2016) (Sabahi, Ghaemi, and Badamchizadeh, 2016)
17
However, more research in type-2-fuzzy logic controllers could help to reduce the
price of the UAV medicine delivery system making it more economically feasible this
is because cheaper sensors can be used to construct UAV’s if type-2-fuzzy logic
controllers are used, assuming cheap sensors produce more measurement
uncertainty. (Sepúlveda et al., 2007) (Sabahi, Ghaemi, and Badamchizadeh, 2016)
(Raju and Pillai, 2016)
6.4.7. Adaptive fuzzy logic controllers
A still controversial topic in the FLC literature relates on how to tune a FLC, and
authors like (Kaur and Kaur, 2012) have leap frog the tuning process by using
Adaptive Fuzzy Logic controllers to improve the performance and (Khan et al., 2008)
used genetic algorithms to optimize the membership functions and if the FLC has
scaling gains this can be tuned as well. However there is still a gap in the Fuzzy
Controller literature; that is the lack of understanding on how to tune a FLC to
achieve certain performance parameters.
7. Project specification
The type of control design for the FLC and PID controller in this project was chosen
to be a closed loop control, because helicopters are unstable in open-loop control.
A closed loop system uses feedback to get the error of the system which is the
difference between the desired state and the current state. As shown in Fig. 1.
(Passino and Yurkovich, 1998)
Figure 1: Representation of a closed loop control system. (Passino and Yurkovich,
1998)
To obtain the closed loop controllers; a model that describes the pitch dynamics is
obtained, consequently a PID controller and FLC were designed, and the controllers
performance relative to each other is analysed using performance measurements as
shown in sections 8, 9, 10 and 11 respectively. (Passino and Yurkovich, 1998)
8. Modelling the quadrotor dynamics
In this section a black-box model is going to be obtained for the pitch attitude
dynamics, the data obtained to estimate the model was obtained from a test-flight
using the AR Parrot Drone 2.0 (APD).
The black-box model used in this project is a Linear ARX model; consequently the
least square error is going to be used to fit the model to the observed data.
18
8.1. Quadrotor dynamics
The pitch of the quadcopter can be controlled by increasing the speed of the rotor
blade three by the same amount that the speed of rotor blade one is decreased, as
shown in Equation (4). Figure 2 shows the Parrot AR Drone 2.0 rotor configuration.
(Coza and Macnab, 2006) (Piskorski et al., 2012)
𝑈 𝜃 = [
Ω1 − 𝛥𝑢
Ω2
Ω3 + 𝛥𝑢
Ω4
]
(4)
Figure 2: Solid work drawing of a symmetrical quadrotor with the same
configuration as the Parrot AR Drone 2.0
The pitch of the quadrotor controls the rotation in the y-axis consequently this
motion is coupled with the translational motion of the quadcopter in the x-axis.
A position controller can be used to control the translational motion of the quadrotor.
The inputs to the position controller are the desire translational motions and the
outputs are the reference angles needed to achieve this translational motion, as
shown in Fig. 3. (Coza et al., 2011) (Stojković, Rodić, and Stevanović, 2012)
(Razinkova et al., 2014)
19
Figure 3: Block-scheme of the global control system of an UAV. (Stojković, Rodić,
and Stevanović, 2012)
In this project only the y-axis rotation in the body frame of the quadrotor is going to
be controlled, this is also known as attitude control. (Stojković, Rodić, and
Stevanović, 2012)
8.2. ARX-Model
The structure of the ARX model is described below.
An ARX model is represented by a linear differential equation as shown in Equation
(5). This model is a discrete time system that represents the relationship between
the input and output at a given time, given a disturbance is present. (Ljung, 2007)
(Kugelberg, 2016)
The ARX model structure uses regression to estimate the output. Essentially the
model contains old values of the variable to be described; hence the model structure
shown in Equation (5) is called an Auto-Regressive model with exogenous input.
(Ljung, 2007) (Kugelberg, 2016)
A more generalised representation of the model is shown in Equations (6), (7) and
(8). (Kugelberg, 2016)
𝐴(𝑞)𝑦(𝑡) = 𝐵(𝑞)𝑢(𝑡) + 𝑒(𝑡) (6)
𝐴(𝑞) = 1 + 𝑎1 𝑞−1
+ ⋯ + 𝑎 𝑛𝑎 𝑞−𝑛𝑎 (7)
𝐵(𝑞) = 𝑏1 𝑞−1
+ ⋯ + 𝑏 𝑛𝑏 𝑞−𝑛𝑏 (8)
The ARX model used in this project has a Multi-Input-Single-Output (MISO).
Therefore it has two inputs and one output. (Coza et al., 2011)
The inputs to the ARX model are: the Pulse width Modulation (PWM) signal to motor
one and the PWM signal to motor three. And it is assumed that the PWM input
signal to the motors is proportional to the angular velocity of the rotor blades. (Coza
et al., 2011)
The output of the ARX model is the rotational angle of the quadrotor in the y-axis
measured in degrees.
The observed data of the pitch dynamics was obtained by connecting the ADP to a
laptop via WIFI. A manually controlled test flight was conducted to obtain the data.
The test-flight lasted a total of 162.27 seconds and it consisted of 32453 samples.
The test flight and data parameters used to record the data are shown in Table 3.
𝑦(𝑡) + 𝑎1 𝑦(𝑡 − 1) + ⋯ + 𝑎 𝑛𝑎 𝑦(𝑡 − 𝑛 𝑎)
= 𝑏1 𝑢(𝑡 − 𝑛 𝑘) + ⋯ + 𝑏 𝑛𝑏 𝑢(𝑡 − 𝑛 𝑏 𝑛 𝑘 + 1) + 𝑒(𝑡)
(5)
20
Table 3: Observed data and test flight parameters
Frequency (sampling rate) 200(Hz)
Number of Samples 32453
Time length of data 162.27 (seconds)
Configuration of quadcopter Close loop configuration
Noise to the quadcopter None
From the test-flight, a text document containing different arrays of information was
obtained. This text file was imported into MATLAB and the code shown in Appendix
A was used to organize the data into a series of arrays.
To estimate and validate the ARX model parameters two different data sets are
used, the first data set is used for the estimation of the parameters and the second
data is used to validate the ARX model. (Ahmad, Chipperfield, and Tokhi, 2002)
(Ljung, 2007)
Because the test flight was controlled manually, only certain ranges of the data
contain the correct excitation signal that exposes the relevant properties of the pitch
attitude dynamics. Therefore the data was plotted and analysed to find these ranges
as shown in Appendix B, Table 4 shows the ranges of data used for estimation and
validation of the ARX model. (Ahmad, Chipperfield, and Tokhi, 2002)
Table 4: Range of data used to estimate and validate the ARX model
Range of samples used to estimate the
ARX model
[25710:26020]
Range of samples used to validate the
ARX model
[27690:27940]
8.2.1. Determining the model orders of the ARX model
In order to estimate the parameters of the model structure, the number of zeros,
poles and the delay in the system has to be input manually. The “order selection”
function in MATALB can be used to select the most suitable model structure. This
function allowed the author to select the model orders with the lowest residuals.
However, trial and error was also used to estimate the most suitable model orders.
Table 5 contains the model orders used to estimate the ARX-structure. (Ljung, 1998)
Table 5: Table of the multi-input ARX model orders as well as the options used to
estimate the model
Number of poles (na) 14
Number of zeros (nb) [1 1]
Delay (nk) [3 5]
Initial state (option) Auto
Focus (option) Prediction
Covariance (option) Estimate
Sample time 0.005 (seconds)
21
8.2.2. Estimating the ARX model parameters
The ARX parameters are estimated using the Least-Square-error Method; This
method works by rearranging Equation (5) to give a prediction of the next output
based on previous observations, as shown in Equation (9). Therefore, the
parameters in Equation (11) can be adjusted, in order to fit the predicted output of
the model as close as possible to the recorded output. (Ahmad, Chipperfield, and
Tokhi, 2002) (Chao et al., 2010) (Ljung, 2007)
After using the least square error to fit the model to the estimation data, the following
structure was obtained as shown in equation (10), equations (11), (12) and (13). T
he model has a fit of 99.71% to the estimation data.
𝐴(𝑞)𝑦(𝑡) = 𝐵(𝑞)𝑢(𝑡) + 𝑒(𝑡) (10)
𝐴(𝑞) = 1 − 1.656 𝑧^ − 1 + 0.08202 𝑧^ − 2 + 0.8692 𝑧^ − 3
+ 0.1443 𝑧^ − 4 − 0.8325 𝑧^ − 5 + 0.4325 𝑧^ − 6
− 0.3216 𝑧^ − 7 + 0.7183 𝑧^ − 8 − 0.5296 𝑧^ − 9
− 0.3743 𝑧^ − 10 + 0.5855 𝑧^ − 11 + 0.1981 𝑧^ − 12
− 0.4307 𝑧^ − 13 + 0.1162 𝑧^ − 14
(11)
𝐵1(𝑞) = −2.531𝑒 − 05 𝑧^ − 3 (12)
𝐵2(𝑞) = 0.0001759 𝑧^ − 5 (13)
The coefficients of the equation 11, 12 and 13 alone have no significant meaning but
the pitch dynamics are dependent upon them (Ahmad, Chipperfield, and Tokhi,
2002)
8.2.3. Validating the ARX model
This model was then validated using the second data set to check if the model is
describing the pitch dynamics and not the disturbances present when the data was
collected. (Kugelberg, 2016)
𝑦(𝑡) = −𝑎1 𝑦(𝑡 − 1) − ⋯ − 𝑎 𝑛𝑎 𝑦(𝑡 − 𝑛 𝑎) + 𝑏1 𝑢(𝑡 − 𝑛 𝑘) + ⋯ + 𝑏 𝑛𝑏 𝑢(𝑡 − 𝑛 𝑏 𝑛 𝑘 + 1)
+ 𝑒(𝑡)
(9)
𝑦(𝑡) = 𝜃𝜑(𝑡) (10)
𝜃 = [ 𝑎1, ⋯ , 𝑎 𝑛𝑎 𝑏1, ⋯ 𝑏 𝑛𝑏] 𝑇 (11)
𝜑(𝑡) = [−𝑦(𝑡 − 1) ⋯ − 𝑦( 𝑡 − 𝑛 𝑎) 𝑢(𝑡 − 1) ⋯ 𝑢(𝑡 − 𝑛 𝑏)]
𝑇 (12)
22
The ARX model shows a fit of 75.49 % to the validation data as shown in Fig. 4.
Figure 4: Graph of the fit of the multi-input ARX model when comparing to the
validation data, Rotational angle in degrees vs Time. The red line is the ARX model
and the black line is the recorded output
To further validate the ARX model residual analysis was used. The residuals are the
prediction errors of the model. The residual confidence interval was set to 99%.
Figure 5, shows the cross correlation between the first input and the output, Fig. 6,
shows the cross correlation between the second input and the output and Fig. 7
shows the auto-correlation between the residuals and the output.
Figure 5 and Fig. 6, shows that the cross correlation between the inputs and the
output lies between the 99% confidence region therefore the model description of
how the output is generated from given inputs is 99% accurate and this model is
going to be used to design and test the controllers. However from Fig. 7 it can be
seen that autocorrelation of residuals does not lie within 99% confidence interval this
could be because a close loop configuration was used to obtain the observed
data.(Tang and Mullholland, 1987)(Westwick and Perreault, 2011)(Kugelberg, 2016)
23
Figure 5: Cross correlation of residuals between input one and output
Figure 6: Cross correlation of residuals between input two and output
Figure 7: Autocorrelation of residuals for the output
9. PID Controller
PID controllers are linear regulators, and is estimated that 90% of the controllers
used today are PID controllers. (Passino and Yurkovich, 1998) (Stojković, Rodić,
and Stevanović, 2012)
A Type-A PID controller works by obtaining the derivative of the error, the integral of
the error and the error this values are then multiplied by a gain constant whose
24
value can change, to tune the controller this values are then added and the result is
the input signal to the model as shown in Equation 14. (Hema, Scientific, and
Publishing, 2013)
Type-A PID controller
𝑢(𝑡) = 𝐾 𝑝 𝑒(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡
𝑡
0
+ 𝐾 𝑑 𝑑𝑒(𝑡)/𝑑𝑡 (14)
The structure used to make the pitch PID controller is shown in Fig. 8.
Constant and summing blocks were used to simulate the matrix used to
couple the pitch, roll, yaw and height controllers in a complete attitude
quadrotor controller, therefore the input signal to motor one and three is equal
and inversely proportional, as shown in Fig. 9. (Santos, Lopez and Morata,
2010) (Coza et al., 2011)
Figure 8: Simulink structure for the PID controller
Figure 9: Input signal to the black-box model
The PID controller was tuned using the PID Tuning tool in MATLAB. The PID was
tuned to get the smallest settling time; the following parameters where obtained as
shown in Table 6. One limitation of tuning the controller by just taking the settling
time into consideration is that the controller has a big overshoot.
25
Table 6: List of parameters for the tuned PID controller
Parameter Value
Proportional gain 19.6312672482784
Integral gain 47.5371083298902
Derivative gain 1.66097140544201
Filter coefficient 48.1589094901108
10. Fuzzy Logic Controller
In this section two fuzzy logic controllers are design; the first fuzzy logic controller
uses nine rules and the second one uses 25 rules. The reason to design two FLC is
to show how the performance of the FLC is dependent on the number of rules used.
(Ishaque et al., 2011)
A fuzzy logic controller has four components as illustrated in Fig. 10 and the
components are explained below.
10.1. Fuzzification
Fuzzification is the process of mapping an input in the universe of discourse to a
fuzzy set in which the fuzzy set has a degree of membership to the given input.
(Bellman, Kalaba, and Zadeh, 1966)(Mendel, 1995)
10.2. Defuzzification
Defuzzification is the inverse operation of the fuzzification process, and this is the
process of going from output fuzzy sets to the universe of discourse.(Mendel, 1995)
10.3. Inference Mechanism
For the Mamdani inference system, the inference mechanism is the process of
going from input fuzzy set to output fuzzy sets with the use of the rules. (Babuška
and Verbruggen, 1996) (Mendel, 1995)
10.4. Rule-base
This part of the controller holds the knowledge on how to control the system in set of
“If- Then “rules. (Fukuda and Arakawa, 1998) (Mendel, 1995)
26
Fig 10: Illustration of a FLC
The Simulink structure shown in Fig. 11 was used to design the FLC. The FLC’s
inference system used to design both controllers is the Mamdani inference system
and the centroid method is for the defuzzification process in both controllers.
Figure 11: Simulink structure used to design the FLC
The type of FLC designed in this project is PD type controllers therefore; the FLC
has two inputs which are the error and the derivative of the error which corresponds
to the angle and the angular velocity of the quadrotor in the y-axis and a single
output which correspond to PWM signal to the motors. (Ishaque et al., 2011)
10.5. Design of the first fuzzy logic controller
10.5.1. Rules used for the first controller
The rules used for this controller are shown in Table 7 and they are shown below:
1. If error is Negative and the change in error is Negative then output is
Negative
2. If error is Negative and the change in error is then Zero then output is
Negative
3. If error is Negative and the change in error is then Positive then output is
Zero
4. If error is Zero and the change in error is then Negative then output is
Negative
5. If error is Zero and the change in error is then Zero then output is Zero
6. If error is Zero and the change in error is then Positive then output is Positive
7. If error is Positive and the change in error is then Negative then output is
Zero
8. If error is Positive and the change in error is then Zero then output is Positive
9. If error is Positive and the change in error is then Positive then output is
Positive
27
Table 7: Rules used for the first FLC
𝑒𝑟𝑟𝑜𝑟/𝛥𝑒𝑟𝑟𝑜𝑟 N Z P
N N N Z
Z N Z P
P Z P P
The two FLC controllers designed in this project contain the rules used by (Passino
and Yurkovich, 1998), in which he uses these rules to control an inverted pendulum.
10.5.2. Fuzzy sets parameters used for the first controller
The first input to the FLC is the error in degrees; the range given to the error is: [-1
3]. Consequently three membership functions where used as shown in Table 8 and
Fig. 12. It is important to understand one major limitation of this range; if the
reference input is bigger than the range of the error input variable, the reference
input would not belong to any Fuzzy set.
Table 8: Fuzzy sets parameters for input variable one “Error”
Linguistic variable for the
fuzzy set
Range of values Shape
Negative (N) [-1 -1 0] Triangular
Zero (Z) [-1 0 1] Triangular
Positive (P) [0 1 3 3] Trapezoidal
Figure 12: Fuzzy sets used for input variable one “Error”
The second input to the FLC is the change in error in degrees per second; the range
given to the change in error was from: [-6 6]. Three membership functions where
used as shown in Table 9 and Figure 13.
Table 9: Fuzzy sets parameters for input variable two “Derivative of Error”
Linguistic variable for the
fuzzy set
Range of values Shape
Negative (N) [-6 -6 -3 0] Trapezoidal
Zero (Z) [-1 0 1] Triangular
Positive (P) [0 3 6 6] Trapezoidal
28
Figure 13: Fuzzy sets used for input variable two “Derivative Error”
The output to the FLC is the input signal to the plant and the range given to the input
signal is: [-10 30]. Consequently three membership functions where used as shown
in Table 10 and Fig. 14.
Table 10: Fuzzy sets parameters for output one “Output”
Figure 14: Fuzzy sets used for the output variable one (Error)
The performance measurements and time response for the first Fuzzy logic
controller is shown in section 11.
10.6. Design of the second fuzzy logic controller
Table 11, contains the rules used to design this controller furthermore a more
intuitive tuning method was used as shown in section 10.7 this was done to increase
the performance of the FLC.
Linguistic variable for
the fuzzy set
Range of values Shape
Negative (N) [-10 -10 0] Triangular
Zero (Z) [-10 0 10] Triangular
Positive (P) [0 10 30 30] Trapezoidal
29
Table 11: Rules used for the second FLC controller
𝑒𝑟𝑟𝑜𝑟/𝛥𝑒𝑟𝑟𝑜𝑟 NB NS Z PS PB
NB NB NB NB NS Z
NS NB NB NS Z PS
Z NB NS Z PS PB
PS NS Z PS PB PB
PB Z PS PB PB PB
The new parameters for input one, input two and the output are shown in Table 12,
Fig.15, Table 13, Fig. 16, Table 14 and Fig. 17 respectively.
Table 12: Fuzzy sets parameters for input variable one “Error”
Linguistic variable for the
fuzzy set
Range of values Shape
Negative Big (NB) [-3 -3 -0.3 -0.1] Trapezoidal
Negative (N) [-0.2 -0.05 0] Triangular
Zero (Z) [-0.06 0 0.06] Triangular
Positive (P) [0 0.05 0.2] Triangular
Positive Big (PB) [0.1 0.3 3 3] Trapezoidal
Figure 15: fuzzy sets used for input variable one
Table 13: Fuzzy sets parameters for input variable two “Derivative of error”
Linguistic variable for the
fuzzy set
Range of values Shape
Negative Big (NB) [-6 -6 -5 -3] Trapezoidal
Negative (N) [-4 -2 0] Triangular
Zero (Z) [-0.95 0 0.95] Triangular
Positive (P) [0 2 4] Triangular
Positive Big (PB) [3 5 6 6] Trapezoidal
30
Figure 16: Fuzzy sets used for input variable two
Table 14: Fuzzy set parameters for output variable one “Output”
Linguistic variable for the
fuzzy set
Range of values Shape
Negative Big (NB) [-35 -35 -15] Triangular
Negative (N) [-30 -22 0] Triangular
Zero (Z) [-15 0 15] Triangular
Positive (P) [0 22 30] Triangular
Positive Big (PB) [15 35 35] Triangular
Figure 17: Fuzzy sets used for output variable one
The performance measurements and the time response of this controller are shown
in section 11.
10.7. Tuning the FLC controller
This FLC was tuned using a combination of trial and error and the following thinking
process:
To achieve the certain performance desired by the designer, the fuzzy set ranges
used to model the state of the system are changed as to fire the rules that designer
thinks are more appropriate at that given range.
31
Graphs of the error, the derivative of the error and the output are plotted against
time and are used with the combination of sketches like the one shown in Fig 18, to
attempt to predict which rules need to be fired at the certain ranges to and
consequently changing the range and shapes of the fuzzy sets in order to force fire
the rules that the designer wants to fire in order to achieve the desire performance
and deep understanding of the system is needed if this approach is to be used.
Figure 18: Sketches showing the states of the system
11. Results & Discussion
11.1. FLC comparison results
Table 15, and Fig. 19 shows the performance parameters and time response to a
step input with a final value of one for both of the FLC designed in this project.
It can be seen that second FLC controller that uses 25 rules outperforms the first
FLC that only uses 9 rules in almost every single performance parameter. This
shows that the performance of the controller is dependent on the number of rules
and the tuning process.
32
Table 15: Performance measurement values for the FLC’s
Performance measurement FLC 1 (9 Rules) FLC 2 (25
Rules)
Steady-state-error (degrees) 0.132 0.014
Percentage Overshoot (%) None None
Rise time to 1% (seconds) Inconclusive 0.31
Settling time to 2%(seconds) Inconclusive 0.55
Equivalent energy 53.74 62.88
Mean Square Error (MSE) 0.1005 0.0389
Figure 19: Step response graph of the FLC’s the pink line is the first fuzzy logic
controller and the blue line is the second fuzzy logic controller
11.2. FLC and PID controller comparison of results
Is important to understand that model used to run the simulations is a linear model
and no disturbances where applied during the simulation. Therefore the controllers
were controlling a highly linear system and if these controllers are to be compared in
a real environment via hardware implementation, and disturbances like wind gust
are present this perturbations will make the system less linear and the performance
of the FLC controller is expected to increase when compared to PID controller
because a FLC is a nonlinear controller. (Leigh, 1992) (Stojković, Rodić, and
Stevanović, 2012)
33
To compare the performance of the Second FLC to the PID controller; a step input
with a final value of one was applied to both controller the simulation lasted five
seconds. The results are shown in Table 16, and in Fig. 20.
Table 16: Performance measurement for FLC and PID controller
Performance measurement PID FLC
Steady-state-error (degrees) 0 0.014
Percentage Overshoot (%) 12 None
Rise time to 2% (seconds) 0.14 0.31
Settling time to 2%(seconds) 0.98 0.55
Equivalent energy 51.64 62.88
Mean Square Error (MSE) 0.0228 0.0389
34
Figure 20: step response graph of the FLC and PID controllers to a step input, blue
colour is used to indicate the FLC and red colour is used indicate the PID controller
11.2.1. Settling time comparison
The FLC reaches a steady state value within 2% of the final value 78% faster than
the PID controller and this shows that the set of rules used to stabilize an inverted
pendulum can be implemented to control the pitch rotation of a quadrotor very
effectively.
11.2.2. Rise time comparison
Figure 20 and Table 16 shows that the PID controller is 121% faster than the FLC at
reaching the reference angle; this is because the PID Controller manages to achieve
an angular velocity of 10 degrees/ second whereas the FLC only achieves a velocity
of 4 degrees/ second as shown in Fig. 21. Therefore the PID controller achieves a
faster angular velocity hence the faster rise time.
Figure 21: Angular Velocity in degrees second vs Time in seconds
11.2.3. Steady state error comparison
From Table 16, it can be seen that PID outperforms the FLC in terms accuracy to
reach the reference angle, this is because the PID controller has a zero steady state
error and the FLC has a steady state error of 0.014. However the difference in the
steady state errors can be considered insignificant if they would be to be
implemented in a quadrotor attitude controller.
35
11.2.4. Mean square error comparison
From Table 16, it is seen that Mean Square Error (MSE) is smaller for the PID
controller, however the MSE measurement was not used to evaluate the
performance of the controllers because: The PID controller has an overshoot and
undershoot which reduces the value of the MSE even though the overshoot and
undershoot are undesirable characteristics in a controller. Furthermore, the FLC
does not achieve steady state error hence the MSE measurement obtained for the
FLC controller is greatly influenced by the length of the simulation and the steady
state error of the controller.
11.2.5. Equivalent energy
From Table 16 it can be seen that the equivalent energy measurement obtained
from the PID controller is smaller than the one obtained from the FLC, hence the
PID controller is more energy efficient this can be understood by observing the
output of the FLC and PID controller shown in Fig. 22 and Fig. 23 respectively.
Figure 22: Output of the FLC
36
Figure 23: Output of the PID controller
11.2.6. Critical analysis
To further analyse the performance of the controllers relative to each other, a
scenario is created to simulate the trajectory that a quadrotor might have to follow in
the near future. As shown in Fig. 24.
In this scenario the quadrotor is controlled autonomously by a position controller as
shown in Fig. 3, the quadrotor has to achieve the fastest linear velocity in the x-axis
but without touching the imaginary or physical boundaries.
Equation 15 can be used to by the position controller, to know the biggest angle ∝
the quadrotor can have if the length of the quadrotor 2 ∗ 𝐿 is bigger than the height
of the imaginary boundary 2 ∗ ℎ2.
∝ = sin−1
(
ℎ2
𝐿
)
(15)
If a position controller is used to control the FLC and PID controller designed in this
project, the FLC would get to 2% of the reference value 75% faster than the PID
controller furthermore the PID has an overshoot of 12% and this would cause the
quadrotor to overshoot the boundary hence failing the objective of the simulation.
37
Figure 24: Critical evaluation sketch
12. Conclusion and recommendations
In conclusion the project shows that the ARX model can model the quadrotor pitch
dynamics effectively and it has a fit of 75.49% to validation data without any cross
correlation between the input and the output. It was also shown that the
performance of the FLC is greatly affected by the number of rules used and the how
well the controlled is tuned. The results show that the FLC is a more effective
attitude controller with the slight draw back that is less energy efficient.
The author would like to recommend the use of an open-loop configuration to obtain
the pitch dynamics as this can improve the accuracy of the black-box model.
Furthermore this model can be used to compare the performance of the PID
controller compared to a FLC, as to validate the results obtained in this project.
The author would like to recommend using quadrotor with a microcontroller that is
compatible with the code generation function in MATLAB like the use of an Arduino
Microcontroller like the “Arducopter” consequently to compare the performance of
the PID against the FLC in a real world environment.
38
13. References
A.Abdelkhalek, M.A., . El-Demerdash, M.S. and . Dief, T.N. (2015) ‘Attitude Stability
of Quadcopter Using Classic Control with Angular Acceleration’, .
Abeywardena, D.M.W., Amaratunga, L.A.K., Shakoor, S.A.A. and Munasinghe, S.R.
(2009) ‘A velocity feedback fuzzy logic controller for stable hovering of a quad rotor
UAV’, 2009 International Conference on Industrial and Information Systems (ICIIS), .
Ackermann, J., Guldner, J., Sienel, W., Steinhauser, R. and Utkin, V.I. (1995)
‘Linear and nonlinear controller design for robust automatic steering’, IEEE
Transactions on Control Systems Technology, 3(1), pp. 132–143.
Ahmad, S.M., Chipperfield, A.J. and Tokhi, M.O. (2002) ‘Dynamic modelling and
open-loop control of a twin rotor multi-input multi-output system’, Proceedings of the
Institution of Mechanical Engineers, Part I: Journal of Systems and Control
Engineering, 216(6), pp. 477–496.
Ali Raza, S. and Gueaieb, W. (2009) ‘Fuzzy Logic based Quadrotor Flight
Controller’, , p. pp. 105–112.
Ali, S. and Gueaieb, W. (2010a) Intelligent Flight Control of an Autonomous
Quadrotor. .
Ali, S. and Gueaieb, W. (2010b) ‘Intelligent flight control of an autonomous
Quadrotor’, Motion Control, .
Amazon (no date) Amazon prime air. Available at:
http://www.amazon.com/b?node=8037720011 .
Amoozegar, D. (2016) ‘DSTATCOM modelling for voltage stability with fuzzy logic PI
current controller’, International Journal of Electrical Power & Energy Systems, 76,
pp. 129–135.
Amza, C.G. and Cicic, D.T. (2015) ‘Industrial image processing using fuzzy-logic’,
Procedia Engineering, 100, pp. 492–498.
AWARDS AND HONORS KEYNOTES, PLENARIES, AND SELECT SPEAKING
ENGAGEMENTS (2016) Available at: http://raffaello.name/wp-
content/uploads/2016/03/DAndreaCV2016Mar1.pdf (Accessed: 24 April 2016).
Babuška, R. and Verbruggen, H.B. (1996) ‘An overview of fuzzy modeling for
control’, Control Engineering Practice, 4(11), pp. 1593–1606.
Belkheiri, M., Rabhi, A., Hajjaji, A.E. and Pegard, C. (2012) ‘Different linearization
control techniques for a quadrotor system’, CCCA12, .
Bellman, R., Kalaba, R. and Zadeh, L. (1966) ‘Abstraction and pattern classification’,
Journal of Mathematical Analysis and Applications, 13(1), pp. 1–7.
Berenji, H.R. and Khedkar, P. (1992) ‘Learning and tuning fuzzy logic controllers
through reinforcements’, IEEE Transactions on Neural Networks, 3(5), pp. 724–740.
39
BILLINGS, S.A. and VOON, W.S.F. (1987) ‘Piecewise linear identification of non-
linear systems’, International Journal of Control, 46(1), pp. 215–235.
Cen, Z., Noura, H., Susilo, T.B. and Younes, Y.A. (2013) ‘Robust fault diagnosis for
Quadrotor UAVs using Adaptive Thau observer’, Journal of Intelligent & Robotic
Systems, 73(1-4), pp. 573–588.
Chamberlain, C.H. (2011) System Identification, State Estimation, and Control of
Unmanned Aerial Robots. .
Chao, H., Luo, Y., Di, L. and Chen, Y.Q. (2010) ‘Roll-channel fractional order
controller design for a small fixed-wing unmanned aerial vehicle’, Control
Engineering Practice, 18(7), pp. 761–772.
Coza, C. and Macnab, C.J.B. (2006) ‘A new robust Adaptive-Fuzzy control method
applied to Quadrotor helicopter stabilization’, NAFIPS 2006 - 2006 Annual Meeting
of the North American Fuzzy Information Processing Society, .
Coza, C., Nicol, C., Macnab, C.J.B. and Ramirez-Serrano, A. (2011) ‘Adaptive fuzzy
control for a quadrotor helicopter robust to wind buffeting’, Journal of Intelligent &
Fuzzy Systems, 22(5,6), pp. 267–283.
D’Andrea, R. (2014) ‘Guest editorial can drones deliver?’, IEEE Transactions on
Automation Science and Engineering, 11(3), pp. 647–648.
D’Andrea, R. (2016) Transcript of ‘meet the dazzling flying machines of the future’.
Available at:
https://www.ted.com/talks/raffaello_d_andrea_meet_the_dazzling_flying_machines_
of_the_future/transcript?language=en .
Deb, K., Mohan, M. and Mishra, S. (2005) ‘Evaluating the ε-domination based multi-
objective evolutionary algorithm for a quick computation of Pareto-Optimal solutions’,
Evolutionary Computation, 13(4), pp. 501–525.
Dong, W., Gu, G.-Y., Zhu, X. and Ding, H. (2015) ‘Development of a Quadrotor test
bed — Modelling, parameter identification, controller design and trajectory
generation’, International Journal of Advanced Robotic Systems, .
Driankov, D., Hellendoorn, H. and Reinfrank, M. (1995) An introduction to Fuzzy
Control. .
E, H.W., F, K.E., Igor, S. and Corp, U.A. (1945) Patent US2529635 - helicopter rotor
control mechanism. . Available at:
https://www.google.co.uk/patents/US2529635?dq=sikorsky&hl=en&sa=X&ved=0ah
UKEwilmoeAt4nMAhUCJw8KHfI5BUIQ6AEITjAH (Accessed: 12 April 2016).
Editors, R., Keay, A., Robotics, S.V., Laskow, S., Obscura, A., Winfield, A., Perlongo,
K., Tobe, F., Machines, T., SPARC and Bevilacqua, R. (2014) Raffaello D’Andrea at
TED2016: Novel flying machines and swarms of tiny flying robots. Available at:
http://robohub.org/raffaello-dandrea-at-ted2016-novel-flying-machines-and-swarms-
of-tiny-flying-robots/ .
Fliess, M. (1990) ‘Generalized controller canonical form for linear and nonlinear
dynamics’, IEEE Transactions on Automatic Control, 35(9), pp. 994–1001.
40
Flores, G. and Lozano, R. (2013) ‘Transition flight control of the quad-tilting rotor
convertible MAV’, 2013 International Conference on Unmanned Aircraft Systems
(ICUAS), .
Flores, G.R., Escareño, J., Lozano, R. and Salazar, S. (2011) ‘Quad-Tilting rotor
convertible MAV: Modeling and real-time hover flight control’, Journal of Intelligent &
Robotic Systems, 65(1-4), pp. 457–471.
Flying toys Ltd (2014) Available at: http://flyingtoys.com .
Forssell, U. and Ljung, L. (1999) ‘Closed-loop identification revisited’, Automatica,
35(7), pp. 1215–1241.
Fu, Y., Li, H. and Kaye, M. (2010) ‘Design and Lyapunov stability analysis of a fuzzy
logic controller for autonomous road following’, Mathematical Problems in
Engineering, 2010, pp. 1–20.
Fukuda, T. and Arakawa, T. (1998) ‘Intelligent systems: Robotics versus
mechatronics’, Annual Reviews in Control, 22, pp. 13–22.
Gautam, D. and H, C. (2013a) ‘Control of a Quadrotor using a smart self-tuning
fuzzy PID controller’, International Journal of Advanced Robotic Systems, .
Gautam, D. and H, C. (2013b) ‘Control of a Quadrotor using a smart self-tuning
fuzzy PID controller’, International Journal of Advanced Robotic Systems, .
Gibiansky, A. (2012) Quadcopter Dynamics and Simulation. Available at:
http://andrew.gibiansky.com/blog/physics/quadcopter-dynamics/ .
Han, J., Di, L., Coopmans, C. and Chen, Y. (2013) ‘Pitch loop control of a VTOL
UAV using fractional order controller’, Journal of Intelligent & Robotic Systems,
73(1-4), pp. 187–195.
Hema, K., Scientific and Publishing, A. (2013) ‘Aircraft flight control simulation using
parallel cascade control’, International Journal of Instrumentation Science, 2(2), pp.
25–33.
Ishaque, K., Abdullah, S.S., Ayob, S.M. and Salam, Z. (2011) ‘A simplified approach
to design fuzzy logic controller for an underwater vehicle’, Ocean Engineering, 38(1),
pp. 271–284.
Jang, J..R. (1993) ‘ANFIS: Adaptive-network-based fuzzy inference system’, IEEE
Transactions on Systems, Man, and Cybernetics, 23(3), pp. 665–685.
Kaur, A. and Kaur, A. (2012) ‘COMPARISON OF FUZZY LOGIC AND NEURO
FUZZY ALGORITHMS FOR AIR CONDITIONING SYSTEM 418 II. FUZZY LOGIC
CONTROL ALGORITHM’, International journal of soft computing and engineering, ,
pp. 417–420.
Khan, S., Abdulazeez, S.F., Adetunji, L.W., Alam, A.Z., Salami, M.J.E., Hameed,
S.A., Abdalla, A.H. and Islam, M.R. (2008) ‘Design and implementation of an optimal
fuzzy logic controller using genetic algorithm’, Journal of Computer Science, 4(10),
pp. 799–806.
Killian, M., Mayer, B. and Kozek, M. (2015) ‘Effective fuzzy black-box modeling for
building heating dynamics’, Energy and Buildings, 96, pp. 175–186.
41
Kugelberg, I. (2016) Black-Box Modeling and Attitude Control of a Quadcopter. .
Lee, C.C. (1990) ‘Fuzzy logic in control systems: Fuzzy logic controller. II’, IEEE
Transactions on Systems, Man, and Cybernetics, 20(2), pp. 419–435.
Leigh, J.R. (1992) Control theory: A guided tour. London: P. Peregrinus on the
behalf of the Institution of Electrical Engineers.
Li, J. and Li, Y. (2011) ‘Dynamic analysis and PID control for a quadrotor’, 2011
IEEE International Conference on Mechatronics and Automation, .
Ljung, L. (1998) System identification: Theory for the user. 2nd edn. United States:
Prentice Hall.
Ljung, L. (2000) ‘Model Error Modeling and Control Design’, .
Ljung, L. (2007) ‘System Identification’, Automatic Control at Linköpings universitet, .
Ljung, L. and Ljung, L. (1987) System identification: Theory for the user. United
States: Prentice Hall PTR.
Mamdani, E.H. and Assilian, S. (1975) ‘An experiment in linguistic synthesis with a
fuzzy logic controller’, International Journal of Man-Machine Studies, 7(1), pp. 1–13.
Matarić, M. and Cliff, D. (1996) ‘Challenges in evolving controllers for physical
robots’, Robotics and Autonomous Systems, 19(1), pp. 67–83.
Mendel, J.M. (1995) ‘Fuzzy logic systems for engineering: A tutorial’, Proceedings of
the IEEE, 83(3), pp. 345–377.
Mian, A.A. and Daobo, W. (2008) ‘Modeling and Backstepping-based Nonlinear
control strategy for a 6 DOF Quadrotor helicopter’, Chinese Journal of Aeronautics,
21(3), pp. 261–268.
Newman, S. and Newman, S. (1994) The foundations of helicopter flight. London: A
Butterworth-Heinemann Title.
Olivares, V., Cordova, F., Sepúlveda, J.M. and Derpich, I. (2015) ‘Modeling internal
logistics by using drones on the stage of assembly of products’, Procedia Computer
Science, 55, pp. 1240–1249.
Pallett, E.H.J. (1979) Automatic Flight Control Systems. London, Granada, 1979:
HarperCollins Distribution Services.
Passino, K.M. and Yurkovich, S. (1998) Fuzzy Control. California: Addison Wesley
Longman, Inc.
Phang, S.K., Cai, C., Chen, B.M. and Lee, T.H. (2012) ‘Design and mathematical
modeling of a 4-standard-propeller (4SP) quadrotor’, Proceedings of the 10th World
Congress on Intelligent Control and Automation, .
Piskorski, S., Brulez, N., Eline, P. and D’Haeyer, F. (2012) AR.Drone Developer
Guide. Available at: http://www.msh-
tools.com/ardrone/ARDrone_Developer_Guide.pdf (Accessed: 15 April 2016).
42
Rai, J.N. (2012) ‘Speed control of Dc motor using fuzzy logic technique’, IOSR
Journal of Electrical and Electronics Engineering, 3(6), pp. 41–48.
Raju, K.S. and Pillai, G.N. (2016) ‘Design and implementation of type-2 fuzzy logic
controller for DFIG-Based wind energy systems in distribution networks’, IEEE
Transactions on Sustainable Energy, 7(1), pp. 345–353.
Razinkova, A., Kang, B.-J., Cho, H.-C. and Jeon, H.-T. (2014) ‘Constant Altitude
Flight Control for Quadrotor UAVs with Dynamic Feedforward Compensation’,
International Journal of Fuzzy Logic and Intelligent Systems, 14(1), pp. 26–33.
Reguera Acevedo, P., Fuertes MartinezJuanJos�, Dominguez Gonzalez, M. and
Garcia Valencia, R. (2008) ‘Case-based reasoning and system identification for
control engineering learning’, IEEE Transactions on Education, 51(2), pp. 271–281.
Ryll, M., Bulthoff, H.H. and Giordano, P.R. (2012) ‘Modeling and control of a
quadrotor UAV with tilting propellers’, 2012 IEEE International Conference on
Robotics and Automation, .
Saad Shaikh, M. (2011) Quadrocopter Fuzzy Flight Controller. .
Sabahi, K., Ghaemi, S. and Badamchizadeh, M. (2016) ‘Designing an adaptive type-
2 fuzzy logic system load frequency control for a nonlinear time-delay power system’,
Applied Soft Computing, 43, pp. 97–106.
Santos, M., Lopez, V. and Morata, F. (2010) ‘Intelligent fuzzy controller of a
quadrotor’, 2010 IEEE International Conference on Intelligent Systems and
Knowledge Engineering, .
Sasaki, M., Ishida, H., Katsuno, T. and Ogasawara, A. (1998) ‘Learning fuzzy logic
controller for hovering a helicopter’, 1998 Conference of the North American Fuzzy
Information Processing Society - NAFIPS (Cat. No.98TH8353), .
Sepúlveda, R., Castillo, O., Melin, P., Rodríguez-Díaz, A. and Montiel, O. (2007)
‘Experimental study of intelligent controllers under uncertainty using type-1 and
type-2 fuzzy logic’, Information Sciences, 177(10), pp. 2023–2048.
Sharma, A. (2012) ‘Controlling of Quad-rotor UAV using PID controller and Fuzzy
logic controller.’, International Journal of Electrical, Electronics and Computer
Engineering, 1(2), pp. 38–41.
Sikorsky, I. (1935) Direct lift aircraft. .
sinha, H. (2012) An Autonomous Quadrotor Flying Robot. .
Soundarajan, V. and Agrawal, A. (2016) Automated package delivery to a delivery
receptable. .
Syed, A., Raza, W. and Gueaieb (2012) Intelligent flight control of an autonomous
Quadrotor Available at: http://cdn.intechweb.org/pdfs/6587.pdf (Accessed: 3
December 2015).
Tang, K.L. and Mulholland, R.J. (1987) ‘Comparing fuzzy logic with classical
controller designs’, IEEE Transactions on Systems, Man, and Cybernetics, 17(6), pp.
1085–1087.
43
Thrift, P. (1991) ‘Fuzzy Logic Synthesis with Genetic Algorithms’, ICGA, .
TURING, A.M. (1950) ‘I.—COMPUTING MACHINERY AND INTELLIGENCE’, Mind,
LIX(236), pp. 433–460.
Visioli, A. (2001) ‘Tuning of PID controllers with fuzzy logic’, IEE Proceedings -
Control Theory and Applications, 148(1), pp. 1–8.
Westwick, D.T. and Perreault, E.J. (2011) ‘Closed-loop identification: Application to
the estimation of limb Impedance in a compliant environment’, IEEE Transactions on
Biomedical Engineering, 58(3), pp. 521–530.
Woodford, K. and Cambridge Dictionaries Online (2016) Artificial intelligence
meaning in the Cambridge English dictionary. Available at:
http://dictionary.cambridge.org/dictionary/english/artificial-intelligence .
Wu, J., Peng, H., Chen, Q. and Peng, X. (2014) ‘Modeling and control approach to a
distinctive quadrotor helicopter’, ISA Transactions, 53(1), pp. 173–185.
Xu, J.-X., Guo, Z.-Q. and Lee, T.H. (2013) ‘Design and implementation of a Takagi–
Sugeno-Type fuzzy logic controller on a Two-Wheeled mobile robot’, IEEE
Transactions on Industrial Electronics, 60(12), pp. 5717–5728.
Yordanova, S. and Jain, lakhmi (2012) ‘Speed Control of Dc Motor Using Fuzzy
Logic Technique’, International journal of innovative computing, 8(12).
Zadeh, L.A. (1973) ‘Outline of a new approach to the analysis of complex systems
and decision processes’, IEEE Transactions on Systems, Man, and Cybernetics,
SMC-3(1), pp. 28–44.
Zadeh, L.A. (1988a) ‘Fuzzy logic’, Computer, 21(4), pp. 83–93.
Zadeh, L.A. (1988b) ‘Fuzzy logic’, Computer, 21(4), pp. 83–93.
Zhang, J. and Knoll, A. (1999) ‘Designing fuzzy controllers by rapid learning’, Fuzzy
Sets and Systems, 101(2), pp. 287–301.
44
14. Appendix A: Code used to arrange the data
The data was collected in a text file; this text file consisted of a single array of strings
and figures. This data was imported into MATLAB using the “import data from file”
option then the code shown, in Fig. 25 was used to read and arrange the single
array data into an organized multiple array structure. The code consist of the
following functions: “fopen” “~feof” “fscanf” “fprintf” “fclose”, it has a
single loop that ends when all the data has been read, and a number is defined as
“%f” representing a figure and a linguistic variable is defined as a “%s” representing
a string.
%%reading and opening files
fid = fopen('dataset2_praises.txt','r');
file_out1= fopen('out.dat_1','w');
file_out2= fopen('out.dat_2','w');
file_out3= fopen('out.dat_3','w');
file_out4= fopen('out.dat_4','w');
file_outix= fopen('out.dat_rix','w');
file_outiy= fopen('out.dat_riy','w');
file_outiz= fopen('out.dat_riz','w');
file_outlvy= fopen('out.dat_lvy','w');
file_outlvx= fopen('out.dat_lvx','w');
file_outtime= fopen('out.dat_time','w');
%scanning data
%%loop data
%%
while ~feof(fid) %loping data with the feof()command
header= fscanf(fid, '%s', 1);
seq= fscanf(fid, '%f', 1);
stamp= fscanf(fid, '%s', 1);
secs= fscanf(fid, '%f', 1);
nsecs= fscanf(fid, '%f', 1);
frame_id= fscanf(fid, '%s', 1);
battery= fscanf(fid, '%f', 1);
state= fscanf(fid, '%f', 1);
magx= fscanf(fid, '%f', 1);
magy= fscanf(fid, '%f', 1);
magz= fscanf(fid, '%f', 1);
pressure= fscanf(fid, '%f', 1);
temp= fscanf(fid, '%f', 1);
ws= fscanf(fid, '%f', 1);
wa= fscanf(fid, '%f', 1);
wc= fscanf(fid, '%f', 1);
rotx= fscanf(fid, '%f', 1);
roty= fscanf(fid, '%f', 1);
rotz= fscanf(fid, '%f', 1);
altd= fscanf(fid, '%f', 1);
vx= fscanf(fid, '%f', 1);
vy= fscanf(fid, '%f', 1);
vz= fscanf(fid, '%f', 1);
ax= fscanf(fid, '%f', 1);
ay= fscanf(fid, '%f', 1);
az= fscanf(fid, '%f', 1);
motor1= fscanf(fid,'%f',1);
motor2= fscanf(fid,'%f',1);
motor3= fscanf(fid,'%f',1);
45
motor4= fscanf(fid,'%f',1);
tagsc= fscanf(fid, '%s', 1);
tagst= fscanf(fid, '%s', 1);
tagsx= fscanf(fid, '%s', 1);
tagsy= fscanf(fid, '%s', 1);
tagswi= fscanf(fid, '%s', 1);
tagshe= fscanf(fid, '%s', 1);
tagso= fscanf(fid, '%s', 1);
tagsd= fscanf(fid, '%s', 1);
tm= fscanf(fid, '%f', 1);
blank= fscanf(fid, '%s', 1);
fprintf(file_out1, '%fn',motor1);
fprintf(file_out2, '%fn',motor2);
fprintf(file_out3, '%fn',motor3);
fprintf(file_out4, '%fn',motor4);
fprintf(file_outix, '%fn',rotx); %f/n used to print an array
file
fprintf(file_outiy, '%fn',roty);
fprintf(file_outiz, '%fn',rotz);
fprintf(file_outlvy, '%fn',vy);
fprintf(file_outlvx, '%fn',vx);
fprintf(file_outtime, '%fn',tm);
end
%closing the files ;)
fclose(fid);
fclose(file_out1);
fclose(file_out2);
fclose(file_out3);
fclose(file_out4);
fclose(file_outix);
fclose(file_outiy);
fclose(file_outiz);
fclose(file_outlvy);
fclose(file_outlvx);
fclose(file_outtime);
Figure 25: Code used to arrange the data obtained from the experiment
46
15. Appendix B: Data analysis
Once the data was organized in different arrays, the data was analysed in order to
find the sample range were the pitch input was applied to it.
The values that described the pitch dynamics are dependent on the: PWM signal to
motor one and three, the rotational speed in the y-axis and the linear velocity in the
x-axis as shown in Figures 26, 27, 28 and 29 respectively.
Figure 26: PWM signal to motor one vs Sample number
Figure 27: PWM signal to three vs Sample number
47
Figure 28: Rotation in the y-axis vs Number of samples
Figure 29: Linear velocity in the x-axis vs Number of samples
Range selection
Because the data was obtained by flying the APD manually only certain ranges of
the data contain pitch inputs, and is only in this ranges that the data describes the
pitch dynamics of the APD.
Therefore looking at the graphs shown above it was stablish that the pitch inputs
were applied somewhere in between sample 24000 and sample 37000 because the
48
linear speed in x-direction and the rotational angle in y-direction increases in
between those samples. Therefore the following data sets were used for validation
and estimation.
Data range used for estimation of the model structure
The range of samples used to estimate the numerical values in the model was
chosen to be samples [25710:26020], this range was chosen as it where the pitch
input affects the plant the most, Fig. 1.5 contains further information about the
estimation range.
Table 17: Data range used for estimation of the ARX model
Number of Samples 310 (samples)
Sampling range [25710:26020]
Time 1.55 (seconds)
Validation data range
The range of samples used to estimate the numerical values in the model was
chosen to be samples [27690:27940]; Fig. 1.6 contains further information about the
validation range.
Table 18: Data range used to validate the ARX model
Number of Samples 250 (samples)
Sampling range [27690:27940]
Time 1.25 (seconds)
49
16. Appendix C: Mathematical model of the quadrotor
To derive a mathematical model of a Quadrotor, the following literature was used:
(A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) (Phang et al.,6 2012)(Gibiansky,
2012)(Li and Li, 2011)(Sinha, 2012)(abeywardena et al., 2009) (Phang et al.,6 2012)
(Santos, Lopez and Morata, 2010)
Mathematical model using a white box technique
To derive the mathematical model of the system, Euler equations are used even
though other papers used the quaternion differential equations, to prevent losing a
degree of freedom when the quadrotor has a pitch angle of 90 degrees also the
following assumptions where made:
 The quadcopter consist of two uniform rods crossed at the origin with the
mass of the motor at each end of the rod
 Quadrotor and its components are rigid bodies
 The origin of inertial coordinate system is in the same position with the
geometric centre and centroid of the quadrotor
 Aerodynamics forces and gyroscopic effects are neglected in this study
Coordinate system
The coordinate system can be acquired through it states. A quadrotor has 12 states
and six degrees of freedom; these consist on the orientation and the position of the
quadrotor. (Santos, Lopez and Morata, 2010)
Two coordinate frames will be used to derive the dynamic behaviour of the system:
Inertial frame
Consist of six states: the position of the centre of gravity of the quadcopter and
respectively the linear velocity components. This frame is time-invariant.
The position and the velocity of the quadrotor are defined as x = (x, y, z)T
,
ẋ = ( ẋ ẏ ż)T
respectively.
Body frame
Consist of six states: the roll, yaw, pitch and the angular velocities around each axis
of the body of frame.
The rotations and the angular velocities of the quadrotor in the body frame are
defined as 𝜃 = (∅, 𝜃, Ψ) 𝑇
, 𝜃̇ = (∅̇ 𝜃̇ Ψ̇ ) 𝑇
respectively.
The equations of motion are formulated in the body frame, the orientation of this
body of frame coordinate system B(Oxyz), has the origin at the centroid of the
quadrotor and the z-axis is pointing upwards as described in Fig. 30.
50
Figure 30: Showing the pictorial representation of the inertial and body frame
coordinates
Transition matrix
The transition matrix 𝑅 in equation (16) is used to convert the vector components in
the body frame to the inertial frame and vice-versa, where equation (17), (18) and
(19) represents the x-axis, y-axis and z-axis projections of the body frame into the
inertial frame respectively
𝑅 = 𝑅 𝑥 𝑅 𝑦 𝑅 𝑧 = (
cos𝛹cos∅ 𝑐𝑜𝑠𝛹𝑠𝑖𝑛𝜃𝑠𝑖𝑛∅ 𝑐𝑜𝑠𝛹𝑠𝑖𝑛𝜃𝑐𝑜𝑠∅ + 𝑠𝑖𝑛𝛹𝑠𝑖𝑛∅
𝑠𝑖𝑛𝛹𝑐𝑜𝑠𝜃 𝑠𝑖𝑛𝛹𝑠𝑖𝑛𝜃𝑠𝑖𝑛∅ 𝑠𝑖𝑛𝛹𝑠𝑖𝑛𝜃𝑐𝑜𝑠∅ − 𝑠𝑖𝑛∅𝑐𝑜𝑠𝛹
−𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃𝑠𝑖𝑛∅ 𝑐𝑜𝑠𝜃𝑐𝑜𝑠∅
) (16)
𝑅 𝑥 = (
1 0 0
0 𝑐𝑜𝑠∅ −𝑠𝑖𝑛∅
0 𝑠𝑖𝑛∅ 𝑐𝑜𝑠∅
) (17)
𝑅 𝑦 = (
𝑐𝑜𝑠𝜃 0 𝑠𝑖𝑛𝜃
0 1 0
−𝑠𝑖𝑛𝜃 0 𝑐𝑜𝑠𝜃
) (18)
𝑅 𝑧 = (
𝑐𝑜𝑠𝛹 −𝑠𝑖𝑛𝛹 0
𝑠𝑖𝑛𝛹 𝑐𝑜𝑠𝛹 0
0 ∅ 1
) (19)
Forces and thrust
From the literature it was establish that the thrust in a single propeller is proportional
to torque. And the thrust is proportional to the square angular velocity therefore the
thrust in the body frame is shown in equation (20).
𝑇𝐵 = 𝑘 (
0
0
∑ Ω𝑖
2
) (20)
To model the torque generated in z-axis it was found that torque is given by the sum
of all torques in the propeller as shown in equation (21), to model the torque in the x-
axis it was found that the torque can be modelled by multiplying the torques
51
generated in the x-axis by the distance of the centre of the quadcopter to the
propeller as shown in equation (22) similarly the same can be done to get the torque
generated in the y-axis as shown in equation (23) therefore the torques in the body
frame are given by equation (24).
𝜏Ψ = 𝑏(Ω1
2
− Ω2
2
+ Ω3
2
− Ω4
2
) (21)
𝜏∅ = 𝑙𝑏(Ω4
2
− Ω2
2
) (22)
𝜏 𝜃 = 𝑙𝑏(Ω1
2
− Ω3
2
) (23)
𝜏 𝐵 = (
𝑙𝑏(Ω4
2
− Ω2
2
)
𝑙𝑏(Ω1
2
− Ω3
2
)
𝑏(Ω1
2
− Ω2
2
+ Ω3
2
− Ω4
2
)
) (24)
To model friction in the inertial frame complex aerodynamic effects are ignored and
the shape of the quadcopter is assumed to be symmetrical therefore a friction
constant is used and multiplied by the linear velocity as shown in equation (25)
𝐹 = (
−𝑘 𝑑 𝑥̇
−𝑘 𝑑 𝑦̇
−𝑘 𝑑 𝑧̇
) (25)
Equations of motion
Using Newton’s second law the linear motion of the quadcopter can be modelled by
taking into account the thrust, friction and gravity and converting the corresponding
body frames vectors to the inertial frame as shown in equation (26)
𝑚𝑥̈ = [
0
0
−𝑚𝑔
] + 𝑅𝑇𝐵 + 𝐹 (26)
Euler’s equations shown in equation (27) can be rearranged and used to model the
rotation of the quadcopter in the body frame as shown in equation, where equation
(29) represents the inertial matrix. From these equation the rotation of the quadrotor
in the body frame are obtained as shown in equation (30)
𝐼 𝜔̇ + 𝜔(𝐼𝜔) = 𝜏 (27)
𝜔̇ = 𝜔(𝐼𝜔) (28)
𝐼 = (
𝐼 𝑥𝑥 0 0
0 𝐼 𝑦𝑦 0
0 0 𝐼𝑧𝑧
) (29)
52
From these the body frame rotations can be obtained.
𝜔̇ =[
𝜏∅ 𝐼 𝑥𝑥
−1
𝜏 𝜃 𝐼 𝑦𝑦
−1
𝜏Ψ 𝐼𝑧𝑧
−1
] −
[
𝐼 𝑦𝑦−𝐼 𝑧𝑧
𝐼 𝑥𝑥
𝜔 𝑦 𝜔 𝑧
𝐼 𝑧𝑧−𝐼 𝑥𝑥
𝐼 𝑦𝑦
𝜔 𝑥 𝜔 𝑧
𝐼 𝑥𝑥−𝐼 𝑦𝑦
𝐼 𝑧𝑧
𝜔 𝑥 𝜔 𝑦 ]
(30)
53
17. Appendix D: Interim report
Design of a linear PID fuzzy logic control for a quadrotor helicopter
Introduction
The UAV type quadrotor helicopter has; low dimensions, good manoeuvrability,
simple mechanics and available payload capacity (Olivares et al., 2015),
furthermore a hybrid configuration which consist of a fixed wing combined with a
quadrotor configuration would enable this rotorcraft to have the advantages of fixed
wing aircraft vertical flight and the advantages of helicopter vertical take-off and
landing (Flores and Lozano, 2013), therefore the use of quadrotors in logistics is a
very controversial topic, the multi-billion dollars company named amazon.com, Inc.
has proposed the use of a UAV quadrotor configuration to handle their complex
logistics(Amazon, no date)
Aims
To design a Liner PID Fuzzy logic controller for an unmanned quadrotor helicopter
consequently to test the control in a Test-bed using Simulink and in a real
environment using the AR parrot 2.0.
Objectives
The objective of this project is to design a Linear PID Fuzzy logic controller for an
unmanned quadrotor helicopter. To reach this objective:
 The non-linear dynamics of the system are derived.
 A suitable linearization method has to be used for the transformation of the
non-linear dynamics.
 A model of the fuzzy logic controller has to be design in Simulink.
 A test bed for the quadrotor dynamics has to be design using Simulink.
Helicopter history
The control dynamics of helicopters are more challenging than that of airplanes
dynamics, and it took longer for the helicopters to be a mass produced vehicle when
compared to airplanes even though the construction of the first quadrotor dates back
to 1907, later on 1924 George De Bothezat design a quadrotor that achieved the
first kilometre long helicopter flight (Ali and Gueaieb, 2010) however the first mass
produced helicopter was the Sikorsky R-4 in 1942 where a tail rotor was used to
counter act the torque generated by blades, (sikorsky, 1935) this rotorcraft
configuration was the first type to be mass produced mainly because of the
lightweight design of the Sikorsky R-4 but many other rotorcraft configurations have
been implemented in helicopters the most common types are: Tandem, side-by-side,
coaxial, synchropter, quadrotor, et. (Pallet, 1979)
Quadrotor helicopter as UAV
Unmanned aerial vehicles (UAV) can fly autonomously or remotely controlled and
are becoming increasingly popular in civil and military applications that are too risky
humans to conduct. (Ali and Gueaieb, 2010) furthermore recent advances in
54
computational power and in the fields of microelectromechanical system and
sensors (Ryll, Bulthoff, and Giordano, 2012) have enabled the UAV to have more
complex, robust and intelligent controllers.
Quadrotor helicopter background
The quadrotor helicopter or quadrotor, has a four rotor configuration and it does not
requires complex mechanical control linkages (Sharma, 2012) therefore the use of
cyclic, collective pitch or tail rotors is not required when compared to previous
rotorcraft configurations. (Coza and Macnab, 2006) Instead the speed of the blades
is varied to achieve control and the directional flight of the controller is achieved by
tilting the vehicle towards the intended flight direction. (Abeywardena et al., 2009)
The quadrotor will have two pairs of rotors rotating clockwise and the other two
rotating anti-clockwise to counteract the moments similarly varying these speeds will
determine the roll, yaw and spin. (Sharma 2012)
Roll
The roll is the movement of the quadrotor sideways.
Fig. 1(Syed, Raza, and Gueaieb, 2012)
“Increasing the speed of the left motor by the same amount that the speed of the
right motor is decreased will keep the total thrust provided by the four rotors
approximately the same” and roll rate is determined (Coza and Macnab, 2006)
Pitch
The pitch is either the movement of the quadrotor either forward or backwards.
55
Fig. 2 (Syed, Raza, and Gueaieb, 2012)
Increasing the speed of front motor by the same amount that the speed of the right
motor is decreased will keep the total thrust approximately the same and the pitch
rate is determined. (Coza and Macnab, 2006)
Yaw
The yaw is the rotation of the head of the quadrotor.
Fig. 3 (Syed, Raza, and Gueaieb, 2012)
The yaw can be obtained by can be obtained by increasing the speed of the front
and rear rotor together and decreasing the speed of the lateral rotors therefore the
thrust is keep constant. (Sharma 2012)
Thrust
The thrust or height is the movement of the quadrotor in the horizontal plane.
56
Fig. 4 (Syed, Raza, and Gueaieb, 2012)
The thrust or height movement can be achieved by increasing the speed of all the
rotors by the same amount therefore keeping the yaw, spin and roll constant.
Hardware description
The Quadrotor helicopter used in this project is the AR Drone 2.0, which has the
following:
 A 1500 mAh rechargeable battery
 Four brushless in-runner motors, that have a maximum power and angular
velocity of 14.5 watts and 28 500 rpm respectively.
 A 3 axis accelerometer
 A 3 axis gyroscope
 A pressure sensor
(Flying toys Ltd, 2014)
Brushless DC motor 2.2
The main advantage of a brushless motor includes optimized torque simplified
system structure and longer life span, compared to brushed motor. A brushless
motor works by using the coil as the stator of the motor and the coil as the
permanent magnet. (H.E.A. and F.N., 2013)
Control Strategies used for quadrotor helicopter
The most commons type of controllers for a quadrotor helicopter is as follows:
 Robust feedback controllers
 Fuzzy controllers
 PDI controllers
 PD controllers
 Back-stepping controllers
 Neural-network adaptive flight control
 Linear quadratic method
57
Table. 5 (Saad Shaikh, 2011) (Coza and Macnab, 2006) ) (Abeywardena et al.,
2009) (Belkheiri et al., 2012)
And the main focus of this project is on fuzzy logic controllers.
Fuzzy logic controllers background
Fuzzy logic controllers are intelligent systems, the first paper on fuzzy logic was on
1965 by Lotfi A. Zadeh (Mendel, 1995) his papers he describes a “methodological
framework which is tolerant of imprecision and partial truths” (Zadeh, 1973) the
behaviour of complex systems can be described without the need of precise
mathematical models therefore the use a fuzzy logic controller for a complex system
like the quadrotor system would offer many advantages.
Fuzzy logic structure
 A fuzzy logic system is a non-linear mapping of an input data vector into a
scalar output. (Mendel, 1995)
 A fuzzy logic control has the following elements: Pre-processing,
Fuzzification, rule table, inference engine, defuzzification, post-processing.
As shown in (fig. 6)
Fig. 6 (Syed, Raza, and Gueaieb, 2012)
Inference engine
The two most common types of inference engines are the: Mamdani type, and
Takagi-Sugeno-Kang. It can though as system that maps inputs into outputs. (Syed,
Raza, and Gueaieb, 2012)
Mamdani inference system
Output membership functions can be higher order models. (Syed, Raza, and
Gueaieb, 2012)
Takagi-Sugeno-kang;
Output membership functions are either linear or constant. (Syed, Raza, and
Gueaieb, 2012)
58
Mamdani requires more computational power but the controller converges to the
desire states relative faster than Takagi-Sugeno-Kang inference engine. (Syed,
Raza, and Gueaieb, 2012)
Rules
Consists of a collection of if-then rules which can be summarised in a relationship
matrix and then the computer is able to compute a control signal based on the error
and the derivative of the error. (Rai, 2012)
Fuzzification
The fuzzification of the crisp data into a fuzzy set is done via membership function.
(Rai, 2012)
Defuzzification
“Defuzzification is when all the actions that have been activated are combined and
converted into a single non-fuzzy output signal which is the control signal of the
system” (Rai, 2012)
Types of fuzzy logic controllers:
 single input fuzzy logic controller (ishaque et al.,2011),
 Smart self-tuning fuzzy PID controller (Gautam and H, 2013),
 Adaptive fuzzy controller (Coza and Macnab, 2006)
 PDI fuzzy logic (Santos, Lopez, and Morata, 2010) (Sharma,
2012) (Abeywardena et al., 2009)
Table 2
Fuzzy logic system design
A fuzzy PID controller for quadrotor configuration looks like the one shown in figure
10, it has six fuzzy logic controllers, 3 fuzzy logic controllers to control the yaw, roll,
and pitch and 3 fuzzy logic controllers to control the x, y, and z quadrotor position.
(YordanovA and JAIN, 2012)
The controller decisions are based on the desire combination of four motions: yaw,
roll, pitch, and height. The PID controller uses the error, the derivative of the error,
and the integral as inputs. The output is the control action and the corresponding
gain. (Santos, Lopez, and Morata, 2010)
The type of controller being design is a fuzzy PID controller and It uses the error and
the derivative of the error as inputs (Santos, Lopez, and Morata, 2010) (Sharma
2012) (Abeywardena et al., 2009)
59
Fig. 10 (YordanovA and JAIN, 2012)
The aggregation block
Each controller gives the power require by each engine, and there is four controller
inputting an output to the dynamics therefore the aggregation block implements the
coupling of the control actions of the four controllers (Santos, Lopez, and Morata,
2010)
Mathematical model
To derive the mathematical model of the system, Euler equations are used even
though other papers used the quaternion differential equations, to prevent losing a
degree of freedom when the quadrotor has a pitch angle of 90 degrees.
(A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) (Phang et al., 2012) (Li and Li,
2011) (sinha, 2012)(loogbook)
Also the mathematical model derived in here uses the same assumptions,
coordinate system orientation, and method as (A.Abdelkhalek, .El-Demerdash,
and .Dief, 2015) (Li and Li, 2011)
Coordinate system
The coordinate system can be acquired through it states. A quadrotor has 12 states
and six degrees of freedom. (Santos, Lopez and Morata, 2010) These consist on the
orientation or attitude and the position of the quadrotor. (Santos, Lopez and Morata,
2010)
Two main coordinate frames will be used in the derivation of the dynamic behaviour
of the system:
60
Inertial frame; consist of six states: the position of the centre of gravity and
respectively linear velocity components. This frame is time-invariant
Body frame; Consist of six states: the roll, yaw, pitch and the angular velocities
around each axis of the body of frame. The equations of motion are formulated in
the body frame, the orientation of this body of frame coordinate system B(Oxyz), has
the origin at the centroid of the quadrotor and the z-axis is pointing upwards as
described in Figure 11
Fig. 11 (Li and Li, 2011)
The definitions of the Euler angles and the transition matrix from the body frame to
the inertial frame of their corresponding axis are shown below:
Yaw angle; angle between the X-axis and the projection of the body frame in the
inertial frame
(Li and Li, 2011) (1)
Pitch angle; angle between the Z-axis and the projection of the body frame in the
inertial frame
(Li and Li, 2011) (2)
Roll angle; angle between the Y-axis and the projection of the body frame in the
inertial frame
(Li and Li, 2011) (3)
61
The transition matrix R will enable the two coordinates (inertial frame and body of
frame) to be converted to each other.
Therefore the transition matrix R from the body frame or quadrotor coordinate
system B (Oxyz) to the inertial frame or inertial coordinate system E (OXYZ) is
derived:
(Li and Li, 2011)
(4)
To mathematically model the movement of the aircraft Newton’s second law of
motion is used to get the net force and net moment on the quadrotor body.
Assumptions:
Quadrotor and its components are rigid bodies;
The origin of inertial coordinate system is in the same position with the geometric
centre and centroid of the quadrotor
Aerodynamics forces and gyroscopic effects are neglected in this study
1st
equation of motion: translational equations of motion
F=m*a (5)
Where “F” and “a” are the force and acceleration in the body axes respectively.
The force vector “F” in the body, can be derived by: calculating the total thrust vector
in the body axes “ ” and the gravitational force vector in the inertial frame of axis
“ ”
(6) (A.Abdelkhalek, .El-Demerdash,
and .Dief, 2015)
(7) (A.Abdelkhalek, .El-Demerdash,
and .Dief, 2015)
Transforming the gravitational force from the inertial frame of axis to the body frame
axis using the rotation transformation:
62
(8) (A.Abdelkhalek, .El-Demerdash,
and .Dief, 2015)
Combining the thrust force and gravitational force in the 1st
equation of motion:
(9) (A.Abdelkhalek, .El-
Demerdash, and .Dief, 2015)
This equation can be rearranged to give the following:
(10) (11)
(A.Abdelkhalek, .El-Demerdash, and .Dief, 2015)
In the equation above the acceleration in the body of axis is the subject.
(12)
(A.Abdelkhalek, .El-Demerdash, and .Dief, 2015)
Where “ ” is the linear velocity in the body axis [u, v, w]
Where “ ” is the resultant angular velocity vector due to the three rotation angles,
yaw, spin, roll as described by equation (13)
(13)
(A.Abdelkhalek, .El-Demerdash, and .Dief, 2015)
Where [p, q, r] are angular velocities component in the body axes.
Using the equations (10) and (13), equation (14) is derived where “ ” is the vector
acceleration in the inertial frame of reference.
63
(14)
(A.Abdelkhalek, .El-Demerdash, and .Dief, 2015)
Using Equation (12) the following equation is derived:
(15)
(A.Abdelkhalek, .El-Demerdash, and .Dief, 2015)
2nd
equation of motion: Rotational equations of motion
(16) (A.Abdelkhalek, .El-Demerdash,
and .Dief, 2015)
Where “ ” is the moment vector in the body axes.
Using the angular velocities “ ” the torque “ ”equations can be derived:
(17)(18) (A.Abdelkhalek, .El-Demerdash,
and .Dief, 2015)
(19) (A.Abdelkhalek, .El-Demerdash,
and .Dief, 2015)
Equation (19) gives the torque results from drag reactions on blades. From this
equation the moment vector in the body axes can be derived. As the assumption
that the quadrotor is rigid body the inertia tensor becomes a rigid body.
64
(20) (A.Abdelkhalek, .El-
Demerdash, and .Dief, 2015)
Therefore using equation (16),
(21) (A.Abdelkhalek, .El-
Demerdash, and .Dief, 2015)
Since,
(22) (A.Abdelkhalek, .El-
Demerdash, and .Dief, 2015)
The following equation is obtained:
(23) (A.Abdelkhalek, .El-
Demerdash, and .Dief, 2015)
Conclusion and revised project plan
From appendix 1 the project Literature review on Thursday the 26 of
November on the mathematical model was supposed to be finish on Friday
65
the 25 of November and the testing or checking of the mathematical
equations was going to be finish on Friday the 4 of December, however the
complexity of the mathematical model was underestimated which lead to only
having half of the mathematical model completed, as the mathematical model
equations where supposed to be solved using mathlab and then input into
the word document using the word format instead the equations and
diagrams where solved in the logbook and screen shoots of the answers
where use instead as the time was limited to construct the equations.
Therefore the plan proposed on the 7th
of October has changed significantly
one of the changes is that the amount of work that was meant for this part of
the Gantt chart is going to increase because the mathematical modelling was
not done on time the other change is a more detail Gantt chart as the 1st
Gantt chart was very broad, consequently it did not provided good managing
reference of how well or bad the project was going in conclusion a more
detail Gantt chart should be able to break the projects into smaller chunks
which will make the project easier keep track of.
To conclude the aim of this literature is to make a case on the importance
that quadrotor helicopters and artificial intelligence (Fuzzy logic) have in the
present world.

More Related Content

Viewers also liked

Fuzzy imp in part
Fuzzy imp in partFuzzy imp in part
Fuzzy imp in part
Monotheist Jilani
 
Central coast mariners official merchandise
Central coast mariners official merchandiseCentral coast mariners official merchandise
Central coast mariners official merchandise
Shah Mohammad Robel
 
Portfolio
PortfolioPortfolio
Portfolio
Teo Atanasovski
 
PID gain scheduling using fuzzy logic
PID gain scheduling using fuzzy logicPID gain scheduling using fuzzy logic
PID gain scheduling using fuzzy logicISA Interchange
 
Adaptive Fuzzy PID Regulator for the Speed Control of Brushless Dc Motor
Adaptive Fuzzy PID Regulator for the Speed Control of Brushless Dc MotorAdaptive Fuzzy PID Regulator for the Speed Control of Brushless Dc Motor
Adaptive Fuzzy PID Regulator for the Speed Control of Brushless Dc Motor
IOSR Journals
 
Integrated fuzzy logic controller for a Brushless DC Servomotor system
Integrated fuzzylogic controller for a Brushless DC Servomotor systemIntegrated fuzzylogic controller for a Brushless DC Servomotor system
Integrated fuzzy logic controller for a Brushless DC Servomotor system
Ehab Al hamayel
 
Design Mathematical Tunable Gain PID-Like Sliding Mode Fuzzy Controller With ...
Design Mathematical Tunable Gain PID-Like Sliding Mode Fuzzy Controller With ...Design Mathematical Tunable Gain PID-Like Sliding Mode Fuzzy Controller With ...
Design Mathematical Tunable Gain PID-Like Sliding Mode Fuzzy Controller With ...
Waqas Tariq
 
Fuzzy
FuzzyFuzzy
Fuzzyhoaln
 
Speed Control of Brushless Dc Motor Using Fuzzy Logic Controller
Speed Control of Brushless Dc Motor Using Fuzzy Logic ControllerSpeed Control of Brushless Dc Motor Using Fuzzy Logic Controller
Speed Control of Brushless Dc Motor Using Fuzzy Logic Controller
iosrjce
 
Brushless Dc Motor Speed Control Using Proportional-Integral And Fuzzy Contro...
Brushless Dc Motor Speed Control Using Proportional-Integral And Fuzzy Contro...Brushless Dc Motor Speed Control Using Proportional-Integral And Fuzzy Contro...
Brushless Dc Motor Speed Control Using Proportional-Integral And Fuzzy Contro...
IOSR Journals
 
Thompson tchobanian ni_li)
Thompson tchobanian ni_li)Thompson tchobanian ni_li)
Thompson tchobanian ni_li)
trtrungviet
 
Fuzzy logic control of brushless dc motor
Fuzzy logic control of brushless dc motorFuzzy logic control of brushless dc motor
Fuzzy logic control of brushless dc motor
Sourav Chowdhury
 
Design of fuzzzy pid controller for bldc motor
Design of fuzzzy pid controller for bldc motorDesign of fuzzzy pid controller for bldc motor
Design of fuzzzy pid controller for bldc motor
Mishal Hussain
 
FUZZY LOGIC CONTROLLER ON DC/DC BOOST CONVERTER
FUZZY LOGIC CONTROLLER ON DC/DC BOOST CONVERTERFUZZY LOGIC CONTROLLER ON DC/DC BOOST CONVERTER
FUZZY LOGIC CONTROLLER ON DC/DC BOOST CONVERTER
RAGHVENDRA KUMAR PANDIT
 
PID Controller
PID ControllerPID Controller
PID Controllersaishah72
 

Viewers also liked (17)

Fuzzy imp in part
Fuzzy imp in partFuzzy imp in part
Fuzzy imp in part
 
Resume
ResumeResume
Resume
 
Central coast mariners official merchandise
Central coast mariners official merchandiseCentral coast mariners official merchandise
Central coast mariners official merchandise
 
Portfolio
PortfolioPortfolio
Portfolio
 
PID gain scheduling using fuzzy logic
PID gain scheduling using fuzzy logicPID gain scheduling using fuzzy logic
PID gain scheduling using fuzzy logic
 
Adaptive Fuzzy PID Regulator for the Speed Control of Brushless Dc Motor
Adaptive Fuzzy PID Regulator for the Speed Control of Brushless Dc MotorAdaptive Fuzzy PID Regulator for the Speed Control of Brushless Dc Motor
Adaptive Fuzzy PID Regulator for the Speed Control of Brushless Dc Motor
 
Integrated fuzzy logic controller for a Brushless DC Servomotor system
Integrated fuzzylogic controller for a Brushless DC Servomotor systemIntegrated fuzzylogic controller for a Brushless DC Servomotor system
Integrated fuzzy logic controller for a Brushless DC Servomotor system
 
Design Mathematical Tunable Gain PID-Like Sliding Mode Fuzzy Controller With ...
Design Mathematical Tunable Gain PID-Like Sliding Mode Fuzzy Controller With ...Design Mathematical Tunable Gain PID-Like Sliding Mode Fuzzy Controller With ...
Design Mathematical Tunable Gain PID-Like Sliding Mode Fuzzy Controller With ...
 
Fuzzy
FuzzyFuzzy
Fuzzy
 
Speed Control of Brushless Dc Motor Using Fuzzy Logic Controller
Speed Control of Brushless Dc Motor Using Fuzzy Logic ControllerSpeed Control of Brushless Dc Motor Using Fuzzy Logic Controller
Speed Control of Brushless Dc Motor Using Fuzzy Logic Controller
 
Brushless Dc Motor Speed Control Using Proportional-Integral And Fuzzy Contro...
Brushless Dc Motor Speed Control Using Proportional-Integral And Fuzzy Contro...Brushless Dc Motor Speed Control Using Proportional-Integral And Fuzzy Contro...
Brushless Dc Motor Speed Control Using Proportional-Integral And Fuzzy Contro...
 
Thompson tchobanian ni_li)
Thompson tchobanian ni_li)Thompson tchobanian ni_li)
Thompson tchobanian ni_li)
 
Fuzzy logic control of brushless dc motor
Fuzzy logic control of brushless dc motorFuzzy logic control of brushless dc motor
Fuzzy logic control of brushless dc motor
 
Design of fuzzzy pid controller for bldc motor
Design of fuzzzy pid controller for bldc motorDesign of fuzzzy pid controller for bldc motor
Design of fuzzzy pid controller for bldc motor
 
FUZZY LOGIC CONTROLLER ON DC/DC BOOST CONVERTER
FUZZY LOGIC CONTROLLER ON DC/DC BOOST CONVERTERFUZZY LOGIC CONTROLLER ON DC/DC BOOST CONVERTER
FUZZY LOGIC CONTROLLER ON DC/DC BOOST CONVERTER
 
PID Controller
PID ControllerPID Controller
PID Controller
 
Mi Trayectoria
Mi TrayectoriaMi Trayectoria
Mi Trayectoria
 

Similar to FinalYearReport_Angel_Francos-2_PDF-2

Durlav Mudbhari - MSME Thesis
Durlav Mudbhari - MSME ThesisDurlav Mudbhari - MSME Thesis
Durlav Mudbhari - MSME ThesisDurlav Mudbhari
 
Masters Thesis - Joshua Wilson
Masters Thesis - Joshua WilsonMasters Thesis - Joshua Wilson
Masters Thesis - Joshua WilsonJoshua Wilson
 
Shu thesis
Shu thesisShu thesis
Maxime Javaux - Automated spike analysis
Maxime Javaux - Automated spike analysisMaxime Javaux - Automated spike analysis
Maxime Javaux - Automated spike analysisMaxime Javaux
 
Airline Fleet Assignment And Schedule Design Integrated Models And Algorithms
Airline Fleet Assignment And Schedule Design  Integrated Models And AlgorithmsAirline Fleet Assignment And Schedule Design  Integrated Models And Algorithms
Airline Fleet Assignment And Schedule Design Integrated Models And Algorithms
Jennifer Roman
 
Pawar-Ajinkya-MASc-MECH-December-2016
Pawar-Ajinkya-MASc-MECH-December-2016Pawar-Ajinkya-MASc-MECH-December-2016
Pawar-Ajinkya-MASc-MECH-December-2016Ajinkya Pawar
 
Innovative Payloads for Small Unmanned Aerial System-Based Person
Innovative Payloads for Small Unmanned Aerial System-Based PersonInnovative Payloads for Small Unmanned Aerial System-Based Person
Innovative Payloads for Small Unmanned Aerial System-Based PersonAustin Jensen
 
Design, Fabrication and Modification of Small VTOL UAV
Design, Fabrication and Modification of  Small VTOL UAVDesign, Fabrication and Modification of  Small VTOL UAV
Design, Fabrication and Modification of Small VTOL UAV
Akshat Srivastava
 
Alternatives Screening Memo: October 2006
Alternatives Screening Memo: October 2006Alternatives Screening Memo: October 2006
Alternatives Screening Memo: October 2006Honolulu Civil Beat
 
Design of a bionic hand using non invasive interface
Design of a bionic hand using non invasive interfaceDesign of a bionic hand using non invasive interface
Design of a bionic hand using non invasive interface
mangal das
 
Asu December 2010 Application For Bio Pcm
Asu December 2010 Application For Bio PcmAsu December 2010 Application For Bio Pcm
Asu December 2010 Application For Bio Pcm
energy4you
 

Similar to FinalYearReport_Angel_Francos-2_PDF-2 (20)

Durlav Mudbhari - MSME Thesis
Durlav Mudbhari - MSME ThesisDurlav Mudbhari - MSME Thesis
Durlav Mudbhari - MSME Thesis
 
Sarda_uta_2502M_12076
Sarda_uta_2502M_12076Sarda_uta_2502M_12076
Sarda_uta_2502M_12076
 
PhD_main
PhD_mainPhD_main
PhD_main
 
PhD_main
PhD_mainPhD_main
PhD_main
 
PhD_main
PhD_mainPhD_main
PhD_main
 
Masters Thesis - Joshua Wilson
Masters Thesis - Joshua WilsonMasters Thesis - Joshua Wilson
Masters Thesis - Joshua Wilson
 
MS Thesis ShashiprakashSingh
MS Thesis ShashiprakashSinghMS Thesis ShashiprakashSingh
MS Thesis ShashiprakashSingh
 
Master thesis
Master thesisMaster thesis
Master thesis
 
Shu thesis
Shu thesisShu thesis
Shu thesis
 
Maxime Javaux - Automated spike analysis
Maxime Javaux - Automated spike analysisMaxime Javaux - Automated spike analysis
Maxime Javaux - Automated spike analysis
 
Airline Fleet Assignment And Schedule Design Integrated Models And Algorithms
Airline Fleet Assignment And Schedule Design  Integrated Models And AlgorithmsAirline Fleet Assignment And Schedule Design  Integrated Models And Algorithms
Airline Fleet Assignment And Schedule Design Integrated Models And Algorithms
 
Pawar-Ajinkya-MASc-MECH-December-2016
Pawar-Ajinkya-MASc-MECH-December-2016Pawar-Ajinkya-MASc-MECH-December-2016
Pawar-Ajinkya-MASc-MECH-December-2016
 
Innovative Payloads for Small Unmanned Aerial System-Based Person
Innovative Payloads for Small Unmanned Aerial System-Based PersonInnovative Payloads for Small Unmanned Aerial System-Based Person
Innovative Payloads for Small Unmanned Aerial System-Based Person
 
Alinia_MSc_S2016
Alinia_MSc_S2016Alinia_MSc_S2016
Alinia_MSc_S2016
 
Design, Fabrication and Modification of Small VTOL UAV
Design, Fabrication and Modification of  Small VTOL UAVDesign, Fabrication and Modification of  Small VTOL UAV
Design, Fabrication and Modification of Small VTOL UAV
 
Alternatives Screening Memo: October 2006
Alternatives Screening Memo: October 2006Alternatives Screening Memo: October 2006
Alternatives Screening Memo: October 2006
 
KHAN_FAHAD_FL14
KHAN_FAHAD_FL14KHAN_FAHAD_FL14
KHAN_FAHAD_FL14
 
Marshall-PhDThesis-2005
Marshall-PhDThesis-2005Marshall-PhDThesis-2005
Marshall-PhDThesis-2005
 
Design of a bionic hand using non invasive interface
Design of a bionic hand using non invasive interfaceDesign of a bionic hand using non invasive interface
Design of a bionic hand using non invasive interface
 
Asu December 2010 Application For Bio Pcm
Asu December 2010 Application For Bio PcmAsu December 2010 Application For Bio Pcm
Asu December 2010 Application For Bio Pcm
 

FinalYearReport_Angel_Francos-2_PDF-2

  • 1. 1 Design of an intelligent fuzzy logic controller for a quadrotor helicopter by Angel J Francos School of Marine Science and Engineering Faculty of Science and Technology University of Plymouth Honours project submitted in partial fulfilment of the requirements for the degree of BEng (Hons) in Mechanical Engineering Projects co-ordinators: Dr Sanjay Sharma, Room 104, Reynolds Building Dr Asiya Khan, Room 009, Reynolds Building May 2016
  • 2. 2 Abstract In this project a black-box model for the attitude pitch dynamics of a quadrotor helicopter is obtained. And two fuzzy logic controllers are design using different number of rules and tuning methods. Then the fuzzy logic controller with the best performance is compared against a proportional integral derivative controller. The results shows a better performance was achieve by the fuzzy logic controller containing a greater number of rules. And the fuzzy logic controller has a better performance than the proportional integral derivative controller.
  • 3. 3 Acknowledgements I am grateful to: Mrs Maria Aurora Cagigas, Mr Angel Francos, Mrs Ana Laura Francos, Mr Angel R Francos, Mrs Mari Carmen Cagigas, Dr Rafel Orozco, Mr Rafael Orozco, Mr Fermin Orozco and Miss Dulce Orozco for all their support and for being my one and only source of motivation. I would like to thank: Dr Asiya Khan, Dr Sanjay Sharma and Dr Jian Wan for their guidance throughout this project and for introducing me to a very interesting topic that made work, an enjoyable action. I would also like to thank: Mr Avinash Sithale, Mr Alesh Obornik and Mr Matthew H Morris for their companionship through this project.
  • 4. 4 1. Table of Contents 2. Nomenclature....................................................................................................6 3. List of Figures....................................................................................................9 4. List of tables....................................................................................................11 5. Introduction .....................................................................................................12 5.1. Aim...........................................................................................................13 5.2. Objectives ................................................................................................13 6. Literature review..............................................................................................13 6.1. Modelling the dynamics of the system......................................................13 6.1.1. Mathematical models or white box models........................................13 6.1.2. Black-Box Models .............................................................................13 6.1.3. Grey Box Models...............................................................................14 6.2. Proportional Integral Derivative Controllers ..............................................14 6.3. Fuzzy Logic systems and Fuzzy logic ......................................................15 6.4. Fuzzy logic controllers..............................................................................15 6.4.1. The Mamdani fuzzy model ................................................................16 6.4.2. Takagi-Sugeno-Kang fuzzy model.....................................................16 6.4.3. Adaptive fuzzy PID controller ............................................................16 6.4.4. Signed distance method....................................................................16 6.4.5. Membership functions .......................................................................16 6.4.6. Type-2-fuzzy logic controllers............................................................16 6.4.7. Adaptive fuzzy logic controllers .........................................................17 7. Project specification ........................................................................................17 8. Modelling the quadrotor dynamics...................................................................17 8.1. Quadrotor dynamics.................................................................................18 8.2. ARX-Model...............................................................................................19 8.2.1. Determining the model orders of the ARX model...............................20 8.2.2. Estimating the ARX model parameters..............................................21 8.2.3. Validating the ARX model .................................................................21 9. PID Controller..................................................................................................23 10. Fuzzy Logic Controller .................................................................................25 10.1. Fuzzification..........................................................................................25 10.2. Defuzzification ......................................................................................25 10.3. Inference Mechanism ...........................................................................25 10.4. Rule-base .............................................................................................25 10.5. Design of the first fuzzy logic controller.................................................26
  • 5. 5 10.5.1. Rules used for the first controller .......................................................26 10.5.2. Fuzzy sets parameters used for the first controller.............................27 10.6. Design of the second fuzzy logic controller............................................28 10.7. Tuning the FLC controller......................................................................30 11. Results & Discussion ...................................................................................31 11.1. FLC comparison results ........................................................................31 11.2. FLC and PID controller comparison of results .......................................32 11.2.1. Settling time comparison ...................................................................34 11.2.2. Rise time comparison ........................................................................34 11.2.3. Steady state error comparison...........................................................34 11.2.4. Mean square error comparison..........................................................35 11.2.5. Equivalent energy..............................................................................35 11.2.6. Critical analysis..................................................................................36 12. Conclusion and recommendations ...............................................................37 13. References...................................................................................................38 14. Appendix A: Code used to arrange the data.................................................44 15. Appendix B: Data analysis ...........................................................................46 16. Appendix C: Mathematical model of the quadrotor.......................................49 17. Appendix D: Interim report ...........................................................................53
  • 6. 6 2. Nomenclature AI Artificial Intelligence ANN Artifical neural networks APD AR Parrot Drone 2.0 AR Autoregressive model ARMA Autoregressive model with moving avarage ARX Autoregressive model with exogenous input FLC Fuzzy Logic Controller Hz Hertz IV Instrumental variable method LSM Least square method MATLAB MATLAB Sotware MISO Multiple-Input Single Output MLE Maximun Likehood method MSE Mean square error na Number of poles nb Number of zeros nk Delay PID Proportional Integral Derivative PWM Pulse width Modulation Quadrotor Quadrotor-Helicopter SISO Single-Input Single-Output TSK Takagi-Sugeno-Kang UAV Unmanned aerial vehicle VTOL Vertical take off and landing Ω𝑖 Angular velocity of corresponding motor 𝐾 𝑑 Derivative gain
  • 7. 7 𝐾𝑖 Integral gain 𝐾 𝑝 Proportional gain 𝑇⃗ Total thrust vector 𝑇𝑖 Thrust in corresponding frame 𝑍 𝑛 Data set containing inputs and outputs 𝑍 𝑡−1 Past observations 𝑘 𝑑 Friction constant 𝑛 𝑎 Number of poles 𝑛 𝑏 Number of zeros plus 1 𝑛 𝑘 Number of samples before input affect the output 𝑥̈ Inertial frame acceleration 𝜏𝑖 Torques in corresponding axis 𝐼 Inertial matrix quadrotor 𝑏 Drag coefficient 𝑏 Motor constant 𝑐 Output 𝑒(𝑡) White noise disturbance value 𝑒𝑟𝑟𝑜𝑟 𝑒𝑟𝑟𝑜𝑟 = 𝑦(𝑡) − 𝑟(𝑡) 𝑔 Gravity 𝑙 Distance from the centre of a quadcopter to propeller centre 𝑚 Mass of the quadrotor 𝑞 Forward shift operator 𝑟(𝑡) Reference signal 𝑡 Time 𝑢(𝑡) Input signal 𝑢(𝑡) Input 𝑦(𝑡) Output signal
  • 8. 8 𝑦(𝑡) Prediction for the next output 𝜃 Dimensional vector 𝜔 Angular velocity vector inertial frame
  • 9. 9 3. List of Figures Figure 1……………………………… Representation of a closed loop control system Figure 2……………………………… Solid works drawing of a symmetrical quadrotor with the same rotor blade configuration as the Parrot AR Drone 2.0 Figure 3……………………………… Block-scheme of the global control system of an UAV Figure 4……………………………… Graph of the fit of the multi-input ARX model when comparing to the validation data, Rotational angle in degrees vs Time. The red line is the ARX model and the black line is the recorded output Figure 5……………………………… Cross correlation of residuals between input one and output Figure 6……………………………… Cross correlation of residuals between input two and output Figure 7……………………………… Autocorrelation of residuals for the output Figure 8……………………………… Simulink structure for the PID controller Figure 9……………………………… Input signal to the black-box model Figure 10……………………………. Illustration of a FLC Figure 11……………………………. Simulink structure used to design the FLC Figure 12……………………………. Fuzzy sets used for input variable one “Error” Figure 13……………………………. Fuzzy sets used for input variable two “Derivative Error” Figure 14……………………………. Fuzzy sets used for the output variable one (Error) Figure 15……………………………. Fuzzy sets used for input variable one Figure 16……………………………. Fuzzy sets used for input variable two Figure 17……………………………. Fuzzy sets used for output variable one Figure 18……………………………. Sketches showing the states of the system Figure 19……………………………. Step response graph of the FLC’s the pink line is the first fuzzy logic controller and the
  • 10. 10 blue line is the second fuzzy logic controller Figure 20……………………………. step response graph of the FLC and PID controllers to a step input, blue colour is used to indicate the FLC and red colour is used indicate the PID controller Figure 21……………………………. Angular Velocity in degrees second vs Time in seconds Figure 22……………………………. Output of the FLC Figure 23……………………………. Output of the PID controller Figure 24……………………………. Critical evaluation sketch Figure 25……………………………. Code used to arrange the data obtained from the experiment Figure 26……………………………. PWM signal to motor one vs Sample number Figure 27……………………………. PWM signal to three vs Sample number Figure 28……………………………. Rotation in the y-axis vs Number of samples Figure 29……………………………. Linear velocity in the x-axis vs Number of samples Figure 30……………………………. Showing the pictorial representation of the inertial and body frame coordinates
  • 11. 11 4. List of tables Table 1………………………………….... List of commonly used Black-Box models Table 2………………………………….... List of commonly used System Identification methods Table 3………………………………….... Parameters used to record the data during the test-flight Table 4………………………………….... Range of data used to estimate and validate the ARX model Table 5………………………………….... Table of the multi-input ARX model orders as well as the options used to estimate the model Table 6………………………………….... List of parameters for the tuned PID controller Table 7………………………………….... Rules used for the first FLC Table 8………………………………….... Fuzzy sets parameters for input variable one “Error” Table 9………………………………….... Fuzzy sets parameters for input variable two “Derivative of Error” Table 10………………………………….. Fuzzy sets parameters for output one Table 11………………………………….. Rules used for the second FLC controller Table 12………………………………….. Fuzzy sets parameters for input variable one “Error” Table 13………………………………….. Fuzzy sets parameters for input variable two “Derivative of error” Table 14………………………………….. Fuzzy set parameters for output variable one “Output” Table 15………………………………….. Performance measurement values for the FLC’s Table 16………………………………….. Performance measurement for FLC and PID controller Table 17………………………………….. Data range used for estimation of the ARX model Table 18………………………………….. Data range used to validate the ARX model
  • 12. 12 5. Introduction Unmanned aerial vehicles (UAVs) have gained a lot of popularity in the past years. UAVs can fly autonomously or remotely controlled therefore they are becoming increasingly popular in military and civil applications. (Ali and Gueaieb, 2010) A particular UAV has gained significant attention; that is the quadrotor helicopter or quadrotor, because of its vertical take-off and landing (VTOL) capabilities, excellent manoeuvrability and the available payload capacity. The quadrotor helicopter was the first helicopter to complete the first-kilometre long helicopter flight. (Sharma, 2012)(Pallet, 1979) (Ali and Gueaieb, 2010) (Coza and Macnab, 2006) (Sikorsky, 1935) Controlling a quadrotor is a highly complex task because; a quadrotor has open loop unstable and highly non-linear dynamics the system is under-actuated, the spinning rotor blades produce a torque that has to be counteracted and there are complex aerodynamics and gyroscopic effects in the rotor blades. But technological advances in; Computational power, sensor measurement and micro electrical systems have endorsed a new helicopter; the electronically actuated and controlled quadrotor. In this quadrotor the angular velocity of the rotor blades is varied to control it, therefore, there is no need to use complex mechanical systems to control the helicopter; this makes this type of helicopters low-cost and easy to Manufacture. Furthermore, these types of helicopters can have more sophisticated and intelligent control algorithms. (Coza et al., 2011) (Ryll, Bulthoff, and Giordano, 2012) (Sharma, 2012) (Pallet, 1979) Using UAV’s to overcome logistic problems is an application that is becoming increasingly popular. And multi-billion dollar companies like Google Inc. and Amazon.com, Inc. are a few of the many companies in the pursuit of this dream. (Soundarajan and Agrawal, 2016) (Santos, Lopez, and Morata, 2010) (Sharma, 2012) (Piskorski et al., 2012) The use of UAV’s in logistic can help to tackle a major societal problem; that is the problem faced by individuals living in remote areas that are difficult or too expensive to access and they are in need of medicine. UAV medicine delivery is a feasible way of solving this problem, as Raffaello D’Andrea suggested in his paper “Can drones deliver?” (D’Andrea, 2014); D’Andrea also suggested that research in autonomous vehicle coordination is needed to make the UAV medicine delivery system a feasible concept. Therefore the use of an intelligent controller could be a viable method to increase the autonomous coordination of UAV’s like the quadrotor helicopter. (Editors et al., 2014) (Andrea, 2016)(D’Andrea, 2014) A Fuzzy Logic Controller (FLC) attempts to mimic the decision making ability of humans hence this intelligent controller offers an alternative to traditional control methods used to control quadrotors like Proportional Integral Derivative (PID) controllers. (Hema, Scientific, and Publishing, 2013) (Mendel, 1995)
  • 13. 13 5.1. Aim The aim of this project is to compare the performance of a FLC compared to a PID controller for a quadrotor as to increase the research in autonomous vehicle coordination. 5.2. Objectives 1. The pitch dynamics of the quadrotor obtained using a black-box model 2. A PID controller is design 3. A FLC is design 4. The controllers are compared and analysed in a simulation 6. Literature review This literature review is divide into four sections; section 6.1, 6.2, 6.3 and 6.4 which correspond to modelling the dynamics of a system, PID controllers, Artificial Intelligence and Fuzzy Logic Controllers respectively. 6.1. Modelling the dynamics of the system White-box, black box and grey box models can be used to obtain the pitch dynamics of the quadrotor, as explained below: 6.1.1. Mathematical models or white box models The forces that affect the controllability of the system can be derived using a set of equations that describe the system dynamics, known as white box modelling. This approach is usually used in well understood models. Appendix C shows the derivation of the equations used to derive a white box model. (Chao et al., 2010) (Ahmad, Chipperfield, and Tokhi, 2002)(Wu et al., 2014) (Babuška and Verbruggen, 1996) 6.1.2. Black-Box Models The use of input-output data with the combination of System Identification techniques is used to get a model of the system dynamics, known as black-box modelling. This approach is generally used in poorly understood models. Table 1 shows some common model structures used to obtain a black-box model. (Ahmad, Chipperfield, and Tokhi, 2002) (Babuška and Verbruggen, 1996) (Ljung, 2007) Table 1: List of commonly used Black-Box models. (Ljung, 2007) (Forssell and Ljung, 1999) (BILLINGS and VOON, 1987) Model type Model structure Linear models Autoregressive model with exogenous input model (ARX) Autoregressive model with moving average model (ARMA) Box-Jenkins model Autoregressive model (AR) Non Linear model Artificial Neural Networks (ANN)
  • 14. 14 However, System Identification methods have to be used to fit the model to the data set. Table 2 shows a list of some commonly used system identification methods. (Ahmad, Chipperfield, and Tokhi, 2002) Table 2: List of commonly used System Identification methods. (Chao et al., 2010) (Ahmad, Chipperfield, and Tokhi, 2002) (Ljung, 2007)(Wu et al., 2014) System Identification methods Least square method (LSM) Instrumental variable method (IV) Maximum Likelihood method (MLE) Prediction error method (PEM) The black-box model used in this project is obtained using a similar methodology as (Kugelberg, 2016); in which he used a closed-loop configuration to acquire observed data of the system dynamics consequently the least square method is used to fit the data to the ARX model ignoring the correlation between the input and the disturbances present when the data was recorded. (Ahmad, Chipperfield, and Tokhi, 2002) used an open loop approach when recording the data, this was done to eliminate the undesirable correlation between the input and the disturbances present when the data was logged, and a rig configuration was used to overcome the open-loop instability of helicopters. 6.1.3. Grey Box Models This approach is a combination of black box modelling and white box modelling where prior information about the system is known but there are certain unknown parameters that can be determined from experimental data; this is known as grey box modelling or hybrid-modelling. This approach is usually used in partly known models. (Kugelberg, 2016) (Ljung, 2007) (Ahmad, Chipperfield, and Tokhi, 2002) (Babuška and Verbruggen, 1996) 6.2. Proportional Integral Derivative Controllers PID controllers are linear regulators. Type A, Type B and Type C PID structures are some commonly used structures as shown in Equations (1), (2) and (3) respectively. These controllers use a proportional constant, a derivative constant and an integral constant to control the system, the value of these constants can be modified in order to achieve a desire performance. (Hema, Scientific, and Publishing, 2013) (Stojković, Rodić, and Stevanović, 2012) Type A 𝑢(𝑡) = 𝐾 𝑝 𝑒(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡 𝑡 0 + 𝐾 𝑑 𝑑𝑒(𝑡)/𝑑𝑡 (1) Type B
  • 15. 15 𝑢(𝑡) = 𝐾 𝑝 𝑒(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡 𝑡 0 − 𝐾 𝑑 𝑑𝑦(𝑡)/𝑑𝑡 (2) Type C` 𝑢(𝑡) = −𝐾 𝑝 𝑦(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡 𝑡 0 − 𝐾 𝑑 𝑑𝑦(𝑡)/𝑑𝑡 (3) The PID controller chosen in this project is a Type-A PID controller as to make the comparison between controllers clearer. (Hema, Scientific, and Publishing, 2013) Further study could be done by comparing a Type-C PID controller with a FLC, as Type-C controller tends to give smoother control. The use of a Type-B PID controlled is not considered in this project because the advantages of this controller are seen when the structure is implemented in hardware and because none of the controllers designed here are going to be implemented in hardware this controller structure is not taken into account. (Hema, Scientific, and Publishing, 2013) 6.3. Fuzzy Logic systems and Fuzzy logic A Fuzzy logic controller derives from Fuzzy logic systems and fuzzy set theory, in which a Fuzzy logic system is a well-known methodology in artificial intelligence. (Mendel, 1995) (Zadeh, 1973) (Fukuda and Arakawa, 1998) Lotfi A. Zadeh proposed fuzzy logic in 1965 where he describes a “methodological framework which is tolerant of imprecision and partial truths” (Zadeh, 1973). And Artificial Intelligence System (AI) can be though as the process of mimicking an intelligent system by using human knowledge. In which (Fukuda and Arakawa, 1998) defines an intelligent system as “a system that has the ability to adapt to changing environments”. And perhaps Alan Turing is the father of artificial intelligence. (Mendel, 1995) (Zadeh, 1973) (Fukuda and Arakawa, 1998) If the functions of an intelligent system are understood, can these functions be replicated through the use of machinery? Similar questions to this where asked by Alan Turing as he was trying to find a way to imitate an adult humans mind. “In considering the functions of the mind or the brain we find certain operations which we can explain in purely mechanical terms” (TURING, 1950). However, he argued that the nervous system cannot be mimicked through a discrete time machine. (TURING, 1950) 6.4. Fuzzy logic controllers The introduction to the Fuzzy logic controller (FLC) starts with understanding of the fuzzy inference mechanism. The inference mechanism is the process of going from input fuzzy sets to output fuzzy sets or singleton function with use of knowledge in the form of rules. Two famous inference systems are used in the FLC literature and that is the Mamdani fuzzy model and the Takagi-Sugeno-Kang fuzzy model as explained below. (Babuška and Verbruggen, 1996)(Jang, 1993)
  • 16. 16 6.4.1. The Mamdani fuzzy model The Mamdani fuzzy model; was proposed by Mamdani and Assilian in 1974. This is the first example of fuzzy logic control where they design a controller for an industrial steam engine. (Ali Raza and Gueaieb, 2009)(Mamdani and Assilian, 1975) (Zadeh, 1988) 6.4.2. Takagi-Sugeno-Kang fuzzy model The Takagi-Sugeno-Kang (TSK) fuzzy model; was proposed by Takagi and Sugeno in 1985. (Ali Raza and Gueaieb, 2009) (Babuška and Verbruggen, 1996) (Syed, Raza, and Gueaieb, 2012) paper compares the Mamdani and TSK fuzzy inference systems by implementing both inference systems to a Fuzzy Logic flight controller and found that the Mamdani inference system converges to the desire state faster than the TSK inference system and that FLC’s are very good at handling external disturbances. Both (Syed, Raza, and Gueaieb, 2012) and (Ali Raza and Gueaieb, 2009) results concur that the TSK inference system uses less computational power when compared to the Mamdani inference system. 6.4.3. Adaptive fuzzy PID controller FLC can also be used to aid controllers. (Gautam and H, 2013b) designed Fuzzy PID controller in which the gains of the PID controller are the outputs of the Fuzzy Logic Controller the results showed an increase in the PID controller performance. 6.4.4. Signed distance method (Ishaque et al., 2011) Designed a Single Input Single Output (SISO) FLC for an underwater vehicle using the signed distance method. The rule table is a one- dimensional table, therefore; it uses less computational power. However, the author believes that the main advantage of using the signed distance method is the simplification of the tuning process of the rules and membership functions. 6.4.5. Membership functions (Sasaki et al., 1998) Used Gaussian membership functions to build a FLC for a helicopter and he found that these functions are very good at stabilizing it. The author considers that using a Gaussian membership functions can make the tuning process harder than it already is. Therefore, triangular functions are utilized in the FLC designed in this project. 6.4.6. Type-2-fuzzy logic controllers (Raju and Pillai, 2016) and (Sabahi, Ghaemi, and Badamchizadeh, 2016) used a type-2-fuzzy logic controller in which the membership functions of this controller consist of a combination of a two membership functions; a primary and a secondary function. The type-2 membership functions allow the modelling of uncertainty in the system. However the model used in this project is a simulated model hence sensors are not used to feed-back the state of the system therefore the uncertainty of the state of the system is minimal and this type of controller is not considered in this project. (Raju and Pillai, 2016) (Sabahi, Ghaemi, and Badamchizadeh, 2016)
  • 17. 17 However, more research in type-2-fuzzy logic controllers could help to reduce the price of the UAV medicine delivery system making it more economically feasible this is because cheaper sensors can be used to construct UAV’s if type-2-fuzzy logic controllers are used, assuming cheap sensors produce more measurement uncertainty. (Sepúlveda et al., 2007) (Sabahi, Ghaemi, and Badamchizadeh, 2016) (Raju and Pillai, 2016) 6.4.7. Adaptive fuzzy logic controllers A still controversial topic in the FLC literature relates on how to tune a FLC, and authors like (Kaur and Kaur, 2012) have leap frog the tuning process by using Adaptive Fuzzy Logic controllers to improve the performance and (Khan et al., 2008) used genetic algorithms to optimize the membership functions and if the FLC has scaling gains this can be tuned as well. However there is still a gap in the Fuzzy Controller literature; that is the lack of understanding on how to tune a FLC to achieve certain performance parameters. 7. Project specification The type of control design for the FLC and PID controller in this project was chosen to be a closed loop control, because helicopters are unstable in open-loop control. A closed loop system uses feedback to get the error of the system which is the difference between the desired state and the current state. As shown in Fig. 1. (Passino and Yurkovich, 1998) Figure 1: Representation of a closed loop control system. (Passino and Yurkovich, 1998) To obtain the closed loop controllers; a model that describes the pitch dynamics is obtained, consequently a PID controller and FLC were designed, and the controllers performance relative to each other is analysed using performance measurements as shown in sections 8, 9, 10 and 11 respectively. (Passino and Yurkovich, 1998) 8. Modelling the quadrotor dynamics In this section a black-box model is going to be obtained for the pitch attitude dynamics, the data obtained to estimate the model was obtained from a test-flight using the AR Parrot Drone 2.0 (APD). The black-box model used in this project is a Linear ARX model; consequently the least square error is going to be used to fit the model to the observed data.
  • 18. 18 8.1. Quadrotor dynamics The pitch of the quadcopter can be controlled by increasing the speed of the rotor blade three by the same amount that the speed of rotor blade one is decreased, as shown in Equation (4). Figure 2 shows the Parrot AR Drone 2.0 rotor configuration. (Coza and Macnab, 2006) (Piskorski et al., 2012) 𝑈 𝜃 = [ Ω1 − 𝛥𝑢 Ω2 Ω3 + 𝛥𝑢 Ω4 ] (4) Figure 2: Solid work drawing of a symmetrical quadrotor with the same configuration as the Parrot AR Drone 2.0 The pitch of the quadrotor controls the rotation in the y-axis consequently this motion is coupled with the translational motion of the quadcopter in the x-axis. A position controller can be used to control the translational motion of the quadrotor. The inputs to the position controller are the desire translational motions and the outputs are the reference angles needed to achieve this translational motion, as shown in Fig. 3. (Coza et al., 2011) (Stojković, Rodić, and Stevanović, 2012) (Razinkova et al., 2014)
  • 19. 19 Figure 3: Block-scheme of the global control system of an UAV. (Stojković, Rodić, and Stevanović, 2012) In this project only the y-axis rotation in the body frame of the quadrotor is going to be controlled, this is also known as attitude control. (Stojković, Rodić, and Stevanović, 2012) 8.2. ARX-Model The structure of the ARX model is described below. An ARX model is represented by a linear differential equation as shown in Equation (5). This model is a discrete time system that represents the relationship between the input and output at a given time, given a disturbance is present. (Ljung, 2007) (Kugelberg, 2016) The ARX model structure uses regression to estimate the output. Essentially the model contains old values of the variable to be described; hence the model structure shown in Equation (5) is called an Auto-Regressive model with exogenous input. (Ljung, 2007) (Kugelberg, 2016) A more generalised representation of the model is shown in Equations (6), (7) and (8). (Kugelberg, 2016) 𝐴(𝑞)𝑦(𝑡) = 𝐵(𝑞)𝑢(𝑡) + 𝑒(𝑡) (6) 𝐴(𝑞) = 1 + 𝑎1 𝑞−1 + ⋯ + 𝑎 𝑛𝑎 𝑞−𝑛𝑎 (7) 𝐵(𝑞) = 𝑏1 𝑞−1 + ⋯ + 𝑏 𝑛𝑏 𝑞−𝑛𝑏 (8) The ARX model used in this project has a Multi-Input-Single-Output (MISO). Therefore it has two inputs and one output. (Coza et al., 2011) The inputs to the ARX model are: the Pulse width Modulation (PWM) signal to motor one and the PWM signal to motor three. And it is assumed that the PWM input signal to the motors is proportional to the angular velocity of the rotor blades. (Coza et al., 2011) The output of the ARX model is the rotational angle of the quadrotor in the y-axis measured in degrees. The observed data of the pitch dynamics was obtained by connecting the ADP to a laptop via WIFI. A manually controlled test flight was conducted to obtain the data. The test-flight lasted a total of 162.27 seconds and it consisted of 32453 samples. The test flight and data parameters used to record the data are shown in Table 3. 𝑦(𝑡) + 𝑎1 𝑦(𝑡 − 1) + ⋯ + 𝑎 𝑛𝑎 𝑦(𝑡 − 𝑛 𝑎) = 𝑏1 𝑢(𝑡 − 𝑛 𝑘) + ⋯ + 𝑏 𝑛𝑏 𝑢(𝑡 − 𝑛 𝑏 𝑛 𝑘 + 1) + 𝑒(𝑡) (5)
  • 20. 20 Table 3: Observed data and test flight parameters Frequency (sampling rate) 200(Hz) Number of Samples 32453 Time length of data 162.27 (seconds) Configuration of quadcopter Close loop configuration Noise to the quadcopter None From the test-flight, a text document containing different arrays of information was obtained. This text file was imported into MATLAB and the code shown in Appendix A was used to organize the data into a series of arrays. To estimate and validate the ARX model parameters two different data sets are used, the first data set is used for the estimation of the parameters and the second data is used to validate the ARX model. (Ahmad, Chipperfield, and Tokhi, 2002) (Ljung, 2007) Because the test flight was controlled manually, only certain ranges of the data contain the correct excitation signal that exposes the relevant properties of the pitch attitude dynamics. Therefore the data was plotted and analysed to find these ranges as shown in Appendix B, Table 4 shows the ranges of data used for estimation and validation of the ARX model. (Ahmad, Chipperfield, and Tokhi, 2002) Table 4: Range of data used to estimate and validate the ARX model Range of samples used to estimate the ARX model [25710:26020] Range of samples used to validate the ARX model [27690:27940] 8.2.1. Determining the model orders of the ARX model In order to estimate the parameters of the model structure, the number of zeros, poles and the delay in the system has to be input manually. The “order selection” function in MATALB can be used to select the most suitable model structure. This function allowed the author to select the model orders with the lowest residuals. However, trial and error was also used to estimate the most suitable model orders. Table 5 contains the model orders used to estimate the ARX-structure. (Ljung, 1998) Table 5: Table of the multi-input ARX model orders as well as the options used to estimate the model Number of poles (na) 14 Number of zeros (nb) [1 1] Delay (nk) [3 5] Initial state (option) Auto Focus (option) Prediction Covariance (option) Estimate Sample time 0.005 (seconds)
  • 21. 21 8.2.2. Estimating the ARX model parameters The ARX parameters are estimated using the Least-Square-error Method; This method works by rearranging Equation (5) to give a prediction of the next output based on previous observations, as shown in Equation (9). Therefore, the parameters in Equation (11) can be adjusted, in order to fit the predicted output of the model as close as possible to the recorded output. (Ahmad, Chipperfield, and Tokhi, 2002) (Chao et al., 2010) (Ljung, 2007) After using the least square error to fit the model to the estimation data, the following structure was obtained as shown in equation (10), equations (11), (12) and (13). T he model has a fit of 99.71% to the estimation data. 𝐴(𝑞)𝑦(𝑡) = 𝐵(𝑞)𝑢(𝑡) + 𝑒(𝑡) (10) 𝐴(𝑞) = 1 − 1.656 𝑧^ − 1 + 0.08202 𝑧^ − 2 + 0.8692 𝑧^ − 3 + 0.1443 𝑧^ − 4 − 0.8325 𝑧^ − 5 + 0.4325 𝑧^ − 6 − 0.3216 𝑧^ − 7 + 0.7183 𝑧^ − 8 − 0.5296 𝑧^ − 9 − 0.3743 𝑧^ − 10 + 0.5855 𝑧^ − 11 + 0.1981 𝑧^ − 12 − 0.4307 𝑧^ − 13 + 0.1162 𝑧^ − 14 (11) 𝐵1(𝑞) = −2.531𝑒 − 05 𝑧^ − 3 (12) 𝐵2(𝑞) = 0.0001759 𝑧^ − 5 (13) The coefficients of the equation 11, 12 and 13 alone have no significant meaning but the pitch dynamics are dependent upon them (Ahmad, Chipperfield, and Tokhi, 2002) 8.2.3. Validating the ARX model This model was then validated using the second data set to check if the model is describing the pitch dynamics and not the disturbances present when the data was collected. (Kugelberg, 2016) 𝑦(𝑡) = −𝑎1 𝑦(𝑡 − 1) − ⋯ − 𝑎 𝑛𝑎 𝑦(𝑡 − 𝑛 𝑎) + 𝑏1 𝑢(𝑡 − 𝑛 𝑘) + ⋯ + 𝑏 𝑛𝑏 𝑢(𝑡 − 𝑛 𝑏 𝑛 𝑘 + 1) + 𝑒(𝑡) (9) 𝑦(𝑡) = 𝜃𝜑(𝑡) (10) 𝜃 = [ 𝑎1, ⋯ , 𝑎 𝑛𝑎 𝑏1, ⋯ 𝑏 𝑛𝑏] 𝑇 (11) 𝜑(𝑡) = [−𝑦(𝑡 − 1) ⋯ − 𝑦( 𝑡 − 𝑛 𝑎) 𝑢(𝑡 − 1) ⋯ 𝑢(𝑡 − 𝑛 𝑏)] 𝑇 (12)
  • 22. 22 The ARX model shows a fit of 75.49 % to the validation data as shown in Fig. 4. Figure 4: Graph of the fit of the multi-input ARX model when comparing to the validation data, Rotational angle in degrees vs Time. The red line is the ARX model and the black line is the recorded output To further validate the ARX model residual analysis was used. The residuals are the prediction errors of the model. The residual confidence interval was set to 99%. Figure 5, shows the cross correlation between the first input and the output, Fig. 6, shows the cross correlation between the second input and the output and Fig. 7 shows the auto-correlation between the residuals and the output. Figure 5 and Fig. 6, shows that the cross correlation between the inputs and the output lies between the 99% confidence region therefore the model description of how the output is generated from given inputs is 99% accurate and this model is going to be used to design and test the controllers. However from Fig. 7 it can be seen that autocorrelation of residuals does not lie within 99% confidence interval this could be because a close loop configuration was used to obtain the observed data.(Tang and Mullholland, 1987)(Westwick and Perreault, 2011)(Kugelberg, 2016)
  • 23. 23 Figure 5: Cross correlation of residuals between input one and output Figure 6: Cross correlation of residuals between input two and output Figure 7: Autocorrelation of residuals for the output 9. PID Controller PID controllers are linear regulators, and is estimated that 90% of the controllers used today are PID controllers. (Passino and Yurkovich, 1998) (Stojković, Rodić, and Stevanović, 2012) A Type-A PID controller works by obtaining the derivative of the error, the integral of the error and the error this values are then multiplied by a gain constant whose
  • 24. 24 value can change, to tune the controller this values are then added and the result is the input signal to the model as shown in Equation 14. (Hema, Scientific, and Publishing, 2013) Type-A PID controller 𝑢(𝑡) = 𝐾 𝑝 𝑒(𝑡) + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡 𝑡 0 + 𝐾 𝑑 𝑑𝑒(𝑡)/𝑑𝑡 (14) The structure used to make the pitch PID controller is shown in Fig. 8. Constant and summing blocks were used to simulate the matrix used to couple the pitch, roll, yaw and height controllers in a complete attitude quadrotor controller, therefore the input signal to motor one and three is equal and inversely proportional, as shown in Fig. 9. (Santos, Lopez and Morata, 2010) (Coza et al., 2011) Figure 8: Simulink structure for the PID controller Figure 9: Input signal to the black-box model The PID controller was tuned using the PID Tuning tool in MATLAB. The PID was tuned to get the smallest settling time; the following parameters where obtained as shown in Table 6. One limitation of tuning the controller by just taking the settling time into consideration is that the controller has a big overshoot.
  • 25. 25 Table 6: List of parameters for the tuned PID controller Parameter Value Proportional gain 19.6312672482784 Integral gain 47.5371083298902 Derivative gain 1.66097140544201 Filter coefficient 48.1589094901108 10. Fuzzy Logic Controller In this section two fuzzy logic controllers are design; the first fuzzy logic controller uses nine rules and the second one uses 25 rules. The reason to design two FLC is to show how the performance of the FLC is dependent on the number of rules used. (Ishaque et al., 2011) A fuzzy logic controller has four components as illustrated in Fig. 10 and the components are explained below. 10.1. Fuzzification Fuzzification is the process of mapping an input in the universe of discourse to a fuzzy set in which the fuzzy set has a degree of membership to the given input. (Bellman, Kalaba, and Zadeh, 1966)(Mendel, 1995) 10.2. Defuzzification Defuzzification is the inverse operation of the fuzzification process, and this is the process of going from output fuzzy sets to the universe of discourse.(Mendel, 1995) 10.3. Inference Mechanism For the Mamdani inference system, the inference mechanism is the process of going from input fuzzy set to output fuzzy sets with the use of the rules. (Babuška and Verbruggen, 1996) (Mendel, 1995) 10.4. Rule-base This part of the controller holds the knowledge on how to control the system in set of “If- Then “rules. (Fukuda and Arakawa, 1998) (Mendel, 1995)
  • 26. 26 Fig 10: Illustration of a FLC The Simulink structure shown in Fig. 11 was used to design the FLC. The FLC’s inference system used to design both controllers is the Mamdani inference system and the centroid method is for the defuzzification process in both controllers. Figure 11: Simulink structure used to design the FLC The type of FLC designed in this project is PD type controllers therefore; the FLC has two inputs which are the error and the derivative of the error which corresponds to the angle and the angular velocity of the quadrotor in the y-axis and a single output which correspond to PWM signal to the motors. (Ishaque et al., 2011) 10.5. Design of the first fuzzy logic controller 10.5.1. Rules used for the first controller The rules used for this controller are shown in Table 7 and they are shown below: 1. If error is Negative and the change in error is Negative then output is Negative 2. If error is Negative and the change in error is then Zero then output is Negative 3. If error is Negative and the change in error is then Positive then output is Zero 4. If error is Zero and the change in error is then Negative then output is Negative 5. If error is Zero and the change in error is then Zero then output is Zero 6. If error is Zero and the change in error is then Positive then output is Positive 7. If error is Positive and the change in error is then Negative then output is Zero 8. If error is Positive and the change in error is then Zero then output is Positive 9. If error is Positive and the change in error is then Positive then output is Positive
  • 27. 27 Table 7: Rules used for the first FLC 𝑒𝑟𝑟𝑜𝑟/𝛥𝑒𝑟𝑟𝑜𝑟 N Z P N N N Z Z N Z P P Z P P The two FLC controllers designed in this project contain the rules used by (Passino and Yurkovich, 1998), in which he uses these rules to control an inverted pendulum. 10.5.2. Fuzzy sets parameters used for the first controller The first input to the FLC is the error in degrees; the range given to the error is: [-1 3]. Consequently three membership functions where used as shown in Table 8 and Fig. 12. It is important to understand one major limitation of this range; if the reference input is bigger than the range of the error input variable, the reference input would not belong to any Fuzzy set. Table 8: Fuzzy sets parameters for input variable one “Error” Linguistic variable for the fuzzy set Range of values Shape Negative (N) [-1 -1 0] Triangular Zero (Z) [-1 0 1] Triangular Positive (P) [0 1 3 3] Trapezoidal Figure 12: Fuzzy sets used for input variable one “Error” The second input to the FLC is the change in error in degrees per second; the range given to the change in error was from: [-6 6]. Three membership functions where used as shown in Table 9 and Figure 13. Table 9: Fuzzy sets parameters for input variable two “Derivative of Error” Linguistic variable for the fuzzy set Range of values Shape Negative (N) [-6 -6 -3 0] Trapezoidal Zero (Z) [-1 0 1] Triangular Positive (P) [0 3 6 6] Trapezoidal
  • 28. 28 Figure 13: Fuzzy sets used for input variable two “Derivative Error” The output to the FLC is the input signal to the plant and the range given to the input signal is: [-10 30]. Consequently three membership functions where used as shown in Table 10 and Fig. 14. Table 10: Fuzzy sets parameters for output one “Output” Figure 14: Fuzzy sets used for the output variable one (Error) The performance measurements and time response for the first Fuzzy logic controller is shown in section 11. 10.6. Design of the second fuzzy logic controller Table 11, contains the rules used to design this controller furthermore a more intuitive tuning method was used as shown in section 10.7 this was done to increase the performance of the FLC. Linguistic variable for the fuzzy set Range of values Shape Negative (N) [-10 -10 0] Triangular Zero (Z) [-10 0 10] Triangular Positive (P) [0 10 30 30] Trapezoidal
  • 29. 29 Table 11: Rules used for the second FLC controller 𝑒𝑟𝑟𝑜𝑟/𝛥𝑒𝑟𝑟𝑜𝑟 NB NS Z PS PB NB NB NB NB NS Z NS NB NB NS Z PS Z NB NS Z PS PB PS NS Z PS PB PB PB Z PS PB PB PB The new parameters for input one, input two and the output are shown in Table 12, Fig.15, Table 13, Fig. 16, Table 14 and Fig. 17 respectively. Table 12: Fuzzy sets parameters for input variable one “Error” Linguistic variable for the fuzzy set Range of values Shape Negative Big (NB) [-3 -3 -0.3 -0.1] Trapezoidal Negative (N) [-0.2 -0.05 0] Triangular Zero (Z) [-0.06 0 0.06] Triangular Positive (P) [0 0.05 0.2] Triangular Positive Big (PB) [0.1 0.3 3 3] Trapezoidal Figure 15: fuzzy sets used for input variable one Table 13: Fuzzy sets parameters for input variable two “Derivative of error” Linguistic variable for the fuzzy set Range of values Shape Negative Big (NB) [-6 -6 -5 -3] Trapezoidal Negative (N) [-4 -2 0] Triangular Zero (Z) [-0.95 0 0.95] Triangular Positive (P) [0 2 4] Triangular Positive Big (PB) [3 5 6 6] Trapezoidal
  • 30. 30 Figure 16: Fuzzy sets used for input variable two Table 14: Fuzzy set parameters for output variable one “Output” Linguistic variable for the fuzzy set Range of values Shape Negative Big (NB) [-35 -35 -15] Triangular Negative (N) [-30 -22 0] Triangular Zero (Z) [-15 0 15] Triangular Positive (P) [0 22 30] Triangular Positive Big (PB) [15 35 35] Triangular Figure 17: Fuzzy sets used for output variable one The performance measurements and the time response of this controller are shown in section 11. 10.7. Tuning the FLC controller This FLC was tuned using a combination of trial and error and the following thinking process: To achieve the certain performance desired by the designer, the fuzzy set ranges used to model the state of the system are changed as to fire the rules that designer thinks are more appropriate at that given range.
  • 31. 31 Graphs of the error, the derivative of the error and the output are plotted against time and are used with the combination of sketches like the one shown in Fig 18, to attempt to predict which rules need to be fired at the certain ranges to and consequently changing the range and shapes of the fuzzy sets in order to force fire the rules that the designer wants to fire in order to achieve the desire performance and deep understanding of the system is needed if this approach is to be used. Figure 18: Sketches showing the states of the system 11. Results & Discussion 11.1. FLC comparison results Table 15, and Fig. 19 shows the performance parameters and time response to a step input with a final value of one for both of the FLC designed in this project. It can be seen that second FLC controller that uses 25 rules outperforms the first FLC that only uses 9 rules in almost every single performance parameter. This shows that the performance of the controller is dependent on the number of rules and the tuning process.
  • 32. 32 Table 15: Performance measurement values for the FLC’s Performance measurement FLC 1 (9 Rules) FLC 2 (25 Rules) Steady-state-error (degrees) 0.132 0.014 Percentage Overshoot (%) None None Rise time to 1% (seconds) Inconclusive 0.31 Settling time to 2%(seconds) Inconclusive 0.55 Equivalent energy 53.74 62.88 Mean Square Error (MSE) 0.1005 0.0389 Figure 19: Step response graph of the FLC’s the pink line is the first fuzzy logic controller and the blue line is the second fuzzy logic controller 11.2. FLC and PID controller comparison of results Is important to understand that model used to run the simulations is a linear model and no disturbances where applied during the simulation. Therefore the controllers were controlling a highly linear system and if these controllers are to be compared in a real environment via hardware implementation, and disturbances like wind gust are present this perturbations will make the system less linear and the performance of the FLC controller is expected to increase when compared to PID controller because a FLC is a nonlinear controller. (Leigh, 1992) (Stojković, Rodić, and Stevanović, 2012)
  • 33. 33 To compare the performance of the Second FLC to the PID controller; a step input with a final value of one was applied to both controller the simulation lasted five seconds. The results are shown in Table 16, and in Fig. 20. Table 16: Performance measurement for FLC and PID controller Performance measurement PID FLC Steady-state-error (degrees) 0 0.014 Percentage Overshoot (%) 12 None Rise time to 2% (seconds) 0.14 0.31 Settling time to 2%(seconds) 0.98 0.55 Equivalent energy 51.64 62.88 Mean Square Error (MSE) 0.0228 0.0389
  • 34. 34 Figure 20: step response graph of the FLC and PID controllers to a step input, blue colour is used to indicate the FLC and red colour is used indicate the PID controller 11.2.1. Settling time comparison The FLC reaches a steady state value within 2% of the final value 78% faster than the PID controller and this shows that the set of rules used to stabilize an inverted pendulum can be implemented to control the pitch rotation of a quadrotor very effectively. 11.2.2. Rise time comparison Figure 20 and Table 16 shows that the PID controller is 121% faster than the FLC at reaching the reference angle; this is because the PID Controller manages to achieve an angular velocity of 10 degrees/ second whereas the FLC only achieves a velocity of 4 degrees/ second as shown in Fig. 21. Therefore the PID controller achieves a faster angular velocity hence the faster rise time. Figure 21: Angular Velocity in degrees second vs Time in seconds 11.2.3. Steady state error comparison From Table 16, it can be seen that PID outperforms the FLC in terms accuracy to reach the reference angle, this is because the PID controller has a zero steady state error and the FLC has a steady state error of 0.014. However the difference in the steady state errors can be considered insignificant if they would be to be implemented in a quadrotor attitude controller.
  • 35. 35 11.2.4. Mean square error comparison From Table 16, it is seen that Mean Square Error (MSE) is smaller for the PID controller, however the MSE measurement was not used to evaluate the performance of the controllers because: The PID controller has an overshoot and undershoot which reduces the value of the MSE even though the overshoot and undershoot are undesirable characteristics in a controller. Furthermore, the FLC does not achieve steady state error hence the MSE measurement obtained for the FLC controller is greatly influenced by the length of the simulation and the steady state error of the controller. 11.2.5. Equivalent energy From Table 16 it can be seen that the equivalent energy measurement obtained from the PID controller is smaller than the one obtained from the FLC, hence the PID controller is more energy efficient this can be understood by observing the output of the FLC and PID controller shown in Fig. 22 and Fig. 23 respectively. Figure 22: Output of the FLC
  • 36. 36 Figure 23: Output of the PID controller 11.2.6. Critical analysis To further analyse the performance of the controllers relative to each other, a scenario is created to simulate the trajectory that a quadrotor might have to follow in the near future. As shown in Fig. 24. In this scenario the quadrotor is controlled autonomously by a position controller as shown in Fig. 3, the quadrotor has to achieve the fastest linear velocity in the x-axis but without touching the imaginary or physical boundaries. Equation 15 can be used to by the position controller, to know the biggest angle ∝ the quadrotor can have if the length of the quadrotor 2 ∗ 𝐿 is bigger than the height of the imaginary boundary 2 ∗ ℎ2. ∝ = sin−1 ( ℎ2 𝐿 ) (15) If a position controller is used to control the FLC and PID controller designed in this project, the FLC would get to 2% of the reference value 75% faster than the PID controller furthermore the PID has an overshoot of 12% and this would cause the quadrotor to overshoot the boundary hence failing the objective of the simulation.
  • 37. 37 Figure 24: Critical evaluation sketch 12. Conclusion and recommendations In conclusion the project shows that the ARX model can model the quadrotor pitch dynamics effectively and it has a fit of 75.49% to validation data without any cross correlation between the input and the output. It was also shown that the performance of the FLC is greatly affected by the number of rules used and the how well the controlled is tuned. The results show that the FLC is a more effective attitude controller with the slight draw back that is less energy efficient. The author would like to recommend the use of an open-loop configuration to obtain the pitch dynamics as this can improve the accuracy of the black-box model. Furthermore this model can be used to compare the performance of the PID controller compared to a FLC, as to validate the results obtained in this project. The author would like to recommend using quadrotor with a microcontroller that is compatible with the code generation function in MATLAB like the use of an Arduino Microcontroller like the “Arducopter” consequently to compare the performance of the PID against the FLC in a real world environment.
  • 38. 38 13. References A.Abdelkhalek, M.A., . El-Demerdash, M.S. and . Dief, T.N. (2015) ‘Attitude Stability of Quadcopter Using Classic Control with Angular Acceleration’, . Abeywardena, D.M.W., Amaratunga, L.A.K., Shakoor, S.A.A. and Munasinghe, S.R. (2009) ‘A velocity feedback fuzzy logic controller for stable hovering of a quad rotor UAV’, 2009 International Conference on Industrial and Information Systems (ICIIS), . Ackermann, J., Guldner, J., Sienel, W., Steinhauser, R. and Utkin, V.I. (1995) ‘Linear and nonlinear controller design for robust automatic steering’, IEEE Transactions on Control Systems Technology, 3(1), pp. 132–143. Ahmad, S.M., Chipperfield, A.J. and Tokhi, M.O. (2002) ‘Dynamic modelling and open-loop control of a twin rotor multi-input multi-output system’, Proceedings of the Institution of Mechanical Engineers, Part I: Journal of Systems and Control Engineering, 216(6), pp. 477–496. Ali Raza, S. and Gueaieb, W. (2009) ‘Fuzzy Logic based Quadrotor Flight Controller’, , p. pp. 105–112. Ali, S. and Gueaieb, W. (2010a) Intelligent Flight Control of an Autonomous Quadrotor. . Ali, S. and Gueaieb, W. (2010b) ‘Intelligent flight control of an autonomous Quadrotor’, Motion Control, . Amazon (no date) Amazon prime air. Available at: http://www.amazon.com/b?node=8037720011 . Amoozegar, D. (2016) ‘DSTATCOM modelling for voltage stability with fuzzy logic PI current controller’, International Journal of Electrical Power & Energy Systems, 76, pp. 129–135. Amza, C.G. and Cicic, D.T. (2015) ‘Industrial image processing using fuzzy-logic’, Procedia Engineering, 100, pp. 492–498. AWARDS AND HONORS KEYNOTES, PLENARIES, AND SELECT SPEAKING ENGAGEMENTS (2016) Available at: http://raffaello.name/wp- content/uploads/2016/03/DAndreaCV2016Mar1.pdf (Accessed: 24 April 2016). Babuška, R. and Verbruggen, H.B. (1996) ‘An overview of fuzzy modeling for control’, Control Engineering Practice, 4(11), pp. 1593–1606. Belkheiri, M., Rabhi, A., Hajjaji, A.E. and Pegard, C. (2012) ‘Different linearization control techniques for a quadrotor system’, CCCA12, . Bellman, R., Kalaba, R. and Zadeh, L. (1966) ‘Abstraction and pattern classification’, Journal of Mathematical Analysis and Applications, 13(1), pp. 1–7. Berenji, H.R. and Khedkar, P. (1992) ‘Learning and tuning fuzzy logic controllers through reinforcements’, IEEE Transactions on Neural Networks, 3(5), pp. 724–740.
  • 39. 39 BILLINGS, S.A. and VOON, W.S.F. (1987) ‘Piecewise linear identification of non- linear systems’, International Journal of Control, 46(1), pp. 215–235. Cen, Z., Noura, H., Susilo, T.B. and Younes, Y.A. (2013) ‘Robust fault diagnosis for Quadrotor UAVs using Adaptive Thau observer’, Journal of Intelligent & Robotic Systems, 73(1-4), pp. 573–588. Chamberlain, C.H. (2011) System Identification, State Estimation, and Control of Unmanned Aerial Robots. . Chao, H., Luo, Y., Di, L. and Chen, Y.Q. (2010) ‘Roll-channel fractional order controller design for a small fixed-wing unmanned aerial vehicle’, Control Engineering Practice, 18(7), pp. 761–772. Coza, C. and Macnab, C.J.B. (2006) ‘A new robust Adaptive-Fuzzy control method applied to Quadrotor helicopter stabilization’, NAFIPS 2006 - 2006 Annual Meeting of the North American Fuzzy Information Processing Society, . Coza, C., Nicol, C., Macnab, C.J.B. and Ramirez-Serrano, A. (2011) ‘Adaptive fuzzy control for a quadrotor helicopter robust to wind buffeting’, Journal of Intelligent & Fuzzy Systems, 22(5,6), pp. 267–283. D’Andrea, R. (2014) ‘Guest editorial can drones deliver?’, IEEE Transactions on Automation Science and Engineering, 11(3), pp. 647–648. D’Andrea, R. (2016) Transcript of ‘meet the dazzling flying machines of the future’. Available at: https://www.ted.com/talks/raffaello_d_andrea_meet_the_dazzling_flying_machines_ of_the_future/transcript?language=en . Deb, K., Mohan, M. and Mishra, S. (2005) ‘Evaluating the ε-domination based multi- objective evolutionary algorithm for a quick computation of Pareto-Optimal solutions’, Evolutionary Computation, 13(4), pp. 501–525. Dong, W., Gu, G.-Y., Zhu, X. and Ding, H. (2015) ‘Development of a Quadrotor test bed — Modelling, parameter identification, controller design and trajectory generation’, International Journal of Advanced Robotic Systems, . Driankov, D., Hellendoorn, H. and Reinfrank, M. (1995) An introduction to Fuzzy Control. . E, H.W., F, K.E., Igor, S. and Corp, U.A. (1945) Patent US2529635 - helicopter rotor control mechanism. . Available at: https://www.google.co.uk/patents/US2529635?dq=sikorsky&hl=en&sa=X&ved=0ah UKEwilmoeAt4nMAhUCJw8KHfI5BUIQ6AEITjAH (Accessed: 12 April 2016). Editors, R., Keay, A., Robotics, S.V., Laskow, S., Obscura, A., Winfield, A., Perlongo, K., Tobe, F., Machines, T., SPARC and Bevilacqua, R. (2014) Raffaello D’Andrea at TED2016: Novel flying machines and swarms of tiny flying robots. Available at: http://robohub.org/raffaello-dandrea-at-ted2016-novel-flying-machines-and-swarms- of-tiny-flying-robots/ . Fliess, M. (1990) ‘Generalized controller canonical form for linear and nonlinear dynamics’, IEEE Transactions on Automatic Control, 35(9), pp. 994–1001.
  • 40. 40 Flores, G. and Lozano, R. (2013) ‘Transition flight control of the quad-tilting rotor convertible MAV’, 2013 International Conference on Unmanned Aircraft Systems (ICUAS), . Flores, G.R., Escareño, J., Lozano, R. and Salazar, S. (2011) ‘Quad-Tilting rotor convertible MAV: Modeling and real-time hover flight control’, Journal of Intelligent & Robotic Systems, 65(1-4), pp. 457–471. Flying toys Ltd (2014) Available at: http://flyingtoys.com . Forssell, U. and Ljung, L. (1999) ‘Closed-loop identification revisited’, Automatica, 35(7), pp. 1215–1241. Fu, Y., Li, H. and Kaye, M. (2010) ‘Design and Lyapunov stability analysis of a fuzzy logic controller for autonomous road following’, Mathematical Problems in Engineering, 2010, pp. 1–20. Fukuda, T. and Arakawa, T. (1998) ‘Intelligent systems: Robotics versus mechatronics’, Annual Reviews in Control, 22, pp. 13–22. Gautam, D. and H, C. (2013a) ‘Control of a Quadrotor using a smart self-tuning fuzzy PID controller’, International Journal of Advanced Robotic Systems, . Gautam, D. and H, C. (2013b) ‘Control of a Quadrotor using a smart self-tuning fuzzy PID controller’, International Journal of Advanced Robotic Systems, . Gibiansky, A. (2012) Quadcopter Dynamics and Simulation. Available at: http://andrew.gibiansky.com/blog/physics/quadcopter-dynamics/ . Han, J., Di, L., Coopmans, C. and Chen, Y. (2013) ‘Pitch loop control of a VTOL UAV using fractional order controller’, Journal of Intelligent & Robotic Systems, 73(1-4), pp. 187–195. Hema, K., Scientific and Publishing, A. (2013) ‘Aircraft flight control simulation using parallel cascade control’, International Journal of Instrumentation Science, 2(2), pp. 25–33. Ishaque, K., Abdullah, S.S., Ayob, S.M. and Salam, Z. (2011) ‘A simplified approach to design fuzzy logic controller for an underwater vehicle’, Ocean Engineering, 38(1), pp. 271–284. Jang, J..R. (1993) ‘ANFIS: Adaptive-network-based fuzzy inference system’, IEEE Transactions on Systems, Man, and Cybernetics, 23(3), pp. 665–685. Kaur, A. and Kaur, A. (2012) ‘COMPARISON OF FUZZY LOGIC AND NEURO FUZZY ALGORITHMS FOR AIR CONDITIONING SYSTEM 418 II. FUZZY LOGIC CONTROL ALGORITHM’, International journal of soft computing and engineering, , pp. 417–420. Khan, S., Abdulazeez, S.F., Adetunji, L.W., Alam, A.Z., Salami, M.J.E., Hameed, S.A., Abdalla, A.H. and Islam, M.R. (2008) ‘Design and implementation of an optimal fuzzy logic controller using genetic algorithm’, Journal of Computer Science, 4(10), pp. 799–806. Killian, M., Mayer, B. and Kozek, M. (2015) ‘Effective fuzzy black-box modeling for building heating dynamics’, Energy and Buildings, 96, pp. 175–186.
  • 41. 41 Kugelberg, I. (2016) Black-Box Modeling and Attitude Control of a Quadcopter. . Lee, C.C. (1990) ‘Fuzzy logic in control systems: Fuzzy logic controller. II’, IEEE Transactions on Systems, Man, and Cybernetics, 20(2), pp. 419–435. Leigh, J.R. (1992) Control theory: A guided tour. London: P. Peregrinus on the behalf of the Institution of Electrical Engineers. Li, J. and Li, Y. (2011) ‘Dynamic analysis and PID control for a quadrotor’, 2011 IEEE International Conference on Mechatronics and Automation, . Ljung, L. (1998) System identification: Theory for the user. 2nd edn. United States: Prentice Hall. Ljung, L. (2000) ‘Model Error Modeling and Control Design’, . Ljung, L. (2007) ‘System Identification’, Automatic Control at Linköpings universitet, . Ljung, L. and Ljung, L. (1987) System identification: Theory for the user. United States: Prentice Hall PTR. Mamdani, E.H. and Assilian, S. (1975) ‘An experiment in linguistic synthesis with a fuzzy logic controller’, International Journal of Man-Machine Studies, 7(1), pp. 1–13. Matarić, M. and Cliff, D. (1996) ‘Challenges in evolving controllers for physical robots’, Robotics and Autonomous Systems, 19(1), pp. 67–83. Mendel, J.M. (1995) ‘Fuzzy logic systems for engineering: A tutorial’, Proceedings of the IEEE, 83(3), pp. 345–377. Mian, A.A. and Daobo, W. (2008) ‘Modeling and Backstepping-based Nonlinear control strategy for a 6 DOF Quadrotor helicopter’, Chinese Journal of Aeronautics, 21(3), pp. 261–268. Newman, S. and Newman, S. (1994) The foundations of helicopter flight. London: A Butterworth-Heinemann Title. Olivares, V., Cordova, F., Sepúlveda, J.M. and Derpich, I. (2015) ‘Modeling internal logistics by using drones on the stage of assembly of products’, Procedia Computer Science, 55, pp. 1240–1249. Pallett, E.H.J. (1979) Automatic Flight Control Systems. London, Granada, 1979: HarperCollins Distribution Services. Passino, K.M. and Yurkovich, S. (1998) Fuzzy Control. California: Addison Wesley Longman, Inc. Phang, S.K., Cai, C., Chen, B.M. and Lee, T.H. (2012) ‘Design and mathematical modeling of a 4-standard-propeller (4SP) quadrotor’, Proceedings of the 10th World Congress on Intelligent Control and Automation, . Piskorski, S., Brulez, N., Eline, P. and D’Haeyer, F. (2012) AR.Drone Developer Guide. Available at: http://www.msh- tools.com/ardrone/ARDrone_Developer_Guide.pdf (Accessed: 15 April 2016).
  • 42. 42 Rai, J.N. (2012) ‘Speed control of Dc motor using fuzzy logic technique’, IOSR Journal of Electrical and Electronics Engineering, 3(6), pp. 41–48. Raju, K.S. and Pillai, G.N. (2016) ‘Design and implementation of type-2 fuzzy logic controller for DFIG-Based wind energy systems in distribution networks’, IEEE Transactions on Sustainable Energy, 7(1), pp. 345–353. Razinkova, A., Kang, B.-J., Cho, H.-C. and Jeon, H.-T. (2014) ‘Constant Altitude Flight Control for Quadrotor UAVs with Dynamic Feedforward Compensation’, International Journal of Fuzzy Logic and Intelligent Systems, 14(1), pp. 26–33. Reguera Acevedo, P., Fuertes MartinezJuanJos�, Dominguez Gonzalez, M. and Garcia Valencia, R. (2008) ‘Case-based reasoning and system identification for control engineering learning’, IEEE Transactions on Education, 51(2), pp. 271–281. Ryll, M., Bulthoff, H.H. and Giordano, P.R. (2012) ‘Modeling and control of a quadrotor UAV with tilting propellers’, 2012 IEEE International Conference on Robotics and Automation, . Saad Shaikh, M. (2011) Quadrocopter Fuzzy Flight Controller. . Sabahi, K., Ghaemi, S. and Badamchizadeh, M. (2016) ‘Designing an adaptive type- 2 fuzzy logic system load frequency control for a nonlinear time-delay power system’, Applied Soft Computing, 43, pp. 97–106. Santos, M., Lopez, V. and Morata, F. (2010) ‘Intelligent fuzzy controller of a quadrotor’, 2010 IEEE International Conference on Intelligent Systems and Knowledge Engineering, . Sasaki, M., Ishida, H., Katsuno, T. and Ogasawara, A. (1998) ‘Learning fuzzy logic controller for hovering a helicopter’, 1998 Conference of the North American Fuzzy Information Processing Society - NAFIPS (Cat. No.98TH8353), . Sepúlveda, R., Castillo, O., Melin, P., Rodríguez-Díaz, A. and Montiel, O. (2007) ‘Experimental study of intelligent controllers under uncertainty using type-1 and type-2 fuzzy logic’, Information Sciences, 177(10), pp. 2023–2048. Sharma, A. (2012) ‘Controlling of Quad-rotor UAV using PID controller and Fuzzy logic controller.’, International Journal of Electrical, Electronics and Computer Engineering, 1(2), pp. 38–41. Sikorsky, I. (1935) Direct lift aircraft. . sinha, H. (2012) An Autonomous Quadrotor Flying Robot. . Soundarajan, V. and Agrawal, A. (2016) Automated package delivery to a delivery receptable. . Syed, A., Raza, W. and Gueaieb (2012) Intelligent flight control of an autonomous Quadrotor Available at: http://cdn.intechweb.org/pdfs/6587.pdf (Accessed: 3 December 2015). Tang, K.L. and Mulholland, R.J. (1987) ‘Comparing fuzzy logic with classical controller designs’, IEEE Transactions on Systems, Man, and Cybernetics, 17(6), pp. 1085–1087.
  • 43. 43 Thrift, P. (1991) ‘Fuzzy Logic Synthesis with Genetic Algorithms’, ICGA, . TURING, A.M. (1950) ‘I.—COMPUTING MACHINERY AND INTELLIGENCE’, Mind, LIX(236), pp. 433–460. Visioli, A. (2001) ‘Tuning of PID controllers with fuzzy logic’, IEE Proceedings - Control Theory and Applications, 148(1), pp. 1–8. Westwick, D.T. and Perreault, E.J. (2011) ‘Closed-loop identification: Application to the estimation of limb Impedance in a compliant environment’, IEEE Transactions on Biomedical Engineering, 58(3), pp. 521–530. Woodford, K. and Cambridge Dictionaries Online (2016) Artificial intelligence meaning in the Cambridge English dictionary. Available at: http://dictionary.cambridge.org/dictionary/english/artificial-intelligence . Wu, J., Peng, H., Chen, Q. and Peng, X. (2014) ‘Modeling and control approach to a distinctive quadrotor helicopter’, ISA Transactions, 53(1), pp. 173–185. Xu, J.-X., Guo, Z.-Q. and Lee, T.H. (2013) ‘Design and implementation of a Takagi– Sugeno-Type fuzzy logic controller on a Two-Wheeled mobile robot’, IEEE Transactions on Industrial Electronics, 60(12), pp. 5717–5728. Yordanova, S. and Jain, lakhmi (2012) ‘Speed Control of Dc Motor Using Fuzzy Logic Technique’, International journal of innovative computing, 8(12). Zadeh, L.A. (1973) ‘Outline of a new approach to the analysis of complex systems and decision processes’, IEEE Transactions on Systems, Man, and Cybernetics, SMC-3(1), pp. 28–44. Zadeh, L.A. (1988a) ‘Fuzzy logic’, Computer, 21(4), pp. 83–93. Zadeh, L.A. (1988b) ‘Fuzzy logic’, Computer, 21(4), pp. 83–93. Zhang, J. and Knoll, A. (1999) ‘Designing fuzzy controllers by rapid learning’, Fuzzy Sets and Systems, 101(2), pp. 287–301.
  • 44. 44 14. Appendix A: Code used to arrange the data The data was collected in a text file; this text file consisted of a single array of strings and figures. This data was imported into MATLAB using the “import data from file” option then the code shown, in Fig. 25 was used to read and arrange the single array data into an organized multiple array structure. The code consist of the following functions: “fopen” “~feof” “fscanf” “fprintf” “fclose”, it has a single loop that ends when all the data has been read, and a number is defined as “%f” representing a figure and a linguistic variable is defined as a “%s” representing a string. %%reading and opening files fid = fopen('dataset2_praises.txt','r'); file_out1= fopen('out.dat_1','w'); file_out2= fopen('out.dat_2','w'); file_out3= fopen('out.dat_3','w'); file_out4= fopen('out.dat_4','w'); file_outix= fopen('out.dat_rix','w'); file_outiy= fopen('out.dat_riy','w'); file_outiz= fopen('out.dat_riz','w'); file_outlvy= fopen('out.dat_lvy','w'); file_outlvx= fopen('out.dat_lvx','w'); file_outtime= fopen('out.dat_time','w'); %scanning data %%loop data %% while ~feof(fid) %loping data with the feof()command header= fscanf(fid, '%s', 1); seq= fscanf(fid, '%f', 1); stamp= fscanf(fid, '%s', 1); secs= fscanf(fid, '%f', 1); nsecs= fscanf(fid, '%f', 1); frame_id= fscanf(fid, '%s', 1); battery= fscanf(fid, '%f', 1); state= fscanf(fid, '%f', 1); magx= fscanf(fid, '%f', 1); magy= fscanf(fid, '%f', 1); magz= fscanf(fid, '%f', 1); pressure= fscanf(fid, '%f', 1); temp= fscanf(fid, '%f', 1); ws= fscanf(fid, '%f', 1); wa= fscanf(fid, '%f', 1); wc= fscanf(fid, '%f', 1); rotx= fscanf(fid, '%f', 1); roty= fscanf(fid, '%f', 1); rotz= fscanf(fid, '%f', 1); altd= fscanf(fid, '%f', 1); vx= fscanf(fid, '%f', 1); vy= fscanf(fid, '%f', 1); vz= fscanf(fid, '%f', 1); ax= fscanf(fid, '%f', 1); ay= fscanf(fid, '%f', 1); az= fscanf(fid, '%f', 1); motor1= fscanf(fid,'%f',1); motor2= fscanf(fid,'%f',1); motor3= fscanf(fid,'%f',1);
  • 45. 45 motor4= fscanf(fid,'%f',1); tagsc= fscanf(fid, '%s', 1); tagst= fscanf(fid, '%s', 1); tagsx= fscanf(fid, '%s', 1); tagsy= fscanf(fid, '%s', 1); tagswi= fscanf(fid, '%s', 1); tagshe= fscanf(fid, '%s', 1); tagso= fscanf(fid, '%s', 1); tagsd= fscanf(fid, '%s', 1); tm= fscanf(fid, '%f', 1); blank= fscanf(fid, '%s', 1); fprintf(file_out1, '%fn',motor1); fprintf(file_out2, '%fn',motor2); fprintf(file_out3, '%fn',motor3); fprintf(file_out4, '%fn',motor4); fprintf(file_outix, '%fn',rotx); %f/n used to print an array file fprintf(file_outiy, '%fn',roty); fprintf(file_outiz, '%fn',rotz); fprintf(file_outlvy, '%fn',vy); fprintf(file_outlvx, '%fn',vx); fprintf(file_outtime, '%fn',tm); end %closing the files ;) fclose(fid); fclose(file_out1); fclose(file_out2); fclose(file_out3); fclose(file_out4); fclose(file_outix); fclose(file_outiy); fclose(file_outiz); fclose(file_outlvy); fclose(file_outlvx); fclose(file_outtime); Figure 25: Code used to arrange the data obtained from the experiment
  • 46. 46 15. Appendix B: Data analysis Once the data was organized in different arrays, the data was analysed in order to find the sample range were the pitch input was applied to it. The values that described the pitch dynamics are dependent on the: PWM signal to motor one and three, the rotational speed in the y-axis and the linear velocity in the x-axis as shown in Figures 26, 27, 28 and 29 respectively. Figure 26: PWM signal to motor one vs Sample number Figure 27: PWM signal to three vs Sample number
  • 47. 47 Figure 28: Rotation in the y-axis vs Number of samples Figure 29: Linear velocity in the x-axis vs Number of samples Range selection Because the data was obtained by flying the APD manually only certain ranges of the data contain pitch inputs, and is only in this ranges that the data describes the pitch dynamics of the APD. Therefore looking at the graphs shown above it was stablish that the pitch inputs were applied somewhere in between sample 24000 and sample 37000 because the
  • 48. 48 linear speed in x-direction and the rotational angle in y-direction increases in between those samples. Therefore the following data sets were used for validation and estimation. Data range used for estimation of the model structure The range of samples used to estimate the numerical values in the model was chosen to be samples [25710:26020], this range was chosen as it where the pitch input affects the plant the most, Fig. 1.5 contains further information about the estimation range. Table 17: Data range used for estimation of the ARX model Number of Samples 310 (samples) Sampling range [25710:26020] Time 1.55 (seconds) Validation data range The range of samples used to estimate the numerical values in the model was chosen to be samples [27690:27940]; Fig. 1.6 contains further information about the validation range. Table 18: Data range used to validate the ARX model Number of Samples 250 (samples) Sampling range [27690:27940] Time 1.25 (seconds)
  • 49. 49 16. Appendix C: Mathematical model of the quadrotor To derive a mathematical model of a Quadrotor, the following literature was used: (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) (Phang et al.,6 2012)(Gibiansky, 2012)(Li and Li, 2011)(Sinha, 2012)(abeywardena et al., 2009) (Phang et al.,6 2012) (Santos, Lopez and Morata, 2010) Mathematical model using a white box technique To derive the mathematical model of the system, Euler equations are used even though other papers used the quaternion differential equations, to prevent losing a degree of freedom when the quadrotor has a pitch angle of 90 degrees also the following assumptions where made:  The quadcopter consist of two uniform rods crossed at the origin with the mass of the motor at each end of the rod  Quadrotor and its components are rigid bodies  The origin of inertial coordinate system is in the same position with the geometric centre and centroid of the quadrotor  Aerodynamics forces and gyroscopic effects are neglected in this study Coordinate system The coordinate system can be acquired through it states. A quadrotor has 12 states and six degrees of freedom; these consist on the orientation and the position of the quadrotor. (Santos, Lopez and Morata, 2010) Two coordinate frames will be used to derive the dynamic behaviour of the system: Inertial frame Consist of six states: the position of the centre of gravity of the quadcopter and respectively the linear velocity components. This frame is time-invariant. The position and the velocity of the quadrotor are defined as x = (x, y, z)T , ẋ = ( ẋ ẏ ż)T respectively. Body frame Consist of six states: the roll, yaw, pitch and the angular velocities around each axis of the body of frame. The rotations and the angular velocities of the quadrotor in the body frame are defined as 𝜃 = (∅, 𝜃, Ψ) 𝑇 , 𝜃̇ = (∅̇ 𝜃̇ Ψ̇ ) 𝑇 respectively. The equations of motion are formulated in the body frame, the orientation of this body of frame coordinate system B(Oxyz), has the origin at the centroid of the quadrotor and the z-axis is pointing upwards as described in Fig. 30.
  • 50. 50 Figure 30: Showing the pictorial representation of the inertial and body frame coordinates Transition matrix The transition matrix 𝑅 in equation (16) is used to convert the vector components in the body frame to the inertial frame and vice-versa, where equation (17), (18) and (19) represents the x-axis, y-axis and z-axis projections of the body frame into the inertial frame respectively 𝑅 = 𝑅 𝑥 𝑅 𝑦 𝑅 𝑧 = ( cos𝛹cos∅ 𝑐𝑜𝑠𝛹𝑠𝑖𝑛𝜃𝑠𝑖𝑛∅ 𝑐𝑜𝑠𝛹𝑠𝑖𝑛𝜃𝑐𝑜𝑠∅ + 𝑠𝑖𝑛𝛹𝑠𝑖𝑛∅ 𝑠𝑖𝑛𝛹𝑐𝑜𝑠𝜃 𝑠𝑖𝑛𝛹𝑠𝑖𝑛𝜃𝑠𝑖𝑛∅ 𝑠𝑖𝑛𝛹𝑠𝑖𝑛𝜃𝑐𝑜𝑠∅ − 𝑠𝑖𝑛∅𝑐𝑜𝑠𝛹 −𝑠𝑖𝑛𝜃 𝑐𝑜𝑠𝜃𝑠𝑖𝑛∅ 𝑐𝑜𝑠𝜃𝑐𝑜𝑠∅ ) (16) 𝑅 𝑥 = ( 1 0 0 0 𝑐𝑜𝑠∅ −𝑠𝑖𝑛∅ 0 𝑠𝑖𝑛∅ 𝑐𝑜𝑠∅ ) (17) 𝑅 𝑦 = ( 𝑐𝑜𝑠𝜃 0 𝑠𝑖𝑛𝜃 0 1 0 −𝑠𝑖𝑛𝜃 0 𝑐𝑜𝑠𝜃 ) (18) 𝑅 𝑧 = ( 𝑐𝑜𝑠𝛹 −𝑠𝑖𝑛𝛹 0 𝑠𝑖𝑛𝛹 𝑐𝑜𝑠𝛹 0 0 ∅ 1 ) (19) Forces and thrust From the literature it was establish that the thrust in a single propeller is proportional to torque. And the thrust is proportional to the square angular velocity therefore the thrust in the body frame is shown in equation (20). 𝑇𝐵 = 𝑘 ( 0 0 ∑ Ω𝑖 2 ) (20) To model the torque generated in z-axis it was found that torque is given by the sum of all torques in the propeller as shown in equation (21), to model the torque in the x- axis it was found that the torque can be modelled by multiplying the torques
  • 51. 51 generated in the x-axis by the distance of the centre of the quadcopter to the propeller as shown in equation (22) similarly the same can be done to get the torque generated in the y-axis as shown in equation (23) therefore the torques in the body frame are given by equation (24). 𝜏Ψ = 𝑏(Ω1 2 − Ω2 2 + Ω3 2 − Ω4 2 ) (21) 𝜏∅ = 𝑙𝑏(Ω4 2 − Ω2 2 ) (22) 𝜏 𝜃 = 𝑙𝑏(Ω1 2 − Ω3 2 ) (23) 𝜏 𝐵 = ( 𝑙𝑏(Ω4 2 − Ω2 2 ) 𝑙𝑏(Ω1 2 − Ω3 2 ) 𝑏(Ω1 2 − Ω2 2 + Ω3 2 − Ω4 2 ) ) (24) To model friction in the inertial frame complex aerodynamic effects are ignored and the shape of the quadcopter is assumed to be symmetrical therefore a friction constant is used and multiplied by the linear velocity as shown in equation (25) 𝐹 = ( −𝑘 𝑑 𝑥̇ −𝑘 𝑑 𝑦̇ −𝑘 𝑑 𝑧̇ ) (25) Equations of motion Using Newton’s second law the linear motion of the quadcopter can be modelled by taking into account the thrust, friction and gravity and converting the corresponding body frames vectors to the inertial frame as shown in equation (26) 𝑚𝑥̈ = [ 0 0 −𝑚𝑔 ] + 𝑅𝑇𝐵 + 𝐹 (26) Euler’s equations shown in equation (27) can be rearranged and used to model the rotation of the quadcopter in the body frame as shown in equation, where equation (29) represents the inertial matrix. From these equation the rotation of the quadrotor in the body frame are obtained as shown in equation (30) 𝐼 𝜔̇ + 𝜔(𝐼𝜔) = 𝜏 (27) 𝜔̇ = 𝜔(𝐼𝜔) (28) 𝐼 = ( 𝐼 𝑥𝑥 0 0 0 𝐼 𝑦𝑦 0 0 0 𝐼𝑧𝑧 ) (29)
  • 52. 52 From these the body frame rotations can be obtained. 𝜔̇ =[ 𝜏∅ 𝐼 𝑥𝑥 −1 𝜏 𝜃 𝐼 𝑦𝑦 −1 𝜏Ψ 𝐼𝑧𝑧 −1 ] − [ 𝐼 𝑦𝑦−𝐼 𝑧𝑧 𝐼 𝑥𝑥 𝜔 𝑦 𝜔 𝑧 𝐼 𝑧𝑧−𝐼 𝑥𝑥 𝐼 𝑦𝑦 𝜔 𝑥 𝜔 𝑧 𝐼 𝑥𝑥−𝐼 𝑦𝑦 𝐼 𝑧𝑧 𝜔 𝑥 𝜔 𝑦 ] (30)
  • 53. 53 17. Appendix D: Interim report Design of a linear PID fuzzy logic control for a quadrotor helicopter Introduction The UAV type quadrotor helicopter has; low dimensions, good manoeuvrability, simple mechanics and available payload capacity (Olivares et al., 2015), furthermore a hybrid configuration which consist of a fixed wing combined with a quadrotor configuration would enable this rotorcraft to have the advantages of fixed wing aircraft vertical flight and the advantages of helicopter vertical take-off and landing (Flores and Lozano, 2013), therefore the use of quadrotors in logistics is a very controversial topic, the multi-billion dollars company named amazon.com, Inc. has proposed the use of a UAV quadrotor configuration to handle their complex logistics(Amazon, no date) Aims To design a Liner PID Fuzzy logic controller for an unmanned quadrotor helicopter consequently to test the control in a Test-bed using Simulink and in a real environment using the AR parrot 2.0. Objectives The objective of this project is to design a Linear PID Fuzzy logic controller for an unmanned quadrotor helicopter. To reach this objective:  The non-linear dynamics of the system are derived.  A suitable linearization method has to be used for the transformation of the non-linear dynamics.  A model of the fuzzy logic controller has to be design in Simulink.  A test bed for the quadrotor dynamics has to be design using Simulink. Helicopter history The control dynamics of helicopters are more challenging than that of airplanes dynamics, and it took longer for the helicopters to be a mass produced vehicle when compared to airplanes even though the construction of the first quadrotor dates back to 1907, later on 1924 George De Bothezat design a quadrotor that achieved the first kilometre long helicopter flight (Ali and Gueaieb, 2010) however the first mass produced helicopter was the Sikorsky R-4 in 1942 where a tail rotor was used to counter act the torque generated by blades, (sikorsky, 1935) this rotorcraft configuration was the first type to be mass produced mainly because of the lightweight design of the Sikorsky R-4 but many other rotorcraft configurations have been implemented in helicopters the most common types are: Tandem, side-by-side, coaxial, synchropter, quadrotor, et. (Pallet, 1979) Quadrotor helicopter as UAV Unmanned aerial vehicles (UAV) can fly autonomously or remotely controlled and are becoming increasingly popular in civil and military applications that are too risky humans to conduct. (Ali and Gueaieb, 2010) furthermore recent advances in
  • 54. 54 computational power and in the fields of microelectromechanical system and sensors (Ryll, Bulthoff, and Giordano, 2012) have enabled the UAV to have more complex, robust and intelligent controllers. Quadrotor helicopter background The quadrotor helicopter or quadrotor, has a four rotor configuration and it does not requires complex mechanical control linkages (Sharma, 2012) therefore the use of cyclic, collective pitch or tail rotors is not required when compared to previous rotorcraft configurations. (Coza and Macnab, 2006) Instead the speed of the blades is varied to achieve control and the directional flight of the controller is achieved by tilting the vehicle towards the intended flight direction. (Abeywardena et al., 2009) The quadrotor will have two pairs of rotors rotating clockwise and the other two rotating anti-clockwise to counteract the moments similarly varying these speeds will determine the roll, yaw and spin. (Sharma 2012) Roll The roll is the movement of the quadrotor sideways. Fig. 1(Syed, Raza, and Gueaieb, 2012) “Increasing the speed of the left motor by the same amount that the speed of the right motor is decreased will keep the total thrust provided by the four rotors approximately the same” and roll rate is determined (Coza and Macnab, 2006) Pitch The pitch is either the movement of the quadrotor either forward or backwards.
  • 55. 55 Fig. 2 (Syed, Raza, and Gueaieb, 2012) Increasing the speed of front motor by the same amount that the speed of the right motor is decreased will keep the total thrust approximately the same and the pitch rate is determined. (Coza and Macnab, 2006) Yaw The yaw is the rotation of the head of the quadrotor. Fig. 3 (Syed, Raza, and Gueaieb, 2012) The yaw can be obtained by can be obtained by increasing the speed of the front and rear rotor together and decreasing the speed of the lateral rotors therefore the thrust is keep constant. (Sharma 2012) Thrust The thrust or height is the movement of the quadrotor in the horizontal plane.
  • 56. 56 Fig. 4 (Syed, Raza, and Gueaieb, 2012) The thrust or height movement can be achieved by increasing the speed of all the rotors by the same amount therefore keeping the yaw, spin and roll constant. Hardware description The Quadrotor helicopter used in this project is the AR Drone 2.0, which has the following:  A 1500 mAh rechargeable battery  Four brushless in-runner motors, that have a maximum power and angular velocity of 14.5 watts and 28 500 rpm respectively.  A 3 axis accelerometer  A 3 axis gyroscope  A pressure sensor (Flying toys Ltd, 2014) Brushless DC motor 2.2 The main advantage of a brushless motor includes optimized torque simplified system structure and longer life span, compared to brushed motor. A brushless motor works by using the coil as the stator of the motor and the coil as the permanent magnet. (H.E.A. and F.N., 2013) Control Strategies used for quadrotor helicopter The most commons type of controllers for a quadrotor helicopter is as follows:  Robust feedback controllers  Fuzzy controllers  PDI controllers  PD controllers  Back-stepping controllers  Neural-network adaptive flight control  Linear quadratic method
  • 57. 57 Table. 5 (Saad Shaikh, 2011) (Coza and Macnab, 2006) ) (Abeywardena et al., 2009) (Belkheiri et al., 2012) And the main focus of this project is on fuzzy logic controllers. Fuzzy logic controllers background Fuzzy logic controllers are intelligent systems, the first paper on fuzzy logic was on 1965 by Lotfi A. Zadeh (Mendel, 1995) his papers he describes a “methodological framework which is tolerant of imprecision and partial truths” (Zadeh, 1973) the behaviour of complex systems can be described without the need of precise mathematical models therefore the use a fuzzy logic controller for a complex system like the quadrotor system would offer many advantages. Fuzzy logic structure  A fuzzy logic system is a non-linear mapping of an input data vector into a scalar output. (Mendel, 1995)  A fuzzy logic control has the following elements: Pre-processing, Fuzzification, rule table, inference engine, defuzzification, post-processing. As shown in (fig. 6) Fig. 6 (Syed, Raza, and Gueaieb, 2012) Inference engine The two most common types of inference engines are the: Mamdani type, and Takagi-Sugeno-Kang. It can though as system that maps inputs into outputs. (Syed, Raza, and Gueaieb, 2012) Mamdani inference system Output membership functions can be higher order models. (Syed, Raza, and Gueaieb, 2012) Takagi-Sugeno-kang; Output membership functions are either linear or constant. (Syed, Raza, and Gueaieb, 2012)
  • 58. 58 Mamdani requires more computational power but the controller converges to the desire states relative faster than Takagi-Sugeno-Kang inference engine. (Syed, Raza, and Gueaieb, 2012) Rules Consists of a collection of if-then rules which can be summarised in a relationship matrix and then the computer is able to compute a control signal based on the error and the derivative of the error. (Rai, 2012) Fuzzification The fuzzification of the crisp data into a fuzzy set is done via membership function. (Rai, 2012) Defuzzification “Defuzzification is when all the actions that have been activated are combined and converted into a single non-fuzzy output signal which is the control signal of the system” (Rai, 2012) Types of fuzzy logic controllers:  single input fuzzy logic controller (ishaque et al.,2011),  Smart self-tuning fuzzy PID controller (Gautam and H, 2013),  Adaptive fuzzy controller (Coza and Macnab, 2006)  PDI fuzzy logic (Santos, Lopez, and Morata, 2010) (Sharma, 2012) (Abeywardena et al., 2009) Table 2 Fuzzy logic system design A fuzzy PID controller for quadrotor configuration looks like the one shown in figure 10, it has six fuzzy logic controllers, 3 fuzzy logic controllers to control the yaw, roll, and pitch and 3 fuzzy logic controllers to control the x, y, and z quadrotor position. (YordanovA and JAIN, 2012) The controller decisions are based on the desire combination of four motions: yaw, roll, pitch, and height. The PID controller uses the error, the derivative of the error, and the integral as inputs. The output is the control action and the corresponding gain. (Santos, Lopez, and Morata, 2010) The type of controller being design is a fuzzy PID controller and It uses the error and the derivative of the error as inputs (Santos, Lopez, and Morata, 2010) (Sharma 2012) (Abeywardena et al., 2009)
  • 59. 59 Fig. 10 (YordanovA and JAIN, 2012) The aggregation block Each controller gives the power require by each engine, and there is four controller inputting an output to the dynamics therefore the aggregation block implements the coupling of the control actions of the four controllers (Santos, Lopez, and Morata, 2010) Mathematical model To derive the mathematical model of the system, Euler equations are used even though other papers used the quaternion differential equations, to prevent losing a degree of freedom when the quadrotor has a pitch angle of 90 degrees. (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) (Phang et al., 2012) (Li and Li, 2011) (sinha, 2012)(loogbook) Also the mathematical model derived in here uses the same assumptions, coordinate system orientation, and method as (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) (Li and Li, 2011) Coordinate system The coordinate system can be acquired through it states. A quadrotor has 12 states and six degrees of freedom. (Santos, Lopez and Morata, 2010) These consist on the orientation or attitude and the position of the quadrotor. (Santos, Lopez and Morata, 2010) Two main coordinate frames will be used in the derivation of the dynamic behaviour of the system:
  • 60. 60 Inertial frame; consist of six states: the position of the centre of gravity and respectively linear velocity components. This frame is time-invariant Body frame; Consist of six states: the roll, yaw, pitch and the angular velocities around each axis of the body of frame. The equations of motion are formulated in the body frame, the orientation of this body of frame coordinate system B(Oxyz), has the origin at the centroid of the quadrotor and the z-axis is pointing upwards as described in Figure 11 Fig. 11 (Li and Li, 2011) The definitions of the Euler angles and the transition matrix from the body frame to the inertial frame of their corresponding axis are shown below: Yaw angle; angle between the X-axis and the projection of the body frame in the inertial frame (Li and Li, 2011) (1) Pitch angle; angle between the Z-axis and the projection of the body frame in the inertial frame (Li and Li, 2011) (2) Roll angle; angle between the Y-axis and the projection of the body frame in the inertial frame (Li and Li, 2011) (3)
  • 61. 61 The transition matrix R will enable the two coordinates (inertial frame and body of frame) to be converted to each other. Therefore the transition matrix R from the body frame or quadrotor coordinate system B (Oxyz) to the inertial frame or inertial coordinate system E (OXYZ) is derived: (Li and Li, 2011) (4) To mathematically model the movement of the aircraft Newton’s second law of motion is used to get the net force and net moment on the quadrotor body. Assumptions: Quadrotor and its components are rigid bodies; The origin of inertial coordinate system is in the same position with the geometric centre and centroid of the quadrotor Aerodynamics forces and gyroscopic effects are neglected in this study 1st equation of motion: translational equations of motion F=m*a (5) Where “F” and “a” are the force and acceleration in the body axes respectively. The force vector “F” in the body, can be derived by: calculating the total thrust vector in the body axes “ ” and the gravitational force vector in the inertial frame of axis “ ” (6) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) (7) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) Transforming the gravitational force from the inertial frame of axis to the body frame axis using the rotation transformation:
  • 62. 62 (8) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) Combining the thrust force and gravitational force in the 1st equation of motion: (9) (A.Abdelkhalek, .El- Demerdash, and .Dief, 2015) This equation can be rearranged to give the following: (10) (11) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) In the equation above the acceleration in the body of axis is the subject. (12) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) Where “ ” is the linear velocity in the body axis [u, v, w] Where “ ” is the resultant angular velocity vector due to the three rotation angles, yaw, spin, roll as described by equation (13) (13) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) Where [p, q, r] are angular velocities component in the body axes. Using the equations (10) and (13), equation (14) is derived where “ ” is the vector acceleration in the inertial frame of reference.
  • 63. 63 (14) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) Using Equation (12) the following equation is derived: (15) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) 2nd equation of motion: Rotational equations of motion (16) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) Where “ ” is the moment vector in the body axes. Using the angular velocities “ ” the torque “ ”equations can be derived: (17)(18) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) (19) (A.Abdelkhalek, .El-Demerdash, and .Dief, 2015) Equation (19) gives the torque results from drag reactions on blades. From this equation the moment vector in the body axes can be derived. As the assumption that the quadrotor is rigid body the inertia tensor becomes a rigid body.
  • 64. 64 (20) (A.Abdelkhalek, .El- Demerdash, and .Dief, 2015) Therefore using equation (16), (21) (A.Abdelkhalek, .El- Demerdash, and .Dief, 2015) Since, (22) (A.Abdelkhalek, .El- Demerdash, and .Dief, 2015) The following equation is obtained: (23) (A.Abdelkhalek, .El- Demerdash, and .Dief, 2015) Conclusion and revised project plan From appendix 1 the project Literature review on Thursday the 26 of November on the mathematical model was supposed to be finish on Friday
  • 65. 65 the 25 of November and the testing or checking of the mathematical equations was going to be finish on Friday the 4 of December, however the complexity of the mathematical model was underestimated which lead to only having half of the mathematical model completed, as the mathematical model equations where supposed to be solved using mathlab and then input into the word document using the word format instead the equations and diagrams where solved in the logbook and screen shoots of the answers where use instead as the time was limited to construct the equations. Therefore the plan proposed on the 7th of October has changed significantly one of the changes is that the amount of work that was meant for this part of the Gantt chart is going to increase because the mathematical modelling was not done on time the other change is a more detail Gantt chart as the 1st Gantt chart was very broad, consequently it did not provided good managing reference of how well or bad the project was going in conclusion a more detail Gantt chart should be able to break the projects into smaller chunks which will make the project easier keep track of. To conclude the aim of this literature is to make a case on the importance that quadrotor helicopters and artificial intelligence (Fuzzy logic) have in the present world.