Genetic Algorithm-Based Tuning of Backstepping Controller for a Quadrotor-Type Unmanned Aerial Vehicle

: Backstepping is a control technique based on Lyapunov’s theory that has been successfully implemented in the control of motors and robots by several nonlinear methods. However, there are no standardized methods for tuning control gains (unlike the PIDs). This paper shows the tuning gains of the backstepping controller, using Genetic Algorithms (GA), for an Unmanned Aerial Vehicle (UAV), quadrotor type, designed for autonomous trajectory tracking. First, a dynamic model of the vehicle is obtained through the Newton-Euler methodology. Then, the control law is obtained, and self-tuning is performed, through which we can obtain suitable values of the gains in order to achieve the design requirements. In this work, the establishment time and maximum impulse are considered as such. The tuning and simulations of the system response were performed using the MATLAB-Simulink environment, obtaining as a result the compliance of the design parameters and the correct tracking of di ﬀ erent trajectories. The results show that self-tuning by means of genetic algorithms satisfactorily adjusts for the gains of a backstepping controller applied to a quadrotor and allows for the implementation of a control system that responds appropriately to errors of di ﬀ erent magnitude.


Introduction
Nowadays, Unmanned Aerial Vehicles (UAV) enjoy great popularity in activities where video or photo shots are required, particularly quadrotor models (with four rotors). Due to their configuration [1], quadrotors can perform tasks that previously had to be performed from a helicopter or airplane by highly qualified personnel, which implies a high cost in terms of the vehicle (helicopter) and personnel (pilot and cameraman); furthermore, the risk to human life is eliminated with UAV. Current UAV can develop different activities such as exploration, transportation, mapping, reconnaissance, environmental monitoring, construction monitoring and surveillance [2][3][4][5][6][7] in civil, police or military activities [8,9]. The advances in robotics, mechatronics, and microelectronics facilitated the development of hardware at a low cost, coupled with the development of real-time processing for navigation. Quadrotors have very simple mechanics since the control of their position is determined by the changes in speed in their motors and they are used when high maneuverability is required, since they are capable of moving in any direction or flying at low speeds. Due to the complexity of the system, different algorithms have been developed to achieve autonomous control in Unmanned Aerial Vehicles, using techniques from linear control methodologies with PID [10,11], to nonlinear control techniques If the vehicle is considered as a rigid solid, the system has six degrees of freedom: three of them define the position of a reference point in the body (the center of mass), and the other three define the orientation of the body, so that, to obtain the model, the quadrotor is supposed to be a rigid body in space, subject to a main force and three moments, which together represent the control inputs of the system. This work will use the Tait-Bryan navigation angles ( , , ) ( Figure 2) to describe the rotation of the system in three-dimensional space. , ℎ angles for an aircraft. The fixed frame , , has been moved backwards from center of gravity (preserving angles) for clarity.
The navigation angles, known in mathematics as Tait-Bryan angles, are a set of three angles that describe the orientation of a rigid body-in this case, the drone-with reference to a fixed system. We considered two vector sets of a right-handed trihedron that belong to a fixed reference system and a body . The body initially allows rotation about the axis through angle ; the other axes, and , are carried along with the body, keeping their orthogonality. Now the drone rotates around axis ′ about angle . As before, the two axes ' and ′ are carried along with the body. Finally, the drone rotates about axis ′′ through angle such that axes ′′ and ′′ are carried along with the body. In each rotation, the other two axes are carried along with the body, so that the set of axes around which the rotations occur ( , , ′′) are not orthogonal. However, the orientation of the drone can now be described using the Tait-Bryan angle set , , .
This sequence is the preferred one to define the dynamics of air vehicles, and is defined with the transformation (1), where s means sine and c means cosine.
= cψsθsϕ − sψcϕ + sψcθ sψsθsϕ + cψcϕ sψsθsϕ − cψcϕ −sθ cθsϕ cθcϕ (1) Each rotation sequence defines a unique orientation of the drone. To solve for these angles, we must place the angles in the correct quadrant. These angles are limited to the range described in Equation (6): If the vehicle is considered as a rigid solid, the system has six degrees of freedom: three of them define the position of a reference point in the body (the center of mass), and the other three define the orientation of the body, so that, to obtain the model, the quadrotor is supposed to be a rigid body in space, subject to a main force and three moments, which together represent the control inputs of the system. This work will use the Tait-Bryan navigation angles (Φ, θ, ψ) ( Figure 2) to describe the rotation of the system in three-dimensional space. If the vehicle is considered as a rigid solid, the system has six degrees of freedom: three of them define the position of a reference point in the body (the center of mass), and the other three define the orientation of the body, so that, to obtain the model, the quadrotor is supposed to be a rigid body in space, subject to a main force and three moments, which together represent the control inputs of the system. This work will use the Tait-Bryan navigation angles ( , , ) ( Figure 2) to describe the rotation of the system in three-dimensional space. , ℎ angles for an aircraft. The fixed frame , , has been moved backwards from center of gravity (preserving angles) for clarity.
The navigation angles, known in mathematics as Tait-Bryan angles, are a set of three angles that describe the orientation of a rigid body-in this case, the drone-with reference to a fixed system. We considered two vector sets of a right-handed trihedron that belong to a fixed reference system and a body . The body initially allows rotation about the axis through angle ; the other axes, and , are carried along with the body, keeping their orthogonality. Now the drone rotates around axis ′ about angle . As before, the two axes ' and ′ are carried along with the body. Finally, the drone rotates about axis ′′ through angle such that axes ′′ and ′′ are carried along with the body. In each rotation, the other two axes are carried along with the body, so that the set of axes around which the rotations occur ( , , ′′) are not orthogonal. However, the orientation of the drone can now be described using the Tait-Bryan angle set , , .
This sequence is the preferred one to define the dynamics of air vehicles, and is defined with the transformation (1), where s means sine and c means cosine.
= cψsθsϕ − sψcϕ + sψcθ sψsθsϕ + cψcϕ sψsθsϕ − cψcϕ −sθ cθsϕ cθcϕ Each rotation sequence defines a unique orientation of the drone. To solve for these angles, we must place the angles in the correct quadrant. These angles are limited to the range described in Equation (6): . Navigation angles (Φ, θ, ψ) defined by Tait-Bryan. Yaw, pitch and roll angles for an aircraft. The fixed frame x, y, z has been moved backwards from center of gravity (preserving angles) for clarity.
The navigation angles, known in mathematics as Tait-Bryan angles, are a set of three angles that describe the orientation of a rigid body-in this case, the drone-with reference to a fixed system. We considered two vector sets of a right-handed trihedron that belong to a fixed reference system P i and a body P h . The body initially allows rotation about the x axis through angle φ; the other axes, y and z, are carried along with the body, keeping their orthogonality. Now the drone rotates around axis y about angle θ. As before, the two axes x and z are carried along with the body. Finally, the drone rotates about axis z through angle ψ such that axes x and y are carried along with the body. In each rotation, the other two axes are carried along with the body, so that the set of axes around which the rotations occur (x, y , z ) are not orthogonal. However, the orientation of the drone can now be described using the Tait-Bryan angle set φ, θ, ψ.
This sequence is the preferred one to define the dynamics of air vehicles, and is defined with the transformation (1), where s means sine and c means cosine. Each rotation sequence defines a unique orientation of the drone. To solve for these angles, we must place the angles in the correct quadrant. These angles are limited to the range described in Equation (6): To end the kinematic analysis, Equation (2) shows the matrix that relates to the angular velocities, where p, q, and r are the angular velocities in the fixed coordinate system in three-dimensional space.
Considering the above and using the Newton-Euler formulation, the forces and acting moments are established with respect to the established coordinate system (Figure 3). The equations that describe the dynamics of a rigid solid in space are as follows: Electronics 2020, 9, x FOR PEER REVIEW 4 of 25 To end the kinematic analysis, Equation (2) shows the matrix that relates to the angular velocities, where , , and are the angular velocities in the fixed coordinate system in threedimensional space.
Considering the above and using the Newton-Euler formulation, the forces and acting moments are established with respect to the established coordinate system (Figure 3). The equations that describe the dynamics of a rigid solid in space are as follows: Since the vehicle is held with the pushing force, the angles must be bounded, that is: From the previous equations, it is clear that is the translational velocity vector with respect to the fixed reference frame, is the angular velocity, m is the mass of the vehicle, represents the vector of forces acting on the vehicle, represents the torques applied to the system, and is the inertia matrix. Using Newton's second law, = , we obtain: where represents the transformation matrix between reference frames and represents the external forces applied to the body of the vehicle, which can be represented by: where is the force that occurs due to gravity, represents the gravity constant ( = 9.81 m/s ), and is defined as the aerodynamic force: where is a diagonal matrix that expresses the friction parameters. Knowing that is the force produced by the thrust of the propellers, it can be represented by the vector shown in Equation (10), which contains the forces , which are the thrust forces generated by each motor and are determined by: = Ω , where is the air density, is the thrust coefficient, is the area of the rotor disk, Given the following vectors: x, . y, Since the vehicle is held with the pushing force, the angles must be bounded, that is: From the previous equations, it is clear that V is the translational velocity vector with respect to the fixed reference frame, ω is the angular velocity, m is the mass of the vehicle, F represents the vector of forces acting on the vehicle, τ represents the torques applied to the system, and J R 3x3 is the inertia matrix. Using Newton's second law, F = ma, we obtain: where R I represents the transformation matrix between reference frames and F ph represents the external forces applied to the body of the vehicle, which can be represented by: where F g is the force that occurs due to gravity, g represents the gravity constant (g = 9.81 m/s 2 ), and A T is defined as the aerodynamic force: where K t is a diagonal matrix that expresses the friction parameters. Knowing that F emp is the force produced by the thrust of the propellers, it can be represented by the vector shown in Equation (10), which contains the forces f i , which are the thrust forces generated by each motor and are determined by: where ρ is the air density, C T is the thrust coefficient, A is the area of the rotor disk, R the radius of the propeller, and Ω is the angular velocity of each motor; since all values are constant with the exception of Ω, the constant b can be defined as b = ρC T AR 2 .
Substituting the corresponding values and using the correct vector operation in the previous equation, we obtain: Torques applied to the vehicle are obtained with a similar procedure, considering τ b as the external torque applied to the system that can be represented as follows: where A R represents the aerodynamic torques and is determined by the expression: Given ω = .
∅ . θ . ψ and K r represents torque's friction coefficients produced by the motors, τ a is a matrix with the torques generated on each axis and is determined by Equation (14): where Q i represents the torques generated by each of the four engines and is represented by the following expression: Q i = ρC q AR 3 ω 2 . Once the above equations have been determined, it is possible to represent the dynamic behavior of the system through the following set of equations: Operating and simplifying Equation (15), we reach: Electronics 2020, 9, 1735 6 of 24 ..
The procedure for obtaining angular accelerations is similar to that used to obtain the equations that describe linear behavior, obtaining: Equation (16) represents the translational dynamics of the vehicle, while Equation (17) represents the rotational dynamics of the vehicle; these equations provide a model that allows for studying and simulating the dynamics of the system.
When we try to control a system, the first step is to develop a mathematical model that is simple enough to be able to represent it, but as close to reality as possible; the more real variables we consider, the more complex the proposed mathematical model will be. When the system is too complex or time-variant, it is difficult to develop a mathematical model that can represent it. In this case, there are intelligent control techniques such as fuzzy control or neural networks, among others. Fuzzy control builds on the experience of an operator to propose a set of rules that can help control the system, and neural networks adjust to system changes regardless of the initial conditions. When there is the possibility of mathematically modeling a system, different algorithms can be developed and tested by means of simulations in software, which allows us to fine-tune the algorithm coefficients, thus increasing the probability of success in field testing with software and hardware under real conditions. This methodology has been tested in various investigations using specific software such as BikeSim, TruckSim, or CarSim for specific simulations of motor vehicles [42], or HARFANG 3D Framework for modern multimedia applications such as virtual reality [43], with MATLAB the most commonly used software for general process simulations, including autonomous guided vehicles (AGV) [44] and aerial autonomous guided vehicles (UAVs) [45][46][47].

Backstepping Control
Backstepping is a recursive control procedure based on Lyapunov's theory and is useful in the design of feedback control; it allows for the control of a nonlinear dynamic system and shows high performance in the face of parametric uncertainties, which is why this technique has been selected for the development of a controller that allows the quadrotor to track a preplanned path.
As a first step, the system is rewritten in state space f (X, U), Considering the vector of system states X as X = (x 1 , x 2 , x 3 , x 4 , x 5 , x 6 , x 7 , x 8 , x 9 , x 10 , x 11 , x 12 ).
By substituting the relationships described in Equation (18) into Equations (16) and (17) and neglecting the gyroscopic effects of the quadrotor, the system can be expressed as follows: Electronics 2020, 9, 1735 where The basis of the backstepping control strategy, like most control techniques, is based on reducing the system error. Control signal U 2 will be based on the system position error on the axis x: With its derivative being: .
A candidate function for Lyapunov V(z) is proposed; considering that it must be defined and positive and its derivative with respect to time must be semidefined and negative, it is proposed as follows: The derivative of Equation (23) is: To achieve the stabilization of z 1 , a virtual control input x 2 must be proposed: Given α 1 > 0 represents a control gain, taking the value of x 2 from Equation (25), we can rewrite Equation (21) as follows: .
We guarantee that the derivative of the proposed Lyapunov function is negative and semidefined. Substituting Equation (25) into Equation (22), we have: Solving .
Electronics 2020, 9,1735 8 of 24 So that it can be modified in the previous equation, the expression of the initial system error has been increased; to stabilize the new terms without modifying the previous system, the following variable change is made: With its derivative being: .
To cancel this new error function, an increased Lyapunov function is proposed: We derive Equation (32) as follows: .
φ as follows: .. where: Substituting Equation (32) into Equation (31) and assuming the acceleration reference has a null value (since it is assumed that the vehicle starts from a resting state), we obtain: Considering Equation (30) and satisfying . v(z 1 , z 2 ) ≤ 0, a control signal is proposed to guarantee it, thus obtaining: If the control signal U 2 proposed in Equation (34) is replaced, we obtain: This guarantees compliance with the Lyapunov criteria, a fact that establishes the expression obtained for the control signal U 2 as appropriate. The same procedure is performed to obtain the control signals U 3 , which is related to z 3 = x 3d − x 3 and z 4 = x 4 − . x 3d − α 3 z 3 ; U 4 , which stabilizes error z 5 = x 5d − x 5 and z 6 = x 6 − .
x 7d − α 7 z 7 ; therefore, the expressions defining said control signals are: Electronics 2020, 9, 1735 9 of 24 Equation (17) defines the movement of the vehicle on the x-y plane, and it can be seen that the only force that it depends on is the thrust U 1 . So U x and U y will be control signals used to calculate the warping and pitch angle necessary to move the drone in the x-y plane and the U x and U y signals must satisfy the condition V(z 9 , z 10 ) < 0, where z 9 = x 9d − x 9 and z 10 = x 10 − .
x 10d − α 10 z 10 , respectively, to ensure system stability. Following the same methodology that was followed to obtain the control signal U 2 , we obtain: Equations (34)-(37) represent the control signals necessary for path tracking. On the other hand, Equations (38) and (39) are used to determine the warping and pitch angles necessary for tracking the reference. The only value that remains unknown is α, so tuning of the controller is required.

Tuning the Backstepping Controller Using Genetic Algorithms
The response of a controller depends largely on the values of its gains; for PID-type controllers, there are tuning methods that allow attainment of the values of K p , K i , and K d , in order to obtain the desired response. However, there is no established method for tuning the α gains of a backstepping controller, which is due to one of the options being the so-called metaheuristic algorithms, within which are the genetic algorithms, so named because they are bio-inspired by the way in which nature selects the strongest genes.
Genetic algorithms will be used because they have greater capacity and adaptability as a universal optimization method; due to their random nature, it is difficult to compare metaheuristic algorithms, but some studies show that GA has a better speed-performance relationship [43], which is important in the development of this work due to the computational weight of the simulations.
The algorithm used is the Fixed-state Genetic Algorithm, which uses a generational scheme like that of mammals and other long-lived animals, where parents and their descendants coexist; however, in the long run, competition between them is generated. In this model, two parents must be selected, and certain members of the previous population must be eliminated to make space for the descendants, so that, after each crossing, the new descendants are immediately available for reproduction. This allows the model to use the characteristics of a promising individual as soon as it is created. The algorithm is based on the flowchart shown in Figure 4 and is basically divided into the following functions: create population, selection, reproduction, mutation, and reintegration into the population.
The process shown in Figure 4 is the overall method of this paper. First, a random population is proposed and the genetic algorithm selects the strongest genes (through reproduction and mutation) for a predetermined number of iterations; then, final values are proposed. The first stage of the implementation consists of defining the parameters used to search for profits. Using this algorithm, these parameters are summarized in Table 1.
The parameter "size of the population" provides genetic diversity, so a large number is desired; however, if the number is very large, the computational cost and the algorithm execution time also increase. With this in mind, the parameter was chosen as 100 initial individuals; this number provides adequate genetic variation without increasing the algorithm run time.
The parameter "generations" is eight and was selected experimentally, since when this number of generations elapsed, it was found that most of the population complied with the genetic model. The parameter "range" is the range of the gains α i and must by definition be greater than 0, so only an upper limit must be defined; for this work it was 30, because with higher numbers a saturation is observed in the torque. however, in the long run, competition between them is generated. In this model, two parents must be selected, and certain members of the previous population must be eliminated to make space for the descendants, so that, after each crossing, the new descendants are immediately available for reproduction. This allows the model to use the characteristics of a promising individual as soon as it is created. The algorithm is based on the flowchart shown in Figure 4 and is basically divided into the following functions: create population, selection, reproduction, mutation, and reintegration into the population. The process shown in Figure 4 is the overall method of this paper. First, a random population is proposed and the genetic algorithm selects the strongest genes (through reproduction and mutation) for a predetermined number of iterations; then, final values are proposed. The first stage of the implementation consists of defining the parameters used to search for profits. Using this algorithm, these parameters are summarized in Table 1. Probability that a selected gene will undergo a mutation. Biological pressure 30% Percentage of genes that will reproduce.

Model [t M ]
Vector that will use a genetic model to follow; t is the establishment time < 0.5 s and M is the maximum over-impulse < 5%.

Selection method Rank Selection
The individual with the best fitness gets rank N and the worst individual gets

Parameter Value Description
Size of the population 100 Quantity of initial α pairs. Generations 8 Number of iterations in which the algorithm will search.

Range 30
Maximum value of each α.

Mutation probability 20%
Probability that a selected gene will undergo a mutation.
Biological pressure 30% Percentage of genes that will reproduce.
Model t s M p Vector that will use a genetic model to follow; t s is the establishment time < 0.5 s and M p is the maximum over-impulse < 5%.
Individual α i α j α k α l Vector with four random α gains.

Selection method Rank Selection
The individual with the best fitness gets rank N and the worst individual gets rank 1. The selection probability is p(i) = rank(i) nx(n−1) Crossover type Single Point Crossover A random point is selected for swapping chromosomes.
The mutation probability was fixed at 20% because a very high number causes the algorithm to take longer to converge and a very low number causes stagnation. On the other hand, the biological pressure was set to 30%, which allows 30% of individuals to reproduce and eliminates 30% of the worst original population; this value allows for rapid convergence in each generation.
Finally, the strongest genes selected are those with the best fitness. This value was obtained by calculating the Euclidean distance between the M p value and the t s obtained by the evaluated genes and the values provided by the genetic model. For evaluation, the system is divided into three subsystems, one for each axis: the x subsystem has four associated α gains (α 3 , α 4 , α 9 , α 10 ), the Y subsystem has four associated α gains (α 1 , α 2 , α 11 , α 12 ), and the Z subsystem has four gains too (α 5 , α 6 , α 7 , α 8 ); this association is due to the displacement in the X axis caused by the roll angle; the movement in the Y axis is caused by the pitch angle. So, the tuning is done in every subsystem, evaluated under the step input as a reference. As in the design of control laws, the system is not tuned globally; instead, it takes advantage of the natural subdivision of the system. Therefore, the tuning of the X axis subsystem corresponds to the control law U 2 , which depends on the speed of rotors 1 and 3. The tuning of the Y axis subsystem corresponds to the control law U 3 , which depends on rotors 2 and 4. Finally, the subdivision of the Z axis system corresponds to the control laws U 3 and U 4 , which depend on the speed of the four rotors-that is why they are tuned together.

Results
In this section, numerical results are provided to facilitate the performance evaluation of the tuning backstepping controller using genetic algorithms. This algorithm was subjected to different tasks, which were split into two main sections. The first one refers to ideal conditions-that is, disturbances were not included. In the second study, random disturbances were considered to simulate the wind current effects.
Simulations were performed on Matlab/Simulink in order to test the validity of the proposed controller. An accurate dynamic model for the four-rotor rotorcraft was used, and the model was developed on the base of the Draganflyer. In addition, due to the inclusion of realistic effects on simulations, the calculation of parameters such as inertia, propeller pitch, maximum rotor speeds, and others was performed, and the information from the drone data sheet was used.
A set of solutions obtained by the genetic algorithm is shown to show the performance of the tuned controller. The selection was performed by means of the numerical simulation of the control law and the drone dynamics. The results are summarized in Table 2.

Experimental Validation
Using these gains, the final step response of the movements in the X, Y, and Z axes was simulated. The responses obtained determine if the tuning fulfills the parameters of the genetic model.
For a validation of the controller performance tuned by the proposed method, the UAV was subjected to a step input on each axis-that is, the system was subjected to the following reference inputs: a.
To prove x axis x r = 1; y r = z r = ψ r = 0; b.
To prove y axis y r = 1; x r = z r = ψ r = 0; c.
To prove z axis z r = 1; x r = y r = ψ r = 0; Figures 5-7 show the corresponding step response in each axis.
Using these gains, the final step response of the movements in the , , and axes was simulated. The responses obtained determine if the tuning fulfills the parameters of the genetic model.
For a validation of the controller performance tuned by the proposed method, the UAV was subjected to a step input on each axis-that is, the system was subjected to the following reference inputs:    Table 3 shows the numeric results, considering as the time necessary for the system response to not vary by more than 5% of the final value.   Table 3 shows the numeric results, considering as the time necessary for the system response to not vary by more than 5% of the final value.  Table 3 shows the numeric results, considering t s as the time necessary for the system response to not vary by more than 5% of the final value. Remembering that the genetic model is t s < 0.5 s and M p < 5%, we can observe that the values obtained by the GA fulfill these parameters for a step input. Subsequently, the system was tested with various trajectories, obtaining favorable results in each of the tests. The most relevant results are as follows: Task 1: xr = 1 2 * cos 1 2 * t − 1 2 ; yr = 1 2 * sin 1 2 * t ; zr = t 30 ; ψ r = π 3 ; Task 2: xr = (3) * cos(0.35 * t) * cos(0.35 * t); yr = (3) * cos(0.35 * t) * sin(0.35 * t); zr = (0.000875 * t); ψ r = π/9; with random disturbances (simulation of wind effects). Task 1. The system was tested with a clover-shaped reference. In this test, the quadrotor starts with an initial error of 1 m in position as shown in Figure 8, which is a challenge given the characteristics of the vehicle.  Remembering that the genetic model is < 0.5 and < 5%, we can observe that the values obtained by the GA fulfill these parameters for a step input. Subsequently, the system was tested with various trajectories, obtaining favorable results in each of the tests. The most relevant results are as follows: Task 1. The system was tested with a clover-shaped reference. In this test, the quadrotor starts with an initial error of 1 m in position as shown in Figure 8, which is a challenge given the characteristics of the vehicle. The results obtained as a response of reference from task 1 show that the tracking reference is appropriate. Figures 9-11 show the behavior of the drone in each axis. The results obtained as a response of reference from task 1 show that the tracking reference is appropriate. Figures 9-11 show the behavior of the drone in each axis.     The functioning of the system can be analyzed by observing the tracking errors in position and orientation, shown in Figures 12 and 13, respectively.  The functioning of the system can be analyzed by observing the tracking errors in position and orientation, shown in Figures 12 and 13, respectively.  As can be seen, the errors of the position and orientation tracking tend to 0 quickly and remain at that value throughout the 90 s of the analysis.
Task 2. Helical-type trajectory in which the quadrotor starts at an initial error of 0; additionally, a random perturbance was added during the simulation, t starting at 4.5 s and finishing at 9 s; the disturbance has random components that change in value during the disturbance. The biggest disturbance in simulation has components of 6.17 m/s, 5.97 m/s, and 3.45 m/s for x, y, and z, respectively, and a magnitude of 9.25 m/s. Through additional tests, it was determined that the designed backstepping controller is capable of rejecting a disturbance with a maximum magnitude of 10.1 m/s, as long as no component of the disturbance is greater than 6.6 m/s. The results of the controller under perturbation are shown in Figures 14-19 The effect of the disturbance can be observed from 4.5 s onward. It can be seen that the controller tuned with the gains in Table 2 is able to return to the desired trajectory once the disturbance disappears.
The helical path used can be seen in Figure 14. The performance of the controller in each of the axes of the fixed inertial system , , is shown in Figures 15-17 and the response of the system is compared against the reference path. As can be seen, the errors of the position and orientation tracking tend to 0 quickly and remain at that value throughout the 90 s of the analysis.
Task 2. Helical-type trajectory in which the quadrotor starts at an initial error of 0; additionally, a random perturbance was added during the simulation, t starting at 4.5 s and finishing at 9 s; the disturbance has random components that change in value during the disturbance. The biggest disturbance in simulation has components of 6.17 m/s, 5.97 m/s, and 3.45 m/s for x, y, and z, respectively, and a magnitude of 9.25 m/s. Through additional tests, it was determined that the designed backstepping controller is capable of rejecting a disturbance with a maximum magnitude of 10.1 m/s, as long as no component of the disturbance is greater than 6.6 m/s. The results of the controller under perturbation are shown in Figures 14-19 The effect of the disturbance can be observed from 4.5 s onward. It can be seen that the controller tuned with the gains in Table 2 is able to return to the desired trajectory once the disturbance disappears.         Finally, the errors in position and orientation, respectively, are shown in Figures 18 and 19. Note the effect of the disturbance and the correction of the controller when disturbance disappears.    Tests show that the controller is capable of following trajectories even in the presence of initial errors or random disturbances, such as those that can cause air currents in a flight. The system correctly manages the added error within a short response time because of the correct tuning of the The helical path used can be seen in Figure 14. The performance of the controller in each of the axes of the fixed inertial system x, y, z is shown in Figures 15-17 and the response of the system is compared against the reference path.
Finally, the errors in position and orientation, respectively, are shown in Figures 18 and 19. Note the effect of the disturbance and the correction of the controller when disturbance disappears.
Tests show that the controller is capable of following trajectories even in the presence of initial errors or random disturbances, such as those that can cause air currents in a flight. The system correctly manages the added error within a short response time because of the correct tuning of the controller; due to the lack of standardized methods, the application of the genetic algorithm shows appropriate results for field tests.

PID Controller
For comparison purposes, a PID-type controller was developed that allows for tracking a trajectory; in this way, the performance of the proposed backstepping controller can be compared. The control signal U(t) in a PID is represented by the sum of the value of the proportional, integral, and derivative components, which depend on the error; that is: The values of the constants Kp, Kd, and Ki determine the behavior of the PID. For the control of the AUV, six control signals of the PID type were implemented; again, the control signals in the xy plane will be used to determine the roll and pitch reference angles, and the four control signals (U 1 , U 2 , U 3 , and U 4 ) will be applied to their corresponding degree of freedom. The values of the control constants used for the PID controllers can be seen in Table 4. With the constants shown in Table 4, the drone is able to follow a trajectory, as shown in Figure 20.
For comparison purposes, a PID-type controller was developed that allows for tracking a trajectory; in this way, the performance of the proposed backstepping controller can be compared. The control signal U(t) in a PID is represented by the sum of the value of the proportional, integral, and derivative components, which depend on the error; that is: The values of the constants Kp, Kd, and Ki determine the behavior of the PID. For the control of the AUV, six control signals of the PID type were implemented; again, the control signals in the xy plane will be used to determine the roll and pitch reference angles, and the four control signals (U1, U2, U3, and U4) will be applied to their corresponding degree of freedom. The values of the control constants used for the PID controllers can be seen in Table 4. With the constants shown in Table 4, the drone is able to follow a trajectory, as shown in Figure 20. For a comparison with the backstepping controller, the design parameters ts and Mp will be considered. For this reason, it is necessary to evaluate the PID controller against step inputs such as trajectories a, b, and c.  For a comparison with the backstepping controller, the design parameters ts and M p will be considered. For this reason, it is necessary to evaluate the PID controller against step inputs such as trajectories a, b, and c. Figures 21-23 show the results of the PID controller.      Table 5 shows the numerical results from the PID controller.     Table 5 shows the numerical results from the PID controller.  Table 5 shows the numerical results from the PID controller.

Conclusions
In this article, we deal with backstepping controller gain tuning for a quadrotor using genetic algorithms. First, the dynamics of the quadrotor were developed using the Newton-Euler method. Then the equations of the rotational and translational dynamics of the system are presented. Subsequently, the setback control system, which is a recursive control procedure based on Lyapunov's theory, is presented; this control system shows high performance in the face of parametric uncertainties, as is clear from the time of establishment (0.5 s) and the maximum impulse (<5%) on different reference inputs and errors of different magnitudes. The stability analysis based on Lyapunov's theorem showed that the control proposal implemented by the self-adjustment of the gains leads to the error of the quadrotor having stability asymptotically. This is reflected in the comparison with other implemented methods; it can even be appreciated in the angles and perturbations implemented to test the method.
Compared with other backstepping controllers such as those presented by Amjad (2019), the present work obtains better results in terms of the error establishment time (less than 0.5 s) compared to the 3 s of the backstepping control proposed by Amjad. Although the systems are different, the controller is still the backstepping type.
Compared with the systems proposed for unmanned aerial vehicles, such as the one reported by Tennakoon and Munasinghe (2008), the present work has better results for the error settlement time, less than 0.5 s.
The present control proposal had satisfactory results in the simulations carried out in MatLab software, leaving as future work its physical implementation in a drone and the carrying out of real flight tests.