Position Control of Quadrotor UAV Based on Cascade Fuzzy Neural Network

: In this article, a cascade fuzzy neural network (FNN) control approach is proposed for position control of quadrotor unmanned aerial vehicle (UAV) system with high coupling and un-deractuated. For the attitude loop with limited range, the FNN controller parameters were trained ofﬂine using ﬂight data, whereas for the position loop, the method based on FNN compensation proportional-integral-derivative (PID) was adopted to tune the system online adaptively. This method not only combined the advantages of fuzzy systems and neural networks but also reduced the amount of calculation for cascade neural network control. Simulations of ﬁxed set point ﬂight and spiral and square trajectory tracking ﬂight were then conducted. The comparison of the results showed that our method had advantages in terms of minimizing overshoot and settling time. Finally, ﬂight experiments were carried out on a DJI Tello quadrotor UAV. The experimental results showed that the proposed controller had good performance in position control.


Introduction
The quadrotor unmanned aerial vehicle (UAV) plays an important role as a flying platform.With decades of rapid development, quadrotors are widely used in civilian and military applications for monitoring [1], transportation [2], cluster flight lighting shows, etc.Therefore, stable and precise position control is the basis of these applications and remains one of the key areas of research [3].
A quadrotor is a classical nonlinear underactuated system with multiple highly coupling variables.Generally, the quadrotor control system includes two control loops: the position loop (outer loop) and the attitude loop (inner loop).Until now, researchers have developed a significant number of control methods to deal with UAVs, including proportional integral derivative (PID) controller, linear quadratic regulator (LQR) [4], nonlinear [5] sliding mode controller [6], backstepping, fuzzy logic, adaptive neural networks, reinforcement learning, and so on [7].Elie Hermand et al. proposed a constrained control scheme to steer an UAV to the desired position while ensuring constraint satisfaction at all times.They used the Explicit Reference Governor framework and validated the proposed scheme through extensive experimental studies [8].Jian Dong and Bin He designed a novel fuzzy PID type iterative learning controller for a quadrotor and used fuzzy control to tune the PID parameters [9].Fabio A. A. Andrade et al. proposed a novel control strategy for UAVs, combining a Cascaded-PID with a fuzzy logic controller [10] and provided a method for fine-tuning the fuzzy range of PID gains values.Khadija El Hamidi et al. deployed fuzzy logic and neural network to schedule PID gains and improve trajectory tracking performance [11].The results presented therein confirmed the effectiveness of the proposed control strategy.

Khadija El Hamidi et al. presented an effective control method based on neural network
Energies 2022, 15, 1763 2 of 18 gain-scheduled proportional-derivative (PD) and model reference controller-based PD for quadcopter attitude stabilization and altitude tracking [12].In Ref. [13], Guiqiu Liao and Jiankang Zhao presented a method based on neural network mapping for the cascade PID parameters tuning.However, their experiment data only demonstrated the efficiency of this method in altitude control while ignoring the effect of horizontal position.Rongjong Wai [14] and Vu Phi Tran [15,16] applied an online adaptive neural network controller to control a quadrotor with high stability in surveillance tasks, particularly in flight environments with uncertainties such as unpredictable wind gusts.Qualid Doukhi provided a robust adaptive controller with an artificial neural network (ANN) and PID, as well used a cascade neural network PID (NNPID) for trajectory tracking [17].The simulation results demonstrated that the closed-loop system's stability was guaranteed under extreme conditions.Qingzheng Xu developed a novel NN finite time backstepping controller based on an anti-saturation control approach [18], which not only retains the benefits of NN finite time back-stepping control, but also protects the system from deterioration or even instability caused by unknown nonsymmetric saturation nonlinearities in the actuator.The effectiveness of the controller was verified through the numerical simulation results.
The above-mentioned studies indicate that fuzzy logic and ANN can all tune PID parameters online to control UAVs adaptively, and the system's stability can be achieved [19].As a result, the method combining fuzzy logic with ANN could be a promising method, in which a fuzzy expert system is used for forward inference control, and ANN is used for online adaptive adjustment based on feedback information.Xinchen Qi et al. studied an aerial manipulator control based on a fuzzy neural network (FNN) for complex tasks [20].The stability of a UAV with a manipulator is improved by blurring the attitude error signal as the input of the neural network.Halima Housny et al. researched a PSO-based ANFIS controller for quadrotor system trajectory-tracking control [21].A PID control approach is used to obtain the training dataset to design an adaptive neuro-fuzzy inference system (ANFIS) controller.The controller is mainly for the inner loop and provides attitude stability; position error effects are not considered in this paper.Boumediene Selma et al. also proposed an intelligent controller based on ANFIS and improved ant colony optimization to govern the behavior of a three-degree-of-freedom quadrotor.The simulations revealed that the proposed controller provided results more satisfactory than those of other methods already developed in the same study [22,23].To deal with the lack of modeling and flight uncertainties, Erdal Kayacan et al. used a learning controller composed of a fuzzy neural network in parallel with a conventional proportional controller for control and guidance of a fixed-wing UAV, and the simulation results showed efficiency in a real-time system [24].Andriy Sarabakha et al. proposed a Levenberg-Marquardt-inspired sliding mode control theory based on adaptation laws to train an intelligent FNN controller for a quadrotor aircraft.Experimental results show that the combination of PD and FNN, which is tuned by SMC and LM algorithms, gives significantly less steady-state error than a conventional PD controller in the presence of time-varying wind conditions [25].Erdal Kayacan et al. [26] and Tien-LOC LE et al. [27] used a type-2 FNN-based controller which included a multilayer structure in membership function for improvement of the learning ability and flexibility of the design network.This controller with the optimal tuning algorithm is superior to a conventional PD controller in noise reduction in presence of unmodeled noise and disturbances.To handle the payload uncertainties and disturbances in real time, Praveen Kumar Muthusamy developed a novel bidirectional fuzzy brain emotional learning (BFBEL) controller to control a six-degrees-of-freedom quadrotor UAV for accurate trajectory tracking [28].Nevertheless, the controller proposed in the paper requires a large amount of calculation.
Therefore, this paper will try to develop a different cascade fuzzy neural network control strategy to realize the accurate position control of quadrotor UAV.According to the difference between in inner and outer loops, in attitude loop, we trained a FNN controller offline while training the FNN controller online in position control loop.This control strategy avoided the problems that arise when the inner and outer loop are learning at the same time and could also reduce the amount of computation.
The rest of the paper is organized into five parts as follows: Section 2 provides the model of the quadrotor UAV adopted in the experiment, while the cascade fuzzy neural network controller (FNN-FNN) is designed in Section 3. In Section 4, the simulation of quadrotor position control using MATLAB is studied.The experimental verification part is given in Section 5. Finally, the conclusion is drawn in Section 6.

Quadrotor Modeling
Quadrotors have two types of layout configuration, as shown in Figure 1: type "+" and type "×".The two types of quadrotors have different torque distributions [19].Since the main perception direction of the camera, Lidar, and other sensors can be installed in line with the type "×" quadrotor's heading to avoid being blocked by rotors, type "×" is a more popular layout type.In this paper, the type "×" quadrotor was the main research object for modeling and experiments.
the difference between in inner and outer loops, in attitude loop, we trained a FNN controller offline while training the FNN controller online in position control loop.This control strategy avoided the problems that arise when the inner and outer loop are learning at the same time and could also reduce the amount of computation.
The rest of the paper is organized into five parts as follows: Section 2 provides the model of the quadrotor UAV adopted in the experiment, while the cascade fuzzy neural network controller (FNN-FNN) is designed in Section 3. In Section 4, the simulation of quadrotor position control using MATLAB is studied.The experimental verification part is given in Section 5. Finally, the conclusion is drawn in Section 6.

Quadrotor Modeling
Quadrotors have two types of layout configuration, as shown in Figure 1: type "+" and type "×".The two types of quadrotors have different torque distributions [19].Since the main perception direction of the camera, Lidar, and other sensors can be installed in line with the type "×" quadrotor's heading to avoid being blocked by rotors, type "×" is a more popular layout type.In this paper, the type "×" quadrotor was the main research object for modeling and experiments.Before modeling, two coordinate frames were introduced: the body frame (see Figure 1b) and the Earth frame.The rotation matrix from body frame to the Earth frame is: where c and  denote cos and cos functions, respectively, whereas s and  denote sin and sin functions, respectively.
The following assumptions were made to simplify the modeling process: ①.The aircraft is a rigid body and the mass and shape remain the same during the flight.
②. Assuming that the discharge capacity of the battery does not decrease with time, the same lift force will be generated at the same speed.
③.The area of motion is limited, where the density of hollow air and the gravitational acceleration remain constant during the flight.
According to Newton's law of motion Euler equation, quadrotor dynamics and kinematics equation can be written as: Before modeling, two coordinate frames were introduced: the body frame (see Figure 1b) and the Earth frame.The rotation matrix from body frame to the Earth frame is: where cθ and cψ denote cos θ and cos ψ functions, respectively, whereas sϕ and sψ denote sin ϕ and sin ψ functions, respectively.
The following assumptions were made to simplify the modeling process: 1 .The aircraft is a rigid body and the mass and shape remain the same during the flight. 2.Assuming that the discharge capacity of the battery does not decrease with time, the same lift force will be generated at the same speed. 3.The area of motion is limited, where the density of hollow air and the gravitational acceleration remain constant during the flight.
According to Newton's law of motion Euler equation, quadrotor dynamics and kinematics equation can be written as: where F T = [0, 0, T] T is the lift generated by the four rotors, F g = [0, 0, g] T is the gravity of the Earth, F d is the translational drag of the airframe, p = p x , p y , p z T is the UAV's position under the Earth frame, J is the matrix of rotational inertia, and ω = [p, q, r] T is the angular speed in the body frame.p, q and r are the angular velocities of roll angle, pitch angle, and yaw angle in the body frame, respectively.M τ = [τ X , τ Y , τ Z ] T are the roll, pitch and yaw torques, respectively.The UAV control input relationship with the rotor velocity can be shown as Equation ( 4): where C T is the lift coefficient of the propeller, d is the length of UAV arm, C M is propeller torque coefficient, and w i is the i-th rotor velocity, i = 1, 2, 3, 4.
The more detailed dynamic and kinematics relationship can be rewritten as:

Control System Design
For the quadrotor, six outputs including the three attitude angles and three-dimensional position values were controlled by four inputs of its control system, so it was a highly coupled underactuated object difficult to control.
Inspired by cascade control and the FNN control idea, a cascade FNN based control structure for a quadrotor UAV was designed as shown in Figure 2. In the position loop, rough adjustment results could be obtained by PID controllers, and FNN controllers would be trained to compensate the PID controller through online learning algorithms.In the attitude loop, the FNN attitude controllers were trained offline to save computational resource, since the Euler angles of the quadrotor changed within a certain range.In this structure and strategy, the training was focused on FNN controllers in the outer loop, and the mutual interference caused by synchronous learning of inner and outer FNN was avoided.Since in the position loop, the algorithm based on FNN-compensated PID reduced the required amount of calculation, thereby the stability of the system would be accelerated.
the mutual interference caused by synchronous learning of inner and outer FNN was avoided.Since in the position loop, the algorithm based on FNN-compensated PID reduced the required amount of calculation, thereby the stability of the system would be accelerated.In the outer loop, the desired pitch and roll angles,  and  , were generated as the inputs of the inner loop through the attitude planner module.The desired attitudes could be obtained by Equation ( 7) as: where  ,  are the output value of the x and y axis position controller. is the yaw angle of UAV.In this study, the desired three-dimensional values of position and yaw angle built the vector [ ,  ,  ,  ] to be tracked.

Attitude Controller
FNNs were used for the attitude loop controller and were trained offline.The training datasets were obtained from variable universe fuzzy PID controllers [29], which have high speed of dynamic response and proper stability.In order to preserve the advantages of these controllers, reduce the computation and simplify control system structure, FNN controllers were used to substitute them.Figure 3 shows the structure of the FNN.The FNN was composed of five layers neurons: In the outer loop, the desired pitch and roll angles, θ d and ϕ d , were generated as the inputs of the inner loop through the attitude planner module.The desired attitudes could be obtained by Equation ( 7) as: where u x , u y are the output value of the x and y axis position controller.ψ is the yaw angle of UAV.In this study, the desired three-dimensional values of position and yaw angle built the vector [x d , y d , z d , ψ d ] to be tracked.

Attitude Controller
FNNs were used for the attitude loop controller and were trained offline.The training datasets were obtained from variable universe fuzzy PID controllers [29], which have high speed of dynamic response and proper stability.In order to preserve the advantages of these controllers, reduce the computation and simplify control system structure, FNN controllers were used to substitute them.Figure 3 shows the structure of the FNN.In the outer loop, the desired pitch and roll angles,  and  , were gene the inputs of the inner loop through the attitude planner module.The desired a could be obtained by Equation ( 7) as: where  ,  are the output value of the x and y axis position controller. is angle of UAV.In this study, the desired three-dimensional values of position a angle built the vector [ ,  ,  ,  ] to be tracked.

Attitude Controller
FNNs were used for the attitude loop controller and were trained offline.T ing datasets were obtained from variable universe fuzzy PID controllers [29], wh high speed of dynamic response and proper stability.In order to preserve the adv of these controllers, reduce the computation and simplify control system structu controllers were used to substitute them.Figure 3 shows the structure of the FNN The FNN was composed of five layers neurons: Layer 2 was the fuzzy layer.There were several membership functions in the universe of each input.The error and error rate would be fuzzified to three or more members with Gaussian membership function in this paper.The Gaussian membership function equation could be defined as: where µ i is i-th node Gaussian membership functions.σ and c are the standard deviation and the mean of the membership functions, respectively.
Layer 3 was the fuzzy reasoning layer.According to some expert experience, some rules could be made, and one of rules could be described as: if M ei is small, and M eci is small, then d ij is small.Layer 4 was the defuzzification layer.This layer simulated the operation of the connection mode of the neural network: where x j is output of layer 4, d i is the output of layer 3, w i is the weights of third layer neurons, and b is the bias of neurons.Layer 5 was the output layer.All node variables needed to be transformed into the output of the network, and the value would be the control input of the UAV.In this paper, the formula used was: where v j are the weights of fourth layer neurons, and u is the output signal of the FNN controller.
The forward propagation of the fuzzy neural network belonged to layer by layer, and the weight update relied on the neural network back-propagation algorithm, so the result of the weight update could be expressed as: 11) where J is the loss function.y d and y are desired position and actual position of UAV respectively.η is the learning rate.

Position Controller
Figure 4 shows the structure of each position control.In this structure, the FNN controller worked in parallel with the PID controller.It had the same structure as shown in Figure 3, and a saturation module was added to limit the upper and lower output of the FNN controller.The FNN controller had two inputs, position error and error rate.The FNN controller constantly observed the input signal e and ec in real time and established a loss function based on the expected position and actual position error.In every control cycle, the weights of the FNN were updated once through the back-propagation algorithm.Then, the FNN controller could output a control signal to compensate PID controllers for quick position tracking.
Energies 2022, 15,1763 cycle, the weights of the FNN were updated once through the back-propaga rithm.Then, the FNN controller could output a control signal to compensate PI lers for quick position tracking.

Simulation and Results
Based on the quadrotor dynamic mathematic model and the control system shown in Figure 2, the simulation model was developed in MATLAB Simulin ment, and the simulation time step was set to 0.01 s.The quadrotor model wa a Tello quadrotor from DJI Ltd.We determined the parameters with reference to ods of parameter measurement and calculation in [30], and the parameters pr DJI (parameters are shown in Table 1).The FNN controllers in the attitude loop were trained offline.Firstly, we ob training data required by FNN offline training through a corresponding variab fuzzy PID controller.These data were collected by different flight tasks such as waypoint following, path line tracking, etc., to cover the actual quadrotor wo comprehensively as possible.The range of pitch, roll angle, and yaw angle of rotor was (−π/2, π/2), (−π/2, π/2), and (−π, π), respectively.Taking yaw channe ample, yaw error, yaw error rate, and output of the PID controller training data in Figure 5a.Then, the offline training of the yaw angle FNN controller was c by the obtained data.Each input variable of the FNN controller was divide Gaussian membership functions, the learning algorithm was the traditional ba gation algorithm, and the maximum number of training cycles was set to 100 stopped when the error was less than 0.0001.The training error is shown in Figu the final error was 0.0008958.Finally, we used the trained FNN controller to yaw angle, and the output of the FNN controller and the original PID controller in Figure 5c.The output of the FNN controller highly matched the output of th troller.It showed that the trained fuzzy neural network controller had high pre

Simulation and Results
Based on the quadrotor dynamic mathematic model and the control system structure shown in Figure 2, the simulation model was developed in MATLAB Simulink environment, and the simulation time step was set to 0.01 s.The quadrotor model was based on a Tello quadrotor from DJI Ltd. (Shenzhen, China).We determined the parameters with reference to the methods of parameter measurement and calculation in [30], and the parameters provided by DJI (parameters are shown in Table 1).The FNN controllers in the attitude loop were trained offline.Firstly, we obtained the training data required by FNN offline training through a corresponding variable universe fuzzy PID controller.These data were collected by different flight tasks such as hovering, waypoint following, path line tracking, etc., to cover the actual quadrotor workspace as comprehensively as possible.The range of pitch, roll angle, and yaw angle of the quadrotor was (−π/2, π/2), (−π/2, π/2), and (−π, π), respectively.Taking yaw channel as an example, yaw error, yaw error rate, and output of the PID controller training data are shown in Figure 5a.Then, the offline training of the yaw angle FNN controller was carried out by the obtained data.Each input variable of the FNN controller was divided into five Gaussian membership functions, the learning algorithm was the traditional backpropagation algorithm, and the maximum number of training cycles was set to 100.Training stopped when the error was less than 0.0001.The training error is shown in Figure 5b, and the final error was 0.0008958.Finally, we used the trained FNN controller to verify the yaw angle, and the output of the FNN controller and the original PID controller are shown in Figure 5c.The output of the FNN controller highly matched the output of the PID controller.It showed that the trained fuzzy neural network controller had high precision and could be used to replace the PID controller of the inner loop.The same training was carried out on its FNN controller with the data obtained from pitch and roll angle channels, and the errors were 0.0011844 and 0.00144, respectively, which also indicated that the trained FNN controller had high accuracy.could be used to replace the PID controller of the inner loop.The same training was carried out on its FNN controller with the data obtained from pitch and roll angle channels, and the errors were 0.0011844 and 0.00144, respectively, which also indicated that the trained FNN controller had high accuracy.As for the position controllers, PID control gain should be tuned simultaneously, and the Ziegler-Nichols method was not applicable.In this paper, the PID gain was tuned initially to obtain stable flight and was further tuned manually to optimize the settling time and rise time according to expert experience.By this approach, satisfactory flight performance was achieved and was used for comparison.The PID controller values are shown in Table 2.As for the position controllers, PID control gain should be tuned simultaneously, and the Ziegler-Nichols method was not applicable.In this paper, the PID gain was tuned initially to obtain stable flight and was further tuned manually to optimize the settling time and rise time according to expert experience.By this approach, satisfactory flight performance was achieved and was used for comparison.The PID controller values are shown in Table 2.In order to test the proposed control system, the result of our method (denoted as FNN-FNN) was compared with those of two other controllers, a PID-PID controller (PID controllers for position control and a variable universe fuzzy PID controller for attitude control) and a PID-FNN controller (a PID controller for the outer loop and a FNN controller for the inner loop, respectively).Since the flight trajectories of a quadrotor mainly consist of hovering, curve, and straight line, in this section flight simulations of fixed set-point flight, spiral tracking, and square trajectory tracking were studied, and the results were obtained and compared, respectively.

Fixed Set-Point Flight Simulation
In this simulation, the drone was required to fly from the origin to the target position (1,1,1).Figure 6 shows the position simulation results under control of different controllers.Figure 6d shows simulation results with a pulse height input of 0.3 m.In order to test the proposed control system, the result of our method (denoted as FNN-FNN) was compared with those of two other controllers, a PID-PID controller (PID controllers for position control and a variable universe fuzzy PID controller for attitude control) and a PID-FNN controller (a PID controller for the outer loop and a FNN controller for the inner loop, respectively).Since the flight trajectories of a quadrotor mainly consist of hovering, curve, and straight line, in this section flight simulations of fixed set-point flight, spiral tracking, and square trajectory tracking were studied, and the results were obtained and compared, respectively.

Fixed Set-Point Flight Simulation
In this simulation, the drone was required to fly from the origin to the target position (1,1,1).Figure 6 shows the position simulation results under control of different controllers.Figure 6d shows simulation results with a pulse height input of 0.3 m.It can also be seen that the overshoot in the axis x and y using our FNN-FNN control method was obviously the smallest.The x position tended to be stable soon after reaching an overshoot, although there were some small oscillations.The overshoot of cascade PID controller was in the majority.After reaching an overshoot, it oscillated back and forth to reach a stable value.The PID-FNN control mode had the largest overshoot, but the response time of this mode was faster than that of the cascade PID controller, and there was It can also be seen that the overshoot in the axis x and y using our FNN-FNN control method was obviously the smallest.The x position tended to be stable soon after reaching an overshoot, although there were some small oscillations.The overshoot of cascade PID controller was in the majority.After reaching an overshoot, it oscillated back and forth to reach a stable value.The PID-FNN control mode had the largest overshoot, but the response time of this mode was faster than that of the cascade PID controller, and there was less vibration.As for the y position, the settling time of PID-PID method was the longest, and our FNN-FNN controller had a significant effect on reducing overshoot and the response time.Since axis z position control was a direct channel without coupling with an attitude loop, the results of our method and traditional PID controller are compared in Figure 6c.It can be seen that the proposed FNN+PID controller had significantly faster response and shorter settling time than the counterpart.In Figure 6d, a pulse height flight of up and down of 0.3 m for 3 s from 40 s was simulated.FNN+PID controller could follow this pulse quickly and precisely.According to the simulation results, the algorithm proposed in this paper could quickly provide the fixed set-point flight control, with small overshot and significantly better response speed than the traditional PID control method.
The quantitative results of overshoot and the settling time of simulations are compared in Table 3.The settling time was when the error of output was no more than 5%.

Spiral Trajectory Tracking Flight Simulation
To test the tracking performance of the proposed controller, a flight simulation of a spiral path tracking was carried out.In the simulation, the yaw angle was set to change with the same frequency.The trajectory path of this simulation was set as: The simulation results are shown as Figure 7.A comprehensive comparison of axis x and y results showed that the proposed FNN-FNN had a smaller tracking error and shorter settling time on the horizontal component than the other two controllers.In addition, the simulation result of the yaw angle showed that the proposed controller could realize angle tracking well, and the change of yaw angle did not affect the tracking of position.Figure 7e shows the 3D process of spiral trajectory tracking simulation.It was clear that a satisfactory control effect of spiral trajectory tracking was achieved using the FNN-FNN controller.In Figure 7f,g, the results of error of x and y position under three different controllers are compared, which showed that the proposed method had significantly lower overshoot and quicker settling time.Since every position controller had a PID module and a FNN module for compensation, there were six outputs that are shown in Figure 7h.When position error existed, the FNN controller tuned the network weight in real-time to compensate the nonlinearity of the system.Meanwhile, the saturation module was used to limit the maximum output value of FNN, so the output value of the FNN controller oscillated back and forth, which showed a feature similar to the nonlinear sliding model.The results show that FNN controller could compensate the PID controller to follow the input target quickly.When the position error was very small, the output of the FNN controller tended to be stable.
The simulation results of x position tracking are given in Figure 8a,b, respectively, and the 3D position is given in Figure 8c.According to the simulation results, it could be seen that the overshoot of the FNN-FNN controller was smaller than that of the PID-PID controller in the position loop, and the adjustment response speed was also slightly faster.From 3D simulation results, we could also see that the FNN-FNN controller had better performance than the PID-PID controller in the square trajectory tracking flight.
The simulation results of x position tracking are given in Figure 8a,b, respectively, and the 3D position is given in Figure 8c.According to the simulation results, it could be seen that the overshoot of the FNN-FNN controller was smaller than that of the PID-PID controller in the position loop, and the adjustment response speed was also slightly faster.From the 3D simulation results, we could also see that the FNN-FNN controller had better performance than the PID-PID controller in the square trajectory tracking flight.

Experiments
Based on the study in previous section, flight experiments were conducted, and some experimental results are given to illustrate the control performance of the developed algorithm in this section.
Experimental equipment: A quadrotor experimental environment was established as shown in Figure 9.A DJI Tello drone was used as the experimental quadrotor platform.It is small and portable and has good indoor flight performance.It was also equipped with a barometer, a 720 p camera, an infrared sensor, and a WIFI module for direct connection to a PC, etc.The cloud controller was developed in a portable notebook computer using Tello Python SDK.It sent the processing results to the Tello drone directly through UDP port to control the Tello's movement.It was a suitable aircraft platform for secondary development of indoor intelligent application.To collect the real-time flight data of the quadrotor, a Qualisys optical motion capture system with four infrared cameras was used in the experiments.Through a computer with Qualisys software, the position and attitude data of the UAV were captured and processed.The sampling frequency of the Qualisys system was set to 100 Hz.The cloud controller received the desired trajectory, real-time trajectory, and attitude of Tello, then sent the control output to Tello to form a control loop.Through replacing control algorithms, the control performances of different controllers could be tested.To avoid the drone hitting the lens, the motion range of the quadrotor was limited in 1 × 1 m between the cameras of the motion capture system.Therefore, the

Experiments
Based on the study in previous section, flight experiments were conducted, and some experimental results are given to illustrate the control performance of the developed algorithm in this section.
Experimental equipment: A quadrotor experimental environment was established as shown in Figure 9.A DJI Tello drone was used as the experimental quadrotor platform.It is small and portable and has good indoor flight performance.It was also equipped with a barometer, a 720 p camera, an infrared sensor, and a WIFI module for direct connection to a PC, etc.The cloud controller was developed in a portable notebook computer using Tello Python SDK.It sent the processing results to the Tello drone directly through UDP port to control the Tello's movement.It was a suitable aircraft platform for secondary development of indoor intelligent application.To collect the real-time flight data of the quadrotor, a Qualisys optical motion capture system with four infrared cameras was used in the experiments.Through a computer with Qualisys software, the position and attitude data of the UAV were captured and processed.The sampling frequency of the Qualisys system was set to 100 Hz.The cloud controller received the desired trajectory, real-time trajectory, and attitude of Tello, then sent the control output to Tello to form a control loop.Through replacing control algorithms, the control performances of different controllers could be tested.To avoid the drone hitting the lens, the motion range of the quadrotor was limited in 1 × 1 m 2 between the cameras of the motion capture system.Therefore, the angles of the four lenses were adjusted and arranged as a square with a side length of 4 m.The experimental equipment is shown as Figure 9.
Camera calibration: The Qualisys optical motion capture system in the experiments had four cameras to locate the position and attitude of UAV.Therefore, data calibration of four cameras was needed to ensure accurate positioning.Firstly, L-shaped and T-shaped rods were used for calibration.In the calibration process, we needed to tune the threshold and brighten to ensure that the camera could accurately receive calibration signals.The configuration should be saved after the calibration.Then, four markers were attached to four rotors of the drone, and the drone was placed in a recognizable area, making sure that each camera could read the four markers.
angles of the four lenses were adjusted and arranged as a square with a side length of 4 m.The experimental equipment is shown as Figure 9. Camera calibration: The Qualisys optical motion capture system in the experiments had four cameras to locate the position and attitude of UAV.Therefore, data calibration of four cameras was needed to ensure accurate positioning.Firstly, L-shaped and Tshaped rods were used for calibration.In the calibration process, we needed to tune the threshold and brighten to ensure that the camera could accurately receive calibration signals.The configuration should be saved after the calibration.Then, four markers were attached to four rotors of the drone, and the drone was placed in a recognizable area, making sure that each camera could read the four markers.
The experimental process is shown in Figure 10.Firstly, the controller developed in the simulation process was deployed on a PC, and then Qualisys software was used to receive the collected data and transfer it to the controller.As shown in Figure 2, the controller calculated the required lift force and torques according to the position error and attitude error.Since DJI SDK only opened the interfaces of four remote control channels, a conversion module was added to calculate the lift and torques as control values of four channels (roll, pitch, yaw, and throttle).Using the "rc control" command provided by Djitello SDK, the control values were transferred to control the flight of Tello via a UDP protocol.Thus, a closed loop could be formed to realize the experiment.To verify performance of the proposed control system, three groups of experiments were carried out, and the experimental results were analyzed.
Figure 11 shows the experiment results of hovering flight with a step height command.Figure 11a,b shows the error of x and y position.The position error of the FNN-FNN controller was smaller than that of the PID-PID controller in the horizontal plane.The experimental process is shown in Figure 10.Firstly, the controller developed in the simulation process was deployed on a PC, and then Qualisys software was used to receive the collected data and transfer it to the controller.As shown in Figure 2, the controller calculated the required lift force and torques according to the position error and attitude error.Since DJI SDK only opened the interfaces of four remote control channels, a conversion module was added to calculate the lift and torques as control values of four channels (roll, pitch, yaw, and throttle).Using the "rc control" command provided by Djitello SDK, the control values were transferred to control the flight of Tello via a UDP protocol.Thus, a closed loop could be formed to realize the experiment.Camera calibration: The Qualisys optical motion capture system in the experiments had four cameras to locate the position and attitude of UAV.Therefore, data calibration of four cameras was needed to ensure accurate positioning.Firstly, L-shaped and Tshaped rods were used for calibration.In the calibration process, we needed to tune the threshold and brighten to ensure that the camera could accurately receive calibration signals.The configuration should be saved after the calibration.Then, four markers were attached to four rotors of the drone, and the drone was placed in a recognizable area, making sure that each camera could read the four markers.
The experimental process is shown in Figure 10.Firstly, the controller developed in the simulation process was deployed on a PC, and then Qualisys software was used to receive the collected data and transfer it to the controller.As shown in Figure 2, the controller calculated the required lift force and torques according to the position error and attitude error.Since DJI SDK only opened the interfaces of four remote control channels, a conversion module was added to calculate the lift and torques as control values of four channels (roll, pitch, yaw, and throttle).Using the "rc control" command provided by Djitello SDK, the control values were transferred to control the flight of Tello via a UDP protocol.Thus, a closed loop could be formed to realize the experiment.To verify performance of the proposed control system, three groups of experiments were carried out, and the experimental results were analyzed.
Figure 11 shows the experiment results of hovering flight with a step height command.Figure 11a,b shows the error of x and y position.The position error of the FNN-FNN controller was smaller than that of the PID-PID controller in the horizontal plane.To verify performance of the proposed control system, three groups of experiments were carried out, and the experimental results were analyzed.
Figure 11 shows the experiment results of hovering flight with a step height command.Figure 11a,b shows the error of x and y position.The position error of the FNN-FNN controller was smaller than that of the PID-PID controller in the horizontal plane.Figure 11c presents the control results of the height channel.The FNN-compensated PID controller had better control effect than PID in both response speed and overshoot.The position root mean square error (RMSE) values for each flight are listed in Table 4.In the hovering experiment, it could be observed that the FNN-PID controller gave significantly less error than the conventional PID controller when it worked alone in z axis position.From the three experiment results, the FNN-FNN controller had lower RMSE than the cascade PID controller by more than 10% in most experiments.

Discussion
Although it was verified that the FNN-FNN controller presented in this paper had a smoother control effect and could track the ideal trajectory better through comparison of these experiments, the advantages of FNN-FNN were not significantly reflected in the experiments.The reasons might be as follows.Firstly, during training, we took the attitude angle error and error rate as the input, and the PID controller output as the output data set for the training, so the generated controller results were lift force and torques.However, in actual use, the signals of four channels needed to be used, so the mapping relationship of this step was very important.Since we used linear mapping, it decreased the precision of the control system.Secondly, since the quadrotor was controlled via a wireless network UDP protocol, wireless network delays influenced real-time control of the quadrotor UAV.
Therefore, there are still some areas worthy of improvement in future work research.For example, the mapping between lift forces and torques and remote channels could be nonlinear.At the same time, there may be room for further optimization of network structure, which can be tested by an RBF neural network.In addition, we also want to use reinforcement learning in the future to achieve precise position control of a quadrotor in  4. In the hovering experiment, it could be observed that the FNN-PID controller gave significantly less error than the conventional PID controller when it worked alone in z axis position.From the three experiment results, the FNN-FNN controller had lower RMSE than the cascade PID controller by more than 10% in most experiments.

Discussion
Although it was verified that the FNN-FNN controller presented in this paper had a smoother control effect and could track the ideal trajectory better through comparison of these experiments, the advantages of FNN-FNN were not significantly reflected in the experiments.The reasons might be as follows.Firstly, during training, we took the attitude angle error and error rate as the input, and the PID controller output as the output data set for the training, so the generated controller results were lift force and torques.However, in actual use, the signals of four channels needed to be used, so the mapping relationship of this step was very important.Since we used linear mapping, it decreased the precision of the control system.Secondly, since the quadrotor was controlled via a wireless network UDP protocol, wireless network delays influenced real-time control of the quadrotor UAV.
Therefore, there are still some areas worthy of improvement in future work research.For example, the mapping between lift forces and torques and remote channels could be nonlinear.At the same time, there may be room for further optimization of network structure, which can be tested by an RBF neural network.In addition, we also want to use reinforcement learning in the future to achieve precise position control of a quadrotor in model-free state.

Conclusions
In this paper, a cascade FNN control idea was presented for quadrotor position control.The model of quadrotor with type "x" layout configuration was studied.To prevent the interference in the online learning of cascade FNN, offline-trained FNN controllers were used for the attitude loop.For the position loop, FNN-based online learning was adopted to complement the disadvantages of PID.The FNN controller could constantly modify itself online according to the position error to ensure that the desired result could be achieved more quickly.In this way, the calculation amount of FNN could be reduced, and the response time of the control system could be accelerated.Based on this approach and the quadrotor model, a flight simulation environment was built.Control effects were compared through simulations of a hovering flight test and spiral and square trajectory tracking.Finally, flight experiments on a DJI Tello drone verified that the proposed controller had good performance in position control.

.
and pitch angles are very small, Equation (6) can be simplified as .

Figure 2 .
Figure 2. The block diagram of the control system.

Figure 2 .
Figure 2. The block diagram of the control system.

Figure 2 .
Figure 2. The block diagram of the control system.

Figure 3 .
Figure 3. Fuzzy neural network controller structure.The FNN was composed of five layers neurons: Layer 1 was the input layer, mainly including the position/attitude (velocity) error and the error rate.Input = [e, ec].

Figure 5 .
Figure 5. Training data sets, error chart, and validation results.(a) Training data sets; (b) error chart.(c) Comparison of the trained FNN controller and PID output verification.

Figure 5 .
Figure 5. Training data sets, error chart, and validation results.(a) Training data sets; (b) error chart.(c) Comparison of the trained FNN controller and PID output verification.

Figure 6 .
Figure 6.Results of fixed set-point flight simulation.(a) x position, (b) y position, (c) z position, and (d) z position with a pulse input.

Figure 6 .
Figure 6.Results of fixed set-point flight simulation.(a) x position, (b) y position, (c) z position, and (d) z position with a pulse input.

Figure 7 .
Figure 7. Results of a spiral trajectory tracking simulation.(a) x position, (b) y position, (c) z position, (d) yaw angle, (e) 3D spiral trajectory tracking simulation, (f) error of x position, (g) error of y position, and (h) outputs of position controllers.

Figure 7 .
Figure 7. Results of a spiral trajectory tracking simulation.(a) x position, (b) y position, (c) z position, (d) yaw angle, (e) 3D spiral trajectory tracking simulation, (f) error of x position, (g) error of y position, and (h) outputs of position controllers.

Figure 9 .
Figure 9. Quadrotor experimental environment.(a) Experimental equipment and control loop and (b) experimental field.

Figure 9 .
Figure 9. Quadrotor experimental environment.(a) Experimental equipment and control loop and (b) experimental field.

Figure 9 .
Figure 9. Quadrotor experimental environment.(a) Experimental equipment and control loop and (b) experimental field.

Figures 12 and 13
describe the experiment results of spiral and square trajectory tracking flights.The left column represents the experimental results on the horizontal component, while the right column presents the 3D experimental tracking trajectory.

FigureFigure 11 .
Figure11cpresents the control results of the height channel.The FNN-compensated PID controller had better control effect than PID in both response speed and overshoot.

Figures 12 and 13
Figures 12 and 13 describe the experiment results of spiral and square trajectory tracking flights.The left column represents the experimental results on the horizontal component, while the right column presents the 3D experimental tracking trajectory.

Figure 12 .
Figure 12.Experiment results of spiral trajectory tracking.

Figure 11 .Figure 11 .
Figure 11.Experiment results of hovering flight with step height command.(a) Error of x position, (b) Error of y position, (c) z position.

Figures 12 and 13
Figures 12 and 13 describe the experiment results of spiral and square trajectory tracking flights.The left column represents the experimental results on the horizontal component, while the right column presents the 3D experimental tracking trajectory.

Figure 12 .
Figure 12.Experiment results of spiral trajectory tracking.

Figure 12 .
Figure 12.Experiment results of spiral trajectory tracking.

16 of 18 Figure 13 .
Figure 13.Experiment results of square trajectory tracking.

Figure 13 .
Figure 13.Experiment results of square trajectory tracking.The position root mean square error (RMSE) values for each flight are listed in Table4.In the hovering experiment, it could be observed that the FNN-PID controller gave significantly less error than the conventional PID controller when it worked alone in z axis position.From the three experiment results, the FNN-FNN controller had lower RMSE than the cascade PID controller by more than 10% in most experiments.

Table 1 .
Parameters of the quadrotor UAV.

Table 1 .
Parameters of the quadrotor UAV.

Table 2 .
Controller values used for the simulation.

Table 2 .
Controller values used for the simulation.

Table 3 .
Quantitative analysis of several simulation results.

Table 4 .
Position RMSE values of experiments.

Table 4 .
Position RMSE values of experiments.