Optimization of PID Controller to Stabilize Quadcopter Movements Using Meta-Heuristic Search Algorithms

: Quadrotor UAVs are one of the most preferred types of small unmanned aerial vehicles, due to their modest mechanical structure and propulsion precept. However, the complex non-linear dynamic behavior of the Proportional Integral Derivative (PID) controller in these vehicles requires advanced stabilizing control of their movement. Additionally, locating the appropriate gain for a model-based controller is relatively complex and demands a signiﬁcant amount of time, as it relies on external perturbations and the dynamic modeling of plants. Therefore, developing a method for the tuning of quadcopter PID parameters may save effort and time, and better control performance can be realized. Traditional methods, such as Ziegler–Nichols (ZN), for tuning quadcopter PID do not provide optimal control and might leave the system with potential instability and cause signiﬁcant damage. One possible approach that alleviates the tough task of nonlinear control design is the use of meta-heuristics that permit appropriate control actions. This study presents PID controller tuning using meta-heuristic algorithms, such as Genetic Algorithms (GAs), the Crow Search Algorithm (CSA) and Particle Swarm Optimization (PSO) to stabilize quadcopter movements. These meta-heuristics were used to control the position and orientation of a PID controller based on a ﬁtness function proposed to reduce overshooting by predicting future paths. The obtained results conﬁrmed the efﬁcacy of the proposed controller in felicitously and reliably controlling the ﬂight of a quadcopter based on GA, CSA and PSO. Finally, the simulation results related to quadcopter movement control using PSO presented impressive control results, compared to GA and CSA.


Introduction
Recently, there has been an upward trend in the popularity of Unmanned Aerial Vehicles (UAVs) in a wide range of practical applications. While large outdoor UAVs are already in application for civil, commercial or military activities, the indoor flight of small UAVs remains a challenging field of application from a scientific point of view. Inland flight requires the right type of vehicle and appropriate navigation, control and collisionavoidance algorithms. In terms of vehicle type, helicopter-like vehicles are among the most encouraging candidates in terms of their weight, low cost, size, high maneuverability, slow-flying ability and even stable hovering flight in constrained conditions. One special helicopter-like vehicle with the added advantage of plain construction and rotor mechanics is the quadrotor.
Quadrotors have received much interest in the research community, where a large number of applications are being presented and experimented. In particular, there has been a growing interest in quadcopter applications, such as object detection and landing to drone stations [1], rescue and disasters [2], agriculture [3], and even other tasks, such as those reported in [4]. It is critically essential for the success of the missions performed that the UAVs precisely and rapidly follow the required path in civilian purposes, such as logistics, mapping, search and rescue, surveillance, exploration and many more military missions, such as attack, defense, supervision and surveillance [5,6].
This current expansion is mostly attributed to the lower cost of on-board sensors, actuators, small-scale embedded computing platforms and simplified rotor mechanics [7]. In spite of the significant advances, flight control is still an open topic of research. By varying the speed of the individual motors, the lift force can be varied, and lateral and/or vertical motion can be generated. However, despite the four actuators, the quadrotor is a non-linear, aerodynamically unstable system that must be stabilized by an appropriate control system. On the one hand, flight control essentially alludes to the ability to carry out highly time-sensitive sensory data acquirement, processing, and the computation of forces for application to aircraft actuators. On the other hand, to name a few, it is advisable that UAV flight controllers are able to withstand faults, adapt to changes in payload and/or the environment, and improve the flight path. UAV flight control systems are mostly implemented using Proportional-Integral-Derivative (PID) control systems. PID has shown exceptional performance in many conditions, including in the context of drone racing, where accuracy and lightness are key factors. In contrast, it has many handicaps: (1) at times, it provides a high control signal due to wind, thus overshooting and continuing to increase as the accumulated error is unwound; and (2) the differentiator leads to the amplification of noise. The PID controller system is the preferred control method [8]. The PID controller has only three parameters, giving it an easy adjustment space to obtain a better control point [9]. It is evident that fast response speed and high controllability can be achieved by implementing proper PID parameters [10]. Therefore, the method of tuning PID parameters has become one of the hot research topics in the engineering field. In stable environments, a PID controller displays close to the best possible performance. When bared to unknown dynamics, such as variable payloads, wind and voltage drops, however, a PID controller can be far from optimal [11]. On the other hand, because quadcopters are dynamically unstable, under-actuated and nonlinear systems, it is difficult to design a quadcopter's PID controller to track a moving target, particularly under the variable speed of the moving target and under the influence of the environment. This is because any error that occurs in any of them can cause serious damage to the quadcopter.
The PID controller successfully tracks a reference altitude, despite undergoing a large overshoot on takeoff. This may be related to the ground impact, which produces an unexpectedly strong lift before the quadcopter surveys the ground. Understanding how to balance the different aspects of flight to make a quadcopter respond optimally to a particular flight style is not a simple matter that can happen overnight. Practical knowledge of PID tuning helps to achieve this easily, and the more familiar the operator is with the PID settings, the easier it is to set the codecs to fly in any way.
Conventional methods, such as Ziegler-Nichols (ZN) [12], for the PID controller does not guarantee optimal control for a quadcopter. This method might cause system instability as well as major losses and damages to the system. Therefore, a more efficient control method is needed for the quadcopter that can make the system very stable with minimal losses and without damaging the system. A secondary goal is to achieve reliable and proper movements and directions for the quadcopter. For next-generation flight control systems to be intelligent, there is a need to devise a way to integrate adaptability to the changeable environment and dynamics. Accordingly, the evolution of intelligent flight control systems remains an active research domain [13], concretely through the use of artificial neural networks, which are an appealing choice that have been agreed on as global approximators, and noise-resistance [14]. Online learning methods [15] have the merit of learning the dynamics of an aircraft in real time. The key restriction with these methods is that the flight control system is only aware of its past experiences. It follows that its performance level is constrained when exposed to an unprecedented event. Offline training models using supervised learning are problematic, as data acquisition is prohibitively expensive and derived from imprecise representations of rudimentary aircraft dynamics, which can result in suboptimal control policies [16].
At present, many research trends in adaptive control are gradually being turned toward the use of meta-heuristic algorithms to accommodate and solve professional engineering problems [17,18]; these algorithms have enticed the attention of many researchers [19]. Overall, a variety of studies have been conducted based on meta-heuristic algorithms to obtain appropriate PID parameters, such as Genetic Algorithms (GA) [20], Particle Swarm Optimization (PSO) [21], the Artificial Immune System (AIS) [22] and the Kidney-Inspired Algorithm (IKA) [23]. A PID controller designed by other meta-heuristic optimization methods was also applied in servo systems. Pršić et al. [24] used the Firefly algorithm to adjust the three parameters of the PID controller in parallel robot platforms with six degrees of freedom gain. The Beetle Antennae Search (BAS) algorithm was adapted for use in UAV avoidance [25], trajectory organizing and control systems [26,27].
Most of the previous studies show reasonable performance and results. However, they either use the Global Positioning System (GPS) to discover the location of the target, which provides inaccurate identification in indoor environments, or they use sensor fusion. Other researchers have focused more on the part of computer vision, ignoring the influence of external disturbances, such as the impact of the environment.

Objectives of the Work
The current work focuses on the PID controller of a quadcopter whose parameters are to be tuned by meta-heuristic algorithms, including Genetic Algorithms (GA) [28], the Crow Search Algorithm (CSA) [29,30] and Particle Swarm Optimization (PSO) [31,32]. These meta-heuristics have long been accepted by the artificial intelligence community for their adequacy in solving a wide range of real applications by arriving at optimal or accurate solutions with respect to a compact set of parameters, such as time or cost [33][34][35]. The optimization methods for the quadcopter PID controller, in this work, were mathematically formulated to control the movements of the quadcopter in the x, y and z directions over the quadcopter coordinates. In the assessment of the performance of the optimization algorithms used in the work, such parameters as overshooting, rising time and settling time were integrated in a multi-objective fitness function in order to achieve an optimal gain for the PID controller.
The key contributions of the proposed work lie in the following: (1) overcoming the nonlinearity and instability of a quadcopter system through the use of three meta-heuristics that control the movements and directions of a quadcopter with the aim of obtaining high gain for the quadcopter's PID controller; (2) it is expected that this will allow verification of the system performance and make a comparison between these meta-heuristics, using a set of related measures, as the second contribution; and (3) the third contribution is the comparison of the results of these meta-heuristics with the results of a traditional method.
The mathematical model used to simulate the movements of a quadcopter is given in Section 2. Section 3 then presents the PID controller for the quadcopter's motors. The following Section 4 presents a brief description of GA, CSA and PSO. The evaluation methods and experimental results are presented in Section 6. Section 7 then presents a statistical analysis test for the controlling methods. Section 8 then discusses the results with closing comments, and further outlooks are given in Section 9.

Mathematical Model of Quadcopter
A mathematical model is needed to simulate and/or monitor the movement of a quadcopter in a three-dimensional space space with the configuration shown in Figure 1. This model is essential to establish a relationship to link the inputs with the outputs of the quadcopter system. The model can be used to predict the position and attitude of a quadcopter, using the four angular velocities of the propellers, where a quadcopter can operate under various operating conditions with respect to different input values. The stability and control of a quadcopter can be achieved with a suitable model [36]. The quadcopter is an UAV with four rotors connected to two horizontal bands. Rotors 1 and 3 rotate clockwise, while rotors 2 and 4 rotate counterclockwise to balance the torque. Quadcopters can move in six different ways by combining translational and rotational motion. The four inputs of the quadcopter can be described as follows:

1.
Thrust (z): This is the vertical force that moves the quadcopter through the air in any direction, which is caused by increasing or decreasing the speed of all four rotors by the same amount, greater or lesser than the gravitational force.

2.
Roll angle (φ): This identifies the rotation of the quadcopter around the x-axis, where the roll movement of the quadcopter is obtained by decreasing the speed of the second rotor and increasing the speed of the fourth rotor. This moves the quadcopter to the sides, engendering it to roll. However, it does not cause the quadcopter to alter its altitude position. These "rolls" make the quadcopter move left and right on its horizontal axis.

3.
Pitch (θ): This identifies the rotation of the quadcopter around the y-axis, where the pitch movement is obtained by decreasing the speed of the first rotor and increasing the speed of the third rotor. The pitch means that the quadcopter tilts downwards or upwards on the basis of its orientation and the location of its nose. An upwards tilt will move the quadcopter in a backwards motion, while a downwards tilt will move it in a forwards motion.

4.
Yaw (ψ): This identifies the rotation of the quadcopter around the z-axis, whereby the yaw motion is obtained by increasing the angular velocities of two opposite rotors and decreasing the velocities of the other two. Yaw refers to the direction that the front of the quadcopter faces when rotating either clockwise or counterclockwise on its vertical axis.

Quadcopter Coordinates
Referring to the dynamic model of a quadcopter presented in Figure 2, the following two reference frames can be used to describe the dynamic behavior movement of a quadcopter [37]: • The linear and angular positions of the Earth's inertial frame (E) can be defined as follows: • The linear and angular velocities of the body-fixed frame (B) can be defined as follows: The following assumptions were taken into account when developing a dynamic model of a quadcopter: • The body of the quadcopter is rigid and symmetrical. • The center of gravity and center of body mass coincide. • The aerodynamic effects are not significant in the case proposed in this work.
Equations (21) and (22) can be used to derive the formulas forζ andη as defined below: The rotation matrices along x, y and z axes are defined below: • Rotation along the x-axis is as follows: where C φ and S φ indicate cos φ and sin φ, respectively.

•
Rotation along the y-axis is as follows: where C θ and S θ indicate cos θ and sin θ, respectively.

•
Rotation along the z-axis is as follows: where C ψ and S ψ indicate cos ψ and sin ψ, respectively.
• Equation (6) can be used to convert all the angles from the B frame to E frame: • The angular velocity translation matrix (J) is defined in Equation (7).
Finally, the kinematic model for a quadcopter is given in Equation (8):

Forces and Moment
The following terms are used in the control optimization process presented in this work: • The moment of inertia or angular mass is the rotating body's resistance to angular acceleration or angular deceleration. It is best described as the product of the mass and the square of its perpendicular distance from the axis of rotation.

•
Torque is a measure of how much force is applied on an object, causing the object to rotate. It can be defined mathematically as τ = r × F, where F is the force and r is the moment arm.
After getting the relationship between the body frame and the inertial frame, we can calculate the forces and torque acting on the quadcopter so that we can control the movements of the quadcopter. The thrust force acting upwards is given as follows: The torque force is the rotational force operating on the body of the quadcopter, making the body rotate in a specific direction.
In the E frame, the linear acceleration of a quadcopter is a combination of gravitational force and thrust force.
where x is a positional vector,ẍ is the linear acceleration, g is the gravity force, and T B is the thrust vector. The motion of angular acceleration can be defined as follows: where ω is the angular velocity, τ is the torque and I is the moment of inertia. The translation and rotation movements can be defined as follows:

PID Controller
Due to the increasing number of applications and complexity of the quadcopter on a daily basis, approved control algorithms also need to progress so that they can deliver better performance and boost flexibility [38]. In the past, modest linear control methods were accepted, due to their lower computational requirements and stable behavior. However, with advanced modeling methods and faster on-board computational power, a widerange of nonlinear methods have been used to run in real time. The proposed nonlinear control methodologies have grown rapidly, and they provide high performance, making the quadcopter more powerful [39,40].
In this paper we explore one of the well-recognized controllers in industry, called the PID controller [34,41]. The PID controller has many merits, such as reducing the downtime, rise time, and peak error, and smoothing the movement of the output in addition to the overshoot of the system. Meanwhile, this type of controller has many difficulties in adjusting its parameters. For example, its low ability to tune P, I and D parameters may result in poor performance, slow control and, in some cases, system instability. Consequently, many types of tuning methods for the PID controller demand considerable attention from the operator to identify the optimal set of values for those parameters to reach a reasonable gain. One of the conventional methods widely used to fine-tune the parameters of the PID controller is the Zeigler-Nichols method [12]. However, in a few past cases, this method did not produce sensible results in reducing the time response of the signal as reported in the literature.
Based on the developed mathematical model for the quadcopter, the four inputs of the PID controller of the quadcopter's motors were tuned to control the altitude, attitude, heading and position of the quadrotor in space. In this work, GAs, PSO and CSA are presented to optimize the gain of the PID controller in order to improve the system's dynamic response.
The control function can be expressed mathematically as given in Equation (24).
The transfer function of the PID controller is defined as presented in Equation (25).
The transfer function is capable of capturing the dynamics of the quadcopter's movements [42]. Furthermore, the transfer function is utilized to demonstrate the effectiveness of the presented method. The transfer functions for the inputs of the PID controller, φ, θ, ψ and z are defined in Equations (26)- (29), respectively [42].
The PID controller was designed using closed-loop feedback control in order to stabilize the closed-loop system based on pre-defined equality characteristics. The PID controller can be described by a discrete transfer function as that given in Equation (30).
At each generation, the error is recomputed for the closed-loop system, where the resulting error is corrected by the PID controller and passed as inputs to the motors of the quadcopter.
In short, flight control systems for UAVs are mostly carried out using PID control systems. A PID controller is typically used to stabilize the rotational and translational motion of an UAV quadrotor system and enforce it to follow a specific path with minimum energy and error. It is evident that a fast response speed and high control capacity can be obtained by implementing adequate PID parameters. Thus, the method of tuning the PID parameter has become one of the hotspots of research in the engineering field. The tuning process, by which optimal values for the controller parameters are gained, is a crucial challenge. Many studies have been performed to locate the best way to fine-tune the PID parameters in order to obtain appropriate performance, such as rapid response, zero steady-state error, and minimal undershoot/overshoot. Although there are only three parameters, tuning PID parameters is a difficult process because it must meet complex criteria within the limitations of system actuators. In addition, the conventional PID controller only works for lower-order systems and lacks robustness against large uncertainties in system parameters. This is due to the inadequate number of parameters for handling the independent specifications of the time-domain response, such as the overshooting and settling time. Therefore, an effective PID controller control method is needed to have a better control point. The evolution of a method for tuning quadcopter PID parameters may save effort and time, and preferable control performance can be reached. For this intent, we propose, in this paper, a mathematics-based framework using several meta-heuristic optimization algorithms to design a robust PID controller for an UAV system. The produced control system should improve time-response dynamic properties, guarantee durability against large parameter uncertainties, and provide an effective tuning tool with fewer tuning parameters. After the determination of the parameters of the PID controller, the closed-loop system will achieve the required performance criteria.

Bio-Inspired Meta-Heuristic Algorithms
Bio-inspired optimizer algorithms are of great value for addressing many types of complex real-world problems, making it feasible to arrive at reasonable global solutions in a plausible time frame with better accuracy and reliability than classical search methods [43]. In fact, there is a great need, in practice, for large reliability and adequacy as well as low computational burden when the problem under investigation is so challenging and the search area is quite large. Moreover, in some cases, there is a need to compare the appropriateness of particular and global solutions.
The fundamental motivation for using meta-heuristic algorithms in this controlling and optimization problem is reliable optimization through the use of a local search strategy and the randomness in their evolutionary processes to find optimal or near-optimal solutions. However, this does not always result in meta-heuristics finding compelling or optimal solutions, as was shown in several cases [33,44,45]. In such a context, exploration and exploitation constitute the fundamental and important processes of meta-heuristic algorithms. While the meta-heuristic algorithm endeavors to assay various areas in the search domain during the exploration process, it seeks to converge the search into all sub-optimal solutions found in the exploitation process [33,43].
Broadly speaking, nature-inspired algorithms have intelligence behavior based on the collective behavior of a group of social individuals with multiple collaborating agents for the sake of optimizing a given problem. Although these algorithms are made up of relatively modest individuals, they offer harmonious social behavior to guide the individuals to their intended goals. These algorithms outset by randomly creating a predetermined number of possible solutions. The candidate solutions are then updated at each iteration loop, using a particular mechanism on the basis of the meta-heuristic algorithm used. Each algorithm evaluates each solution within each iteration loop, using an objective function. Evolutionary Algorithms (EAs), such as Genetic Algorithms, and Swarm Intelligence (SI), such as Particle Swarm Optimization and the Crow Search Algorithm, are two categories of bio-inspired meta-heuristic algorithms.

Proposed Multi-Objective Fitness Function
Fitness function plays a key role in the optimization problems that assists the optimization method in measuring the quality of the solution of the problem under study and how effective the solution of the problem is. The fitness function used by the meta-heuristic algorithms presented in this work, namely GA, CSA and PSO, to optimize the parameters of the PID controller for the inputs of the quadcopter is the integration of the weighted absolute error time and other three parameters identified as the overshoot, rise time and settling time of the quadcopter. Therefore, this fitness function is a multi-objective function as given in Equation (31): where β 1 , β 2 , β 3 and β 4 represent the weighting parameters that boost the efficacy of PSO; r, s and o are the rise time, settling time and overshoot, respectively; and K is the integral of the weighted absolute error time defined in Equation (32) [46]: where n stands for the number of samples, t represents the sample time and e stands for the error difference between unity and the response time of the closed-loop system. In Equation (31), the values of β 1 , β 2 , β 3 and β 4 are arbitrarily defined as 0.7, 0.1, 0.1 and 0.1, respectively. So, the proposed fitness function is intended to reduce all the parameter values, K, r, s and o, concurrently based on the priority that is set as the weight parameters, namely β 1 , β 2 , β 3 and β 4 .
Notably, the fitness function proposed for GA, CSA and PSO to implement the problem under study is a multi-objective function that integrates several parameters, including K, o, r and s. This combination of these parameters is targeted to increase the gain of the PID controller in the optimization process as well as to contribute to measuring the impact of the closed system performance based on the step response. As a matter of fact, K in Equation (32) is utilized in Equation (31) to arrive at an optimal PID control system design as confirmed in [30]. This parameter is integrated into the multi-objective fitness function to produce a system with a much faster settling time.

Experimental Results
This section presents the evaluation results of the conventional ZN method along with the results of GA, CSA and PSO in adjusting the PID parameters while controlling the movements of the quadcopter and provides an overall analysis of the varied computational time elapsed by these algorithms.

Parameter Setting
The parameter settings used by GA, PSO and CSA to optimize the gain of the PID controller for the developed experiments are displayed in Table 1. The parameters' values were selected based on the design of the experiments to conform each algorithm to the fundamental nature of the controlling problem. In fact, the values of the parameters were changed several times until a reasonable solution was found. However, only good settings are often obtained, not the best settings.

Time Results
The overshoot, rise time and settling time values obtained by the ZN method, GAs, PSO and CSA during controlling the parameter inputs of the PID controller, namely, roll (φ), pitch (θ), yaw (ψ) and thrust (z), while controlling the movement of the quadcopter are presented in Table 2. The overshoot, rise and settling times in Table 2 obtained by the ZN method and optimization process conducted by GAs, PSO and CSA for the PID controller parameters for a quadcopter illustrate the efficiency of these methods in controlling the movement of the quadcopter. It is clearly noted from Table 2 that the overshoot, rise time and settling time reported by the ZN method for the roll, pitch, yaw and thrust inputs of the quadcopter are relatively large. The overshoot for input yaw of the ZN method is analogous to the overshoot for the thrust input. The rise and settling times reported for the input yaw by the ZN method are very small, compared to the rise and settling times reported for the input thrust. Moreover, the settling time reported for the input roll by the ZN method is comparable to that of the input roll reported for the input pitch. The overshoot, rise time and settling time obtained by the GA-based approach are relatively small. Further, the overshoot values obtained with the GA-based approach are small, compared to the corresponding overshoot values obtained by the ZN method. However, the rise and settling times obtained by the ZN method for inputs yaw and thrust are smaller than those inputs obtained with the GA-based approach. The overshoot values for inputs roll, pitch and thrust obtained by CSA are smaller than those obtained by GA. However, the overshoot value for the input yaw-obtained CSA-based approach is smaller than that obtained by GA. By comparing the control responses from GA-and CSA-based methods for the position and orientation of the PID controller, the CSA-based method has smaller overshoots for inputs roll and yaw of the quadcopter. However, the CSA-based method has longer settling times for these inputs.
As Table 2 shows, the overshoot, rise time and settling time values obtained based on PSO provide better large performance rates, compared to the corresponding time values obtained by the ZN, GAs and CSA methods. The respective obtained values based on PSO and those corresponding values obtained based on CSA are not significant. In short, the results of the performance values of the quadcopter inputs obtained based on GA, PSO and CSA are valuable, promising and denote that these meta-heuristic optimization algorithms have acquired desirable control for the movement of a quadcopter. These results confirm the eligibility of the proposed controlling optimization approach to optimize any nonlinear dynamic system, using the meta-heuristic algorithms utilized in this work.

PID Controller Tuning Parameters
The PID controller values, K p , K i and K d , obtained by GA, PSO and CSA for the inputs of the quadcopter, denoted as roll (φ), pitch (θ), yaw (ψ) and thrust (z), along with the fitness values, are presented in Table 3. The fitness cost values obtained by the GA-based approach for the quadcopter inputs in Table 3 are encouraging for all inputs of the quadcopter, which confirm reasonable control for the movement of the quadcopter. Table 3 confirms that PSO reported low fitness costs for all inputs of the quadcopter. Obviously, the fitness cost reported for the input φ is lower than the fitness cost reported for the other inputs of the quadcopter. However, the difference is relatively small compared to the inputs, θ and ψ, which are insignificant. Furthermore, PSO reported a fitness cost for the input φ that is significantly less than the fitness cost reported for the input z. PSO also reported a fitness cost for the input θ that is comparable to the fitness cost reported for the input ψ. In a nutshell, the low fitness values obtained by PSO in Table 3 underline the suitability of PSO in controlling the movement of the quadcopter through optimizing the PID controller parameters. The fitness values obtained by CSA are promising, where the values obtained for inputs roll and thrust are smaller than those obtained by GA. However, the fitness values reported by CSA for inputs pitch and yaw are larger than those reported by GA.

Convergence Results
The convergence curves of GA, PSO and CSA used to accomplish the optimization process presented in this work are presented, using different population sizes to demonstrate the ability of these algorithms to provide accurate control for the quadcopter movements through tuning the PID parameters of the quadcopter. Figures 3-5 show the convergence characteristic curves of the roll control input of the quadcopter obtained by GA, PSO and CSA, respectively, over a different number of population sizes.     It is observed from Figure 3 that there is significant convergence in the evolutionary process of the GA-based approach in optimizing the PID controller of the quadcopter. These convergence curves are promising and affirm the effectiveness of GA in controlling the quadcopter's movements. The convergence curves of controlling the quadcopter movement using the PSO-based approach are rendered for up to 100 iterations. These convergence curves show that PSO lays out fast convergence with very low error. It can be seen from Figure 4 that the convergence curve for the population of size 60 converges more rapidly to the optimal cost than that for the other population sizes, although PSO with population sizes of 40, 60, 80 and 100 roughly reach near fitness cost values. The fitness cost value obtained by PSO for the population of size 20 is not optimal and is significantly higher than the fitness cost values reported by PSO for larger population sizes. Thus, any further increase in the population sizes is likely to reach a very small fitness cost value. It is possible that a very large increase in the size of populations will not significantly reduce the fitness cost value further. The fitness cost value for some population sizes continues to decline slightly with further population sizes. The fitness cost value may reduce further with more than 100 particles in the population of PSO. There is a big difference between the curves of population size 20 and the other curves, which indicates that the controlling process implemented by PSO with 100 particles and 80 particles achieves better control than the controlling process carried out by PSO with 20 particles. The performance of CSA in optimizing the roll input for the quadcopter is shown for up to 100 iterations in Figure 5. These curves represent the fitness cost values obtained using the fitness criterion in Equation (31). The convergence curves in Figure 5 demonstrate that the CSA-based approach provides stable control of the quadcopter with fast convergence and very low error. Figure 6 compares the convergence characteristic curves of the roll control input of the quadcopter obtained by GA, PSO and CSA for a population size of 100.
The convergence curves in Figure 6 confirm that the control method presented based on GA, PSO and CSA reaches a sensible degree of performance in controlling the roll input of the quadcopter for all of these meta-heuristic methods. It is clearly observed that PSO converges to a very small error value, compared to GA and CSA.

Simulation Results
The simulated step signal representations of the quadcopter's inputs, roll (φ), pitch (θ), yaw (ψ) and thrust (z), using a PID controller along with simulations of the amplitudes of square signals of the inputs' responses obtained by the GA and ZN methods, are illustrated in Figures 7, 8, 9 and 10, respectively.    It is clearly evident from Figures 7-10 that there are significant differences between GA and ZN step response curves, indicating that GA achieves a slight overshoot, a small rise time and a small settling time, compared to those arrived at by the ZN method. By comparing the simulated step responses from the GA-and ZN-based methods, the GAbased approach is faster and has a smaller overshoot for input yaw of the quadcopter. However, the GA-based approach has a longer settling time. Remarkably, the degree of separation between the GA and ZN curves is relatively large for all quadcopter inputs.
The simulated step signals of the inputs-roll, pitch, yaw and thrust-using the PID controller of the quadcopter as well as the simulations of amplitudes of the input responses obtained by the PSO and ZN methods are presented in Figures 11, 12, 13 and 14, respectively.    Obviously, Figures 11-14 confirm that PSO is substantially more effective than the ZN method in controlling the movement of the quadcopter. This is due to the fact that the signal representations obtained by PSO report small overshoot, modest rise and settling times, compared to those reported by the ZN method.
The simulated step signal representations using the PID controller of the quadcopter inputsroll, pitch, yaw and thrust-along with the simulations of amplitudes of the input responses obtained by the CSA and ZN methods are displayed in Figures 15, 16, 17 and 18, respectively.
It is clearly observed from Figures 15-18 that there are appreciable differences between CSA and ZN step signal representations, indicating that CSA arrives at slight overshoot, small rise and small settling times compared to those reached by the ZN method. Significantly, there is a relatively large degree of separation between the CSA and ZN curves for all of the quadcopter inputs.   The simulated step signals for the roll, pitch, yaw and thrust inputs of the quadcopter shown in Figure 1 based on the use of GA, PSO, CSA and ZN methods by optimizing the PID controller of the quadcopter to stabilize its movements are presented in Figure 19.
The results shown in Figure 19a-d demonstrate the effectiveness of GA, PSO and CSA in reliably controlling the roll, pitch, yaw and thrust inputs of a quadcopter, respectively. As it is clear, the simulated signals for the roll, pitch, yaw and thrust inputs in Figure 19a-d, respectively, obtained based on GA, PSO and CSA are better than those corresponding responses obtained by the ZN method. Interestingly, the responses obtained based on GA, PSO and CSA for roll, pitch, yaw and thrust inputs of the quadcopter are almost similar to each other, with not much difference between them. However, PSO provides the best results, compared to the others.

Statistical Test Analysis
To locate the importance of the differences between the optimization outcomes arrived at by each method, we utilize the Friedman statistical test. This test is conducted to find out if there are perceivable differences between the overshoot results of the methods presented in this work [47]. If there are statistically notable differences between the optimization results, the Holm method [47] will be conducted as a posterior statistical procedure that is usually used to compare the best method of performance (i.e., the control method) with the rest of the methods. The level of confidence, pointed out as α, is 5% in all evaluated cases.
In more detail, Friedman's test requires the calculation of the average ranked value. Then, a comparison is used to assess the critical values obtained for the level of significance tested (α = 0.05) with Friedman's test to check whether or not the null hypothesis is rejected. In such a context, if the level of significance (i.e., the p-value) divulged by Friedman's test is less than or equal to 0.05, the null hypothesis is rejected, denoting that there is a big difference between the performance scores of the algorithms. After that, further steps are needed to determine which algorithm's performance is crucially different from the best algorithm and which algorithms are similar. This is to check whether the outcomes arrived at by the best algorithm differ from the outcomes of the other methods in a statistically significant manner. For this intent, this study looks at a post-hoc statistical analysis method of Holm's test [48] to see which methods are worse or better than the best algorithm and at what level of significance. Holm's test is a widely applicable test method based upon the sequential rejection method. It orders all optimization algorithms on the basis of their p-values and compares them to α/k − i, where α is the significance level, k represents the freedom degree and i denotes the algorithm number. The method starts with the most significant p-value and consecutively rejects the null hypothesis as long as p i < α/k − i. Once the method is not able to reject the hypothesis, it stops and stops all the remaining hypotheses passable. In applying Friedman's test, the best-performing algorithm obtains the lowest ranking, while the worst performing algorithm obtains the highest rank. The lowest ranked method is used as a control algorithm for post-hoc analysis.
The average order of the optimization results arrived at by Friedman's method as per the overshoot metric is tabulated in Table 4. The controlling results based the presented methods in this work are ranked as PSO in the first order, followed, in order, by CSA, GA and ZN. The p-value, computed using Friedman's statistical test for the overshoot measure in Table 2, is 0.025557; the null hypothesis of the homologous performance level is unacceptable to assert if there are statistically significant differences between the performance of all evaluated methods.
The Holm's method is then appealed as a post-test procedure to determine if there are statistically substantial differences between the best performing algorithm (that is, PSO) and the remaining algorithms (ZN, GA and CSA). Holm's method dismisses the hypotheses with p-values of less than 0.025. The results obtained based on the Holm's procedure are presented in Table 5. The findings of Holm's method reveal that the optimization results obtained based on PSO in controlling the movement of the quadcopter are statistically better than the optimization results obtained based on the ZN-, GA-and CSA-based approaches. In the case of the optimization results obtained using the CSA-based approach, there is no significant difference between these results and those obtained using the PSO-based approach, in accordance with the results given in Tables 4 and 5. In summary, these end results imply that controlling the movement of the quadcopter using a CSA-based approach is a feasible alternative approach to the PSO-based approach, which needs further investigation.

Discussion of the Results
It is clearly observed from Table 2 that PSO reports overshoot values for the quadcopter inputs that are significantly lesser than the overshoot values reported by the ZN method, shown in Table 2, for the same corresponding quadcopter inputs. Further, GA and CSA reported overshoot values as shown in Table 2, which are lower than those reported by the ZN method for the corresponding inputs. These findings are attributed to the powerful features of GA, CSA and PSO as meta-heuristic optimization methods and the robustness of the presented multi-objective fitness function given in Equation (31). However, the overshoot values reported by PSO for the inputs of the quadcopter in Table 2 are lower than those reported by GA and CSA as shown in Table 2.
The rise and settling times reported by GA, CSA and PSO for all quadcopter inputs are remarkably lower than those reported by the ZN method for the same corresponding inputs. This clarifies and may prove that GA, CSA and PSO are reliable and more effective than the classical ZN method in controlling the movements of the quadcopter, using PID control parameters. Additionally, the differences in the rise and settling times between the control process developed based on PSO, GA and CSA for the four inputs of the quadcopter are respectively less than 0.0045, 0.0209, 0.00925, and 0.431625, on average, which are small and not statistically significant.
Overshoot of the motor signal of the quadcopter is a critical factor that should be slashed. If the temperature of the insulation of the motor of a quadcopter is elevated further away than its rated limits, then the motor will be ruined rapidly [49]. Table 2 states that the overshoot values of all movements of the quadcopter reported by PSO are close to zero in all cases considered; the overshoot values for all movements of the quadcopter reported by GA and CSA are very small in all cases considered. Outstandingly, this outcome is highly desirable for reaching an extremely low temperature for the motors of the quadcopter to protect them from destruction.
The control approaches developed based on GA, CSA and PSO report very low fitness values for all quadcopter inputs, which simply means that the controlling processes developed using these meta-heuristic algorithms for the PDI controller of the quadcopter reached an optimal control for the movements of the quadcopter. Moreover, there is no significant difference between the cost values of these algorithms, whereas the differences in fitness cost values between the optimization developed based on PSO, GA and CSA for the four inputs of the quadcopter are, respectively, less than 0.0015475 and, 0.0209, 0.00925, and 0.009815, on average, which are not statistically significant.
Simply put, the step signals representations of the quadcopter inputs plotted using GA, CSA and PSO demonstrate that these meta-heuristic algorithms are robust tuning algorithms for the quadcopter's PID controller and are better than the conventional tuning methods, such as the evaluated ZN method. In short, this expected upshot asserts the reliability level of GA, CSA and PSO in optimizing the PID parameters for the quadcopter.
All in all, the following observations can be made from the experimental results of GA, CSA and PSO when used to optimize the PID parameters to control the movements of the quadcopter.

•
As per the overshoot evaluation method, GA, CSA and PSO outperform the ZN method through reporting significant reductions in the overshoot values as presented in Table 2. • In accordance with the rise and settling time values, GA, CSA and PSO report rise and settling time values that are considerably lower than the rise and settling time values reported by the ZN method for all inputs of the quadcopter as presented in Table 2. • As per the fitness function values for the inputs of the quadcopter, GA, CSA and PSO reach extremely low fitness costs for all inputs, indicating that GA, CSA and PSO are robust and effective in optimizing the PID parameters for the quadcopter flight as presented in Table 3. • The convergence curves of the evolutionary processes of GA, CSA and PSO confirm the appropriateness of these methods and the robustness of the proposed multi-objective fitness function in controlling the flight of a quadcopter.
For all evaluation criteria, the meta-heuristic algorithms presented in this paper, including GA, CSA and PSO, are able to control the PID controller of the quadcopter to control its movement in all orientations. The superior performance of these algorithms in such an optimization and control problem is attributed to the astonishing features of meta-heuristics and the fitness function, which suggested carrying out such work. The meta-heuristic optimization algorithms is presented in Appendix A.

Conclusions and Future Work
This work presented the use of Genetic Algorithms (GAs), Particle Swarm Optimization, and the Crow Search Algorithm (CSA) to adjust the parameters of the Proportional Integral-Derivative (PID) controller to control the movements of a quadcopter. The goal was a reliable scheme to control the movements and direction of a quadcopter. We adopted a multi-objective fitness function for GA, PSO and CSA to optimize the parameters of the PID controller by controlling the quadcopter's flight. The performance of these algorithms was studied in detail with respect to time and accuracy. Convergence curves were presented to demonstrate the ability of this algorithm to provide an accurate controlling process. A fitness function was used to evaluate the performance of the PID controller to control the movements of a quadcopter. Superb results and credible flight orientation of the quadcopter were obtained through the use of GA, PSO and the traditional Ziegler-Nichols (ZN) method. The gain of the developed PID controller was tested through a closed-loop step response system. Further study is needed to assess the suitability of this method to control a quadcopter in a range of directions. It would be beneficial to perform a comparison of alternative meta-heuristic algorithms to control the PID of a quadcopter. Further work is needed to generalize the proposed controlling method based on meta-heuristics to tune the parameters of the PID controller for different types of aerial vehicles.

Conflicts of Interest:
The authors declare that there is no conflict of interest regarding the publication of this paper.

Appendix A. Meta-Heuristic Optimization Algorithms
Appendix A.1. Genetic Algorithms Genetic Algorithms are one of the most well-known EAs inspired from Darwin's theory of evolution by John Holland in 1975 [50] and subsequently extended and explored in depth by [51] and Goldberg [52]. The key inspiration features of GAs were inspired based on the evolutionary concepts of natural selection and genetic operators, referred to as crossover and mutation operators. GA does not demand any gradient information and is more likely to converge to the search area for optimum global solutions. The population of GA is initialized by a number of candidate solutions. The iterative procedure of GAs is prolonged through the application of the difference vector based on GAs reproduction operators, in order, including mutation and crossover operators followed by the selection mechanism. Then, each solution within each loop in the evolutionary computational process is evaluated using a pre-determined objective criterion presented to fit to the optimization problem under consideration. In such a context, an objective value is allocated to each individual of the GAs to determine the solution quality of the individuals at each iteration loop of the evolutionary process. In general terms, the problem under study is usually represented by a number of individuals (i.e., chromosomes) that are commensurate with the nature of the problem. Each chromosome acts for a candidate potential solution. The fitness function in GA is always used to judge the quality of the solution of each chromosome in the population. Chromosomes undergo mutation and crossover operators throughout the evolutionary process, eventually leading to the following generation. The crossover operation integrates picked pairs of chromosomes to evolve the following generation that comes up with a new solution. Mutation is always used to prohibit coming down into local solutions. GA can be adapted to a wide range of problems and domains. Hence, it is widely known for its ability to solve complex optimization problems. GA has few mathematical requirements, and these implement an important characteristic of GA when used to address optimization issues. The main steps of GAs can be briefly outlined by a pseudo-code as illustrated in Algorithm A1.
Algorithm A1: Pseudo-code of GAs. 1: N ← Population size. 2: L ← Number of iterations. 3: l ← Current iteration. 4: P c ← Crossover rate. 5: P m ← Mutation rate. 6: Initialize the population of GA with a size of N. 7: Evaluate the fitness function of each chromosome using Equation (31) given below. 8: while l ≤ L do Selection: Select Parents from the current population. 9: Crossover: Perform crossover operation for offsprings with a probability of P c . 10: if (rand(0.0, 1.0) < P m ) then Mutation: Mutate the generated offsprings from the population. end Evaluation: Evaluate every chromosome using the fitness function. 11: Updating: Update the population by removing certain limit of lease fit solutions. end Results: Return the global best solution.
In the proposed work, the evolutionary GA process comprises a number of basic steps to reach the optimal movement and orientation of a quadcopter as given below: • Representation: This step uses a proper chromosome representation so that it can optimize the gain of the PID controller. In this case, the candidate solutions (i.e., individuals) are stored in a three-dimensional parameter vector. • Initialization: This step defines a set of chromosomes in the population and creates random values of genes for those chromosomes. • Evaluation: In this step, the fitness function value is recomputed for each chromosome generated in the initialization phase. • Selection: In this step, the roulette wheel selection mechanism is used to select the suitable chromosomes from the population for mating and the creation of the offsprings produced. • Crossover: A single point crossover mechanism is used to identify one point for each parent and to generate a new child, using a combination of all the data before the allocated crossover point from the first parent with all data after the allocated crossover point of the second parent. • Mutation: This genetic step implements a random tweak in the chromosomes to boost the diversity concept in the population. In other words, it is implemented by replacing the gene at a random position with a new value.

Appendix A.2. Particle Swarm Optimization
Particle swarm optimization is a well-known and familiar type of SI algorithm proposed by Kennedy and Eberhart in 1995 [31,53]. The main inspiration of PSO is to mimic the collective interactive behavior of non-intelligent social swarms, such as birds and fishes, with collaborating agents in nature. It represents a set of solutions (i.e., particles) that move in groups in the search space. The particles of PSO explore possible solutions in the search area and accelerate to the global solutions based on a predetermined criterion. The term "particles" was adopted because particles experience positions, velocities and accelerations of the swarms in accordance with specific equations that update the particles' movement. The particles of the PSO algorithm are updated at each iteration based on the optimal solutions found so far by all particles, as the best solution can be explicitly identified by the best updated particle. The position of each particle is controlled based on the fitness score of each particle as well as the fittest particle of the swarms in the search area. Equation (A1) can be used to update the velocity, v, and the position, x, for each particle for a number of n particles in PSO.
where i identifies the index number of each particle, d indicates the dimension of the problem under consideration, t identifies the iteration number, v id is the velocity of the ith particle in the dth dimension, p id represents the best position of the ith particle visited so far in the dth dimension, p gd represents the global best position of a particle in the swarm in the dth dimension, ω is a positive inertia weight, r 1 and r 2 are two randomly generated numbers between 0 and 1, α and β are two constants that represent the values of the degree of influence of p id and p gd on the particles velocity, respectively, and x id is the position of the ith particle in the dth dimension. Equation (A1) can be used to find a new solution in the search space and to update the global best solution. The key steps of PSO can be summarized as shown by the pseudo-code in Algorithm A2.
The PSO algorithm embraces exploration search properties, making it well suited for optimizing nonlinear functions and complex real-world problems. It is expected that through the use of PSO, there is a high probability of evading minimal local solutions over and over by encouraging more exploration of the search domain. This issue is concerned with the fact that survival is the ultimate goal for fish schooling and bird flocking. Consequently, PSO exhibits a coordinated behavior that distinguishes the social behavior of bird and fish swarms in nature.
There are many applications presented in the literature based on PSO that have reported convincing results in a wide range of optimization issues [28,54]. Today, there is rapid development in the use of meta-heuristic algorithms, and especially PSO, to address real contemporary problems, such as the problem under consideration. The particle representation for the problem under study is represented in Table A1. pbest ← Personal best solution. 5: gbest ← Global best solution. 6: p ← Best particle. 7: Initialize the positions of all N particles. 8: Evaluate the fitness function of each particle using Equation (31)  9: while While l ≤ L do foreach particle in p do Update pbest: 10: if ( f (p) < f (pbest)) then pbest = p. end Update gbest 11: if ( f (pbest) < f (gbest))then gbest=pbest end end foreach particle in p do Update velocity and position: using Equation (A1) end end Results: return gbest.

Appendix A.3. Crow Search Algorithm
The Crow Search Algorithm is a meta-heuristic algorithm inspired from the collective behavior of crows in nature [29]. Specifically, abstract ideas of living social behavior and crows feeding aspects led to the evolution of this algorithm with a mathematical model, described in detail in [29]. Many studies have reported in the literature that crows exhibit intelligent behavior and capabilities of intelligently hiding food in a specific location and the capabilities of finding it again. In such a context, crows communicate in a complex way, as they have a good memory of where they store their food. As such, CSA is a meta-heuristic population-based search algorithm, and it is implemented in accordance with the following rules: • Crows inhabit in nature in flocks. • Crows can recall the places in which they store their food and fetch it once more. • Crows can see other animals when they pillage their stored food. • Crows have the capacity to manage themselves in ratios to safeguard their unattended food.
To solve a particular optimization problem using CSA, the solution is represented as the position of the crows at any instant of time as given in Equation (A2).
x j,g = x j,g 1 , x j,g 2 , . . . , x j,g D (A2) where x j,g stands for the position of the jth crow at generation g and D identifies the dimension of the problem under study.
Similar to any population-based algorithm, CSA begins by randomly generating a pool of possible solutions, representing a flock of crows. As mentioned earlier, crows make use of their memory to recover hidden food placements, which implicitly typifies the quality of the crows' positions. The quality of each solution is judged by the fitness value computed from a fitness evaluation criterion used to solve the given problem. The quality of each solution is collected in a predefined array as stated in Equation (A3). The crows in flocks update their positions as per the following procedure: each crow j realizes another crow k from the flock to pursue it with the aim to locate the hidden food by the last crow, and is referred to as m k . This mechanism is illustrated in Equation (A4).
x j,k+1 = x j,g + r j × f l j,g × m k,g − x j,g r k ≥ AP k,g a random position Otherwise (A4) where r k indicates a random number generated from a uniform distribution in the interval from 0 to 1, and AP k,g stands for the awareness probability of crow kth at generation g. The solution quality is valued for each new crow position, using the fitness score obtained in each iteration. The crow's position is updated if its solution is better than the current crow's solution. However, the crow remains in place if the quality of its solution is lesser than that of the current crow. The crows' location memory can be updated, using Equation (A5). m j,g+1 = x j,g+1 f x j,g+1 is better than f m j,g m j,g Otherwise (A5) where f denotes the score value of the fitness criterion. Likewise, each crow updates its memory if its solution quality in the new position is higher than the memorized position. CSA is implemented in an iterative procedure: the new positions and memories of the crows are created, assessed, and updated at each iteration loop until convergence, in which a defined evaluation method fit to the problem under study is met.
In short, the iterative steps of CSA can be described briefly by an pseudo-code as outlined in Algorithm A3.
While the usefulness of CSA in optimization problems is incontrovertible, it has not been used to optimize a control problem. Therefore, in light of the stimulating results of the CSA in many fields, we explore, in this work, its significance in a control problem for optimizing the parameters of the PID controller of a quadcopter to control its movement.