Adaptive Trajectory Tracking Algorithm of a Quadrotor with Sliding Mode Control and Multilayer Neural Network

To improve the trajectory tracking accuracy, the anti-jamming performance, and the environment adaptability of a quadrotor, the paper proposes a new adaptive trajectory tracking algorithm with multilayer neural network and sliding mode control method. ,e major difference between other related approaches is that the paper uses the multilayer neural network in the system and the neural network is online computing in the whole process. Firstly, the paper establishes the quadrotor dynamic model and introduces the conception of Sigma-Pi neural network. ,en, the paper adds the neural network to the attitude and trajectory tracking control loop. Moreover, the paper designs the adaptive neural network control law. At last, to illustrate the stability of the adaptive control law, the paper gives the Lyapunov stability analysis. Finally, to demonstrate the effectiveness of the method, the paper gives different types of simulation. Comparing with different cases, when increasing the layer of the neural network, the trajectory tracking performance becomes better. In addition, introducing multilayer neural network into the system could improve the anti-interference ability of the system and has a high-precision in tracking the desire trajectory.


Introduction
Nowadays, the quadrotor UAV is widely applied both in military and civilian areas [1][2][3]. At the same time, all these applications drive a continuous progress in path planning, system stability analysis, and trajectory tracking areas [4]. All these areas consisted of tracking the desire trajectory, designing a high control accuracy algorithm, and improving the environment adaptability of a quadrotor and others. However, it is well known that the quadrotor UAV is a strong nonlinear, underactuated, and highly coupled system [5]. So, how to design a proper control algorithm to tack the desire trajectory and improve the accuracy and stability of the system has become challenging research.
To research these problems, researchers have proposed many methods all over the world. FOPD (Robust Fractional-Order PD) Controller is researched for a Wheeled Mobile Robot (WMR) in reference [6], which firstly presents an improved flat phase property as a robust controller tuning specification to improve the controlled system robustness while this reference just considers how to guarantee the stability of the system and the tracking error is very large. To stabilize the translational and rotational motion of a quadrotor system and enforce it to track a given trajectory with minimum energy and error, a NLPID (nonlinear proportional integral derivative) controller is proposed in reference [7], where their parameters are tuned using a genetic algorithm (GA) to minimize a multiobjective output performance index. However, this reference just analyzes the certain conditions on the gains of the NLPID controllers and the tracking performance is very poor. To improve the system's transient responses, the genetic self-tuning PID algorithm is studied for the aerosonde UAV model in reference [8]. ough the GA is introduced to the PID algorithm to improve the intelligence degree, it does not analyze the pitching, rolling, and yawing characteristic of the UAV and the simulation is too simple. In reference [9], the strategies for Model Predictive Control (MPC) design and implementation for UAV are discussed. e main idea of this literature is the system identification techniques which are used to derive an estimate of the system model while the tracking performance and the environmental adaptability is so poor. To avoid the frequent periodic execution of the control tasks and reduce the computing cost, an eventtrigger-based fractional-order sliding mode control strategy is investigated in reference [10]. All simulations results demonstrated that the proposed controller based on the event-triggered technique can track the attitude command well. In reference [11], a new controller including an estimate of the external disturbance is proposed to deal with the presence of constant wind disturbance. When considering the external disturbance, this method just introduces the constant wind disturbance. A new adaptive controller is designed by using adaptive output feedback linearization and H∞ optimal control techniques in reference [12]. Simulation results show that the tracking errors is very large. An integrator backstepping approach is proposed in [13]. Several numerical simulation results verify the effectiveness in yaw direction. However, in this paper, it just uses this method in position control of the quadrotor. To deal with a quadrotor in the existence of matched disturbances, a barrier function adaptive nonsingular terminal sliding mode controller is designed in reference [14]. Several numerical simulations show the tracking performance using this method, while in this paper we will track more difficult curve and improve the external disturbance force. When considering input-delay, model uncertainty, and wind disturbance, an adaptive super-twisting terminal sliding mode control approach is designed in reference [15]. Comparing with the traditional sliding mode control method, the adaptive compensation term and the integral term are introduced to construct the sliding surfaces. Several simulations are provided to demonstrate the validation and success of planned control technique. As in [16], the Backstepping, Feedback Linearization control-oriented algorithms, NLGL, and Carrot-Chasing geometric algorithm are implemented and a quadrotor simulation platform is compared. Considering the disturbances and input constraints, the paper proposes a novel finite-time backstepping approach to tackle the trajectory tracking problem of quadrotors in reference [17]. Several contrast simulations demonstrate the effectiveness and superiority of the method. However, it is obvious that the performance is not better with large angle manoeuvring. To solve the parametric uncertainties and external disturbances, an extended state observer-based robust dynamic surface trajectory tracking controller is designed in reference [18]. e main idea of this literature is that it designs the extended state observers to online estimate the unmeasurable velocity states and lumped disturbances existed in translational and rotational dynamics, respectively, based on the separate outer-and inner-loop control methodologies. From different simulations, we will conclude that this method can track different shaped trajectories, but the tracking error is large. To track the moving target, a Fuzzy-PI controller is developed in [19]. It uses the position data as input to adjust the parameters of the PI controller. Several simulations of a quadcopter tracking a moving target are conducted in different environments to verify the performance of the system. Above all these classical trajectory tracking methods, many researchers start introducing neural network into the UAV control system, especially in recent years. In reference [20], an adaptive switch controller (ASC) is proposed for the nonlinear multi-input multi-output system (MIMO). In this paper, the ASC is an online switch between the neural network adaptive PID (APID) controller and the neural network indirect adaptive controller (IAC). rough this method is workable, it does not consider any disturbance or parameter perturbation and just track the 2D curve. A robust neural adaptive BS control is designed to deal with the limitations proposed in [21]. Using this method, a neural approximator is introduced to estimate and compensate for the perturbations. In [22], the BP neural network is just used to train the flight data before constructing the related dynamic model and BP neural network plays a very weak role during the flight course. To deal with the UAV landing on a ground marker, an autonomous quadrotor landing algorithm using deep reinforcement learning is proposed in [23]. From all simulations, it is clear that this method just uses deep reinforcement learning approach to train the landing data. An adaptive dynamic controller to track a trajectory in 3D space is proposed in [24]. is controller structure consists of a kinematic controller that generates reference commands to a dynamic compensator in charge of changing the reference commands according to the system dynamics. Using this method, the parameters of the dynamic compensator are directly updated during navigation, configuring a directly updated self-tuning regulator with input error, aiming at reducing the tracking errors, thus improving the system performance in task accomplishment. However, the tracking performance is poor. In [25], the performance and accuracy of the inner control loop providing attitude control are investigated when using intelligent flight control systems trained with state-of-the art RL algorithms, deep deterministic gradient policy (DDGP),trust region policy optimization (TRPO) and proximal policy optimization (PPO). However, this method just develops an open-source high-fidelity simulation environment to train a flight controller attitude control of a quadrotor through RL off-line training.
In a word, it is clear that when using neural network in the UAV control system, all those previous researchers often use signal layer neural network or use it to train the flight data offline. However, the prominent disadvantage of using signal layer neural network and off-line calculation is that the environment adaptability is very poor. So, to improve the trajectory tracking accuracy and the environmental adaptability, the multilayer neural network is introduced into the control system and the major difference between previous methods is that the multiplayer neural network is online calculation. So, after introducing the conception of neural network, it is added to the quadrotor dynamic model to compensate the model error and external disturbance. Moreover, the neural network is added to the attitude and trajectory tracking control loop, and then taking three layers neural network as an example, the paper designs the adaptive neural network control law. At last, to illustrate the stability, the paper gives the Lyapunov stability analysis. e rest of the paper is organized as follows: the trajectory tacking problem is defined in Section 2. In Section 3, the quadrotor dynamic model is presented. Section 4 gives the Sigma-Pi neural network and designs the Sigma-Pi neural network control law. e stability analysis of the control law will also be given in this section. Section 5 reports the comparative simulation results of different algorithms and discusses their performance. Finally, Section 6 points out some conclusions about the proposal. e future recommendation is given in Section 7.

Trajectory Tracking Problem
In this paper, it addresses the trajectory tracking control problem of a quadrotor. is problem is defined as making a quadrotor track the pre-established trajectory in 3D space.

Trajectory Tracking Definition.
e desired trajectory be described by a curve . c f represents the total virtual arc length in the space. en, the trajectory tracking problem can be regarded as designing an appropriate controller that ensures convergence of the position P(t) to τ d (c). e desire trajectory τ d (c) and position P(t) are shown in Figure 1.

Coordinate Definition.
To describe the relative motion of the quadrotor, the coordinate frames are defined as follows.

Inertial Coordinate Frame.
In this paper, the earth coordinate frame ς e is assumed as the inertial coordinate denoted as ς e � O e , x e , y e , z e , and it is located at the surface of the earth with x e in the direction of North, y e pointing West, and z e pointing opposite direction to the centre of the Earth.

Body-Fixed Coordinate Frame.
As can be seen in Figure 1, the coordinate system denoted as e origin of the body-sfixed reference frame coincides with the centre of the quadrotor. In this coordinate, x b points front rotor, y b points the left rotor, and z b points the direction such that the orthogonal triad and right-hand rule are satisfied.
e detailed information of this coordinate is shown in Figure 1.

Transformation Matrices. As defined previously, ς b
and ς e will be used in the derivation of the dynamic model. By making successive rotations around corresponding axis, one can obtain the transformations matrices. en, using this approach, the transformation matrix L be that transforms from ς e to ς b is as follows: Using the same approach, the transformation matrix L be that transforms from ς b to ς e is as follows: In (1) and (2), s( * )c( * ) represents sin( * ) and cos( * ) function, respectively. en, from (1) and (2), it is clear that

Quadrotor Dynamic Model
Before presenting the dynamic model, the paper considers that the quadrotor is a grid body and be just affected by gravity, thrust, and aerodynamic drag during the flight. en, using Newton's equations of motion for translational and rotational dynamics, the dynamic model of the quadrotor will be obtained as follows: T refer to the quadrotor's position and velocity vector, respectively. m is the mass, and g is the gravitational acceleration constant. e � [0 0 1] T is a unitary vector. K t denotes the aerodynamic drag coefficient, which is a diagonal matrix. w � [p q r] T is body angular velocity and its time derivative T represents rate of change of Euler angles, which denote roll, pitch, and yaw angles, respectively. e rotation matrix R from ς b and Complexity ς e is dependent on these three Euler angles. J represents the approximate inertia matrix. e rotation matrix R and the body inertia matrix J are denoted as follows: where M is denoted as follows: In addition, F thrust represents the resultant thrust force defined as follows: 3.1. Linearization. From (5), the rotation matrix R can be simplified by making the assumption that the body angular velocities w and rate of change of Euler angles _ Θ are equal if perturbations from hover condition are small. en, the rotation matrix R can be written as follows: Finally, the relation between body angular velocities w and rate of change of Euler angles _ Θ becomes Combining all these equations, the dynamic model of a quadrotor can be written in the following form: where u x , u y , and u z are

Sigma-Pi Neural Network.
Like other neural networks, the Sigma-Pi neural network also consists of input layer, hidden layer, and output layer. e hidden layer consisted of the summation neurons and quadrature neurons. e advantages of this structure are that it not only preserves the highly nonlinear mapping ability but also increases the flexibility of the network. So, according to the specific problem, one can construct the appreciate networks to improve the learning efficiency. e typical structure of Sigma-Pi neural network is shown in Figure 2.

Complexity
As shown in Figure 2, the command and the state feedback consist the input space of neural network. e hidden layer is composed of alternating summation neurons and quadrature neurons. X i is an N-dimensional vector, and x i is the i th element of X. W ij is an adjustable weight from X i layer to j th quadrature neurons in hidden layer, and hidden layer also has W jk which is an adjustable weight from j th quadrature neurons to summation neurons. Choosing different hidden layer, there is an involved weight matrix between each layer. h ij is the j th quadrature neurons for i th output. Y N is the output of the neural network. en, the equation of Sigma-Pi neural network is as follows: In (12), m is the net layers of neural network excepting output layer. When m � 1, the hidden layer just has a signal net layer with quadrature neurons. σ(x) denotes the nonlinear activation function and is selected as the logistic function, σ(x) � 1/(1 + e − x ) for all the results reported in this paper. β represents the basic function vector. θ ij denotes the adjustable threshold of the j th quadrature neurons of the i th output. In this paper, it will talk about adding the neural network to attitude and position control system.

Sigma-Pi Neural Network Control Structure.
To design the corresponding Sigma-Pi neural network control law, this paper will combine the sliding mode control method. e control structure is shown in Figure 3.
As shown in Figure 3, it includes trajectory references module, command filter module, controller, adaptive control module, dynamics module, and sliding mode control module. e adaptive control structure is shown in Figure 4.
As shown in Figures 4 and 5, U NN represents the control input calculated by neural networks. e number of hidden layers and neurons is determined by the specific problem. In this paper, we will discuss the one or three hidden layers Sigma-Pi neural network.

Adaptive Control Law Design.
In this section, this paper will design the adaptive control law. Combining (4) and considering the modelling error, equation (4) can be written as follows: where X 1 � [ϕ θ ψ x y z] T presents the Euler angles and position of the quadrotor; U NN represents the neural network control input; e � [e ϕ e θ e ψ e x e y e z ] T denotes the modelling error; U represents the input generated by rotors; and M denotes the moment generated by fours rotors. In this paper, the neural network is used to compensate the tracking error. If we choose different hidden layers, the control input U NN will be different. If we chose a signal hidden layer, the neural network will become a neural network with the input layer and a signal hidden layer with quadrature neurons. en, the neural network control input U NN can be written as follows: where β represents basis function vector which is defined as follows: where kron represents the Kronecker product.
To design the adaptive control law, the paper defines that U 8 NN is the optimal neural network control input. en, we will get the following equation: where W * T ij represents the optimal weight coefficient matrix; then, the error between the optimal control input and the modelling error can be expressed as follows: So, choosing different hidden layers, we will get different Sigma-Pi neural network control input NN U .

Attitude Control Law Design.
e attitude control law will be designed in this section, and then the paper will give the appropriate Lyapunov-type stability analysis.

Theorem 1.
e adaptive attitude control law with three layers neural network for yaw, roll, and pitch is defined as follows.
Proof. Firstly, the roll angle x 1 (ϕ) tracking error can be defined as follows: en, the first-order differential equation _ e 1 can be obtained as the following equations: According to (22) and (23), we can construct the sliding surface as follows: en, the first-order differential function _ s can be defined as the following equation: where κ 1 � (I y − I z )/I x and κ 2 � d/I x . According to (23), we can select the control law U 2 as follows: Substituting into (22) and (23), the first-order differential s function is as follows: where η ≥ κ 2 θ * ij .
en, the paper defines the Lyapunov function related tos and W * T ijϕ .

V s, W
en, the first-order differential equation _ V(s, W * T ijϕ ) can be defined as the following equation: According to (26), we will define the adaptive control law as follows: Substituting into (26) and (27), the first-order differential _ V(s, W * T ijϕ ) function is as follows: According to (29), when η ≥ κ 2 θ * ijϕ , the Lyapunov function _ V(s, W * T ijϕ ) ≤ 0. e system is stable. Using the same method, we can get the adaptive Sigma-Pi neural network control law of the pitch and the yaw channel.

Position Control Law Design
Theorem 2. e adaptive position control law with threelayer neural network in the x, y, and z direction is defined as follows: To reduce the trajectory tracking error, the paper also adds the Sigma-Pi neural network to quadrotor position control loop. Using the same method, we can get the Sigma-Pi neural network compensation control law in the x, y, and z direction. Firstly, we will define the tracking error in x direction as follows: en, the first-order differential equation _ e 4 can be obtained as the following equations: According to (32) and (33), we can construct the sliding surface as follows: en, the first-order differential function _ s can be defined as the following equation: According to (11), _ x 8 is defined as follows: where κ 7 � k x /m. en, we can get the function _ s as follows: en, where η ≥ θ * ijx . en, we can define the Lyapunov function which is related to s and W * T ijx .
en, the first-order differential equation _ V(s, W * T ijx ) can be defined as the following equation: 8 Complexity According to equations (13), (31), and (38), _ V(s, W * T ijx ) can be written as follows: According to (41), the Lyapunov function _ V(s, W * T ijx ) ≤ 0. e system is stable. Using the same method, we can get the adaptive Sigma-Pi neural network control law in the y and z direction.

Numerical Simulation
In this section, several numerical examples will be introduced to demonstrate the effectiveness of the adaptive control law. e simulation parameters of quadrotor are shown in Table 1. In this paper, to solve the problem and simulate all experiments, we all use Matlab Simulink software and the computer we used is inkPad E480. e parameter of this computer is shown in Table 2.

Case A: Simulation with Different Hidden Layers.
In this case, the paper will demonstrate that the tracking performance will be better when increasing the hidden layers. So, the paper uses different hidden layers neural network to track the same curve. e desired curve is shown in Table 3. Simulation results are shown in Figures 6-8.
As can be seen in Figure 6, it illustrates the trajectory tracking results using different hidden layers neural network. ese three curves are reference curve, the tracking curve with a signal hidden layer, and the tracking curve with 3 hidden layers. It is clear that the quadrotor can soon track the desire trajectory using three hidden layers neural network. To be more specific, it is observed that with increase in hidden layer, the tracking performance becomes better. e curve of tracking error by using neural network with different hidden layers is shown in Figure 7. It is obvious that the tracking error with three hidden layers neural network is obviously small in each direction. To be more specific, we can also observe that using three hidden layers neural network, the track error will be soon converged to 0 before 4s in each direction. So, we can conclude that with the increase in network layers, the tracking error will be soon converged and the tracking time can also be decreased.
As can be seen in Figure 8, it gives the attitude angle change of the quadrotor by using different hidden layers neural network. By contrast, we can observe that with the increase in the hidden layer, the attitude angle jitter is Table 3: Parameters of desired trajectory.

Symbol
Description Value x 1 Desire trajectory (x 1 ) t/s y 1 Desire trajectory (y 1 ) 3 * sin(t/4 + pi/2)/m z 1 Desire trajectory (z 1 ) 3 + 3 * sin(t/4)/m   obviously eliminated. It also demonstrates that introducing the neural network into the attitude control loop can improve the stability of the system. At the same time, it can decrease the jitter of the control system.

Case B:
Tracking 3D "8-Shaped" Spiral Curve. In this simulation, the paper will evaluate the lift, sideslip, and forward performances of a quadrotor to track the "8-shaped" spiral curve using three hidden layers neural network. Comparing with reference [24], we increase the tracking difficulty that the initial position error is larger and improve the frequency of sine curves. e desired curve parameters are shown in Table 4. All these simulation results are shown in Figures 9-12. Figures 9 and 10 show the result of tracking "8-shaped" curve based on the adaptive trajectory tracking method proposed in this paper. From different perspectives, we can observe that the quadrotor can soon track the desire trajectory. It is also demonstrated that the quadrotor has a better performance in lift, sideslip, and forward. Comparing with reference [24], the tracking performance is better, even increasing the tracking difficulty. Figure 11 shows the trajectory tracking error curve when tracking the "8-shaped" curve. Comparing with reference [28], when tracking the same 8-shaped trajectory, it is obvious that the tracking error in each direction is very small and the initial tracking error will be soon converged to 0 before 3 s. Figure 12 shows the change of attitude angle. It is obvious that despite the initial attitude angle fluctuates greatly, the attitude will be soon converged. e main reason for this phenomenon is that the difference between the initial position, pointing and the desire position, pointing.

Case C: Anti-Interference Simulation.
To verify the disturbance rejection properties of the method, we will add the external disturbance which effects the translation motion in x, y, and z direction. In the simulation, the quadrotor will also track the 3D curve used in Case A and uses three hidden layers neural network to compensate the tracking error. e involved 3D curve parameters are shown in Table 5.
As shown in Table 5, the paper will regard the white noise as the external disturbance force added to the system and the units of this force is N. e corresponding disturbance force curve is shown in Figure 13. As shown in Figure 13, it is clear

Symbol
Description Value x 1 Desire trajectory (x 1 ) t/s y 1 Desire trajectory (y 1 ) 3 * sin(t/4 + pi/2)/m z 1 Desire trajectory (z 1 ) 3 + 3 * sin(t/4)/m x 1 Init (x 1 ) 0/m y 1 Init (y 1 ) 3/m Complexity that the change of the noise force is so random and the magnitude of the force is bigger than reference [10]. So, this type of the external force is very suitable to verify the disturbance rejection properties of the method proposed in this paper.
e trajectory tracking results in disturbance circumstance are shown in Figures 13-17.
As can be seen in Figures 14 and 15, even adding the external disturbance to the system, the quadrotor still tracks the desire curve well. In addition, we can also observe that when disturbances occur, the tracking curve fluctuates slightly. However, the quadrotor will soon be stabilized. Figure 16 shows the trajectory tracking error curve of the quadrotor. It is obvious that despite adding the strong noise to the system, the tracking error in each direction is very small and the initial tracking error will be soon converged to 0 before 4 s. As a whole, the system is unaffected by the noise force. Comparing with reference [26], it is clear that the method proposed in this paper has a strong anti-interference feature. Figure 17 shows the change of the attitude angle. It is obvious that when adding the noise force to each direction, the involved Euler angles fluctuate slightly. is illustrates that introducing the neural network to the system can improve the ability of anti-inference. It also demonstrates that the external disturbances can be successfully rejected.

Conclusions
is paper proposes a new adaptive trajectory tracking algorithm of the quadrotor by introducing multilayer neural network into the system. First of all, the paper gives the dynamic model of the quadrotor. en, the principle of Sigma-Pi neural network was introduced. At the same time, the paper designs the corresponding adaptive control law and gives the Lyapunov-type stability analysis. To demonstrate the effectiveness of the method proposed in this paper, several involved simulations are given. By comparison, using the adaptive control method proposed in this paper can decrease the tracking error and improve the stability of the system. We also conclude that with increasing the neural network layer, the trajectory tracking performance is becoming better.

Future Recommendations
ough a new adaptive trajectory tracking algorithm is better than traditional process especially in having a highprecision in trajectory tracking, the stability of the system is improved.
ere remain many problems such as how to transplant the adaptive trajectory tracking algorithm to the platform. In our experience, we cordially recommend the Xilinx-Z7 platform. When transplanting the algorithm, we will face how to simplify the algorithm model to increase computational efficiency. We will continue researching all these problems in the future.

Data Availability
e data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
e authors declare that they have no conflicts of interest.