Modelling and Genetic Algorithm Based-PID Control of H-Shaped Racing Quadcopter
Modelling and Genetic Algorithm Based-PID Control of H-Shaped Racing Quadcopter
DOI 10.1007/s13369-017-2433-2
123
Arab J Sci Eng
123
Arab J Sci Eng
η̇ = T ∗ ωb (3) Forces The forces acting on the quadcopter are divided into
two types: the propulsive force and the gravitational force.
where Each of the four propellers produces a propulsive force when
⎡ ⎤ spinning. The overall generated force is the algebraic sum of
1 sin(φ) tan(θ ) cos(φ) tan(θ ) that produced by the four propellers. The propulsive force
⎣ π π
T = 0 cos(φ) − sin(φ) ⎦ − < θ < for the ith rotor expressed in the body frame is:
2 2
0 sin(φ) sec(θ ) cos(φ) sec(θ )
⎡ ⎤
2.2 Simplification Hypotheses 0
FRi =⎣ 0 ⎦ for i = 1, 2, 3, 4. (4)
The following are some important assumptions that are used K th ∗ Ωi2
to simplify writing the system mathematical model. Without
these hypotheses, the system equations of motion will be where K th is the thrust coefficient and Ωi is the spinning
complicated. speed of the ith propeller.
Then the overall force of the four propellers is the vector
– The structure supposed to be symmetrical and rigid. sum of the individual forces.
123
Arab J Sci Eng
4
The total torque due to the four rotating propellers is:
FT = FRi
i=1
⎡ 2⎤
4
⎡ ⎤ Ω1 (5) MT = MRi (10)
0 0 0 0 ⎢Ω 2 ⎥
=⎣ 0 0 0 0 ⎦∗⎢ 2⎥
⎣Ω 2 ⎦
i=1
K th K th K th K th 3
Ω42 substituting (9) in (8) and the resulting equation into (10) and
let L x = L y = L, yield:
Not only the propulsive force affects the quadcopter motion
but also the gravitational force tries to pull it down to the ⎡ 2⎤
⎡ ⎤ Ω1
ground. The gravitational force in the earth frame is deter- L ∗ K th L ∗ K th −L ∗ K th −L ∗ K th ⎢Ω 2 ⎥
mined by: MT = ⎣−L ∗ K th L ∗ K th L ∗ K th −L ∗ K th ⎦ ∗ ⎢ 2⎥
⎣Ω 2 ⎦
⎡ ⎤ KD −K D KD −K D 3
0 Ω42
F Ge = ⎣ 0 ⎦ (6) (11)
−M ∗ g
2.3.2 Control Vector U
where M is the total mass of the quadcopter and g is the
gravitational constant. At this stage and for the purpose of better understanding
The total force applied on the quadcopter is a couple of the mathematical model of the quadcopter, it is important
the propulsive and gravitational forces: to define a control vector U that is consist of four inputs
U 1, U 2, U 3, and U 4.
Fe = F G e + Rbe ∗ FT (7) The first control input (U 1) is the total forces generated by
the rotors in the z axis direction. It is responsible of altitude
In the above equation, the rotation matrix is inserted to trans- control.
fer the propulsive force from the body to the earth coordinate
so that, it can be added to the gravitational force. U 1 = FTz = K th ∗ Ω12 + Ω22 + Ω32 + Ω42 (12)
⎡ ⎤
0 Equations (12) through (15) can be combined into one matrix
MDi =⎣ 0 ⎦ for i = 1, 2, 3, 4. (9) equation as follow:
(−1)i ∗ K D ∗ Ωi2
⎡ ⎤ ⎡ 2⎤
U1 Ω1
where K D is the drag coefficient and (−1)i is negative for CW ⎢U 2⎥ ⎢Ω 2 ⎥
⎢ ⎥ = K ∗ ⎢ 2⎥ (16)
rotated propellers (1 and 3) and positive for CCW propellers ⎣U 3⎦ ⎣Ω 2 ⎦
3
(2 and 4). U4 Ω42
123
Arab J Sci Eng
where K ∈ R 4×4 is the coefficient matrix and equal to: then the following set of equations, which describes the trans-
lational motion of our model, can be obtained.
⎡ ⎤
K th K th K th K th
⎢ L ∗ K th L ∗ K th −L ∗ K th −L ∗ K th ⎥ ẍCθ Cψ + ÿCθ Sψ − (z̈ + g)Sθ = 0 (21)
K =⎢
⎣−L ∗ K th
⎥
L ∗ K th L ∗ K th −L ∗ K th ⎦ ẍ(Sφ Sθ Cψ − Cφ Sψ ) + ÿ(Sφ Sθ Sψ
KD −K D KD −K D
+Cφ Cψ ) + (z̈ + g)Sφ Cθ = 0 (22)
The rotation speed of the rotors for a specific control input ẍ(Cφ Sθ Cψ + Sφ Sψ ) + ÿ(Cφ Sθ Sψ
vector can be calculated by: U1
−Sφ Cψ ) + (z̈ + g)Cφ Cθ = (23)
M
⎡ ⎤
⎡ ⎤
Ω1 U1 Rotational motion equations According to Newton–Euler
⎢Ω2 ⎥ ⎢U 2⎥
⎢ ⎥ = K −1 ∗ ⎢ ⎥ (17) formalism, the rotational motion equations are derived and
⎣Ω3 ⎦
⎣U 3⎦ expressed in the body coordinates.
Ω4 U4
MT = I ∗ ω˙b + (ωb × I ∗ ωb ) (24)
2.3.3 Dynamic Model
where I ∈ R 3×3 is a moment of inertia matrix of the quad-
The dynamic model of the quadcopter describes its behaviour copter. The quadcopter assumed to be symmetrical in Sect.
over the time. Unlike terrestrial mobile robots in which 2.2, so the moment of inertia matrix is expected to be diag-
it is possible to describe their models kinematically, the onal.
quadcopter modelling requires their dynamics to be con- ⎡ ⎤
sidered which involves the gravitational effects [21]. There Ix x 0 0
are two methods used to represent the dynamic model, the I =⎣ 0 I yy 0 ⎦ (25)
Lagrangian and the Newton–Euler method, and both are 0 0 Izz
consistent in describing the quadcopter dynamic model.
Nevertheless, Newton–Euler method is more continent in The set of rotational equation of motion can be obtained by
describing the physics of the system and so it is easy to be means of (13–15) and (24) as follows:
understood [22]. The dynamics of a standard quadcopter falls ⎛⎡ ⎤ ⎞
U1
into two categories: a translational motion (x, y, and z) which
ω˙b = I −1 ∗ ⎝⎣U 2⎦ − (ωb × I ∗ ωb )⎠ (26)
is underactuated and a rotational motion (roll φ, pitch θ , and
U3
yaw ψ) which is fully actuated.
To this end, we have obtained the complete dynamics for
Translational motion equations Newton’s second law of the H -shaped quadcopter and the next step is to propose and
motion can be applied to describe the translational motion design a suitable trajectory tracking controller.
of the quadcopter in the earth frame.
where v˙b = [ẍ, ÿ, z̈]T is the quadcopter linear accelera- The MATLAB/Simulink environment on a personal com-
tion. puter with 2.5 GHz processing speed and 6 GB RAM is used
By substituting (7), (12) into the above equation, we can to verify the derived dynamical model and to carry out all the
get: subsequent tests in the following sections. The quadcopter
⎡ ⎤ ⎡ ⎤ ⎡ ⎤ model parameters that are used during the simulation are
ẍ 0 0 shown in Table 1. The complete block diagram for the model
⎣ ÿ ⎦ = ⎣ 0 ⎦ + Rbi ∗ ⎣ 0 ⎦ (19) with the controllers is shown in Fig. 3. The following is the
z̈ −g U1
M detailed description for each individual controller.
123
Arab J Sci Eng
M 1.2 kg
L 0.3 m
K th 7.5e-05 N s2 /rad2
KD 1.7e-06 Nm s2 /rad2
Ix x 0.01987 kg m2
I yy 0.01987 kg m2 Fig. 5 Attitude feedback control block diagram
Izz 0.03848 kg m2
Ωmin 100 rad/s
Ωmax 750 rad/s
1
U 1 sin(φ) = ẍ sin(ψ) − ÿ cos(ψ) (27)
M
Fig. 4 Altitude feedback control block diagram
then the desired roll angle φ can be extracted by rearranging
the above equation as:
that will adjust the value of the control input U1 to achieve
the desired altitude. (ẍ sin(ψ) − ÿ cos(ψ))
φd = sin−1 M ∗ (28)
U1
3.2 Attitude Control
Pitch (θ ) angle calculation In our design, it is assumed that
The attitude controller is a combination of 3 PID controllers. φ and θ angles are in the ±90◦ range. With this in mind, (21)
These controllers are responsible of producing a control sig- can be divided by cos(θ ) = 0 then:
nal U2, U3, and U4 to orient the quadcopter to the required
roll φ, pitch θ , and yaw ψ angle, respectively. Attitude con-
ẍ cos(ψ) + ÿ sin(ψ) − (z̈ + g) tan(θ ) = 0 (29)
trol block diagram is shown in Fig. 5.
3.3 X–Y Position Control and the desired pitch angle (θ ) can be obtained as:
In contrast to the altitude and attitude control, the x and y −1 ẍ cos(ψ) + ÿ sin(ψ)
θd = tan (30)
position cannot be controlled directly. The desired x and y (z̈ + g)
position can be obtained by tilting the quadcopter body with
a specific roll and pitch angles. The required roll and pitch In view of (20), we can get:
123
Arab J Sci Eng
⎛ ⎡ ⎤⎞T ⎛ ⎡ ⎤⎞ ⎡ ⎤T ⎡ ⎤
ẍ ẍ 0 0
⎝ R b ⎣ ÿ ⎦⎠ ∗ ⎝ R b ⎣ ÿ ⎦⎠ = ⎣ 0 ⎦ ∗ ⎣ 0 ⎦ (31)
i i
z̈ + g z̈ + g U1
M
U1
M
⎡ ⎤T ⎡ ⎤ ⎡ ⎤T ⎡ ⎤
ẍ ẍ 0 0
T
⎣ ÿ ⎦ R ∗ R ⎣ ÿ ⎦ = ⎣ 0 ⎦ ∗ ⎣ 0 ⎦
b b (32)
i i
z̈ + g z̈ + g U1
M
U1
M
then
U 1 2 Fig. 7 PID controller configuration
(z̈ + g) = − ẍ 2 − ÿ 2 (33)
M Table 2 PID controller parameters
substitute (33) into (30) yield: Control Kp Ki Kd
⎛ ⎞
z position (z d = 1 m) 14.88 0.7994 0.4734
⎜ ẍ cos(ψ) + ÿ sin(ψ) ⎟ Yaw (ψd = 20◦ ) 0.4768 0.00864 0.512
θd = tan−1 ⎜
⎝ 2
⎟
⎠ (34)
Roll (φd = 10◦ ) 2.151 0.0019 0.1723
U1
M − ẍ 2 − ÿ 2
Pitch (θd = 10◦ ) 1.454 0.00239 0.2134
x position (xd = 1 m) 1.0083 0.0096 0.4965
3.4 PID Parameters Tuning Using GA y position (yd = 1 m) 9.7023 0.0099 0.5420
123
Arab J Sci Eng
X position (m)
1.5 1.5 2
Y position (m)
Z position (m)
1 1
0.5 ts =1.50 sec 0.5 ts =1.92 sec 1
Mp =1.56 % Mp =1.44 %
0 0
0 1 2 3 4 5 0 1 2 3 4 5
0
Time (sec) Time (sec) 1
Y
(a) (b) po
sit
0
ion -1 0.5 1 1.5 2
(m 0
)
X position (m)
1 10
(a)
0.5 ts =1.66 sec 5 ts =0.45 sec
Mp =1.97 % Mp =0.06 %
X error (mm)
Y error (mm)
0 0 10
0 1 2 3 4 5 0 1 2 3 4 5 20
Time (sec) Time (sec) 0 0
-20
(c) (d) -10
0 10 20 30 0 10 20 30
Yaw angle (deg)
Pitch angle (deg)
Z error (mm)
xd = 1 − ρ ∗ cos(0.2 ∗ (t))
yd = ρ ∗ sin(0.4 ∗ (t))
zd = 1
123
Arab J Sci Eng
6 Conclusion
Y error (mm)
40 50
has been obtained. The dynamics of the model have been
0 0 described in a comprehensive and systematic way. A PID
-40 -50
control scheme has been proposed to control the six DOFs
0 10 20 30 0 10 20 30
of the quadcopter. Besides, the PID coefficients have been
Time (sec) Time (sec)
tuned using GA with a novel objective function that compro-
(b) (c)
mises between three important step response characteristics.
Fig. 10 Random noise test results a noise signal, b x position error, c The GA set the PID coefficients to achieve the best perfor-
y position error mance that minimize the tracking error, the settling time, and
the peak overshoot while maintaining the actuators in the
normal operation limits. The derived model along with the
X error (mm)
Y error (mm)
40
10
0 0
designed controller has been implemented in the Simulink
-10 environment. The system has been commanded to follow a
-40
0 10 20 30 0 10 20 30 desired infinity-shaped trajectory, and the simulation results
Time (sec) Time (sec)
have shown a perfect trajectory tracking performance with a
(a) (b) very low tracking error. In the final analysis, the controller
has been tested for its robustness in terms of sensor noise sup-
pression, disturbance rejection, and the sensitivity to model
parameters uncertainties. The robustness test results revealed
the designed controller effectiveness and performance.
(c) References
Fig. 11 Model uncertainty test results a x position error, b y position 1. Erginer, B.; Altug, E.: Modeling and PD control of a quadrotor
error, c rotors behaviour VTOL vehicle. In: IEEE Intelligent Vehicles Symposium, pp. 894–
899. IEEE (2007)
2. Hamel, T.; Mahony, R.; Lozano, R.; Ostrowski, J.: Dynamic mod-
Disturbance (N)
100
Z error (mm)
1 50
elling and configuration stabilization for an X4-flyer. IFAC Proc.
0.5
Vol. 35(1), 217–222 (2002)
0
0
3. Mokhtari, A.; Benallegue, A.: Dynamic feedback controller of
-50
0 5 10 0 5 10 Euler angles and wind parameters estimation for a quadrotor
Time (sec) Time (sec) unmanned aerial vehicle. In: IEEE International Conference on
(a) (b) Robotics and Automation (ICRA’04), vol. 3, pp. 2359–2366 (2004)
4. Zemalache, K.M.; Beji, L.; Marref, H.: Control of an under-
actuated system: application a four rotors rotorcraft. In: IEEE
International Conference on Robotics and Biomimetics-ROBIO,
pp. 404–409 (2005)
5. Tayebi, A.; McGilvray, S.: Attitude stabilization of a VTOL
quadrotor aircraft. IEEE Trans. Control Syst. Technol. 14(3), 562–
571 (2006)
(c) 6. Bouabdallah, S.; Murrieri, P.; Siegwart, R.: Design and control
of an indoor micro quadrotor. In: IEEE International Conference
Fig. 12 Disturbance test results a disturbance input, b z position error, on Robotics and Automation (ICRA ’04), vol. 5, pp. 4393–4398
c rotors behaviour (2004)
7. Bouabdallah, S.; Noth A.; Siegwart, R.: PID vs LQ control
techniques applied to an indoor micro quadrotor. International Con-
directly under the COG point and it is continued for 1 s. The ference on Intelligent Robots and Systems (IROS 2004), vol. 3, pp.
2451–2456 (2004)
controller shows the capability to reject the disturbance and
8. Bresciani, T.: Modelling, Identification and Control of a Quadrotor
maintain the stability and the position of the system. The Helicopter. In: Department of Automatic Control. Master Thesis
simulation results are shown in Fig 12. Lund: Lund University (2008)
123
Arab J Sci Eng
9. Bayrakceken, M.; Kemal, M.; Kursat Y.; Aydemir A.; Abdurrah- 16. Gruber, D.: The mathematics of the 3D rotation matrix. In: The
man K.: HIL simulation setup for attitude control of a quadrotor. Xtreme Game Developers Conference (2000)
In: IEEE International Conference on Mechatronics (ICM), pp. 17. Padfield, G.D.: Helicopter Flight Dynamics. Wiley, New York
354–357. IEEE, Havard (2011) (2008)
10. Çetinsoy, E.: Design and flight tests of a holonomic quadrotor UAV 18. Cai, G.; Chen, B.M.; Lee, T.H.: Unmanned Rotorcraft Systems.
with sub-rotor control surfaces. In: IEEE International Conference Springer, Berlin (2011)
on Mechatronics and Automation (ICMA), pp. 1197–1202. IEEE 19. Leishman, R.C.; Macdonald, J.C.; Beard, R.W.; McLain, T.W.:
(2013) Quadrotors and accelerometers: state estimation with an improved
11. Benallegue, A.; Moktari, A.; Fridman, L.: Feedback linearization dynamic model. IEEE Control Syst. 34(1), 28–41 (2014)
and high order sliding mode observer for a quadrotor UAV. In: Pro- 20. Mahony, R.; Kumar, V.; Corke, P.: Multirotor aerial vehicles: mod-
ceedings of the 2006 International Workshop on Variable Structure eling, estimation, and control of quadrotor. IEEE Robot. Autom.
Systems (2006) Mag. 19(3), 20–32 (2012)
12. Lara, D.; Romero, G.; Sanchez A.; Lozano, R.: parametric robust 21. Salih, A.L.; Moghavvemi, M.; Mohamed, H.A.; Gaeid, K.S.: Flight
stability analysis for attitude control of a four-rotor mini-rotorcraft. PID controller design for a UAV quadrotor. Sci. Res. Essays 5(23),
In: Proceedings of the 45th IEEE Conference on Decision and 3660–3667 (2010)
Control, pp. 4351–4356. San Diego (2006) 22. Zhang, X.; Li, X.; Wang, K.; Lu, Y.: A survey of modelling and
13. Li, J.; Li, Y.: Dynamic analysis and PID control for a quadrotor. In: identification of quadrotor robot. Abstr. Appl. Anal. 2014, 1–16
IEEE International Conference on Mechatronics and Automation, (2014)
pp. 573–578. Beijing (2011) 23. Mitchell, M.: An Introduction to Genetic Algorithms. MIT press,
14. Gupte, S.; Mohandas, P.I.T.; Conrad, J.M.: A survey of quadrotor Cambridge (1996)
unmanned aerial vehicles. In: Proceedings of IEEE Southeastcon,
pp. 1–6 (2012)
15. Stingu, E.; Lewis, F.: Design and implementation of a structured
flight controller for a 6DoF quadrotor using quaternions. In: IEEE
17th Mediterranean Conference on in Control and Automation
MED’09, pp. 1233–1238 (2009)
123