Sliding Mode Controller Based on the Extended State Observer for Plant-Protection Quadrotor Unmanned Aerial Vehicles

: Owing to the complex dynamics of quadrotor unmanned aerial vehicles (UAVs) and their susceptibility to unknown interferences in an actual working environment, the ﬂight control accuracy of UAVs is extremely high. Moreover, their anti-interference ability is particularly important. This study designed a sliding-mode controller based on the extended state observer. The position control was obtained through the outer-loop position controller. The attitude control was determined through the inner-loop attitude controller. The input of the UAV system was obtained through the controller. The boundary-layer function was used to weaken the oscillatory response of the system, and the traditional extended state observer was improved to improve the response speed, robustness, and tracking accuracy of the controller. For the entire process, the input and output state information of the system and total internal and external disturbances were estimated in real-time through the extended state observer. A sliding-mode control law was designed to compensate for the estimated disturbance in real-time to realize attitude control. Finally, Lyapunov theory was used to conﬁrm the stability of the system. The simulation results demonstrated the improved anti-interference and tracking ability of the designed controller.


Introduction
Quadrotor unmanned aerial vehicles (UAVs) are efficient, flexible, small, and convenient, which paved the way for their usage in agricultural and military fields and, consequently, their promising and unlimited application prospects [1]. A quadrotor UAV is a representative of a nonlinear system with strong coupling. It is a complex underactuated system with four control inputs and a six-degrees-of-freedom output. Moreover, quadrotor UAVs can achieve six-degrees-of-freedom flight and average anti-interference ability. However, their aerodynamic characteristics are easily disturbed by the external environment. For UAVs used in plant protection, which carry pesticides for spraying, their control method is important as they operate mostly in an outdoor environment [2].
At present, researchers have proposed several control methods [3]. The traditional proportional-integral-derivative (PID) control algorithm is a simple approach; however, with this algorithm, it is difficult to self-adjust the control parameters with environmental changes [4]. Badr et al. [5] designed a PID controller for a quadrotor UAV, which achieved weak anti-interference ability. Yobi and Shuxi [6] proposed a hover control for a PID quadrotor UAV based on fuzzy self-tuning. However, the mathematical model of the backstepping control (BSC) has high requirements. Unknown interference results in the insufficient accuracy of the model, which often affects the tracking effect of the system. Zuo and Mallikarjunan [7] and Djamel et al. [8] proposed a control method for rotorcraft based on BSC whereby its control effect was improved compared with the traditional

Quadrotor UAV Dynamics Model
As quadrotor UAVs are typically underactuated systems, they are simplified for analysis in modeling, and the following four assumptions were made: (1) a quadrotor UAV has a uniformly symmetrical rigid body exhibiting no change in mass or rotational inertia during flight; (2) the center of mass of a quadrotor UAV coincides with the geometric center of its airframe; (3) the resistance and gravity of a quadrotor UAV are not affected by factors such as flight height and remain unchanged; (4) and air resistance and gyroscopic effects are ignored.

Establishing the Coordinate System
Li J et al. [23] built a mathematical model of a quadrotor UAV. Figure 1 shows a diagram of the movement of the quadrotor UAV. To describe the model of the quadrotor UAV, the earth coordinate system E − x e , y e , z e and body coordinate system B − x b , y b , z b of the quadrotor should be established first. The conversion relationship from the earth coordinate system to the body coordinate system is shown in Equation (1).

Quadrotor Dynamic Modeling
Neglecting the air resistance during flight and after analyzing the force the dynamic model of the quadrotor UAV can be further obtained, and the attitude controls can be obtained using Equations (2) and (3) where is the lift coefficient; is the drag coefficient; is the distance from the center of the body; ( = 1, 2, 3, 4) is the rotation speed of each rotor; a are the moments of inertia on the , , and axes, respectively.

SMC Design
The SMC design is determined as follows: Figure 1. Diagram of the movement of the quadrotor UAV.

Quadrotor Dynamic Modeling
Neglecting the air resistance during flight and after analyzing the force of the UAV, the dynamic model of the quadrotor UAV can be further obtained, and the position and attitude controls can be obtained using Equations (2) and (3), respectively, as follows: where b is the lift coefficient; d is the drag coefficient; l is the distance from the rotor to the center of the body; ω n (n = 1, 2, 3, 4) is the rotation speed of each rotor; and I x , I y , and I z are the moments of inertia on the x, y, and z axes, respectively.

SMC Design
The SMC design is determined as follows:

Design of the Position SMC
The controlled quantities and feedback input of the controller were labeled as , , and . Taking the height control as an example, a sliding-mode position controller was designed because the position controller is affected by the attitude controller, which was designed as the outer loop.
First, with the state variable defined as = [ ̇ ̇ ̇ ̇ ̇ ̇] , a disturbancefree altitude controller was designed using the position state in Equation (2): Setting the desired height as , the height error and its derivative can be defined as: The sliding surface is designed as: where > 0. According to the second method of Lyapunov, if the scalar function ( ) satisfies: (1) ( ) = 0 if and only if = 0; (2) ( ) > 0 if and only if ≠ 0; (3) ̇( ) ≤ 0 when ≠ 0; Then the system is stable. In particular, if ≠ 0, ̇( ) < 0, then the system is asymptotically stable.
The Lyapunov function is defined as: Using the exponential approach law, we obtain: Subsequently, the SMC based on the exponential reaching law can be solved as:

Design of the Position SMC
The controlled quantities and feedback input of the controller were labeled as x, y, and z. Taking the height control z as an example, a sliding-mode position controller was designed because the position controller is affected by the attitude controller, which was designed as the outer loop.
First, with the state variable defined as ψ , a disturbancefree altitude controller was designed using the position state in Equation (2): Setting the desired height as z d , the height error and its derivative can be defined as: .
The sliding surface is designed as: where α z > 0. According to the second method of Lyapunov, if the scalar function V (x) satisfies: .
V (x) ≤ 0 when x = 0; Then the system is stable. In particular, if x = 0, . V (x) < 0, then the system is asymptotically stable.
The Lyapunov function is defined as: .
Using the exponential approach law, we obtain: Subsequently, the SMC based on the exponential reaching law can be solved as: where ε z > 0, ρ z > 0. Substituting Equation (12) for Equation (10), we obtain: Thus, the Lyapunov stability condition is satisfied. Similarly, the two controllers for the x and y channels were designed. From Equation (2), the x and y state equations can be respectively obtained as: .
The control quantities of x and y can be obtained as: where ε y > 0, ρ y > 0, e y = y d − y, y d − α y e y , α y > 0. If u 1 = 0, u y = 0.
Subsequently, the desired angle φ d can be obtained by the inverse solution, and θ d is obtained as:

Design of the Attitude SMC
As attitude is not affected by position, the attitude control was designed as an inner loop. The expected angles φ d and θ d obtained from the inverse solution of the position controller and set ψ d were used as the input of the attitude controller. Taking the roll angle φ as an example, the attitude SMC was designed.
From Equation (3), the state equation of the φ channel can be obtained as: where The expected angle φ d and the error and its derivative are defined as: .
The sliding surface is designed as: Mathematics 2022, 10, 1346 The SMC based on the exponential reaching law is: where ε φ > 0, and ρ φ > 0. Similarly, the SMC for the other two angles were designed. The state equation of the θ channel can be obtained from Equation (3) as: .
The control quantity of the θ channel of the solution is: (3), the state equation of the ψ channel can be obtained as: The control quantity of the ψ channel of the solution is: In the simulation process, the discontinuity of the control command caused by the sign function in the designed sliding-mode control part may cause chattering. Boundary-layer technology was used, and the sign function was approximately replaced by the sigmoid function to reduce oscillatory response.

Simulation Analysis
The parameters of the quadrotor UAV are as follows: m = 2 kg, g = 9.8 m/s 2 , I x = 0.03 kg·m 2 , I y = 0.03 kg × m 2 , I z = 0.04 kg·m 2 , and l = 0.225 m. All parameters of the SMC were set to 1.
In the case of no disturbance, the desired positions were set to x d = sin t, y d = cos t − 1, and z d = 0.2t to obtain the desired angle through the outer-loop position control and pass the inner-loop attitude controller for the desired angle. The control variables u 1 , u 2 , u 3 , and u 4 obtained from the controller were used as inputs for the quadrotor UAV model. The initial data of the quadrotor UAV were: [x y z φ θ ψ] T = [0 0 0 0 0 0] T . The simulation time was set to 25 s. MATLAB/Simulink was used for the simulation. The results were compared with those of the BSC. The simulation results are shown in Figure 3.  In Figure 3b−g, e i1 (i = x, y, z, φ, θ, ψ) represents the channel error of the BSC, and e i2 (i = x, y, z, φ, θ, ψ) represents the channel error of the SMC. The tracking speed of the SMC was faster, and its tracking error stabilized to zero within 4 s. Meanwhile, the tracking speed of the BSC was slightly slower, resulting in a fluctuation of the tracking error within the allowable range when the expected values continuously varied. Compared with the BSC, the SMC had better tracking accuracy and stability. Overall control performance has been improved.
In the case of disturbance, the disturbance model should be added to the controller to solve the channel control quantity. However, in the outdoor operation of plant-protection UAVs, whereby pesticides are carried for spraying, an unknown disturbance is expected, and the quality of the pesticides is expected to change. Thus, the BMC and SMC cannot solve the UAV model very well. Therefore, the SMC, which has better robustness, tracking accuracy, and responsiveness, was combined with the traditional ADRC to design a new controller.

Design of SMC Based on ESO
Owing to the limitations of the BSC and SMC, the actual working environment of plantprotection UAVs has unknown disturbances and variable loads. Therefore, a state observerbased SMC, which does not need to add a clear disturbance model in the controller design, was developed to address this problem. When the system was disturbed, the estimated value of the disturbance was obtained through the ESO and added to the controller to solve the channel control quantity. From Equations (2) and (3), the channel control quantity of the controller is: Based on the system model of the quadrotor UAV obtained in Equations (2) and (3), the three attitude angles of the UAV were changed as follows: u 21 , u 31 , u 41 , and u 11 . The three attitude angles controlled the position of the UAV, and the position change was achieved by changing the attitude angle. Similar to the SMC and BSC, the control system of the UAV was divided into two parts to solve the underactuated problem of four inputs and six outputs: the position control of the outer loop and the attitude control of the inner loop. The control system of the quadrotor UAV is shown in Figure 4. within the allowable range when the expected values continuously varied. Compared with the BSC, the SMC had better tracking accuracy and stability. Overall control performance has been improved.
In the case of disturbance, the disturbance model should be added to the controller to solve the channel control quantity. However, in the outdoor operation of plant-protection UAVs, whereby pesticides are carried for spraying, an unknown disturbance is expected, and the quality of the pesticides is expected to change. Thus, the BMC and SMC cannot solve the UAV model very well. Therefore, the SMC, which has better robustness, tracking accuracy, and responsiveness, was combined with the traditional ADRC to design a new controller.

Design of SMC Based on ESO
Owing to the limitations of the BSC and SMC, the actual working environment of plant-protection UAVs has unknown disturbances and variable loads. Therefore, a state observer-based SMC, which does not need to add a clear disturbance model in the controller design, was developed to address this problem. When the system was disturbed, the estimated value of the disturbance was obtained through the ESO and added to the controller to solve the channel control quantity. From Equations (2) and (3), the channel control quantity of the controller is: Based on the system model of the quadrotor UAV obtained in Equations (2) and (3), the three attitude angles of the UAV were changed as follows: 21 , 31 , 41 , and 11 . The three attitude angles controlled the position of the UAV, and the position change was achieved by changing the attitude angle. Similar to the SMC and BSC, the control system of the UAV was divided into two parts to solve the underactuated problem of four inputs and six outputs: the position control of the outer loop and the attitude control of the inner loop. The control system of the quadrotor UAV is shown in Figure 4.

Position Controller Design
According to Equations (2) and (31), the decoupling of the position controller can be achieved as follows:

Position Controller Design
According to Equations (2) and (31), the decoupling of the position controller can be achieved as follows: The position control model can be obtained as: where λ x , λ y , and λ z represent the internal uncertainties in the respective channels and the total disturbance of the external disturbances. . .
Based on Equation (34) and taking the x channel as an example for designing an ESO-based SMC as well as designing the first ESO for the x channel, the observation error is defined as: e x1 = r x1 − x, where r x1 represents the estimated value of x. Subsequently, the ESO x is designed as follows: where β 1 > 0, β 2 > 0, β 3 > 0; r x2 is the estimated value of .
x; r x3 is the estimated value of the total disturbance λ x ; and the galn function is used to replace the f al function in the traditional ESO [24]. However, nonlinear state error feedback (NLSEF) in ADRC is essentially a PD controller, and its response speed and robustness are not as good as those of the SMC, so the combination of the improved ESO and SMC not only improves the estimation accuracy of systematic error but also retains the advantages of fast response and good robustness in the SMC. Its expression is as follows: where σ > 0 is the adjustable parameter of the function. When |x| ≤ 1, gal(x, σ) = x σ 2 e − |x| 3 2σ 2 is a composite function, which contains an exponential function term. It can be seen that the composite function has an infinite derivative, so the function is smooth when |x| ≤ 1. According to Han J.Q. [15], a sufficiently small observation error can be achieved simply by selecting the appropriate parameters. Thus, r x2 can replace .
x, and r x3 can replace the total disturbance λ x .
With x d as the desired value of x, the sliding surface is designed as: where k 1 > 0, e x = x d − x, and . e x = .
x d − r x2 + (λ x − r x3 ) . The error of the system converges asymptotically to zero.
The Lyapunov function and its derivative are respectively defined as: . ..
Substituting Equation (38) for (40), we obtain: The designed observer ESO X can ensure a sufficiently small error as long as ρ x1 selects an appropriate value, and ρ x1 ≥ k 1 r x2 − .
x + (r x3 − λ x ) at time . V x1 ≤ −ε x1 S 2 x1 ≤ 0, which satisfies the Lyapunov stability condition. Thus, the control system is stable, and the error converges asymptotically to zero.
When the models of the x, y, and z channels are similar, the controllers for the y and z channels can be designed similarly. Thus, ESO y is designed as: where β 1 > 0, β 2 > 0, β 3 > 0, r y2 is the estimated value of . y, r y3 is the estimated value of the total disturbance λ y , and e y1 = r y1 − y is the observation error variable.
Let the desired value of y be y d ; the sliding surface is then designed as: where k 2 > 0, e y = y d − y, and . e y = . y d − .
y. Subsequently, the SMC designed for the y channel is: where ε y1 > 0, and ρ y1 ≥ k 2 . y d − r y2 + λ y − r y3 . The error of the system then converges asymptotically to zero.
ESO z is then designed as: where β 1 > 0, β 2 > 0, β 3 > 0, r z2 is the estimated value of . z, r z3 is the estimated value of the total disturbance λ z , and e z1 = r z1 − z is the observation error variable.
Let the desired value of z be z d ; the sliding surface is then designed as: where k 3 > 0, e z = z d − z, and The SMC designed for the y channel is: where ε z1 > 0, and ρ z1 ≥ k 3 . z d − r z2 + (λ z − r z3 ) . The system error converges asymptotically to zero.
The inverse solution is obtained using Equation (32), which can determine u 11 , and the desired angles φ d and θ d required by the inner loop.

Attitude Controller Design
The φ d and θ d from Equation (48)  θ/I z are used as internal disturbances estimated by the ESO. After finishing Equation (3), we can obtain: θ/I z + λ ψ are the total disturbances of each channel of the inner loop.
Similar to the design process of the outer-loop controller, the inner-loop attitude controller is designed. The φ channel ESO φ is designed as: where β 4 > 0, β 5 > 0, β 6 > 0, r φ2 is the estimated value of . φ, r φ3 is the estimated value of the total disturbance λ φ , and e φ1 = r φ1 − φ is the observation error variable.
Let the desired value of φ be φ d ; the sliding surface is then designed as: φ. The SMC designed for the φ channel is: where ε φ1 > 0, and ρ φ1 ≥ k 4 . φ d − r φ2 + λ φ − r φ3 . The system error converges asymptotically to zero.
The desired value of θ is θ d , and the sliding surface is designed as: θ. The SMC designed for the θ channel is: where ε θ1 > 0, and ρ θ1 ≥ k 5 . θ d − r θ2 + λ θ − r θ3 . The system error converges asymptotically to zero.
The desired value of ψ is ψ d , and the sliding surface is then designed as: where ψ d − ψ. The SMC designed for the ψ channel is: where ε ψ1 > 0, and ρ ψ1 ≥ k 6 . ψ d − r ψ2 + λ ψ − r ψ3 . The system error converges asymptotically to zero.
In Figure 5c-h, e i1 (i = x, y, z, φ, θ, ψ) are the channel errors of the ESO−SMC, and e i2 (i = x, y, z, φ, θ, ψ) is the channel error of ADRC. Without external disturbance, the ESO−SMC had the fastest tracking speed, and the tracking error tended to stabilize to zero within 1 s, whereas ADRC had a slightly slower response speed. In addition, the effect of the position control and BSC were similar, whereas the angle control of the ESO−SMC was better than that of ADRC. Compared with ADRC, the ESO−SMC had better tracking accuracy and stability. Overall control performance has been improved.
Plant−protection UAVs can determine spraying concentration according to the information returned by the camera. As the simulation only needs to verify the anti-interference ability of the controller, an equal spraying concentration of the pesticide was assumed, that is, the change in quality is the same as time: M = 3 − 0.1t, which is added to the quadrotor UAV system as a disturbance. The desired trajectory was still set as: x d = sin t, y d = cos t − 1, and z d = 0.2t, and the desired angle was ψ d = 0.3. In addition to the load disturbance, the disturbances applied by the position loop were: 0.3 sin t 0.3 sin t 0.3 sin t , and the disturbances applied by the attitude loop were: 0.2 sin t 0 0.3 sin t . The initial data of the quadrotor UAV were: [x y z φ θ ψ] T = [0 0 0 0 0 0] T . The simulation was performed using MATLAB/Simulink with the time set to 25 s. The results were compared with that of the traditional ADRC. The simulation results are shown in Figure 6.

Simulation Analysis
In the simulation experiment, the parameters were set as follows: 1 = 2 = 3.5, 3 = 35 , 1 = 2 = 4 , 3 = 75 , 1 = 2 = 1.5 , 3 = 10 , 1 = 100 , 2 = 510 , 3  In Figure 5c-h, 1 ( = , , , , , ) are the channel errors of the ESO−SMC, and 2 ( = , , , , , ) is the channel error of ADRC. Without external disturbance, the ESO−SMC had the fastest tracking speed, and the tracking error tended to stabilize to zero within 1 s, whereas ADRC had a slightly slower response speed. In addition, the effect of Even with the additions of variable load and external disturbance, the ESO−SMC can still quickly track the desired target, and the tracking error was reduced and stabilized to approximately 0 within 1 s, as shown in Figure 6. ADRC exhibited a slightly slower response speed that can estimate the error well and achieve tracking. Compared with the Even with the additions of variable load and external disturbance, the ESO−SMC can still quickly track the desired target, and the tracking error was reduced and stabilized to approximately 0 within 1 s, as shown in Figure 6. ADRC exhibited a slightly slower response speed that can estimate the error well and achieve tracking. Compared with the undisturbed case, the z-axis error gradually fluctuated as the load decreased, and the angle control also slightly fluctuated. The ESO−SMC improved the robustness, tracking accuracy, and stability of the system. Overall control performance has been improved.
The disturbance is the same as above, and the desired trajectory was as follows: when 16), and z d = 2; 20 < t ≤ 24, x d = 0, y d = 0, and z d = 2 − 0.5(t − 20); and 24 < t ≤ 25, and x d = y d = z d = 0. The desired angle was ψ d = 0.3. The initial data of the quadrotor UAV were: [x y z φ θ ψ] T = [0 0 0 0 0 0] T . The simulation was carried out using MATLAB/Simulink with the time set to 25 s. The results were compared with that of the traditional ADRC. The simulation results are shown in Figure 7. undisturbed case, the z-axis error gradually fluctuated as the load decreased, and the angle control also slightly fluctuated. The ESO−SMC improved the robustness, tracking accuracy, and stability of the system. Overall control performance has been improved. The disturbance is the same as above, and the desired trajectory was as follows: when 0 ≤ ≤ 4 , = 0 , = 0 , = 0.5 ; when 4 < ≤ 8 , The tracking speed of the ESO−SMC was faster than that of ADRC, whereby the tracking error was highly stable as it approached 0 within 1 s. Meanwhile, the response speed of ADRC was slightly slower, the error changed within a large range, and it was difficult to stabilize the error at 0 point. Thus, the ESO−SMC improved the robustness, tracking accuracy, and stability of the system. Overall control performance has been improved.

Conclusions
In this study, the control system is decomposed into two parts (the outer-loop position control and the inner-loop attitude control) for the underactuated system of a quadrotor UAV. With a view toward the practical application of UAVs in plant protection, an SMC based on the ESO was designed considering load change and unknown external disturbance. When the plant-protection UAV is designed under interference, its tracking error can be reduced to 0 within 1 s and remain stable. However, the error of ADRC fluctuates greatly, error stabilization takes about 4S, and it is difficult to stabilize at 0. Simulation and comparison experiments show that the tracking error is stably shortened by more than 3S, the average error is reduced by more than 50%, the tracking response speed is significantly improved, the tracking error is significantly reduced, and stability is enhanced. It shows that the controller can improve the anti-interference ability, tracking speed, tracking error, fluctuation amplitude, robustness, and flight stability of the system. The overall control performance is significantly improved.   The tracking speed of the ESO−SMC was faster than that of ADRC, whereby the tracking error was highly stable as it approached 0 within 1 s. Meanwhile, the response speed of ADRC was slightly slower, the error changed within a large range, and it was difficult to stabilize the error at 0 point. Thus, the ESO−SMC improved the robustness, tracking accuracy, and stability of the system. Overall control performance has been improved.

Conclusions
In this study, the control system is decomposed into two parts (the outer-loop position control and the inner-loop attitude control) for the underactuated system of a quadrotor UAV. With a view toward the practical application of UAVs in plant protection, an SMC based on the ESO was designed considering load change and unknown external disturbance. When the plant-protection UAV is designed under interference, its tracking error can be reduced to 0 within 1 s and remain stable. However, the error of ADRC fluctuates greatly, error stabilization takes about 4S, and it is difficult to stabilize at 0. Simulation and comparison experiments show that the tracking error is stably shortened by more than 3S, the average error is reduced by more than 50%, the tracking response speed is significantly improved, the tracking error is significantly reduced, and stability is enhanced. It shows that the controller can improve the anti-interference ability, tracking speed, tracking error, fluctuation amplitude, robustness, and flight stability of the system. The overall control performance is significantly improved.

Conflicts of Interest:
The authors declare no conflict of interest.