1. Introduction
An unmanned aerial vehicle (UAV) is an aircraft that does not have any human pilot, crew, or passengers on board. Quadrotor, a type of UAV, usually designed in an X configuration, with two diagonal motors rotating in one direction and two other diagonal motors rotating in the opposite direction to balance the torque. Quadrotors are under-actuated systems with four control inputs but six degrees of freedom. The attitude and altitude of the vehicle can be adjusted by controlling the four motors using pulse-width modulation (PWM) to increase and decrease thrust. Quadrotors are being used in an increasing number of civilian applications, including data collection, product delivery, and rescue searches [
1,
2]. In agriculture, quadcopters are used to spray pesticides and implement artificial rainfall [
3]. In addition, UAVs have applications and developments in the fields of transportation, aerial photography, disaster relief, and artificial intelligence [
4]. In the military field, quadcopters are used for combat, reconnaissance, patrol, and defense [
5].
With the rapid development of science and technology, more and more disciplines and topics related to UAVs have been developed, such as UAV control [
6] and UAV aerodynamics [
7]. Recent research in the field of UAV control has progressed in several directions. Linear controllers have been proposed to control the position and the attitude of UAVs, for example, the Linear Quadratic Regulator (LQR) [
6,
8,
9]. LQR is an optimal control strategy, primarily for linear systems, whereby a controller is designed by optimizing certain performance indicators such as control effort and state variables. The control law of LQR has a linear relationship with the state of the system and is applicable also to multi-input and multi-output systems (MIMO). However, the LQR design may require an accurate system model, may lack robustness, and would be more feasible for linear models [
10].
Although Proportional Integral Derivative (PID) control is more than 100 years old, it is still the most commonly used control method for UAVs due to its simplicity, intuitiveness, reliable performance, and ease of adjustment. However, PID controllers do not perform well in the face of high-frequency noise and external disturbances due to their simplified linear model and simple structure. Therefore, many researchers have conducted experiments and proposed modifications over the traditional PID controller. For example, Goel et al. [
11] introduces an adaptive Digital PID Control for unknown dynamics problems, and Dong and He [
12] propose a fuzzy PID method for quadrotor aircraft. Meanwhile, to improve the robustness of the controller in the face of wind disturbances, Zhou et al. [
13] uses a cascade PID attitude control in the inner-loop control of the UAV. The automatic PID gain tuned by reinforcement learning neural networks is also mentioned within the field of UAV control [
14].
In addition, some researchers have proposed the backstepping method. Backstepping is a recursive design method, applicable to both linear control and nonlinear control. The main idea of this method is to obtain a feedback controller by recursively constructing the Lyapunov function of the system and selecting an appropriate control law so that the Lyapunov function is bounded along the trajectory of the closed-loop system and the trajectory tends to be stable. The controller is designed without excessive simplification of the model, and the control of the UAV is more accurate, and the response speed is improved [
15]. However, due to its weak disturbance-rejection capabilities, researchers usually combine the backstepping control with other methods such as disturbance observer-based control [
16] and adaptive backstepping control [
17].
The sliding mode control (SMC) has been proven to be a robust way to maintain the stability of an unknown UAV dynamics [
18,
19]. Much work has been conducted in this area as well, for example, in [
20] where researchers verified the second-order sliding-mode approach and implemented it on a fixed-wing micro aerial vehicle (MAV). The study verifies that the performance of the sliding-mode controller exceeds a benchmark classical controller. The basic idea of sliding-mode control is to design the switching hyperplane (sliding mode plane) according to the dynamic characteristics of the system and then force the system state to converge from outside the hyperplane to the switching hyperplane by the sliding-mode controller. Sliding-mode control can overcome uncertainties of the system and provide provable stability in the control of nonlinear systems [
21]. Moreover, it has the characteristics of having a fast response, simple operation, and robustness to external environmental disturbances [
22].
Other research on UAVs, such as attitude estimation for collision recovery [
23], bidirectional thrust for aggressive, and inverted quadrotor flight [
24]; swift maneuvers [
25]; and ROS-based trajectory generation [
26] have also been developed. A controller-tuning strategy for the MAV carrying a cable-suspended load is proposed in [
27], which finds a reasonable trade-off between the fast displacements of the MAV and well-damped oscillations of the load. On the other hand, the system may lose robustness to non-ideal dynamics and uncertainty.
In general, a controller that can be adopted into a real-world autopilot requires far more adaptability, robustness, and sophistication. This is because it should handle the non-linearities of the UAV, under-actuation limitations, as well as sensor dynamics, sensor noise, and disturbances in the surrounding environment [
28]. In this study, we chose the PX4 autopilot as the UAV simulation platform. Some previous studies have validated the advantages and feasibility of PX4 in developing new flight controllers. For example, Gomez et al. developed a new PX4 Optimal PID Tuning method [
29], Saengphet et al. focused on PX4 implemented PID control [
30], and Niit and Smit validated the PX4 autopilot architecture with adaptive control and demonstrated the robustness of the controller under ideal conditions [
31].
Nowadays, we still have a wide variety of quadrotor control problems, since non-linearity and inter-dependency of UAV state variables within the mathematical model, as well as sensor implementations, noise, Kalman filters, and GPS delays, combined together are the main challenges in the design of fast responding, accurately tracking UAV controllers. In addition, the robustness of UAVs becomes a stringent requirement, in the face of turbulence effects and increasingly diverse external disturbances such as wind gusts [
13] and additional loads [
27]. Given the many strengths of sliding-mode controllers (SMC), this work focuses on the design of SMC that can be embedded into the PX4 framework. Simulation results show that SMC control outperforms PID control in many aspects, especially under large sensor noise and different types of random disturbances.
The design process of the SMC controller can be divided into six parts. (1) The development of a mathematical model in the MATLAB for the theory validation; (2) building a general PX4-based quadrotor as well as the test sites in a high-quality simulator; (3) developing a 6-degrees-of-freedom sliding-mode surface controller, which is a control scheme that includes an outer loop for position control and an inner loop for attitude control; (4) developing a 6-degreed-of-freedom disturbance observer that detects disturbance forces in the NED frame XYZ and disturbance moments around the NED frame XYZ axis; (5) optimizing SMC parameters based on an offline particle swarm optimization (PSO) method, a process that improves transient performance while reducing response time; and (6) verifying and comparing SMC against benchmark PID controllers in terms of settling time, overshoot, rise time, and tracking performance.
The article is presented in five sections. In
Section 2, some assumptions and an introduction about the PX4 autopilot and baseline PID controllers (e.g., PID Position only controller, PID Rate based controller) will be described. The dynamic equations of quadrotors will be listed. The details of the SMC control structure and the disturbance observer will also be derived. Finally, the PSO algorithm will be implemented to optimize the SMC parameters. In
Section 3, time simulations of UAV maneuvers are evaluated with SMC and PID controllers, including controllers optimized with PSO, and performances of these controllers are documented under noisy sensors and wind disturbances. In
Section 4, we discuss the results, and, in
Section 5, some future directions will be presented.
2. Materials and Methods
Computer simulation is used in many research areas to reduce experimental costs as well as the research and development cycle [
10]. PX4 is an autopilot flight-control architecture and jMAVsim is the simulator we used in this study. One advantage of using PX4 and jMAVsim is that they provide a comprehensive model of the UAV and its sensors, as well as the UAV environment, such as wind speeds.
Table 1 shows the sensor properties: GPS interval (GPS_I), GPS Delay (GPS_D), GPS Start time (GPS_S), Accelerometer Noise (Acc_N), Gyroscope Noise (Gyr_N), Magnetometer Noise (Mag_N), and Pressure Sensor Noise (Prs_N), and
Table 2 introduces the initial Magnetometer condition, including the set values and their deviations (N: north; E: east; D: down; Incl: Magnetic inclination; Decl: Magnetic declination; H-Magn: Magnetic field strength; T-Magn: Magnetic flux density).
Table 3 displays the wind conditions (N: north; E: east; D: down; SET: current wind; DEV: deviation), and, in the beginning of simulations, the airflow speed has been set to zero, which will be adjusted in the wind-resistance-testing section. The final
Table 4 gives the home position as well as the gravity setting (LAT: latitude; LON: longitude; ALT: altitude; Grav: Gravity; INIT: initial home position).
The general approach in this manuscript can be summarized as follows: We first utilized the mathematical model of the UAV to design the inner/outer loop SMC. The UAV model as well as the SMC architecture is next implemented in MATLAB/SIMULINK to verify the reliability of SMC. This architecture also includes disturbance observers who are able to compensate against disturbances. Benchmark PID controllers are also implemented in these simulations. Next, PSO was used as an offline optimization tool to intelligently iterate the controller’s parameters to improve, for example, the settling time, overshoot, and tracking performance.
Once the SMC and PID controllers performed as expected in the ideal mathematical model, we next port them to the PX4-based simulated UAV as shown in
Figure 1, where we can simulate and evaluate the UAV flight dynamics, by customizing the physical parameters of the UAV, the noise range of the sensors, the ambient magnetic field, and the environmental disturbances. Finally, we can quantify the performance of SMC and PID based on simulation data collected from PX4 flight tests.
2.1. Baseline PID Controllers and Quadrotor Dynamics Equations
Two predefined proportional-integral-derivative (PID) controllers were chosen as the baseline and compared with SMC. The first PID controller is a pure-position PID controller, which is widely used for the position control of quadcopters [
32]. This controller can track the desired attitude, including the pitch, roll, and yaw, based on only position errors. In its control loop, shown in
Figure 2, three separate PID modules compare the difference between the current XYZ position values and the desired XYZ position values, and those PID for XY positions help generate the desired rotation angles for roll and pitch. In our simulations, we limit the maximum rotation angle in roll and pitch to 50 degrees. The inputs to the PID controllers are errors in
X,
Y,
Z,
,
, and
. The outputs are virtual control signals
, which can be converted to PWM signals in four channels to the motors via the mixer.
The second PID controller is a rate controller shown in
Figure 3, which controls the speed of the UAV in addition to position tracking, so this PID controller has the potential to offer greater flight dynamic responses, as it acts on the “rate” [
33]. In short, the rate controller tracks the desired trajectory based on the velocity error, while the pure position controller tracks based on position error. In our experiments, the velocity limits are set to 20 m/s in the XY direction and 10 m/s in the Z direction. The inputs to the controllers are errors in
X,
,
Y,
,
Z,
,
,
, and
. The outputs are virtual control signals, which are converted to PWM signals in four channels to the motors via the mixer.
We use the X mode quadcopter drone in PX4, as shown in
Figure 4, and NED (north, east, and down) as the global coordinate system. The UAV dynamics equations are expressed as [
34]:
where the
directions are in the global coordinate system,
are in drone’s body coordinate system;
are angular velocity in the drone body frame;
are Euler angles;
m is the mass of the drone;
l is the distance between the center of the propeller and the center of the drone;
are the moment of inertia;
are the thrusts of each propeller;
are anti-torques of each motor given by the propellers;
is the coefficient of air drag force;
is the air drag torque coefficient;
is the full thrust of motor; and
is anti-torque at the full thrust of the motor.
are also shown in
Figure 4. The aerodynamic forces are modeled as a nonlinear drag opposing the motion, and the aerodynamics moments are modeled as a nonlinear drag moment opposing the rotation:
The thrust of each propeller
and torque
are determined by normalized signal
.
where:
where
represent the
virtual control inputs to control the thrust, pitch motion, roll motion, and yaw motion of the drone, respectively, the ranges of the virtual control inputs are set as:
; and
, which are represented as
, which are the maximum and minimum values in the process of PWM normalization, respectively. Equation (
4) is a normalization process, which is called “mixing” in PX4 architecture, the structure of the 4 × 4 matrix which provides the virtual control signals is decided by the motor number and propeller spin direction. Mixing means to receive commands (e.g., turn right) and translate them to actuator commands, here with regards to motors or servos. According to the PX4 definition,
and
. Substituting these into Equation (
4), we have:
The physical parameters of the UAV dynamics model are shown in
Table 5.
2.2. Sliding Mode Controller
Sliding-mode control (SMC), a type of variable structure control (VSC), is a nonlinear control method [
22]. The non-linearity is created by the discontinuity in the control law as explained next. The sliding-mode control designs a sliding surface (usually expressed as
), and it has different control actions, usually expressed as
, to make the system states approach to the sliding surface depending on the sign of
s. SMC has the advantages of a fast response, robustness, and handling nonlinear dynamical systems. However, when the state trajectory reaches the sliding surface, instead of sliding along the surface perfectly, it will rapidly switch between both sides of the surface. Hence, it is common for SMC to have chattering problems.
The overall control structure of the SMC controller is shown in
Figure 5. Each SMC is equipped with a disturbance observer.
2.2.1. SMC X-Y Position Controller
The position controllers of x and y are similar.
Figure 6 shows an example of how the system approaches the desired sliding surface. Here the x and y axes are the error
e and derivative of error
, respectively, and
is the initial state, which means there is some error between the initial state and desired state. Naturally, the desired final value should be
, which means the error and the derivative of the error must both go to zero, and the system reaches its steady state. Moreover, the blue line is the sliding surface that should be designed, and the system states should approach this line and slide over the line toward
.
In this process, the motion of the system state can be divided into two types: one is the reaching mode (the process that the system state leaves
and moves toward the sliding surface), which is controlled by control law u; and the other is called sliding mode (the process that the system state approaches the desired value along the sliding surface and remains on this surface, moving toward the origin
), which is defined by the sliding-mode surface. To obtain high performance of the state trajectories, we should carefully design the characters of both the control laws and the sliding surfaces. Accordingly, the design of the sliding mode controller is performed in two steps. A reasonable sliding surface makes the system to have quality performance in the sliding mode, and the design of the control law
u needs to ensure that the system can reach the sliding-mode surface from any state. According to (
1):
where
is the control signal and
Thrust . The sliding surface is selected as:
where
, and
is the tracking error. To perform the stability analysis, we choose
as the Lyapunov function. If
, then the system is stable, since this implies
s approaches 0 (i.e.,
and
). To this end, we obtain
as:
Next, we propose the control law:
where:
In (
9), the saturation function is used to solve the chattering problem due to the switches in the sign of
s:
where
is a user-defined constant value. Here, we use
. Inserting (
9) into (
8), we obtain:
From Equation (
12), we can derive that
is the sufficient condition for
to hold. These are the conditions for stability in the x direction. When optimizing the SMC using PSO in
Section 2.4, these conditions will be incorporated into PSO to make sure PSO will optimize the drone dynamics while respecting theoretical stability.
Figure 6 shows how
e and
reach the sliding surface. The data used in this figure are from one of the simulation tests conducted with PX4. Due to the aforementioned sensor noise, we observe from the zoom-in figure that
e and
do not reach (0,0) perfectly.
Due to the outputs of the SMC, the position controller should be desired values of roll angle and pitch angle to be passed to the attitude controller, we need to calculate the desired
and
, see
Figure 5. Recall that we have
from the x controller, and, similarly, we use the same SMC controller structure for the y direction, where it is easy to show that the control law will be
. Then, using
,
, we derive the desired
and
quantities as:
The above quantities are denoted below by and , respectively.
2.2.2. SMC Altitude Controller
According to Equations (
1), (
3), and (
5):
and
is the control signal. The sliding surface is designed as:
where
, and
. Let the control law be:
where:
with
and
. Proposing again
, it is possible to render
for
in (
16). To show this, we calculate
as:
Hence, satisfy .
In
Figure 7, we show how
e and
approach the sliding surface in the z direction in one of the simulation tests.
2.2.3. SMC Attitude Controller
Different from the position control, as for the attitude controllers, the reaching law is designed as the following isokinetic form:
. Firstly, we present the roll-angle control. According to Equations (
1), (
3), and (
5), we derive the following relationship:
where
:
Next, we propose a sliding surface:
where
and
. The control law:
can guarantee stability. To show this, let
. Then:
Thus, we obtain to make .
Secondly, for the pitch-angle controller, consider similarly,
where
:
We next propose the sliding surface:
with
and
. The control law:
can guarantee stability. To show this, let
, then:
Hence, we obtain to make .
Thirdly, for the yaw angle, we have:
where
:
With the sliding surface:
where
and
. The control law:
can guarantee stability. Stability analysis follows similarly, where we set
and obtain:
Hence, we obtain to make .
Finally, based on Equations (
22), (
27), and (
32), we have:
where:
In other words, we have a unique closed-form solution for
,
, and
based on all known and measured quantities. Combining
,
, and
with
in (
16), we can construct, based on the mixer, the PWM signals to be sent to each of the UAV motors.
Figure 8 shows how
e and
approach the sliding surface in the yaw motion in one of the simulation tests. Notice that, because of sensor noise, the state of the system cannot come back to (0,0) perfectly. Therefore, the state will move around the origin with a relatively small error due to noise.
2.3. Disturbance Observer
The SMC controller includes six separate disturbance observers, one for each of X, Y, Z, Yaw, Pitch, and Roll (see
Figure 5). In the X, Y, and Z directions, disturbance observers estimate the horizontal and vertical forces, while in the Yaw, Pitch, and Roll directions, disturbance observers estimate the disturbance torque around each axis. The estimated disturbance will then be fed back into the loop and thus be compensated by the SMC controller [
16], see
Figure 9.
We present below the disturbance observers of x and pitch controllers as examples, since the disturbance observers for the other four directions are quite similar to these two examples. Firstly, for the x controller:
where
d is the disturbance assumed to be a continuous signal, independent of the UAV states, and
is the control signal. Hence, the disturbance observer is formed as:
where
is the value, which the observer shows, and
is an intermediary variable. So, the error between the actual disturbance and the value of the disturbance observers
reads:
Therefore, if
is bounded, then the disturbance error
is bounded as along
. Moreover, when
, we have
. Next, to eliminate the steady-state error caused by disturbances, we should bring the
back to the controller. Therefore, to eliminate the influence of disturbance, we bring back the value of the observed disturbance and obtain the new control law:
Similarly, for the pitch controller:
where
d is the generic notation for disturbance and should be considered different from that in (
37). We have the disturbance observer as follows:
Hence, the new control law reads:
where we select
.
2.4. Particle Swarm Optimization for PIDs and SMC
Notice that, in
Section 2.2, we established the theoretical conditions guaranteeing the stability of the SMC-drone dynamics based on the Lyapunov stability theory. The next question is then how to optimize the SMC parameters for improved drone performance without violating stability. Since stability conditions are established in
Section 2.2, these conditions can guide us to carefully tune the SMC controller gains. To this end, we propose to utilize PSO, as we explain next.
2.4.1. PSO Optimization Procedures
Particle-Swarm Optimization (PSO) is an evolutionary computational method that originated from the study and simulation of birds’ predatory behavior [
35]. PSO is inspired by the fact that we can imagine birds finding food by using a set of particles to solve a problem. Based on the observation of the activity behavior of a group of birds, the PSO algorithm uses the information-sharing property among individuals in a group to change the movement of the whole group in the problem-solving space from disorder to order, so as to obtain the optimal solution. In addition, compared with other swarm-intelligence algorithm methods [
27] and back propagation neural network algorithms [
36], PSO has the advantages of fewer parameters to be adjusted, fast convergence, and simple algorithmic structure [
37,
38,
39].
In detail, the basic idea of PSO is to consider a swarm of particles as a population of potential solutions to a problem. According to some simple mathematical formulations, these particles can move in the problem-solving space to search for solutions. The movement of each particle is guided by its individual best-known position and the best-known position of the entire population of particles (which is also called the global best position). In addition, the individual best position and the global best position should be updated when the particles find other better positions. Thus, when this process is repeated, the whole swarm is expected to move toward a solution of higher quality.
In view of the above, the mathematical expressions for velocity and position updates are given by:
where
,
,
. Here,
N is the number of particles in the swarm,
D is the dimension of particle (the number of the parameters),
K is the maximum number of iterations,
is the position of particle
i in the dimension
j at iteration
k,
is the velocity of particle
i in the dimension
j at iteration
k,
is a personal best position of particle
i in the dimension
j,
is a global best position of all particles in the dimension
j,
is the inertia weight factor,
and
are the acceleration constants,
and
are random numbers in the interval [0, 1], and
is the learn rate (
), which is the proportion at which the velocity affects the movement of the particle (where
means velocity will not affect the particle at all, and
means velocity will fully affect the particle) [
37].
To choose the
and
of the particles, we use a scoring system concerning three standards: the Integraltime absolute error (ITAE), settling time (Ts), and the absolute value addition of overshoot and undershoot between desired trajectory and actual flight path (
). As the performance of the controller is superior when all these three standards have smaller values, and we want the change of scores be more sensitive when the controller has a satisfactory performance, we use the normal distribution to build the score model. Moreover, we divide the parameters into three parts: to control the x and y motion, to control the z motion, and to control the yaw angle. Each part will have their own scoring system, and the general formula is as follows:
where
is the score when the standard has
value, where
is either ITAE, Ts, or OsUs, and the value of
is shown in
Table 6. Thus, we have the scores shown in
Figure 10.
The flow chart of the PSO algorithm is shown in
Figure 11. In this paper, the parameter initialization process is omitted, but the core idea is to initialize the parameters within a reasonable range of the SMC parameters respecting the stability criterion, and the initialization script will select the initial particle population. Then, the flight performance is scored according to the simulation of the mathematical UAV model. Based on the scoring results, the algorithm can find the individual best position of each particle and the best-known position of the swarm of all particles; thus, the position and velocity of the particles can be updated and iterated based on the mathematical formula. Finally, after a sufficient number of iterations, we can arrive at a final solution to the problem.
For the case of SMC, optimization can iterate while respecting the theoretical stability conditions derived in
Section 2.2 on the SMC parameters. In other words, the SMC stability conditions can be incorporated into PSO to assure that PSO always suggests a stabilizing set of SMC parameters. On the other hand, since we do not have explicit stability conditions for the PID controllers, there is no guarantee that the PSO at each iteration will yield stabilizing parameters. However, we judiciously select the initial PID gains in view of PX4 documentation and find out that PSO eventually yields optimized and stabilizing PID gains.
2.4.2. PSO-Tuned Results
In the simulations, we choose:
The initial state: , , , ;
The desired position and yaw angle: , , , ;
The PSO algorithm parameters: , , , .
During the PSO tuning, we observed the change of scores and values of the three predefined standards in
Figure 12.
From
Figure 12, the total score keeps increasing, even though one of the criteria fluctuates up and down, and this swarm of particles almost finds the optimal solution at around 20 iterations. Finally, after 100 iterations, we obtain a high total score and small ITAE, short settling time, and low overshoot and undershoot, which means expected flight performance. The optimized parameters for SMC controller are provided in
Table 7, and the fixed parameters for SMC are listed as following:
,
,
,
.
It is important to note that the above PSO algorithm is run offline, meaning it is iterated first in conjunction with the SIMULINK model, to reveal the optimum control parameters. Once these parameters are revealed (
Table 7), we can then implement them in SIMULINK as well as in PX4 for comparison purposes. In
Figure 13, we compare the performance of the initialized and optimized SMC parameters and observe an improvement in the controller performance. In the left panel of
Figure 13, the settling time of XYZ is significantly reduced, and, in the right panel of
Figure 13, the pitch and roll change rapidly and the yaw angle converges quickly to the reference value.
As a control group, we also need to use the same PSO method to adjust the PID position and PID rate parameters. For the sake of brevity, here we provide only the results of PSO, see
Table 8 and
Table 9.
3. Simulation Results
Now that we have PSO-optimized SMC and PSO-optimized PID controllers at hand, we next incorporate these controllers into PX4 under various scenarios. We note here that PSO is implemented offline a priori. In PX4 simulations, we do not perform PSO optimization in real time.
3.1. Trajectory Tracking Performance
In the previous sections, the SMC controller was designed on a fully nonlinear mathematical model of a quadrotor aircraft. In this section, the SMC controller has been continuously developed under the PX4 architecture and validated with a PX4-simulated UAV, which means that environmental noise and uncertainties have been taken into account. Several test scenarios, including step tracking, slope tracking, and force and torque disturbances have been applied. All small oscillations in position and attitude are considered to be the combined result of sensor noise, wind interference, discretization, time delay, and vehicle dynamics uncertainty. As a baseline for comparison, a PSO-tuned PID-position controller and a PSO-tuned PID-rate were also tested.
The following is the list of standards used to evaluate the performance of the controllers:
The Maximum Overshoot (Mp);
The Settling time (Ts);
The Rise time (Tr);
The Integral absolute error (IAE);
The Integral time absolute error (ITAE);
The Integral square error (ISE);
The Integral time squared error (ITSE).
The IAE, ITAE, ISE, and ITSE are assumed to be measured starting from two times the settling time (2 ·) and last for 10 s (2 · + 10), during which we assume that the UAV reached a relatively stable state.
We would like to find out which controller has less overshoot, less settling time, and smaller IAE, ITAE, ISE, and ITSE. However, rise time is not our main concern, as it can easily lead to large overshoot and significant wander of the UAV. From our point of view, the desired controller should enable smooth, rapid, and accurate UAV movement.
3.1.1. Step Profile Tracking
In the first case of this study, the UAV is controlled to track a step contour in terms of distance, height, and angle, respectively. Throughout the time axis, the UAV should rise from 0 m to 20 m, starting at 5 s and moving from 0 m to 4 m in the X and Y directions, starting at 15 s, and rotating 90 degrees starting at 40 s, as shown in the black dash reference curves in
Figure 14.
Table 10 summarizes the simulation results, which show the SMC controller has the smallest overshoot and the smallest settling time. Compared to the PID controllers, its rise time becomes slightly longer in the horizontal position (X and Y), but slightly shorter in height and angle (Z and YAW). Furthermore, we analyzed the zoom-in figures of z and yaw motion. The PID-based controllers need a longer time to reach steady states, which leads to a small steady-state error even after a long period of time. In contrast, the SMC UAV does not have many errors, given its IAE, ITAE, ISE, and ITSE values are relatively small.
Figure 14 shows that SMC motion has a smaller range and fewer oscillations, and its time derivative is smaller, compared to the PID, especially in terms of pitch and roll tracking. If we assume that smoothness and stability have greater weights in our evaluation, SMC is more preferable.
It can be observed that the proposed SMC outperforms the other two PID control methods in terms of tracking accuracy. The benchmark PID-position and PID-rate controllers can stabilize the simulated UAV under PX4 architecture but with a larger overshoot. These phenomena are undesirable in reality, especially when tracking accuracy and stability are required. On the other hand, the proposed SMC can exhibit much improved tracking performance.
3.1.2. Ramp Profile Tracking
The second case focuses on the ramp tracking performance. This is also important when the UAV is intended to perform curvilinear trajectory tracking. We separate the ramp experiment into four discrete scenarios: (a) ramp only in the X direction; (b) ramp only in the Y direction; (c) ramp only in the Z direction; and (d) ramp only in the Yaw.
The tracking results for this case study are given in
Figure 15, where the error histograms in panels b, d, f, and h show that the PID-rate-based controller design exhibits much larger tracking error (blue bars shift away from the origin in the error histograms). Although the PID-position controller gives a finer tracking performance than the PID-rate, see panels a, c, e, and g, and behaves similarly to the SMC, it is more oscillatory.
In detail, for X and Y slope tracking, SMC fits the reference value best (compare IAE, ITAE, ISE, and ITSE on
Table 10), and the PID-position controller, however, has a relatively smaller tracking error than the PID-rate controller (
Table 10); it continuously oscillates around the reference slope (panels a, c), which results in a wider position error distribution around the zero-error than SMC, see panels b and d. A similar result arises in the Z-axis slope tracking, where the green area (SMC) is larger than the red area (PID-position) near the zero-error boundary, see panel f. Finally, the yaw angular tracking performance of SMC outperforms the PID controllers, see panel g zoom-in plot.
3.1.3. Complex Trajectory Tracking
Finally, we introduce a complex trajectory which is a combination of X, Y, and Z position set-points. We set these references as:
;
;
. The UAV takes off at
and starts tracking the trajectory at
. The result is shown in
Figure 16a (top view), from which we can see the trajectory resembles a flower. To compare the overall tracking performance of three controllers, the figure also introduces a timeline in
Figure 16b,c.
From the top view of
Figure 16a, we observe that SMC tracks the desired trajectory during the simulation, while PID-position- and PID-rate-based controllers show notable tracking errors and deviations continuously. Panel a also shows that PID-position produces oscillations around the reference (overshoots and undershoots). On the other hand, from the time trace of x and y in
Figure 16b,c, we observe the PID-rate controller has a persistent time delay (about 1 s) compared with SMC and the desired set-points.
Figure 17 and
Figure 18 show the error histograms of the SMC controller and the PID controllers during the flower-pattern trajectory-tracking simulations. These two figures show that the position errors of SMC are mostly concentrated around zero with respect to the both x and y directions, i.e., −0.19 m to +0.06 m in the x direction and −0.08 m to +0.23 m in the y direction; conversely, the position-error distribution of PID controllers is relatively scattered across the range of errors in the histograms. We can observe that SMC responded quicker than the PID controllers from
Figure 16 (see when the slope changes in the desired trajectory), and, meanwhile, it produces smaller position-tracking errors as evident in
Figure 17 and
Figure 18. Therefore, combining the performances of the tracking accuracy and tracking speed, SMC demonstrates superiority over these two PID controllers with respect to complex trajectory tracking.
3.2. Disturbance Resistance
Accurate control of position and altitude in environments with disturbances is critical to the safety of UAVs. In this study, the UAV was controlled to maintain its position under disturbances in different directions. There are six discrete scenarios: (1) Constant force disturbance in X direction, (2) Constant force disturbance in Y direction, (3) Constant force disturbance in Z direction, (4) Constant torque disturbance around X axis, (5) Constant torque disturbance around Y axis, and (6) Constant torque disturbance around Z axis.
3.2.1. Force Disturbances
The tracking performance, together with their force disturbance estimates from the proposed disturbance observer, is illustrated in
Figure 19. In scenario (1), panel (a) and panel (b) correspond to a constant force disturbance added in the X direction as 1 m/s
; in scenario (2), panel (c) and panel (d) correspond to a constant force disturbance added in the Y direction as 1 m/s
; and in scenario (3), panel (e) and panel (f) correspond to a constant force disturbance added in the Z direction as 10 m/s
.
Despite the relatively small gain used in the design of the observer (), disturbance estimates can quickly converge to the true value of the disturbance. It can also be observed that the proposed SMC controller outperforms the other two controllers in resisting the force disturbance. In both the vertical and horizontal directions, the PID-position and PID-rate controllers have large oscillations in the presence of disturbance bursts, and they have large steady-state errors in the presence of disturbances. These phenomena are undesirable, especially when the natural wind changes rapidly or when the payload changes, and these characteristics are likely to cause a true UAV crash. On the other hand, SMC control can use the estimated disturbance information to form an active compensation-control effort. As a result, it exhibits a much-improved force-interference-rejection capability with a higher tracking accuracy.
3.2.2. Comparison of the Wind Resistance under the Cross-Wind Effect
Crosswind, as a special form of disturbance, often occurs when UAVs are flying, especially in indoor or narrow environments, and these winds can be superimposed in multiple directions and are often unpredictable. Therefore, the wind resistance of UAVs is often used as an important factor to evaluate their flight-control performance. For this reason, in addition to the tracking performance, we investigate the effects of variable crosswinds. The wind resistance results in the horizontal plane for each controller are listed in
Figure 20 and
Figure 21, with X representing north and Y representing east. The corresponding estimates of the disturbances based on the disturbance observer in SMC are also shown in
Figure 20.
First, we add a variation of horizontal wind as shown in
Figure 20. Starting at 18 s, we add 3 m/s (about 5.83 Kts) of wind in the X and Y in each 5 s, which means the resultant wind added in each period should be 3
m/s in the northeast direction. Although the wind added looks more similar to step functions, the actual wind’s increasing rate was around 4.2426 m/s
, which means that the wind speed was accelerated to the reference value in about 1 s. Starting from around 55 s, the wind speed was gradually reduced down to 0 m/s. Throughout the simulations, SMC was able to reject wind forces and maintain the desired point within ±20 cm, but the PID drifted considerably, up to 75 cm away from the desired point. During the test, the maximum wind resistance of the SMC- and PID-controlled PX4 UAV was 30.5 m/s (about 59.28 Kts); exceeding this value would result in irreversible trajectory deviation, leading to instability.
In addition, the wind speed estimated by the disturbance observer is also shown, which matches well with the actual wind-speed magnitude. Due to the symmetry of the UAV, the response on the Y-axis is similar to the response on the X-axis, and the Y-plot is omitted here for clarity. It can be observed from
Figure 21 that UAV motion with the SMC controller is concentrated more around the origin than with other controllers; hence, SMC has the best crosswind resistance in terms of position accuracy. This is due to its active disturbance compensation.
3.2.3. Torque Disturbances
The tracking performance together with the torque disturbance estimates from the proposed disturbance observer is illustrated in
Figure 22. In scenario (4), panels (a) and (b) correspond to a constant torque disturbance added around the X axis as 5 rad/s
; in scenario (5), panels (c) and (d) correspond to a constant torque disturbance added around the Y axis as 5 rad/s
; in scenario (6), panels (e) and (f) correspond to a constant torque disturbance added around the Z axis as 1 rad/s
.
It can be seen that the proposed SMC controller is superior to the other two PID controllers in the face of torque disturbance especially in the yaw direction. The PID-position and PID-rate controllers initially have larger drifts when pitch and roll disturbances are present, although they can slowly stabilize the UAV. These phenomena may cause the UAV to move uncontrollably during takeoff, especially when the center of gravity is not near the center of the UAV. SMC has smaller drifts and corrects faster (see panels a, c, and t < 30 s). In the steady state, however, PID is more acceptable in terms of keeping the tracking error in x and y small. Note that, in the yaw direction, the other two controllers cannot quickly compensate for the disturbance (settling time out of range of the plot), so the PID-rate will slowly return to its original angle, while the PID-position will be slower. On the other hand, SMC is able to use the estimated disturbance information to form active compensation. In the case of circular wind or rotational forces acting on the UAV, SMC controllers with disturbance observers are more sensitive to torque than PID-based controllers, which results in SMC having stronger torque immunity.
4. Discussion and Conclusions
This work describes the design and implementation of a disturbance-observer-based sliding-mode surface controller (SMC) and validates a SMC with a simulated PX4 quadcopter. As a model-based design, this study started from a mathematical MATLAB/ SIMULINK model, from which we adopted the PSO algorithm to optimize the parameters for the controllers, followed by testing and validating in a highly realistic jMavsim simulator. In the simulations, we compared two different benchmark PID controllers (PID-rate controller and PID-position controller) with the proposed SMC and evaluated their performance by applying different disturbances (e.g., disturbance-force, disturbance-torque, and crosswind effects.) within the sensor-noisy environment.
On the one hand, for precise motion in the horizontal plane, SMC is way ahead of the pack. On the other hand, the PID-based controller took more time to return to the reference value under sudden increases in force and torque disturbances, while the SMC could track the desired trajectory smoothly and quickly. In addition, when focusing on contour tracking under wind effects, both PID controllers performed similarly but were inferior to the SMC controller. This means that the SMC-based UAV has improved wind resistance. Another advantage of the SMC controller is that the sliding-mode controller was designed for a fully nonlinear model based on Lyapunov stability analysis; however, the PID controller was designed for a simplified linear form, which leads to a more robust SMC approach. An SMC with disturbance observers facilitates accurate and fast UAV adaptation in inconsistent dynamic environments.