Comparison of Metaheuristic Optimization Algorithms for Quadrotor PID Controllers

: In the present study, different solution methods are discussed in order to control the quadrotor with the most optimal PID parameters for the determined purposes. One of these methods is to make use of meta-heuristic algorithms in control systems. There are some limitations of using a PID controller as a classical construct. However, it is thought that more successful results will be obtained by optimizing its parameters through meta-heuristic algorithms. Initially, the mathematical model of the vehicle was created in MATLAB/Simulink. Then, genetic algorithms (GA), artificial bee colony (ABC), particle swarm optimization (PSO) and firefly algorithms (FA) were determined respectively as optimization methods. And these optimization methods used to determine the PID control parameters are applied to the developed mathematical model in the MATLAB/Simulink environment. In addition, the performances of the optimization methods are evaluated according to the comparison criteria. As a result of the comparison carried out according to ITAE (Integral Time Absolute Error) fitness criteria, ABC (1.2% - 4.4%) in terms of altitude, FA (4% - 13%) in terms of roll angle, GA (13% - %21) in terms of pitch angle, and PSO (4% - %15) in terms of yaw angle has been more successful than other methods.


INTRODUCTION
Quadrotor is one of the most preferred UAVs.The outstanding features of this vehicle are vertical take-off and landing, stable hovering, and fast maneuvering.However, it has several limitations such as having a complicated and difficult control [1].In the literature, there are many studies on precision altitude and attitude control related to quadrotor [2][3][4][5][6][7].Due to various parametric uncertainties and the non-linearity of the vehicle, it is necessary to develop the most accurate mathematical model.The control methods of the quadrotor, a system with four control inputs and six output parameters, are generally classified as linear and non-linear.The most preferred among linear methods is the PID method due to its simple robust structure.It usually has a performance that gives adequate results [8][9][10].However, there are considerations that the PID method cannot be applied effectively in quadrotors due to its non-linear structure.According to these considerations, the PID method cannot always efficiently control systems due to changing conditions [11][12][13].At this point, optimization methods may need to be included in the process to use the PID controller in nonlinear applications such as quadrotor.Thus, optimum PID controller coefficients can be found.Tuning PID parameters with metaheuristic optimization methods are used in many applications.Some of these applications are as follows: mobile robot system [14], electrical machines [15,16], energy systems [17,18] and magnetic levitation system [19].In this study, PID method and metaheuristic algorithms are used for altitude and attitude controls of the quadrotor in the simulation environment.These algorithms are genetic algorithm (GA), artificial bee colony (ABC), particle swarm optimization (PSO) and firefly algorithms (FA), respectively.Performance comparisons of the algorithms used in setting the PID parameters were done in detail and given in the results section.

MATHEMATICAL MODEL OF QUADROTOR
The quadrotor usually has four equally spaced rotors at the corners of a square body.As a result of the simultaneous increase or decrease of the rotational speeds of all rotors, the quadrotor moves in the vertical direction.The motion in the lateral axis is achieved by decreasing the rotation speed of the rotors in the desired direction of motion and increasing the rotation speed in the opposite direction.The longitudinal motion and yaw motion are also obtained by the moment of the rotors rotating at different speeds, similar to the lateral motion.The quadrotor's motions are given in Fig. 1.

Figure 1 Motions of a quadrotor
Fig. 2 shows the axis of a quadrotor motion.The abstract control inputs (f i ) and the reference system are related to the model of the air vehicle.Body reference and inertial axes are represented with i, j, k and x, y, z, respectively.The roll (ϕ), pitch (θ) and yaw (ψ) motions are rotational motions around the x, y and z axes, respectively.So, the quadrotor is able to fly to any location in space with a combination of several motions or a series of different motions.The connection between the aircraft's inertial reference axis and the body reference axis is created through Euler angles ϕ, θ, ψ and position vectors x, y, z.At this point, some assumptions are used.According to these assumptions, the aircraft is rigid and symmetrical.Moreover, the center of mass, the center of gravity and the origin of the body axis intersect.In line with these assumptions, the mathematical expression of T z,y,x matrix to describe transformation from body axis to inertial axis is obtained (Eq.( 1) -Eq.( 3)).Herein and in subsequent uses, the mathematical notations s and c represent sine function and cosine function, respectively.
The rotational motion of each quadrotor rotor produces thrust and moments in the vertical axis of the aircraft.The total moment is balance by reciprocatively matching rotors.Pairs of rotor 1 -3 and rotor 2 -4 produce counter clockwise and clockwise moments, respectively.Four input forces and six outputs are mainly used in the mathematical modelling of the quadrotor.
The U 1 is the thrust force acting on quadrotor body, U 2 is the force causing roll motion, U 3 is the force causing pitch motion and U 4 is the force causing yaw motion.All of these are given in Eq. ( 4) as a matrix where b represents the thrust factor, d represents the drag factor and Ω i represents angular velocity of rotors (i = 1, 2, 3, 4).The speed of the rotors is calculated using the control inputs.For this, the rotor speeds in Eq. ( 5) are obtained by performing the inverse matrix operation from the control inputs.
Based on the assumptions that the quadrotor structure is completely rigid and symmetrical and that the center of gravity and the origin of the object are on the same axis, a complete mathematical model of the system is created.The calculations of the linear acceleration and angular acceleration by using the Euler-Lagrange approach are given in Eq. ( 6).
where, I x,y,z are the inertia of body of quadrotor on x, y, z axes respectively; J is the inertia of one rotor; l is the distance of rotor to the center of mass; m is the mass of quadrotor; and g is the gravitational acceleration.In this study, the simulation parameters are taken from OS4 quadrotor project [9].They are presented in Tab. 1.

PID CONTROLLER
A PID controller is a linear controller commonly used in different types of systems around the world due to its simple and robust construction and often satisfactory performance.The output of PID controller is given in Eq. (7).
where, controller parameters k p , k i and k d are proportional, integral, and derivative gains respectively, e(t) is the error [20].The achievement of PID controller depends on correct selection of gain parameters.In the literature, it can be established that Ziegler-Nichols formula is generally used in the determination of PID parameters.But this traditional method can limit performance of controller within a narrow range than operating points.
In order to prevent this situation, optimization methods can be used to adjust the PID parameters and obtain the most optimal result.For a more dynamic and adaptive PID controller, nature-inspired optimization algorithms can be preferred as a tuning method.Fig. 3 shows the structure of tunning PID controller.

OPTIMIZATION
Optimization is finding the best solution among many viable solutions to a problem.Solutions that meet all the constraints of the optimization problem are feasible solutions.The best solution goals may include minimizing the cost of a process or maximizing the efficiency of a system.Control theory is concerned with dynamic systems and their optimization over time.Thus, it is aimed to find a control for a dynamical system over a period such that an objective function is optimized.The nature-inspired metaheuristic optimization algorithms can be used for tuning parameters in PID control applications.These optimization algorithms have common tasks such as selection of initial solutions randomly, evolution of the solutions depends on a fitness function, elimination of the worst solutions and generation of new solution.
The way new solutions are generated is the main difference between these algorithms.It may be desirable to evaluate the effect of these algorithms on the controller.In this case, system performances such as overflow and settling time are considered.In the multi-objective problem, instead of using more than one fitness function together, other performance indexes based on dynamic error are used.These are Integral Absolute Error (IAE), Integral Time Absolute Error (ITAE), Integral Square Error (ISE), Integral Time Squared Error (ITSE) [11].In this study, ITAE performance criterion given in Eq. ( 8) is determined as the fitness function to be minimized.

 
The ITAE performance index has smaller oscillations and overshoots when compared to the IAE (integral of absolute error) or ISE (integral square error) performance indexes.It also has more sensitivity and better selectivity.In addition, it has a computational advantage when compared to the ITSE (integrated time-squared error) index [21].
The altitude, roll, pitch, and yaw responses of the quadrotor are each treated as an optimization problem.It is evaluated based on the fitness function and the optimal parameters are obtained as proportional, integral, and derivative gains.These are k pz , k iz and k dz for altitude control, k pϕ , k iϕ and k dϕ for roll control and k pψ , k iψ and k dψ are for yaw control, respectively.Control gains consisting of twelve parameters in total are obtained.The best response is found by evaluating each problem response with the optimization algorithms used.And the twelve parameters that provide the best response are determined as the PID index.The following parts introduce natureinspired algorithms used for PID index optimization.

Genetic Algorithm
The GA is a metaheuristic algorithm which is inspired from the natural selection.The GA was proposed firstly by Holland and Goldberd [22].There are biological concepts and operators in this algorithm.These are gene, chromosome, crossover, mutation, selection, and population.There is a population divided into individuals in which strong individuals have a chance to survive and pass on their characteristics to the next generation.Each individual is the chromosome that represents a solution.In this process, the individual is considered a real coded solution.The generation is created through iterations to generate new solutions.

ABC Algorithm
The ABC is a metaheuristic algorithm inspired from behaviour of honey bees colonies.The ABC was presented firstly by Karaboga and Basturk [23].There are three groups of bees in the artificial bee colony: employed bees, onlookers, and scouts.There is a food source for each employed bee.The transformation of the employed bee into a scout occurs when the food source is abandoned.Each food source location includes a possible solution for the optimization problem.And the amount of nectar of a food source determines the quality (fitness) of the associated solution.The number of solutions depend on the number of employed or onlooker bees in the population.

PSO Algorithm
The PSO is a metaheuristic algorithm which is inspired from the social behaviour of animals moving in swarm as bird flocking.The PSO has been developed in 1995 by Kennedy and Eberhart [24].Each foraging bird estimates its flight speed using information gained from personal experience and interaction with other swarm members.Birds are considered as particles dispersed in the solution space of the optimization problem.The main aim of PSO is to search parameter space in an optimal way to maximize probability of finding the global optimum.The main idea lying behind PSO is to fuse information gathered by individual particles in such a way that both current global optimum and chance of a better optimum is considered.

Firefly Algorithm
The FA is a metaheuristic algorithm inspired by the flashing light of fireflies.Three assumptions have been suggested by Yang to clarify the behaviour of fireflies [25].These are the following: all fireflies are unisex and will move towards the more attractive and brighter ones regardless of their gender.A firefly's degree of attraction is proportional to its accuracy, which decreases with distance from other fireflies.If it is not more attractive or brighter than a certain firefly, it will make a random move.In an optimization problem, the flashing light fitness function is correlated to obtain efficient optimal solutions.

SIMULATION
The comparative use of different approaches in studies in the field of engineering is a factor that increases the value of the study.We can find studies using meta-heuristic algorithms in optimization problems in the literature.
The aim of this study is to show the success of the results obtained with the PID controller parameters tuned depending on the types of meta-heuristic algorithms GA, ABC, PSO and FA.After the quadrotor was modelled in MATLAB/Simulink, simulations were carried out with different optimization methods for reference values of altitude (Z), roll angle (ϕ), pitch angle (θ) and yaw angle (ψ), respectively.Since the number of individuals in the optimization algorithms used will affect the simulation results, the population sizes are of the same value.The common parameters of optimization algorithms are population size 50 and maximum number of iterations 50.In terms of the accuracy of the results, each optimization algorithm was run 20 times.The reference parameter values to be used in the simulation were chosen as altitude (Z) 2 m, roll angles (ϕ) 10°, pitch angles (θ) 10° and yaw angles (ψ) 30°, respectively.The value range of PID controller parameters is determined as (0 -5).The graphs of change in fitness value of optimization algorithms for each of the determined reference values are given in Fig. 4.  The best result was produced by ABC when the altitude (Z) controller parameter was evaluated according to the fitness function ITAE.The results of PSO and FA are close to ABC.The difference between the second PSO and ABC is 1.2%; the difference between the third FA and ABC is 2.1% and the difference between the most unsuccessful GA and ABC is 4.4%.The altitude (Z) graph obtained by using the PID parameters determined according to the best results of different optimization algorithms is given in Fig. 5.The difference between the second FA and GA is 2%.The difference with the third ABC is 59%.The best result in terms of rise time is obtained from ABC.The longest rise time is seen in the PSO.The difference between the shortest and longest rise time is 20%.With the best rising time result, the difference between GA and FA is 4% and 9%, respectively.At the second comparison stage, the best result was obtained by FA when the roll angle (ϕ) controller parameter was evaluated according to the fitness function ITAE.The difference between the second ABC and FA is 4%, the difference between the third GA and FA is 5.9% and the difference between the most unsuccessful PSO and FA is 11%.The roll angle (ϕ) graph obtained by using the PID parameters determined according to the best results of different optimization algorithms is given in Fig. 6.At the same time, performance comparisons of optimization algorithms according to overshoot, settling time and rising time values based on the roll angle (ϕ) graph are given in Tab. 5.The least overshoot in the roll angle (ϕ) response occurs in the FA.The largest overshoot is seen in the PSO.In terms of overshoot, there is twice difference between the lowest and the highest values.With the least overshoot result, the difference between ABC and PSO is 41% and 60%, respectively.The best result in terms of settling time is obtained from PSO.The longest settling time is seen in FA.The difference between the shortest and the longest settling times is 24%, the difference between the second GA and PSO is 1.6% and the difference with the third ABC is 5.4%.The best result in terms of rising time is obtained from GA.The longest rising time is seen in the ABC.The difference between the shortest and longest rising times is 47%.With the best rising time result, the difference between GA and FA is 3.7% and 43%, respectively.At the third comparison stage, the best result was obtained by GA when pitch angle (θ) controller parameter was evaluated according to the fitness function ITAE.The difference between the second FA and GA is 13%, the difference between the third ABC and GA is 21% and the difference between the most unsuccessful PSO and GA is 22.4%.The pitch angle (θ) graph obtained by using the PID parameters determined according to the best results of the different optimization algorithms is given in Fig. 7.The least overshoot in the pitch angle (θ) response occurs in the GA and FA.The largest overshoot is seen in the ABC.With the least overshoot result, the difference between ABC and PSO is 45% and 55%, respectively.The best result in terms of settling time is obtained from ABC.The longest settling time is seen in GA.The difference between the shortest and the longest settling times is 31%.The difference between the second PSO and ABC is 2%.The difference with the third FA is 22%.The best result in terms of rising time is obtained from ABC.The longest rising time is seen in the GA.The difference between the shortest and longest rising times is 43%.With the best rising time result, the difference between PSO and FA is 10% and 37%, respectively.
At the fourth comparison stage, the best result was obtained by PSO when yaw angle (ψ) controller parameter was evaluated according to the fitness function ITAE.The difference between the second FA and PSO is 4%, the difference between the third ABC and PSO is 14% and the difference between the most unsuccessful GA and PSO is 15%.The yaw angle (ψ) graph obtained by using the PID parameters determined according to the best results of the different optimization algorithms is given in Fig. 8.With the least overshoot result, the difference between ABC and PSO is 43% and 67%, respectively.The best result in terms of settling time is obtained from GA.The longest settling time is seen in FA.The difference between the shortest and the longest settling times is 60%, the difference between the second ABC and GA is 3% and the difference with the third PSO is 25%.The best result in terms of rising time is obtained from PSO.The longest rising time is seen in the GA.The difference between the shortest and longest rising times is 39%.With the best rising time result, the difference between FA and ABC is 27% and 30%, respectively.

CONCLUSIONS
In this study, a quadrotor model with PID controller was developed and simulated in MATLAB/Simulink.The attitude and altitude controller parameters of the developed model were determined using nature-inspired algorithms and the results were discussed comparatively.These algorithms are GA, ABC, PSO and FA.The controller performances of the optimization algorithms in four different areas were compared according to the ITAE chosen as the fitness function.In terms of the reliability of the results obtained, each algorithm was run 30 times.The most successful result in the control of the altitude (Z) was obtained by ABC.In terms of altitude, ABC was 1.2% and 4.4% more successful than the method that gave the closest result and the method that gave the farthest result, respectively.At another stage, the most successful result in the control of the roll angle (ϕ) was obtained by FA.In terms of roll angle, FA was 4% and 11% more successful than the method that gave the closest result and the method that gave the farthest result, respectively.In the next stage the most successful result in the control of the pitch angle (θ) was obtained by GA.In terms of pitch angle, GA was 13% and 21% more successful than the method that gave the closest result and the method that gave the farthest result, respectively.And in the final stage, the most successful result in the control of the yaw angle (ψ) was obtained by PSO.In terms of yaw angle, PSO was 4% and 15% more successful than the method that gave the closest result and the method that gave the farthest result, respectively.
In terms of overall performance, it is seen that ABC and FA have better results than GA and PSO according to the selected fitness function.In addition, the optimized controller performances were also examined according to the overshoot, settling time and rising time values in the obtained graphics.In terms of overshoot, the best results were obtained from FA in all controllers.The best performance in terms of settling time was obtained by GA for altitude (Z) and yaw angle (ψ) controllers, PSO for roll angle (ϕ) controller and ABC for pitch angle (θ) controller.In terms of rising time, the best performance was obtained by the ABC for altitude (Z) and pitch angle (θ) controllers, GA for the roll angle (ϕ) controller, PSO for the yaw angle (ψ) controller.Our main goal in obtaining these controller parameters with optimization methods is to reveal an optimal controller without being subject to the limitations of the system.As a result of this study, this goal has been achieved.

Figure 2 A
Figure 2 A quadrotor model with the reference system

Figure 4
Figure 4 Fitness resultsIn addition, the ITAE results of each algorithm are presented in Tab. 2 and the controller parameters

Figure 5
Figure 5 Altitude (Z) graphs of the quadrotor.GA: genetic algorithm; ABC: artificial bee colony algorithm; PSO: particle swarm optimization; FA: firefly algorithm At the same time, performance comparisons of optimization algorithms based on altitude (Z) graph according to overshoot, settling time and rising time values are given in Tab. 4. The least overshoot in the altitude (Z) response occurs in the FA.The largest overshoot is seen in the PSO.In terms of overshoot, the difference between the lowest and the highest value is 20%.The overshoot values of GA and ABC are close to the first-order FA.The best result in terms of settling time is obtained from GA.The longest settling time is seen in PSO.The difference

Figure 7
Figure 7 Pitch angle (θ) graphs of the quadrotor.GA: genetic algorithm; ABC: artificial bee colony algorithm; PSO: particle swarm optimization; FA: firefly algorithm At the same time, the performance comparisons of the optimization algorithms according to the overshoot, settling time and rising time values based on the pitch angle (θ) graph are given in Tab. 6.

Figure 8
Figure 8 Graphs of the yaw angle (ψ) of the quadrotor.GA: genetic algorithm; ABC: artificial bee colony algorithm; PSO: particle swarm optimization; FA: firefly algorithm At the same time, the performance comparisons of the optimization algorithms according to the overshoot, settling time and rising time values based on the yaw angle (ψ) graph are given in Tab. 7. The least overshoot in the yaw angle (ψ) response occurs in the FA.The largest overshoot is seen in the GA.In terms of overshoot, there is 71% difference between the lowest and the highest values.With the least overshoot result, the difference between ABC and PSO is 43% and 67%, respectively.The best result in terms of settling time is obtained from GA.The longest settling time is seen in FA.The difference between the shortest and the longest settling times is 60%, the difference between the second ABC and GA is 3% and the difference with the third PSO is 25%.The best result in terms of rising time is obtained from PSO.The longest rising time is seen in the GA.The difference between the shortest and longest rising times is 39%.With the best rising time result, the difference between FA and ABC is 27% and 30%, respectively.

Table 1
Simulation parameters of quadrotor

Table 4
Controller performance in the altitude parameter (Z)

Table 5
Controller performance in the roll angle (ϕ)

Table 6
Controller performance in the pitch angle (θ)

Table 7
Controller performance in the yaw angle (ψ)