A parameter tuning approach of the Sliding Mode
Control for a Quadcopter based on Genetic
Algorithms
Vanessa Orosco*, Danilo Chávez*, Oscar Camacho*, Jose Aguilar**
*Departamento de Automatización y Control Industrial, Facultad de Ingeniería Eléctrica y Electrónica
Escuela Politécnica Nacional, Quito, Ecuador
** Facultad de Ingeniería. Universidad de Los Andes, Mérida. Venezuela
{[Link], [Link], [Link]}@[Link], aguilar@[Link]
Abstract—In this work is presented a parameter tuning Absolute Error), among others, can be used as fitness functions
approach of a Sliding Mode Control (SMC) using Genetic for the tuning of the controller parameters through GA[4].
Algorithms (GA). The GA are used for the tuning of the parameters There are other methods of optimization based on
of the Orientation Control and Height of quadcopter, considering metaheuristics such as ant colony, particle swarm, among
all the cases in a sliding surface PD. The objective of GA is to
others, however, in this article it has been decided to work with
provide a set of parameters that minimizes the integral square
error (ISE) of the SMC. The SMC is improved when it is used the GA due to its ability to adapt and ensure obtaining a local
GA. minimum. The purpose of this paper is to use GA as a tuning
method for a sliding mode controller. Previous works [5], [6],
Keywords—Parameter Tuning; SMC; Quadcopter; Genetic [7] present the utilization of GA in several plants, for the tuning
Algorithms of parameters of different controllers. In the present work, we
present the utilization of GA in the context of a quadcopter. In
I. INTRODUCTION
this investigation, a robust control in sliding mode is designed
One of the principles that determines the performance of a for the control of the orientation and height of the quadcopter,
system is the tuning of its control parameters. In general, the from the dynamic model of the UAV (Unmanned Aerial
performance of the laws of control depends on the values of Vehicle). This work proposes a scheme based on GA, for the
these parameters. The design and calibration of the controllers tuning of parameters of a SMC applied to a quadcopter. In our
is carried out based on existing tuning methods, however, in the case, the ISE of the z, roll, pitch and yaw parameters will be used
case of SMC controllers, due to their use in non-linear plants, as the objective function of the GA, in order to obtain the best
the calibration of their parameters becomes a work of test and parameters of the controller.
error. On the other hand, it is important to point out that new The paper is organized as follows. In section 2, dynamic
techniques have been developed, so that the parameters of the modeling of quadcopter and height and orientation control is
controllers can be tuned automatically. Among these new explained. GA is used to tune the parameters of the SMC applied
techniques, we can highlight the GA as a tool for the tuning of to the height and orientation control in section 3. Section 4
controllers[1],[2]. presents the results obtained from a SMC controller with the
GA are optimization techniques based on the Darwin's tuned parameters heuristically using ISE, followed with a
theory of evolution, where individuals with better genetic comparative analysis with the tuned parameters using GA.
characteristics are naturally selected. GA allow a population Finally, the conclusions for this work are presented.
composed of many individuals to evolve under specified
selection rules into a state that maximizes the "fitness" of the II. FUNDAMENTALS
population [3]. This section shows the equations that govern the dynamic
GA have been mainly used in the automation context, to behavior of the quadcopter based on [8], [9] and [10], and also,
optimize movements of manipulators, in the regulation and the control laws for the height and orientation of the quadcopter
tuning of parameters, in the trajectory tracking and evasion of are designed using SMC.
obstacles, among others. GA are a method that differs from
traditional algorithms, since they use values of the objective A. Quadcopter Dynamic Model
function, in our case of the control systems, as quantitative Quadcopter is formed by four rotors separated
measures of the performance of the system. In this way, symmetrically, in each rotor is found a propeller, which are
performance indices like ISE(Integral of the Square Error), responsible for the propulsion force to achieve six degrees of
IAE(Integral of the Absolute Error), ITAE (Integral of the Time freedom, three translational (x, y, z), and three rotational (roll ,
pitch , yaw )[8]. Two propellers turn clockwise and two
978-1-5386-6657-9/18/$31.00 ©2018 IEEE
counterclockwise to create the pushing force necessary for the in ‘x’, ‘y’ and ‘z’, respectively; and Ω is the total speed of the
system rises. The mechanics of the quadcopter is governed by propellers.
four movements that are: push or vertical elevation (altitude),
B. Sliding Mode Control applied to Height and Orientation
roll (X axis), pitch (Y axis) and yaw (Z axis)[9]. To model and
Control
find the quadcopter dynamic equations, it is necessary to define
the reference systems to which the quadcopter is governed. The SMC or Control by Sliding Modes is a robust control
reference system is fixed to ground I, and the mobile reference technique derived from the Control by Variable Structure or
system B is in the center of mass of the quadcopter, as is shown VSC (Variable Structure Controller) [13]. Due to its robustness,
in Fig. 1. To obtain the dynamic model, quadcopter is considered it controls without problems plants with uncertainties and non-
as a rigid solid with symmetric structure of mass m, the linearities. Its control law consists of two parts: an equivalent or
translational coordinates of the axis I are defined by the vector continuous function and a switching or discontinuous function
. [13].
= , , ∈ ℝ (1) ( )= ( )+ ( ) (9)
The orientation of the quadcopter is obtained by knowing the Where ( ) is the control law, ( ) is the continuous
angles of Euler with respect to I, which indicates the rotation of function and ( ) is the discontinuous function. For the SMC
quadcopter in the space [10]. design a sliding surface ( ) is defined, which represents the
= , , ∈ ℝ (2) dynamics of the closed loop system, for which we have a
different equation that acts on the error as is observed in the
equation (10) and the Fig. 2.
( )= + ( ) (10)
Where represents the order of the system, is a tuning
parameter and ( ) is the error. If the system is of order = 1,
then eq. (10) can be rewritten as:
= + (11)
Fig. 1. Scheme and reference systems of quadcopter
Quadcopter has twelve output variables
( , , , , , , , , , , , ), which are obtained since the
equations that governed a quadcopter [11].
= (3)
= (4)
Fig. 2. SMC performance scheme
=− + (5)
= + + − (6) The second part of the control law ( ) is responsible for
forcing the error towards the sliding surface. This function
= + − + (7) contains a nonlinear element that acts as a switch of the control
law, allowing to reach the sliding surface at high speed [14]. The
= + + (8) discontinuous function is described as:
Where the vertical lift or thrust is expressed as U1, and it is ( )= ( ( )) (12)
the result of achieving that the force generated by 4 motor –
propeller pairs is greater than the weight generated by the Where is the tuning parameter responsible for the speed
gravitational action, that is, it can ascend, descend or maintain of reach of sliding surface, and ( ( )) is a non–linear
the flight depending of the force applied to the quadcopter function of the sliding surface ( ). To diminish the
(increase or decrease in the speed of the rotors equitably) [12]; phenomenon of “chattering” that creates high frequency
U2, U3, U4 are the moments for roll ( ), pitch ( ), and yaw ( ), oscillations, the discontinuous function is softened by
respectively; m represents the mass of the quadcopter; is the approximating it to a sigmoid function, as is described in eq.
rotational inertia; , and are the inertia of the quadcopter (13):
( ) Finally, the law of control for altitude is described as:
( ) ≅ (13)
| ( )|
Where is the positive tuning parameter scalar adjustment =( + ( − )+ ) + | |
(25)
of the sigmoid, whose job is to reduce the high frequency
oscillations. Substituting (13) in (12), the discontinuous function Following the same process, the control laws for roll, pitch
is rewritten as: and yaw are defined:
( )
( )= (14)
| ( )|
= − − + + − +
To find the law of control of the height, the next process is
followed: (26)
A surface of first order is chosen, and in function of z, it is
rewritten. = − + − + − +
= + (15)
(27)
The error in z is defined as the subtraction between the | |
desired altitude and the real value of the system.
= − − + − +
= − (16)
(28)
Applying the derivative:
In the Fig. 3, a scheme for the control of quadcopters, is
= − (17) shown.
Substituting (17) and (16) in (15):
=( − )+ ( − ) (18)
Deriving (18):
=( − ) + ( − ) (19)
The dynamic that defines the altitude is given by: Fig. 3. Height and Orientation Control scheme
=− + (20) III. GENETIC ALGORITHMS APPLIED TO QUADCOPTER
The objective of the GA is to find acceptable parameters for
Replacing (20) in (19):
the SMC of a given quadcopter. This optimization is carried out
through selective processes and the exchange of genetic
= − − + + ( − ) (21) information[15].
To find good solutions and implement the natural selection,
Equaling the derivative of the surface to 0, for the continues an identifier is needed to evaluate and differentiate the good and
bad results. In our case, this indicator is defined by the fitness
part of z, we have: function. This value indicates the performance of the system for
the current parameters of the SMC. In Fig. 4, the classical steps
=0= − − + + ( − ) (22) of the GA are shown.
A. Initialization and generation of the initial population
( )= + ( − )+ (23) The values of the parameters define each individual in the
GA. In this way, each individual is defined by the number of
The system will follow the defined surface and will remain variables to tune, and each variable can have a value according
to its domain. The domains established for each variable were
there, if slip condition is fulfilled: determined after having previously tuned the plant under the ISE
criterion. Other variables of the GA are the number of
generations, the percentage of crossing between 0 and 1, the
( )= (24) selection method, the method of crossing or mating, and
| |
percentage of mutation. The size of the population depends on
the complexity of the problem to be solved. The optimum is to A scheme for the tuning of controllers based on GA is
establish an adequate population size according to the problem. proposed, using as objective function the ISE of the system[16],
as is shown in Fig. 5.
Fig. 5. Scheme for the tuning of a controller using ISE as objective function.
For the tuning of the parameters and , for the control of
orientation and height of the quadcopter, it is proposed to work
with the scheme shown in Fig. 6. In this Fig. is presented the
objective function used in the tuning parameters of SMC for a
quadcopter, which consists of the average of the ISE of each
controller to optimize using the 8 corresponding parameters. In
this work, tuning was done with a population of 50 individual, a
cross rate of 0.8, a rate mutation of 0.01, 30 generations,
selection per tournament, and crossing of a single point. These
values were established after conducting a series of tests in terms
of population size, population domain, number of generations
and crossing rate.
Fig. 4. Flow Diagram of the GA
B. Evaluation Fig. 6. Scheme for tuning a SMC using GA
All the individuals of the population are evaluated using a
fitness function, which is the average of the ISE of each IV. RESULTS AND COMPARISONS
parameter to tune (roll, pitch, yaw) [3]. In this section is shown the comparison of a SMC control
tuned in a heuristic way and another tuned by our GA. In the
C. Selection
first phase, only reference variations are shown, and in the
Through the selection stage, it is decided which are the second phase, perturbations have been added to the system. The
chromosomes that have better genetic characteristics to survive, tuning parameters are shown in Table 1.
and they are used to reproduce in the next generation. The
process of natural selection must occur in each iteration of the TABLE I. VALUES OF THE TUNING PARAMETERS
algorithm, to give rise to the evolution of the population Parameter
throughout the generations. Not all survivors are considered
suitable for reproduction, only the superiors (best values of the SMC SMC-GA
POSITIONS
fitness function) are kept for mating, and the rest are discarded
to make room for the new offspring. In this work, the selection
Height 30 29 0.6 15.234 69.7696 0.6
is made per tournament. Roll 5 12 0.3 15.25 25.012 0.3
D. Mating or Crossing Pitch 5 12 0.3 16.995 24.857 0.3
Yaw 5 12 0.3 16.214 23.478 0.3
The mating or crossing is the creation of one or more
descendants from previously selected parents. In this work,
mating is made per a single point crossing. A. SMC and SMC-GA controllers’comparison for set point
changes
E. Mutation
In this section are shown graphics obtained through SMC
Commonly, the mutation consists of changing a 1 to 0 and tuning in a heuristic way and with GA, using Matlab® , for the
vice versa, the genes to change are randomly selected. simulation of the system for several set point changes. These
changes were carried to test if the controllers can respond 1) Performance comparisons: To measure the performance
properly to each change. In the Fig. 7, tests to ascents and of each controller quantitatively, the ISE (Integral of Quadratic
descents of quadcopter are carried out. The initial angle Error) index is used, which is defined by:
references have been given in approximately 5 degrees,
equivalent to 0.08 radians.
= ( ) (29)
Performance results appear in Table 2. In general, SMC-GA
controller overcomes the SMC until 44.68%
TABLE II. PERFORMANCE ANLYSYS FOR DIFFERENT SET POINT CHANGES
ISE
POSITIONS Δ%
SMC SMC-GA
Height 6.236 4.769 23.68%
Roll 0.002722 0.001556 42.83%
Pitch 0.002634 0.001457 44.68%
Yaw 0.002657 0.001655 37.77%
Fig. 7. Responses for set point changes of height
B. SMC and SMC-GA controllers’comparison fordisturbances
Another way to test controllers is to add disturbances to the
system. For the height, the amplitude of the disturbances is of
20 cm, and for the angles, the disturbances have an amplitude of
0.02 radians, equivalent to 1.15 degrees. In all cases, the
disturbances have a duration 2 seconds.
Fig. 8. Responses for set point changes of Angle
Fig. 11. Responses for perturbances to the Height
Fig. 9. Responses for set point changes of Angle
Fig. 12 Responses for perturbances to Roll
Fig. [Link] for set point changes of Angle
ACKNOWLEDGMENT
The authors thank to the robotic and intelligent systems
laboratory (LARSI) of EPN for its sponsorship of this work.
REFERENCES
[1] T. Jiménez et al., “An auto-tuning PID control system based on
genetic algorithms to provide delay guarantees in Passive Optical
Networks,” Expert Syst. Appl., vol. 42, no. 23, pp. 9211–9220, 2015.
[2] A. Jayachitra and R. Vinodha, “Genetic Algorithm Based PID
Controller Tuning Approach for Continuous Stirred Tank Reactor,”
Hindawi Publ. Corp. Adv. Artif. Intell., vol. 2014, pp. 1–8, 2014.
Fig. 13. Responses for perturbances to Pitch [3] P. Ponce Cruz, INTELIGENCIA ARTIFICIAL CON APLICACIONES
A LA INGENIERÍA, 1era ed. México, 2010.
[4] I. A. Ruge and M. A. Alvis, “Aplicación de los algoritmos genéticos
para el diseño de un controlador PID adaptativo,” Tecnura, vol. 13,
no. 25, pp. 81–87, 2009.
[5] H. O. Ozer, A. Sayin, N. Korkmaz, and N. Yagiz, “Sliding mode
control optimized by genetic algorithm for building model,” J. Vib.
Eng. Technol., vol. 4, no. 1, 2016.
[6] C. C. Lin, “Hierarchical path planning for manipulators based on
genetic algorithm with non-random initial population,” Int. J. Innov.
Comput. Inf. Control, vol. 8, no. 3 A, pp. 1773–1786, 2012.
[7] A. K. Kar, N. K. Dhar, R. Chandola, S. S. F. Nawaz, N. K. Verma,
Fig. 14. Responses for perturbances to Yaw and S. Member, “Trajectory Tracking by Automated Guided Vehicle
using GA optimized Sliding Mode Control,” 11th Int. Conf. Ind. Inf.
1) Performance comparisons: To analyze the performance Syst., pp. 71–76, 2016.
of the system with disturbances, again it is used ISE. The Table [8] G. V. Raffo, “Modelado y control de un helicóptero quadrotor,”
3 shows that the SMC controller tuned with GA responds up to Universidad de Sevilla, 2007.
38.41% better against disturbances with respect to the [9] M. Herrera, A. P. Gomez, W. Chamorro, and O. Camacho, “Sliding
heuristically tuned SMC. Mode Control: An Approach to Control a Quadrotor,” 2015 Asia-
Pacific Conf. Comput. Aided Syst. Eng., no. July, pp. 314–319, 2015.
TABLE III. PERFORMANCE ANLYSYS FOR PERTURBATIONS
[10] A. Emilov, “Diseño e Implementación de un Cuadricóptero Basado en
ISE
el Microcontrolador STM32F4,” Universidad Politécnica de Valencia,
POSITIONS Δ%
SMC SMC-GA 2016.
Height 2.910 2.279 21.68% [11] T. Jiřinec, “Stabilization and control of unmanned quadcopter,” Czech
Roll 0.001711 0.001089 36.35% Technical University in Prague, 2011.
Pitch 0.001618 0.0009964 38.41%
Yaw 0.001416 0.0008985 36.54% [12] D. Garijo, I. López, and I. Pérez, “Control de un Vehículo Aéreo No
Tripulado,” Universidad Complutense de Madrid, 2009.
[13] O. Camacho and C. Smith, “Application of Sliding Mode Control to
C. Conclusions
Nonlinear Chemical Processes with Variable Deadtime,” 2nd Congr.
The SMC controller uses a PD controller as the sliding Colomb. Assoc. Autom., no. March 1997, pp. 122–128, 1997.
surface to orientation and height control of quadcopter. All
simulations with reference changes and disturbance indicate that [14] L. J. Capito Ruiz and P. A. Proaño Chamorro, “Seguimiento de
the SMC controller tuned with GA has a better performance than Trayectorias mediante cuatro Técnicas de Control utilizando una
the heuristically tuned SMC, showing an improvement of up to Plataforma Robótica Pioneer 3DX y el Sistema Operativo Robótico
44% . After analyzing the experiments carried out in this work, ROS,” Quito, 2015., 2015.
it can be concluded that it is possible to improve the performance [15] C. R. Luna Ortíz, “Diseño e Implementación de un Algoritmo
of the SMC using GA for the tuning of its parameters. Genético en FPGA para sintonización de controladores PID,”
The tuning method for controllers based on GA proposed in Universidad Autónoma de Querétaro, 2011.
the present work presented satisfactory results, however, it is [16] J. C. Terán and O. Camacho, “Genetics algorithms as a tuning tool for
recommended from GA to develop tuning equations that further PID and sliding mode controllers,” Rev. Técnica la Fac. Ing. Univ. del
facilitate the process of adjusting values to the parameters of the Zulia, vol. 28, no. 3, pp. 10–16, 2005.
controllers.