Inner/Outer-Loop Control of a Drone under Disturbances and Uncertainties; A Sliding Mode Control Approach A Thesis Presented by Runjiang Zhao to The Department of Mechanical and Industrial engineering in partial fulfillment of the requirements for the degree of Master of Science in Mechanical engineering Northeastern University Boston, Massachusetts April 2020
82
Embed
Inner/Outer-Loop Control of a Drone under Disturbances and ...m046qg834/fulltext.pdfInner/Outer-Loop Control of a Drone under Disturbances and Uncertainties; A Sliding Mode Control
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Inner/Outer-Loop Control of a Drone under Disturbances and
Uncertainties; A Sliding Mode Control Approach
A Thesis Presented
by
Runjiang Zhao
to
The Department of Mechanical and Industrial engineering
Inner/Outer-Loop Control of a Drone under Disturbances and
Uncertainties; A Sliding Mode Control Approach
by
Runjiang Zhao
Master of Science in Mechanical engineering
Northeastern University, April 2020
Rifat Sipahi, Adviser
Drones can be rendered functional only if we can control them properly. Most flightcontrollers utilize what is known as Proportional Integral Derivative (PID) controllers owing to easeof their implementation at the software level. However, PID controllers cannot address uncertaintieshence a drone with parameter uncertainties may not achieve desirable flight performance. Moreover,determination of PID parameters for a drone cannot be performed systematically since the dronedynamics is nonlinear. This then inhibits one’s ability to guarantee a robustly functioning drone usingPID controllers. To address the above shortcomings, we present our in-house sliding mode controllerdesign and test it against PID in computer simulations, in scenarios where system parameters such asair resistance coefficient, mass, and moment of inertia are uncertain. Arising simulation results arethen analyzed in terms of common metrics, such as errors in drone position tracking, response time,and undesired oscillations. We show in these scenarios that the sliding mode controller outperformsthe PID controller, and furthermore as a nonlinear control methodology, enables a theoretical founda-tion to render the drone dynamics robust against uncertainties.
key words:Sliding mode control, Robust control, drone control, PID control
vii
Chapter 1
Introduction
1.1 Background
In general, unmanned aerial vehicle (UAV) mainly refers to a type of aircraft with certain
autonomous operation, self-provided energy and self-driven capabilities. This type of aerial vehicle,
which has been studied since the birth of the aircraft nowadays plays a very important role in many
fields, such as disaster rescue, cargo transportation, aerial observation, film and photogrammetric
recording [12].
There are many types of UAVs, which can be roughly characterized in three categories:
fixed-wing UAVs; rotor UAVs, also called drones, and other types of UAVs, such as those that
combine fixed-wing with rotors. Fixed-wing UAVs are the first type of UAVs that were developed.
Their low cost, mature technology, easy control, and long flight distances have made them dominate
the initial stage of drone development. As early as the beginning of the twentieth century, the U.S.
Navy and the U.K. Royal Navy conducted a number of experiments by modifying fixed-wing UAVs.
Among them, the famous ones are the DH.82B designed by the U.K. Royal Air Force and the OQ-2
designed by the Radioplane Company [9].
In contrast, the difficulties in theoretical analysis and practical applications of rotor UAVs
are much higher than fixed-wing UVAs. However, with the advancement of technology, especially
the micro-electromechanical system (MEMS) that emerged around the 1990s, made the application
of micro-sensors possible, which provided an effective means to measure/observe a drone’s dynamic
states. Although the sensors at that time had a lot of noise interference, these developments paved
the way for drones.
With the beginning of the 21st century, drone research has entered a period of rapid and
1
CHAPTER 1. INTRODUCTION
growing development. A major change in this period is that there are many platforms provided
by different research institutions, so that when people start to study drones, they can directly
perform many mission-oriented research without building their own platforms. Two of the well-
known environments are ‘real-time indoor autonomous vehicle test environment’ [14] developed by
Professor Jonathan P. How’s laboratory from Massachusetts Institute of Technology and ‘GRASP
Multiple Micro-UAV Testbed’ [23] developed by Professor Vijay Kumar’s laboratory from University
Pennsylvania. Professor Kumar also gave a lecture on drones on TED, which comprehensively and
systematically summarized the technology, collaboration capabilities and development of micro
quadrotor drones [18]. The lecture made both academia and business see the future of rotary drones.
Simultaneously, with the expansion of application scenarios, limitations of fixed-wing
UAVs have surfaced. For example, takeoffs and landings require runways, aircrafts are generally
large and cannot fulfill the hovering requirements in some civilian and commercial applications. The
vertical take-off and landing characteristics of the rotary wing UAVs make them suitable for many
small space operations and are more suitable in cities, forests and other areas with physical obstacles.
Different from the general helicopter structure, drones mostly adopt the form of multi-rotor in the
same plane, instead of the cooperation of main propeller and tail propeller or double main propeller
in different planes. This makes drone’s structure simpler and help meet the requirements of low cost,
easy maintenance and simple technology of civil aircraft.
Among all types of drones, quad-rotor drone, with its simple, reliable and versatile features,
has become one of the most widely used and researched drone type. One of the application scenarios
worth mentioning is the prime air project [3] developed and released by Amazon. This project
proposes a drone express service that provides 30 minutes delivery time for their prime members.
This idea has important implications for saving labor costs. Another very interesting example is
given by Prof. Raffaello D’ Andrea’s team; they demonstrated a method that allows drones to catch
thrown tennis balls and perform batting actions [24]. They also demonstrate many amazing tasks
that drones can accomplish in a TED lecture [4], for example, holding the wine glass smoothly or
four drones cooperating to pull a net. All these results have shown strong promise that application
scenarios of drones can potentially be expanded to a variety of scenarios.
At present, many quad-rotor drones are still operated manually, with automatic driving as
a mode of assistance. The advantage of this is that it can simplify the difficulty of the control system.
However, the drone’s flight performance, safety, and reliability highly depend on the proficiency of
the operator. These conditions not only increase the cost of drone applications, but also bring about
security risks. Therefore, it is also necessary to develop unmanned aerial vehicles with autonomous
2
CHAPTER 1. INTRODUCTION
driving capabilities. The quad-rotor drone system can be divided into perception, path planning,
control, and execution. Among them, the control system is the most fundamental and important in
the drone system, simply because without an adequate controller, the drone cannot be operated. This
thesis will discuss the overall control design and implementation of the controller on a full nonlinear
drone model, supported by time simulations to assess controller performance.
1.2 Research status
In this section, I intend to summarize the current control methods for drones.
Proportional Integral Derivative control (PID) is one of the most widely used control
methods in the drone control system. Although other control design tools are available, PID still
takes an important role in the control systems field, with its advantages such as simplicity of tuning
and ease of implementation [10]. If the controllers are classified as linear controllers, non-linear
controllers, and model-free controllers, PID can be regarded as either a model-free controller or a
linear controller. This is because PID can be applied by means of model-free tuning directly, or
converting the linear system to be controlled into a transfer function and then performing analysis
in the Laplace domain. For the first method, the parameter adjustment is very difficult, and a
lot of simulations and experiments are required to obtain good results. For the second method,
its application is limited to linear systems, and the trade-off between tracking performance and
robustness can be difficult to deal with. In order to address the difficulty in tuning the PID controller,
the work in [6] puts forward a self tuning method based on gradient decent. In [31], authors
proposed a method based on neural networks and an extreme learning machine, and explored how to
improve the robustness of the PID controller. More discussion and research on the application of
PID controllers on drones were proposed in [33][22][42]. These studies explored the possibility of
improving the PID controller performance on drones from different perspectives.
The linear quadratic regulator (LQR) is also a widely used tool for designing controllers
for drones. As an optimization-based control method, its advantage is that it can use the control
parameters to effectively adjust the control law matrix, and then adjust the relationship between
energy cost and system performance [2]. A 3D LQR based drone landing controller was proposed by
[15], which can calculate the safe area for drone landing and control the landing processes smoothly.
However, there may be some challenges in using LQR. For example, in the case when the LQR
controller requires full state feedback and if all system states are not measurable, one then would also
need to design an appropriate observer to complete the missing state measurements. LQR design
3
CHAPTER 1. INTRODUCTION
may also be sensitive against parameter uncertainties. An unscented-Kalman-Filter (UKF) is used
to strengthen the performance of LQR controller in [16], in order to reduce the error between the
simplified model and the actual drone model.
Sliding mode control (SMC) is another controller that is widely used in drones. The
essence of SMC is to first design a low-order sliding mode surface with good convergence and
performance, and then use the controller to drive the system states to slide to the sliding mode
surface, to ensure the performance of the entire system. Sliding mode control is a type of non-linear
controller and has robustness characteristics against uncertainties, and thus it can control the dynamic
model with uncertainties and large disturbances. In general, the robustness of sliding mode control is
achieved with the knowledge of the upper/lower boundaries of uncertainties and disturbances. The
main problem of sliding mode control in research and engineering applications is the problem of
controller chattering [35][17]. Chattering causes many problems for drone systems, such as reducing
performance and increasing energy consumption [8]. The discussion about the chattering of sliding
mode control are established in [29][25][21][26]. For drones’ dynamic coupling problem at large
orientation angles, a combination of under-actuated system sliding mode control (NASSMC) and
novel robust terminal sliding mode control (NRTSMC) are proposed in [41].
In addition to the above three control methods, there are a series of successful control
implementations for drones, including but not limited to back-stepping control [20], model predictive
control (MPC) [32][11][7], H-infinite control [28], fuzzy and neural networks control [30] and robust
control [40]. In general, research in the field of drone control has gradually shifted from primary
control to more in-depth control theory, and is committed to solving the diverse challenges faced by
drones.
Two biggest problems faced when designing controllers for drones are high coupling
between system states and modeling uncertainties [37]. In view of these two problems, this thesis
discusses how to design a sliding mode controller to maintain the performance of the drone in the
face of large Euler angles and uncertainties and disturbances, while removing the inherent chattering
problem of sliding mode controller.
1.3 Research content
Chapter 1 first introduces the current development status of UAVs, especially quad-rotor
drones. Then we summarize several drone control methods and their advantages and drawbacks.
4
CHAPTER 1. INTRODUCTION
Chapter 2 first derives the kinetic equations of a quad-rotor drone, organizes the model
equations to prepare them for control design, and also introduces some other dynamic factors
including aerodynamics and ground effects.
In Chapter 3, we first design the inner loop and outer loop structure of the drone con-
troller, and also show how to build the simulation model of this inner and outer loop structure in
Matlab/Simulink. Then the dynamic model of the drone is linearized and simplified. Finally, we
carry out the design and basic analysis of general PID controllers on this linearized model, and also
present time simulations of these PID controllers on the full scale nonlinear drone model.
Chapter 4 first discusses the theoretical principles of classical sliding mode control and
then demonstrates this controller over a simple benchmark system. The corresponding stability proof
and simulation results are also provided. Finally, for the linearized inner loop system of the drone,
we design a classical sliding mode controller, and present how to use the Lyapunov function to prove
the stability of the closed-loop system. Finally, time simulations are performed in Matlab/Simulink
where the sliding mode controller is implemented on the full scale nonlinear drone model.
Chapter 5 first discusses the chattering problem caused by the sign function in the classical
sliding mode controllers. This chattering problem is very important for drones because we cannot
accept a high-frequency propeller speed commands. Then several continuous sliding mode controllers
are designed for the linearized drone dynamics to solve the problem of chattering. The stability of
continuous sliding mode controller is also proved by Lyapunov function. Finally, we performed time
simulations in Matlab/Simulink where the sliding mode controller is implemented on the full scale
nonlinear drone model.
In Chapter 6, we design outer loop continuous sliding mode controller based on the results
in Chapter 5. The stability of the system is also proved by Lyapunov function. These results are then
combined with those in the next chapter.
In Chapter 7, we firstly show the control laws of PID controllers and continuous sliding
mode controllers, as well as the selection of system and controller parameters. The uncertainties and
disturbances are also defined. Then we simulate and compare the controllers in terms of robustness
and agility in maneuvering. It is worth mentioning that we briefly discuss how to change the
continuous sliding mode controller into an adaptive coefficient continuous sliding mode controller in
order to achieve a faster drone response.
Finally, we systematically summarize the results obtained from the simulations.
5
Chapter 2
Dynamic Analysis
2.1 Euler angles and rotation matrix
Before we talk about drone dynamic model, we will give a short introduction of Euler
angles and rotation matrix. We are going to study the dynamic problem of drone from two coordinates:
earth coordinate and drone body coordinate:
Figure 2.1: Earth coordinate and body coordinate, modified from [13]
where blue solid line represents earth coordinate system which is fix on the earth and will not rotate
or move, the red dotted line represents body coordinate system which is fixed on the drone and
6
CHAPTER 2. DYNAMIC ANALYSIS
rotates or moves with the drone. We also define θ as pitch angle, φ as roll angle, ψ as yaw angle.
We are going to control the drone based on both these two coordinate systems, so a
transformation matrix is necessary to relate them. First we have the basic rotation matrix for rotation
along x,y and z axis.
Rx =
1 0 0
0 cos θ − sin θ
0 sin θ cos θ
(2.1)
Ry =
cosφ 0 sinφ
0 1 0
− sinφ 0 cosφ
(2.2)
Rz =
cosψ − sinψ 0
sinψ cosψ 0
0 0 1
(2.3)
Then we can define coordinate transform matrix from body frame to earth frame as:
Reb = Rz ·Ry ·Rx
=
cos θ cosψ − cosφ sinψ sinφ sinψ + cosφ sin θ cosψ
cos θ sinψ cosφ cosψ + sinφ sin θ sinψ − sinφ cosψ + cosφ sin θ sinψ
− sin θ sinφ cos θ cosφ cos θ
(2.4)
And another matrix I want to introduce is the angle rotation matrix [13], from body frame to earth
frame, which is a deformation matrix of Reb.
φ
θ
ψ
=
1 tan θ sinφ tan θ cosφ
0 cos θ − sinφ
0 sinφsecθ cosφsecθ
·b ω (2.5)
where bω is angular velocity vector in body frame. This matrix mainly describes the relationship
between the angular velocity of the drone and the Euler angle. However, when the Euler angle is not
particularly large, in most cases we can consider that the derivative of the Euler angle is equal to the
angular velocity of the drone.
7
CHAPTER 2. DYNAMIC ANALYSIS
2.2 Dynamic equations
In this part we will build a dynamic model for the drone. I will also organize the equations
to prepare the model for controller design. The dynamic model consists of two parts, translational
dynamics and rotational dynamics. We can take this classification because they have different
dynamic formulas and different dynamic characteristics.
2.2.1 Translational dynamics
Translational dynamics can be divided into XY direction movement and Z direction
movement. The analysis of Z direction movement will be a little bit easier because when the drone
is flying in the air, if we just ignore the air drag, there are only two forces working on the drone,
gravity and thrust produced by the propellers. Of course, if all the Euler angles are zero, we can view
this part as a one dimensional linear model. The movement in the XY direction needs to first have a
certain Euler angle to adjust the direction of thrust. Here is the original equation for the translational
dynamics:
x
y
z
=
0
0
−g
+1
m·Re
b ·Thrust (2.6)
We can get a specific equation by solving formula (2.5) combined with (2.4):x
y
z
=
0
0
−g
+1
m
sinφ sinψ + cosφ sin θ cosψ
− sinφ cosψ + cosφ sin θ sinψ
cosφ cos θ
·Thrust (2.7)
where Reb represent the rotational matrix from body coordinate to earth coordinate,
and Thrust = [0 0 Thrust]T is the thrust vector produced by the propellers.
2.2.2 Rotational dynamics
Next we are going to talk about rotational dynamics. In fact, what we are discussing here
is how to obtain the Euler angles. For rotational dynamics, we first have rigid body angular motion
differential equation: ∑M =
dL
dt+ ω × L (2.8)
8
CHAPTER 2. DYNAMIC ANALYSIS
where L refers to Momentum moment. Then we can derive an equation for the rotational dynamics:∑M = J ·b ω +b ω × (J ·b ω) (2.9)
Here,∑
M refers to Torque combination, J refers to inertial moment vector of drone, bω refers to
angular acceleration of drone in body frame, bω refers to angular velocity of drone in body frame.
J =
Jx 0 0
0 Jy 0
0 0 Jz
(2.10)
bω =
p
q
r
(2.11)
bω =
p
q
r
(2.12)
where Jx, Jy, Jz are inertial moments around x, y, z axis; p, q, r, p, q, r are angular velocity
and acceleration of drone around x, y, z axis under body frame. After we combined formula
(2.8), (2.9), (2.10) and (2.11) we can derive a specific equation for rotational dynamics for drone:
∑M =
Jx 0 0
0 Jy 0
0 0 Jz
·p
q
r
+
p
q
r
×Jx 0 0
0 Jy 0
0 0 Jz
·p
q
r
(2.13)
∑M has three parts: Thrust difference, Rotor drag torque difference and Gyro effect. So we are
going to talk something about motor and propeller modeling to get∑
M.
For thrust difference:
MT =
(T1 + T4 − T2 − T3) · l(T2 + T4 − T1 − T3) · l
0
(2.14)
where Ti = Kt · Ω2i means the thrust produced by propeller, Kt is the simplify torque coefficient; l
is the distance from center of motor to center of drone. We can clearly have the conclusion that this
9
CHAPTER 2. DYNAMIC ANALYSIS
torque can affect pitch and roll, but cannot affect yaw.
For rotor drag torque difference:
MQ =
0
0
−Ω21 − Ω2
2 + Ω23 + Ω2
4
·KQ (2.15)
where Ω is the propeller speed (RPM/min). Contrary to the torque caused by the thrust difference,
rotor drag torque difference can only affect yaw. Gyro moment has been ignored by almost all articles
because propeller have very little inertial moment and mass, comparing with the drone. So we have :
∑M =
∑MT +
∑MQ =
(T1 + T4 − T2 − T3) · l(T2 + T4 − T1 − T3) · l
0
+
0
0
−Ω21 − Ω2
2 + Ω23 + Ω2
4
(2.16)
when we combine formula (2.13) and (2.16), we can get the equations of drone angular acceleration
in the body frame:p
q
r
=
1Jx1Jy1Jz
·l ·KT · (Ω2
1 + Ω24 − Ω2
2 − Ω23)− q · r · (Jz − Jy)
l ·KT · (Ω22 + Ω2
4 − Ω21 − Ω2
3)− p · r · (Jz − Jy)KQ · (−Ω2
1 − Ω22 + Ω2
3 + Ω24)− p · q · (Jy − Jx)
(2.17)
2.3 Simplified formula for controller design
According to formula (2.5), (2.7) and (2.17), we can write [19]:x
y
z
=
0
0
−g
+1
m
sinφ sinψ + cosφ sin θ cosψ
− sinφ cosψ + cosφ sin θ sinψ
cosφ cos θ
·KT · (Ω21 + Ω2
2 + Ω23 + Ω2
4) (2.18)
p
q
r
=
1Jx1Jy1jz
·l ·KT · (Ω2
1 + Ω24 − Ω2
2 − Ω23)− q · r · (Jz − Jy)
l ·KT · (Ω22 + Ω2
4 − Ω21 − Ω2
3)− p · r · (Jz − Jy)KQ · (−Ω2
1 − Ω22 + Ω2
3 + Ω24)− p · q · (Jy − Jx)
(2.19)
φ
θ
ψ
=
1 tan θ sinφ tan θ cosφ
0 cosφ − sinφ
0 sinφsecθ cosφsecθ
·p
q
r
(2.20)
10
CHAPTER 2. DYNAMIC ANALYSIS
The equations we described above are going to represent the real drone for time simulations. But for
controller design, it is better for us to organize these equations. We are going to view some parts of
the equation to be a command we use to control the drone, and obviously we use propeller speed to
control the thrust and then control the drone, so firstly, we decouple the propeller speed from the
formula:
x
y
z
=
0
0
−g
+1
m
sinφ sinψ + cosφ sin θ cosψ
− sinφ cosψ + cosφ sin θ sinψ
cosφ cos θ
· u1 (2.21)
p
q
r
=
1Jx1Jy1Jz
·lu2 − q · r · (Jz − Jy)lu3 − p · r · (Jz − Jy)u4 − p · q · (Jy − Jx)
(2.22)
φ
θ
ψ
=
1 tan θ sinφ tan θ cosφ
0 cosφ − sinφ
0 sinφ sec θ cosφ sec θ
·p
q
r
(2.23)
where u1
u2
u3
u4
=
KT · (Ω2
1 + Ω22 + Ω2
3 + Ω24)
KT · (Ω21 + Ω2
4 − Ω22 − Ω2
3)
KT · (Ω22 + Ω2
4 − Ω21 − Ω2
3)
KQ · (−Ω21 − Ω2
2 + Ω23 + Ω2
4)
(2.24)
Through this transformation, we can see that the terms with propeller speed in the formula become
simpler, so that we can calculate command vector more easily. So in the future control part design,
ui is going to be command vector calculated by the controller. We can also use ui to back-calculate
the propeller speeds Ωi.
And now let me talk a little bit more on how we back-calculate the propeller speeds of the
drone from ui. This is actually a mathematical operation:
R =
KT KT KT KT√22 KT −
√22 KT −
√22 KT
√22 KT
−√22 KT −
√22 KT
√22 KT
√22 KT
KQ · l KQ · l −KQ · l −KQ · l
(2.25)
11
CHAPTER 2. DYNAMIC ANALYSIS
Ω21
Ω22
Ω23
Ω24
= R−1 ·
u1
u2
u3
u4
(2.26)
And propeller speed in this thesis is limited between 0 to 7000 RPM1. Then we can use propeller
speeds to calculate the dynamic model (2.17) (2.18) (2.19) (2.20).
2.4 Other kinetic factors
In this part, I am going to introduce some other effects that may have an impact on drone
dynamics, such as air drag and ground effect. These effects may not be considered for all situations,
but sometimes they play an important role in the dynamic analysis of drone.
2.4.1 Air drag
Air drag means the force produced by ‘air’ when the drone is moving at a high speed
or relatively high speed in the air. There are various ways to analyze air drag. The most essential
formula is [27] [34]:
Fc =1
2· Cd · S · ρ · V 2 (2.27)
Here Fc is air drag force, S is cross-sectional area, ρ is the air density, Cd is resistance coefficient,
which can be calculated by the formula below [27] [34]
Cd = CD1(1− sin3 θ) + CD2(1− cos3 θ) (2.28)
Here we use X direction as an example, which means Cd in formula (2.28) is related to θ angle.
CD1 and CD2 is the resistance coefficient when the pitch angle is 0 and π2 calculated by CFD (A
professional software for calculating air resistance).
From the formula we can clearly conclude that the pitch angle and speed will strongly
affect the value of the air resistance, and other factors such as size and density do not change much
during the flight. Generally speaking, the air resistance of the drone can be ignored when flying at
low angles and low speeds, but if we start to discuss high speed or large angles, air resistance issues
will become important. Of course, the direction of resistance force is always opposite to the direction
of speed.1In the process of control design, we shall assume that actuator saturation does not arise. When the controllers are
implemented in time simulations, propeller speeds will be accordingly saturated.
12
CHAPTER 2. DYNAMIC ANALYSIS
In the literature [1][38], a simplified formula is adopted for air drag force, and its form is
as follows: Fc = K1 · x
Fc = K2 · y
Fc = K3 · z
(2.29)
Here we can see that the air resistance in one direction is actually simplified to a function of speed,
and has nothing to do with the Euler angle. This is because when the Euler angle changes, the air
resistance does not change much. In this thesis, I have chosen this empirical formula to build the
drone simulation model.
2.4.2 Ground effects
The ground effects mainly refer to the fact that when the aircraft is flying near the ground,
the ground will affect the aerodynamic characteristics of the aircraft and the propeller, which will
cause the conventional lift coefficient to change, thereby making the final lift different from expected.
The most common specific manifestation in the research of quad-rotor drones is that when the drone
is close to ground, the lift will be greater than the theoretical lift and eventually causes a sudden
change in drone height.
This can actually be considered as a kind of disturbance or uncertainty, which makes system
parameters change when it is close to the ground. If we do not consider the ground effect when
designing the controller, it is actually possible for a robust controller to have a good performance.
But for controllers without robustness or poor robustness, the influence is great. At the same time,
analyzing the forces in this process can also improve the control effect for a robust controller.
Regarding this effect, we also adopted empirical formulas in [27] for modeling
c = (2.6− 1.6 · ( z
2 · l)) 0 ≤ z ≤ 2 · l
c = 1 z > 2l
Freal = Fthrust · c
(2.30)
where c is a scale factor, which refers to the relationship between theoretical lift and lift after
considering ground effects, z is vertical height, l is the distance between rotor center to drone center.
From this we can also see that the ground effect is almost reduced to 0 when the vertical
height is twice the radius of the rotor, but at a height of 0, the lift under the ground effect can almost
reach 2.6 times the theoretical lift.
13
Chapter 3
PID Controller Design
3.1 Introduction
As we mentioned in Chapter 1.1, PID controllers are widely used in the field of drone
control system. However, as a linear controller, PID still has its limitations. In other words, when
we use a lot of technologies to improve PID, in fact, it is no longer the original PID. Maybe trying
another controller is a better choice. But as a comparison, we still need to understand the principle of
the PID controller.
Therefore, I will first adopt a PID controller to control the drone, which can sort out the
overall control framework, and can also be compared with the effect of sliding mode controller. The
PID controller considered here is given by:
u(t) = Kpe(t) +Ki
∫ t
0e(t)dt+Kd
de(t)
dt(3.1)
Here u refers to control command, Kp,Ki,Kd are controller parameters. Its expression in Laplace
domain reads [5]
G(s) = Kp +Ki
s+Kds =
Kds2 +Kps+Ki
s(3.2)
where s is the Laplace variable.
3.2 Control system structure
The control system of drone is divided into two parts, position controller, also called outer
loop controller, and attitude controller, also called inner loop controller or angle controller. Each
14
CHAPTER 3. PID CONTROLLER DESIGN
sub-system needs a controller and should cooperate with each other to achieve better performance.
Figure 3.1: Complete control system structure
What we can see here is a complete drone control system model, including the outer loop
controller in the green dotted line, inner loop controller in yellow dotted line, drone model and sensor
in green blocks (Figure 3.1). However, the research content of this thesis does not include state
estimation, so in the subsequent simulations we will adopt an ideal state estimator, and an ideal
sensor (Figure 3.2).
Figure 3.2: Simplified control system structure
15
CHAPTER 3. PID CONTROLLER DESIGN
Here we can see that the main difference is that we ignore the state estimator and sensor,
namely, we only build a dynamic model to represent the ‘real drone’ and a model to represent motor
model without dynamics. Another point to mention here is the altitude or height controller has
nothing to do with Euler angles. Therefore, there is no need to design an inner loop controller for
altitude controller. The control command from altitude controller will be directly given to the motor
system.
Below we will take a look at the drone simulation model built in Simulink:
Figure 3.3: Simulink model of the drone system in Figure 3.2
It is worth mentioning that the combination of inner loop and outer loop is not unique to PID control.
The sliding mode controller mentioned later will also adopt this system structure. For example, we
can see the two modules named as ‘inner loop controller’ and ‘outer loop controller’ in the figure,
they can be PID controllers, sliding mode controllers or any other controllers. If necessary, we can
even use different controllers in the inner loop and outer loop.
3.3 System linearization and transfer function
According to the dynamic analysis performed in Chapter 2, it is known that the drone
system is a non-linear system, but the design of the PID controller is more suitable for linear systems.
16
CHAPTER 3. PID CONTROLLER DESIGN
In order to better design the PID controller, the drone system is linearized based on the assumption
of small angles and the weak coupling between different motions.
According to formulas (2.21),(2.22), (2.23) and (2.24). we can obtain the simplified linear
dynamics as:
x =u1 · θm
y =u1 · φm
z =u1m
φ =l · u2Jx
θ =l · u3Jy
ψ =l · u4Jz
(3.3)
It is worth mentioning here that we linearize and decouple the angle calculation of the drone through
the small angles assumption and the weak coupling between different motions, so the three angles
are decoupled from each other under this assumption. In other words, these three controllers u1, u2,
u3 control the three Euler angles φ, θ, ψ independently. On the one hand, this simplifies the difficulty
of analyzing and designing PID parameters, on the other hand, it makes our controller design subject
to certain error, because as the Euler angle increases, the small angle assumption may no longer hold.
3.4 Inner loop controller
First we get the Laplace transform of the linearized formula of Euler angles in (3.3):
Tφ(s) =l
Jxs2(3.4)
Tθ(s) =l
Jys2(3.5)
Tψ(s) =l
Jzs2(3.6)
It is also feasible firstly write the state space equation of drone dynamic model, and then use the state
space matrix operation to get the Laplace transfer function [19]. Combining (3.4), (3.5) and (3.6)
with formula (3.2), we get:
17
CHAPTER 3. PID CONTROLLER DESIGN
Gφ(s) =l(Kφ
d s2 +Kφ
p s+Kφi )
Jxs3(3.7)
Gθ(s) =l(Kθ
ds2 +Kθ
ps+Kθi )
Jys3(3.8)
Gψ(s) =l(Kψ
d s2 +Kψ
p s+Kψi )
Jzs3(3.9)
This is the open loop transfer function of the drone inner loop system under separate PID controllers.
Then, we can design the parameters of the PID controller by drawing the root locus and other Laplace
domain tools to achieve the performance requirements.
3.5 Outer loop controller
Next we design the outer loop controller. The outer loop controller will take reference
position as input, and the control commands given by the outer loop controller are actually the target
angles for the inner loop controller. In other words, the purpose of this controller is mainly to tell the
inner loop controller how many rads or degrees are needed to reach the specified position.
We return to formula (3.3) again. This time we deal with the position part. It should be
noted that this time we include both inner loop and outer loop, which means that we need to transfer
the inner loop system to a close loop transfer function.
Tx(s) =u1 · θms2
(3.10)
Ty(s) =u1 · φms2
(3.11)
Tz(s) =u1ms2
(3.12)
Here u1 is actually the thrust component controlled by height controller. When considering the X
and Y displacement, we can temporarily consider this component to be a fixed value or a known
variable. And m is the mass of drone.
Then we write the inner loop system as a closed loop transfer function for θ and φ system:
T φinner(s) =Gφ
1 +Gφ=
lKφd s
2 + lKφp s+ lKφ
i
Jxs3 + lKφd s
2 + lKφp s+ lKφ
i
(3.13)
T θinner(s) =Gθ
1 +Gθ=
lKθds
2 + lKθps+ lKθ
i
Jys3 + lKθds
2 + lKθps+ lKθ
i
(3.14)
18
CHAPTER 3. PID CONTROLLER DESIGN
We only need one transfer function to represent θ angle system and φ angle system, because we
assume that the drone is symmetrical. The reason why we do not talk about Z direction controller
is because compared to X and Y direction, Z direction controller, also called altitude controller is
simpler and has nothing to do with Euler angles or inner loop controllers. In the following analysis,
the control in the Z direction will also be omitted.
In order to reduce the complexity of the transfer function, we substitute the system
parameters and a basic version controller parameters into the transfer function (see Table 3.1 and
Table 3.6: PID controller parameters balanced for robustness and aggressiveness
Figure 3.10: Comparison of PID controllers without uncertainties
25
CHAPTER 3. PID CONTROLLER DESIGN
Figure 3.11: Comparison of PID controllers with uncertainties
Here we can see that after weighing the several aspects of the PID controller including
response time, settling time, robustness, overshoot, and degree of oscillation, the PID controller
parameters were redesigned and improved.
It is worth mentioning that the analysis and simulation here are based on the inner loop
control system of the drone, that is, the angle controller. This selection was made because the inner
loop control system is not affected by the outer loop and hence the results can inform us directly
about the inner loop control performance1. In the final simulation section, we will also take similar
design and tuning steps for the outer loop controller, which means that we will balance various
characteristics when selecting the PID controller parameters.
1On the contrary, the outer loop performance is affected by both outer and inner loop controllers due to outer looputilizing information received from the inner loop.
26
Chapter 4
Sliding Mode Control
4.1 Introduction
Sliding mode control (SMC) is a non-linear control method. The core idea is to limit
the state of the system to reference sliding mode surface which represent the performance of our
system, and it is designed according to requirements, usually has a reduced-order dynamics. When
the state of the system is not on the sliding mode surface, the controller will drive the system toward
the sliding mode surface, so it is called sliding mode control. Another main advantage of sliding
mode control is its strong robustness, that is, the ability to resist disturbances and system modeling
uncertainties.
Figure 4.1: Sliding mode surface tracking
27
CHAPTER 4. SLIDING MODE CONTROL
Figure 4.1 shows how the sliding mode controller makes the system to slide to the required
sliding surface. Here x1 and x2 are usually defined as the system output error (compared with
reference signal) e and its derivative e. Then when we design the sliding mode surface, we are
actually designing relationship between e and e.
In sliding mode control process, the motion of the system state can be divided into two
types: one is arrival motion, also called approaching motion, which is controlled by control law u
and the other is sliding motion, also called sliding mode, which is defined by sliding mode surface s.
These two parts of motion have their own characteristics, and they can maintain high performance
under their respective conditions, so as to achieve better overall results. Accordingly, the design
of the sliding mode controller is also performed separately. Reasonable sliding surface makes the
system have good performance quality in 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.
4.2 Example for sliding mode control
4.2.1 Controller design and stability analysis
Here, I will explain the basic idea of sliding mode control with a universal example. We
consider a linear time-invariant system:x = A1x+A2x
2 + u+ d d ≤ 5
A1 = 1
A2 = 1 +A2(x) |A2(x)| ≤ 0.5
(4.1)
Here we consider the parameter A1 as a constant system parameter and A2 as a system parameter
with uncertainty. d is disturbance. It is worth mentioning that we need to define the boundary of
uncertainty to ensure the robustness of sliding mode controllers.
If we define the error as follows:
e = x− xref (4.2)
Then we can define the sliding surface. We have many choices for sliding surface, which are selected
28
CHAPTER 4. SLIDING MODE CONTROL
according to the requirements of system performance. Here are two common approaches for designs:
s = ae+ e (4.3)
s = Ce (4.4)
The sliding mode surface coefficient C in formula (4.4) can be further optimized by optimal control
methods, and the sliding mode surface coefficient a in (4.3) is selected according to certain require-
ments1. One can also define the sliding surface as a nonlinear function of the error, see, for example,
[39].
We also need to design the expression of the control law u to ensure that our system can
reach the sliding mode surface within a limited time from any state and stay on the sliding mode
surface. Similar to the design of the sliding mode surface, we have many options. Here are some
common control laws:
u = −k · sgn(s) (4.5)
u = −k1 · sgn(s)− k2 · s (4.6)
u = −k|s|αsgn(s) (4.7)
u = −k · sgn(s)− f(s) (4.8)
where k is a gain value, sgn represent the sign function, defined as:
sgn(s) =
1 s > 0
0 s = 0
−1 s < 0
(4.9)
It can be seen here that the sgn function is a discontinuous function, which causes chattering problem.
We will explain this issue and how to solve it in detail later.
No matter which control law is used, the purpose is to make the system close to sliding
surface as soon as possible. Therefore, the value of k needs to be selected appropriately. A very
small k will make the system respond too slowly, while a large k will make the system chatter too
much. The selection of k is also the key to ensure the robustness of sliding mode control. When we1We caution the reader that s is utilized to denote the Laplace variable and also the sliding surface. The design/analysis
with Laplace domain is distinctly handled in the frequency domain, which is different from the design/analysis of slidingmode control in time domain. For this reason, we expect that the use of s will be clear from the context of discussions.
29
CHAPTER 4. SLIDING MODE CONTROL
know the upper/lower bounds of uncertainty and disturbance, we can use these bounds to design the
value of k. When disturbances and uncertainties exist, a reasonable value of k will ensure the system
can still slide to surface and then stable.
Here we choose formula (4.5) as the law of control. Now our system and controller can be
expressed as [17]
x = A1x+A2x2 + u+ d
A1 = 1
A2 = 1 +A2(x) |A2(x)| ≤ 0.5
s = ae+ e
u = −k1 · sgn(s) · x2 − k2 · sgn(s)−A1x
(4.10)
This is a fundamental form for sliding mode controller, where s is sliding mode surface. The purpose
of the controller is to maintain the system state on the sliding mode surface, u is the control law, k1
and k2 are controller parameters, and sgn represents sign function.
In general, the part of the control law that contains the sign function is called the discontin-
uous control law part. The part used for feedback linearization or feedback cancellation becomes the
equivalent control law part. ueq = −A1x
ud = −k1 · sgn(s) · x2 − k2 · sgn(s)
u = ueq + ud
(4.11)
We next briefly discuss the stability of sliding mode controller. There are many ways to
prove the stability of sliding mode controllers. The following two are commonly used:
Generalized sliding mode arrival condition proof:
ss < 0 (4.12)
Lyapunov stability proof:
V (x), V (x) < 0 (4.13)
Now we use the Lyapunov stability proof method to prove the stability of the system. First we define
the Lyapunov function as: V (x) = 12s
2
V (x) = ss(4.14)
30
CHAPTER 4. SLIDING MODE CONTROL
And in our system, we have the following states:e = 0
s = ae+ e = ae = ax(4.15)
When we combine formulas (4.11) and (4.15), we can get the final simplified formula:s = ax = a[(A1x−A1x) + (A2(x)− k1 · sgn(s))x2 + (d− k2 · sgn(s))]
|d| ≤ 5
|A2(x)| ≤ 0.5
(4.16)
If we analyze the sign of ss:ss = a[(A2(x)s− k1 ·
s2
|s|)x2 + (ds− k2 ·
s2
|s|)]
|A2(x)| ≤ 0.5
|d| ≤ 5
(4.17)
So we can get the condition for k1 and k2 as:
(A2(x)− k1)x2 ≤ 0
d− k2 ≤ 0
|A2(x)| ≤ 0.5
|d| ≤ 5
(4.18)
From the formula (4.18), we can clearly see that the value range of k1 and k2 is:k1 ≥ A2max = 0.5
k2 ≥ dmax = 5(4.19)
4.2.2 Time simulations
In this section, we will test our controller’s ability to control non-linear systems with
uncertainty and disturbance. At the same time, we will compare the difference between simple PID
controller and sliding mode controller for a system with uncertainties. More detailed comparisons
will be shown in later chapters. First, let us examine the two controllers under a system without
any disturbances and uncertainties, and when the controller parameters and system parameters are
Table 4.2: Example sliding mode controller parameters with uncertainties
The effect of the two controllers and the phase diagram of the sliding mode controller are provided in
Figure 4.4:
Figure 4.3: Comparison for example SMC and PID with bounded uncertainty and disturbance
33
CHAPTER 4. SLIDING MODE CONTROL
Figure 4.4: Phase diagram for example SMC
Here we can see that the disturbances and uncertainties have almost no effect on the sliding mode
controller, but they have made the performance of the PID controller significantly lower. This is
not to say that the PID controller is not robust at all, but to point out that for PID systems, whether
it is based on linear system tuning or direct model-free tuning, it is difficult to guarantee good
performance in the case of system uncertainty and disturbance.
4.3 Sliding mode controller for drone inner loop
In this chapter we will discuss how to design a sliding mode controller for drones. In
Chapter 3, we learned that the controller design of the rotor drone is divided into an inner loop
controller and an outer loop controller. This is also the same for sliding mode control. We also
need to design the outer loop controller to calculate the demand angle according to the reference
position, and then design an inner loop controller to track the reference angle. Through subsequent
discussions, we will find that the uncertainties of different parameters will affect different controllers
differently. For example, the error of the mass of the drone mainly affects the robustness of the outer
loop controller, and the error of the distance from the center of the drone to the propeller center
mainly affects the robustness of inner loop controller.
34
CHAPTER 4. SLIDING MODE CONTROL
4.3.1 Controller design
Now we are focus on how to design a sliding mode controller for inner loop. Similar to the
first step in designing a PID controller, we first simplify the dynamics equations. Firstly, the drone is
a highly coupled dynamic model. We need to decouple the three Euler angles into three separate
controllers. In fact, the reason we do this is that in most cases, our drone will not fly at a very large
Euler angle, and many articles make small angle assumptions about this. It is worth noting that if we
are pursuing flight under large Euler angle, then the coupling of the drone must be considered. We
will talk about how to solve the problem of high coupling degree of the drone later. At present, we
first adopt a decoupled model and focus on the design of the sliding mode controller.
Another point I want to note is that because the drone is symmetrical, the design of the
pitch angle controller and the roll angle controller are the same. The controller parameters of the
yaw angle controller are different from the previous two, but the principle is the same. This also can
be confirmed from the analysis and parameter selection in Chapter 3. Therefore, the design of the
pitch angle controller is mainly introduced here. By the way, the displacement in the x direction is
achieved by the pitch angle.
After simplifying the formula (2.22), we can get
q =lu
Jy+ d (4.20)
θ = q (4.21)
And we design sliding surface as:
s = ae+ e (4.22)
s = ae+ e (4.23)
And we choose the control law as
u = −k · sgn(s)− ae · Jyl
(4.24)
35
CHAPTER 4. SLIDING MODE CONTROL
Therefore, the current pitch angle control system is:
q =lu
Jy+ d
θ = q
s = ae+ e
u = −k · sgn(s)− ae · Jyl
(4.25)
4.3.2 Stability analysis
Next, we continue to prove the stability of this sliding mode controller and find stable
conditions. We define the Lyapunov function as:
V (x) =1
2s2 (4.26)
We want to prove
V (x) < 0 (4.27)
First we combine formulas (4.33) and (4.27) to get
V (x) = ss
s = ae+ e
s = ae+ e
u = −k · sgn(s)− ae · Jyl
(4.28)
We also define e, e and e as e = θ − θref −π
2 ≤ θ ≤π2
e = θ = q
e = θ = q
(4.29)
We first consider the case that d = 0 and there are no uncertainties on l and Jy, and two cases are
discussed at this time.
a) When s is positive:
s > 0
sgn(s) = 1
s = ae+ e
e = q = luJy
+ d d = 0
(4.30)
36
CHAPTER 4. SLIDING MODE CONTROL
We continue to simplify:
ss = s[ae+l
Jy
Jyl
(−a · e)− k l
Jy] (4.31)
We will finaly get:
ss = −s · k · lJy
(4.32)
Therefore, it is clear that in the case of no disturbance, the k only needs to be positive definite to
make the system stable, so here we define:
k > 0 (4.33)
So finally we have:
V (x) = ss = −ks lJy
< 0 (4.34)
The system is Lyapunov stable.
b) When s is negative:
s < 0
sgn(s) = −1
s = ae+ e
e = q
k > 0
(4.35)
Same as the previous proof, except that s is negative this time, so the value of the sgn function is -1,
k still remains positive definite as we defined.
We can have the result as follows:
ss = s[ae+l
Jy
Jyl
(−a · e) + kl
Jy] (4.36)
We will finally get:
ss = s · k · lJy
(4.37)
And as we define, this time s < 0, so we still have:
V (x) = ss < 0 (4.38)
In summary, combined with the proof of a) and b), we can get that, in the absence of
disturbance, the condition to maintain the stability of the system is that k is positive definite.
37
CHAPTER 4. SLIDING MODE CONTROL
If disturbance and uncertainties are added, the situation is a bit more complicated this time,
and we need to use more terms to compensate for uncertainties and disturbances. First we define the
range of uncertainty and disturbance:d = d0 + d(x) |d(x)| ≤ dmax
Jy = Jy0 + J(x) |J(x)| ≤ Jmax
l = l0 + l(x) |l(x)| ≤ lmax
(4.39)
Here d0, Jy0 and l0 are the estimated system parameter values, and d, Jy and l represents the actual
parameter value of the system. dmax, Jmax and lmax represent the maximum deviation between the
estimated value and the actual value of the system parameter.
We will redefine the control law as:
u = −k1sgn(s)− k2 · |e|sgn(s) (4.40)
Here we can see that the important change is the k2 gain compensation term. The reason for changing
this term is that when we know exactly Jy and l, we can perfectly compensate ae as we did in (4.36),
but if there are uncertainties in Jy and l, then we need to compensate according to the maximum
value of Jy and l, instead of directly using the coefficient a.
a)when s > 0, ss becomes:
ss = s[ae+l
Jy(−k1 − k2|e|) + d] (4.41)
Then we continue to simplify the formula:
ss = s[(−k1lJy
+ d) + (ae− l · k2Jy|e|)] (4.42)
We will analyze the two formulas. In the k1 part, we can see that the condition to make this term
negative is very obvious:
k1 ≥ |Jyd
l| = |Jy0 + Jymax
l0 − lmax· (d0 + dmax)| (4.43)
For the second half, here we can see why we are taking the absolute value of e for feedback, that
is, whether e is positive or negative, we only need to analyze the magnitude of the coefficient to
determine whether this term is negative definite or not. So our coefficient requirement for k2 is :
k2 ≥ |Jya
l| = |Jy0 + Jymax
l0 − lmax· a| (4.44)
38
CHAPTER 4. SLIDING MODE CONTROL
Finally, we summarize the requirements for k1 and k2 and the definition of uncertainty and
disturbance: k1 ≥ |
Jyd
l|
k2 ≥ |Jya
l|
(4.45)
It can be concluded here that if there are modeling errors for l and Jy, k1 and k2 need to be
selected appropriately to achieve sign condition as we just analyzed. If we know the upper bound of
disturbance and uncertainty, we can also set the boundary of k1 and k2 to maintain the stability of
the system, thus improving the robustness of the controller.
For example, if we assume that:
d = 1 + d(x) |d(x)| ≤ 0.5
Jy = 0.05 + J(x) |J(x)| ≤ 0.03
l = 0.25 + l(x) |l(x)| ≤ 0.05
a = 1
(4.46)
We should set k1 and k2 as: k1 ≥ |0.05+0.030.25−0.05 · 1.5| = 0.6
k2 ≥ |0.05+0.030.25−0.05 · 1| = 0.4
(4.47)
4.3.3 Time simulations
First, let’s simulate a model with no disturbance and uncertainties, using the parameters in
Table 4.3:
Parameter symbol Value unit
Distance from propeller to drone center l 0.25 mDrone mass m 1 kg
Moment of inertia of rotation around the z-axis Jz 0.08 kg ·m2
Moment of inertia of rotation around the x-axis Jx 0.05 kg ·m2
Moment of inertia of rotation around the y-axis Jy 0.05 kg ·m2
Table 4.3: Inner loop system parameters
39
CHAPTER 4. SLIDING MODE CONTROL
Figure 4.5: System response for k=2
Figure 4.6: Phase diagram for k=2
We can see that when we choose the sliding mode surface coefficient a = 2 and the controller gain
k = 2, both the system response and the system phase diagram have achieved our expected results.
Then in the next simulation, we want to verify the stability condition for k, and observe the effect of
40
CHAPTER 4. SLIDING MODE CONTROL
k on the amplitude of chattering.
Figure 4.7: System response for k =0.02, 0.05, 0.1, 0.25, 0.5, 1, 2
Here we can see that as k gets smaller, the performance of the system becomes worse. In fact, the
decrease of k means that the system’s ability to reach the expected sliding mode surface becomes
worse. Just like the phase diagram we saw in the Figure 4.6, when k = 2, the system can track the
expected sliding mode surface very well. So the performance of the system is very good. But when k
is small, the system cannot track the sliding surface. To illustrate this phenomenon, let us look at the
system response and phase diagram when k takes different values:
41
CHAPTER 4. SLIDING MODE CONTROL
Figure 4.8: System response and Phase diagram for k=2 and 1
Figure 4.9: System response and Phase diagram for k=0.5 and 0.25
42
CHAPTER 4. SLIDING MODE CONTROL
According to the comparison in Figure 4.8 and Figure 4.9, we can see that as the value
of k decreases, the system chattering becomes smaller, but the performance also decreases. This is
because a smaller k value makes the system weaker in tracking ability when it is far away from the
expected sliding mode surface. While a larger k value increases the lower bound of the controller
output value, that is, when the error is very small, we still had to adjust with a larger control command.
Next we continue to reduce the value of k in Figure 4.10:
Figure 4.10: System response and Phase diagram for k=0.1, 0.05, 0.02
Here we can see that, as just mentioned, as the value of k decreases further, the controller’s ability to
follow the expected sliding mode surface further decreases, and even after completing the control
target, it still cannot follow the expected sliding mode surface, but no matter how small k is, the
system can remain stable, which is consistent with the previous proof.
Now when we add the disturbances and uncertainties defined as fellow, we continue the
simulations:
43
CHAPTER 4. SLIDING MODE CONTROL
d = 1 + d(x) |d(x)| ≤ 0.5
Jy = 0.05 + J(x) |J(x)| ≤ 0.03
l = 0.25 + l(x) |l(x)| ≤ 0.05
(4.48)
Here actually we have requirements for both k1 and k2, but since k2 ≥ |Jya
l| is determined by the
sliding mode surface coefficient a, generally we can directly take the appropriate compensation value
for k2. Here, k1 is determined by the disturbance d, so we consider adjusting the value of k1 under
the condition that k2 meets the requirement. According to the formula (4.47), our k2 can be selected
as 0.4, and k1 value should be greater than 0.6. First, let ’s try what happens when k1 = 0.5.
Figure 4.11: System response with disturbance and uncertainty, k1 = 0.5, k2 = 0.4
It can be seen that the system cannot be stabilized at this time due to the presence of uncertainty and
disturbance, which cannot be compensated by k1. Next we increase the value of k1 to compensate
for uncertainty and disturbance. We set k1 = 0.7 and k1 = 1.
44
CHAPTER 4. SLIDING MODE CONTROL
Figure 4.12: System response with disturbance and uncertainty, k1 = 0.7,k2 = 0.4
Figure 4.13: System response with disturbance and uncertainty, k1 = 1 , k2 = 0.4
It can be found that as long as k1 ≥ 0.6, the system can be stabilized, but because k1 = 0.7 is too
close to the boundary determined by the uncertainties and disturbances, the remaining margin to
adjust the system performance will be very small, the system performance is very poor (Figure 4.12).
45
CHAPTER 4. SLIDING MODE CONTROL
When k1 = 1, the controller still has a large margin to track the expected sliding mode surface
after compensating the uncertainty and disturbance, so the overall system performance is still good
(Figure 4.13).
46
Chapter 5
Continuous Sliding Mode Control
5.1 Chattering problem
Are there any disadvantages to the sliding mode controller discussed in the previous
chapter? In fact, from the phase diagram, we can clearly see the difference.
Figure 5.1: Chattering
We take k = 1 for analysis. The reason why we choose this k value is that according to the analysis
in Chapter 4, when k = 1, for the inner loop system, under bounded disturbances and uncertainties,
controller can still make the system maintain good performance. If we zoom in on the phase diagram,
we find that after reaching the sliding mode surface, the controller always shakes near the sliding
mode surface. This is because for the above-mentioned sliding mode controller, the minimum value
47
CHAPTER 5. CONTINUOUS SLIDING MODE CONTROL
of the controller instruction is ksgn(s). Even if the error between system state and reference sliding
mode surface is very small, the controller will still take this control instruction, which makes the
system chatter near the sliding mode surface. A large value of k actually makes the chattering
very severe. Here we can see that in fact the existence of disturbances and uncertainties reduces
the chattering for the system because they actually reduce the minimum value of the controller
instruction, of course, it is not to say that these uncertainties and disturbances have helped us, because
this larger k value is chosen due to their presence, otherwise we can take a smaller k value.
It is worth mentioning that chattering problem mentioned here is actually a unique problem
caused by the discontinuity of the sign function. The main feature of this chattering problem is
its high frequency. In order to solve the problem of chattering, [17] discusses the state feedback
equivalent compensation method and the continuous function method. The state feedback equivalent
compensation method is actually the method we applied to compensate for ae in the previous chapter.
So now we consider using the continuous function method to further reduce chattering.
We first design the continuous function, an effective and basic continuous function named
saturation function [17]:
sat(s
ε) =
s
ε| sε | ≤ 1
sgn(s
ε) | sε | > 1
(5.1)
Here we introduce a new parameter ε. This parameter is mainly to define the slope of the continuous
part of the function as 1ε . When ε is close to 0, we can find that the saturation function will
approximate the sign function. If ε is too large, the tracking ability of the controller will be greatly
affected. In short, we need to choose the appropriate value of ε to make the system eliminate
chattering and maintain good performance.
48
CHAPTER 5. CONTINUOUS SLIDING MODE CONTROL
Figure 5.2: Sign function and Saturation function with ε = 0.2 and ε = 1
Another continuous control law named approximate function was proposed by [36]:
u = −k · s
|s|+ ε2(5.2)
Here we see that we also use a new parameter ε2 , and ε2 here also determines the closeness of this
saturation function to the sign function.
5.2 Controller with saturation function
We firstly apply the saturation function (5.1) to the sliding mode controller we just de-
signed.We will have:
System model: q =
lu
Jy+ d
θ = q
(5.3)
Sliding mode surface: s = ae+ e
s = ae+ e(5.4)
Tracking error: e = θ − θref
e = θ(5.5)
49
CHAPTER 5. CONTINUOUS SLIDING MODE CONTROL
Control law:
u = −k · sat(sε)− Jy
lae (5.6)
5.3 Stability analysis
Before performing time simulations, we also analyze stability, and consider the selection
of the control law parameter k under the condition of adding uncertainty and disturbance. We still
first prove the system stability when there are no disturbances and uncertainties.
We define the Lyapunov function as:
V (x) =1
2s2 (5.7)
And we aim to prove that:
V (x) = ss < 0 (5.8)
a) For s > 0, we will have:ss = s[ae+
l
Jy
Jyl
(−a · e)− k l
Jy· (sε)] |s
ε| ≤ ε
ss = s[ae+l
Jy
Jyl
(−a · e)− k l
Jy· 1] |s
ε| ≥ ε
(5.9)
And after simplifying: ss = −k l
Jy ·ε · s2 |s
ε| ≤ ε
ss = −k lJy ·ε · s |s
ε| ≥ ε
(5.10)
Similar to Section 4.3.2, if there are no disturbances and uncertainties, we only need select a positive
k to make the system stable.
b) For s < 0, also similar to Section 4.3.2, we can clearly see that the analysis above is
the same as the stability proof of the sliding function controller with sign function in Chapter 4.
According to the definition of the saturation function in formula (5.1), replacing sign function by
saturation function does not affect the sign of ss under s > 0 or s < 0. So the design steps are not
repeated here. We have that as long as k is positive definite, the system can remain stable.
Different from Section 4.3.2, we need to reconsider the stability after adding disturbances
and uncertainties. First we use the same method to replace Jyl a by k2 to compensate for the
uncertainties of l and Jy. The control law now changes to:
u = −k · sat(sε)− k2|e|sat(
s
ε) (5.11)
50
CHAPTER 5. CONTINUOUS SLIDING MODE CONTROL
The derivative of the Lyapunov function becomes:
a) For s > 0:ss = s[(
−k1lJy
s
ε+ d) + (ae− l · k2
Jy|e|sε)] |s
ε| ≤ ε
ss = s[(−k1lJy
+ d) + (ae− l · k2Jy|e|)] |s
ε| ≥ ε
(5.12)
The analysis of k2 is is not affected by the saturation function. Because we did not use sign function
in the k2 term. Therefore, we mainly discuss the term which is related to k1. To analyze when sε > ε,
the stability analysis of the system is the same as the previous analysis in Chapter 4. In fact, the
saturation function at this time is a sign function. But when sε < ε, we can find that the system is
stable with a steady-state (st-st) error. We can extract this part for more detailed analysis. To prove
the stability of the system, we need to prove that:−l · k1Jy
s
ε+ d < 0 s > 0
−l · k1Jy
s
ε+ d > 0 s < 0
(5.13)
We can take s > 0 for example, after mathematically simplifying formula (5.13), we can get the
range of k1:
k1 >Jyd
l· εs
(5.14)
We notice that s is included in formula (5.14), which means that our system does not reach s = 0, but
reaches in steady-state the equilibrium at sst−st =d·Jy ·εl·k1 . Theoretically speaking, this is because after
we replaced the sign function with a saturation function, as s decreases, control law u will become
smaller and smaller. At this time, the disturbance d will cause the system to have a steady-state error
that cannot be eliminated.
Next, we use formulas to calculate the steady-state error when the system reaches the
following status:
qst−st =k1l
Jy
sst−stε− d = 0 (5.15)
The controller’s output, which is determined by state error is equal to the disturbance, but the system
has not yet reached sst−st = 0. The system will remain at sst−st =d·Jy ·εl·k1 but not sst−st = 0 we
want, which causes steady-state errors. In order to better understand this controller, we substitute the
model parameters and system uncertainties and disturbances defined in formula (4.46) and Table 7.4
to calculate. Combining these parameters with formula (5.15), we obtain:
51
CHAPTER 5. CONTINUOUS SLIDING MODE CONTROL
a = 2
ε = 0.1
l = 0.2
Jy = 0.08
d = 1.5
sst−st =d·Jy ·εl·k1 = 0.03
(5.16)
When the system is in steady state, we have e = 0, so s = ae+ e = ae = 2e = 0.03, so we have
our final steady-state error est−st = 0.015.
For drones, the deviation of 0.015 rad, which is about 1 degrees, is not very large, and
further, we can reduce the steady-state error by adjusting ε. If we choose ε = 0.0125, then the
steady-state error is 0.001875 rad, which is about 0.1 degree. This is already a very ideal control
accuracy for drone control.
If we wish to make the steady-state errors exactly zero, we can consider re-introducing
sign functions:
u = −k1a · sat(s
ε)− k1b · sgn(s)− k2|e|sgn(s) (5.17)
Here k1b is used to eliminate steady-state errors, and k1a is used to track reference sliding mode
surface and reduce chattering. The difference between using sign function and saturation function
as a combination and using them separately is that if we only use the k1b part to track the reference
sliding mode surface, it will fall into dilemma that a large value of k1b will cause chattering, and a
small value of k1a can not offset the disturbance. The problem caused by only applying k1a part
has just been analyzed in detail, in terms of steady state error. But when we add both of them to the
control law, they perfectly solve the problem of chattering and steady-state error, and also maintain
the high performance of the system. The specific effect will be shown in the time simulations.
The proof of stability has not changed much here, so we will not go into details. The
difference is actually the choice of parameters. This time we will accurately select k2 and k1b
according to the upper bound of uncertainties and disturbances, and adjust the system performance
by coefficient k1a.
52
CHAPTER 5. CONTINUOUS SLIDING MODE CONTROL
5.4 Time simulations
We focus on the results of the single saturation function and the mixture of the saturation
function and the sign function in different situations.
First we observe the performance of the single saturation function controller defined by
formula (5.6). Here our simulation still uses the data in formula (4.46) and Table 7.4. And we pick
controller parameters as: k1 = 2
k2 = 0.8
ε = 0.1
(5.18)
According to the calculation in formula (5.16), the steady-state error at this time should be est−st =
0.015, see Figure 5.3
Figure 5.3: Error output for ε = 0.1
Here we can see that the simulation results are consistent with the theoretical calculations. When
system state approaches reference sliding mode surface, the system will reach an equilibrium state
with steady-state errors. And if we change the ε value to be 0.00125, we obtain Figure 5.4:
53
CHAPTER 5. CONTINUOUS SLIDING MODE CONTROL
Figure 5.4: Phase diagram for saturation function with ε = 0.00125
Here we can see that the system can follow the expected sliding mode surface well, and when zoomed
in, it will be found that chattering is still completely eliminated at this time. The only disadvantage is
that it can only ‘approximate’ the sliding mode surface at this time, and cannot reach s = 0.
Instead when we use the control law as a combination of saturation function and sign
function as defined is (5.17), for the system with disturbances and uncertainties defined in (4.48),
and for controller parameter as follows:
k1a = 2
k1b = 0.6
k2 = 0.8
ε = 0.1
(5.19)
the response and phase diagram of the system are obtained as shown in Figure 5.5 and Figure 5.6:
54
CHAPTER 5. CONTINUOUS SLIDING MODE CONTROL
Figure 5.5: System response for mixed function with disturbances and uncertainties
Figure 5.6: Phase diagram for mixed function with disturbances and uncertainties
Here we can see that the combination controller performs very well when it has disturbances and
uncertainties, not only completely eliminates the chattering, but also enables the system to have no
steady-state error and truly reach s = 0.
55
CHAPTER 5. CONTINUOUS SLIDING MODE CONTROL
If we change the simulation conditions to that we designed a controller according to the
boundary of disturbances and uncertainties, but the disturbances and uncertainties do not actually
appear, or they are very small. For example, this time we assume that the system does not have any
uncertainty and disturbance, but we still use a combination function:
Figure 5.7: Phase diagram for mixed function with no disturbance and uncertainties
We conclude from the phase diagram in Figure 5.7 that the controller can still ensure that the system
reaches s = 0 at this time, but as we just mentioned, when there is no disturbance and uncertainty,
the system will chatter. This is because the sign function used to compensate for uncertainty and
disturbance becomes a discontinuous term.
It is worth mentioning that the difference between the mixed function and sign function in
Chapter 4 is that in addition to the previously mentioned elimination of chattering in the presence of
disturbances and uncertainties, chattering phenomenon caused by mixed function is also significantly
lower than using sign function alone when there is no disturbances and uncertainties (Figure 5.7).
This is because when we use a single sign function, the choice of k must be responsible for improving
the system performance while compensating for the uncertainty and disturbance, which makes k to
be a relatively large value. However, in the mixed function here, the system performance is partially
improved by the saturation function, and the saturation function does not generate chattering, so the
total chattering at this time must be smaller than the chattering when using the sign function alone.
In short, from the perspective of chattering elimination, a single saturation function works
best, followed by a mixed function, and a single sign function is the worst. But in terms of sliding
mode surface tracking performance, mixed function is similar to a single sign function, and a single
56
CHAPTER 5. CONTINUOUS SLIDING MODE CONTROL
saturation function is slightly worse.
However, this thesis considers that for drones, even a small chattering can generate high-
frequency propeller signals, which is very harmful. Therefore, this thesis considers that a single
saturation function controller with an acceptable steady-state error is more in line with the physical
model of the drone.
57
Chapter 6
Continuous Sliding Mode Controller for
Outer Loop
In this chapter, we will design the outer loop sliding mode controller based on the analysis
in Chapter 4 and Chapter 5. Aerodynamic factors are also generally considered in the design of the
outer loop controller, which is also one of the main disturbance factors that we consider in the outer
loop.
6.1 Controller design
Similarly, this time we analyze the position controller in the X direction. The reason we do
this is because the symmetry of the drone makes its controllers similar in the X and Y directions.
The control in the Z direction is relatively simple, so we will not expand it here. According to the
kinetic model (2.21) and (2.29), we again get a simplified model:
x = T · −uθm− K1 · x
m+ d (6.1)
Here T is the thrust produced by propellers, K1 is empirical air resistance coefficient, m is drone’s
mass.
Our sliding surface is designed as:
s = a2 · e+ e (6.2)
58
CHAPTER 6. CONTINUOUS SLIDING MODE CONTROLLER FOR OUTER LOOP
According to the analysis in Chapter 5, we want to reduce the chattering to a minimum, so we adopt
a sliding mode controller with continuous function, but this time we used another more directive
control law, which has the form as:
u = k3 · s+ a · e · mT
+ L · sgn(s)− K1 · xT
(6.3)
Here k3 is the gain coefficient of the controller, and ae is a compensation term that is convenient to
increase the stability of the system, so that our system can better maintain stability. We will explain
this term in detail later in the proof of stability. L is the maximum value of the disturbance d.
We have also added a compensation function for air resistance. The compensation for air
resistance is actually an equivalent control law. Based on the knowledge of our model’s thrust, the air
resistance is perfectly compensated by this term. It can be noted here that the compensation function
is a function of the drone speed, that is, in the steady state, the compensation term and air resistance
force will both become 0.
6.2 Stability analysis
According to the formula (6.1) and (6.3), we can get the expression of the system controller
and the sliding surface as:
s = a2 · e+ e
uθ = k3 · s+ a · e · mT− K1 · x
T
x = T · −uθm− K1 · x
m+ d T ≥ 9.8
d = d0 + d(x) |d(x)| ≤ L = 0.5
(6.4)
Then we choose the Lyapunov function as:V (x) =1
2s2
V (x) = ss(6.5)
Here we firstly assume that there is no uncertainty about the weight of the drone, mainly to show
how to compensate and eliminate the term a2, we will have:s = a2 · e+ e
e = x
x = T · −uθm− K1 · x
m+ d T ≥ 9.8
(6.6)
59
CHAPTER 6. CONTINUOUS SLIDING MODE CONTROLLER FOR OUTER LOOP
So s will become:
s = a2e−T
m· mTa2 · e+ L · sgn− T
mk3 · s+ (s) +
K1 · xm
− K1 · xm
+ d (6.7)
s = − Tmk3 · s− (L · sgn(s)− d) (6.8)
and so ss becomes:
ss = − Tmk3 · s2 − (L · |s| − ds) (6.9)
Here L refers to the maximum value of d, so this formula is obviously negative definite. At this point
we can prove that the entire system is stable.
When there is a bounded uncertainty in m, we have the following formulations. Similar
to the operation in Chapter 5, we need to change the compensation term parameter a2 to k4 and
determine the value k4 according to the upper bound of m. Stability proof process is similar to
previous discussions and will not be explained in detail here, see Chapter 5. We directly give the
control law under the consideration that m has bounded uncertainty:
uθ = k3 · s+k4T· |e|+ K1 · x
T(6.10)
The value of k4 is determined by the sliding mode surface coefficient a2 and the upper bound of m.
In this chapter, we will not perform time simulations. The simulation of the sliding mode
controller of combination of the inner loop and outer loop of the drone will be directly compared
with the effects of the PID controller in Chapter 7.
60
Chapter 7
Comparison and Conclusion
7.1 Simulation parameters and control laws
In this chapter, we will compare the response of nonlinear drone dynamics under the sliding
mode controllers and PID controllers separately, including propeller saturation. First we summarize
the control laws we applied and specific control parameters in the following.
7.1.1 PID control
For both inner loop ceontroller and the outer loop controller, we adopt the classical PID
control law:
u = Kp · e+Ki ·∫e+Kd · e (7.1)
7.1.2 Sliding mode control
Our inner loop controller and reference sliding mode surface are defined as:s = a1eangle + eangle
u = −k1 · sat( sε )− k2eangle(7.2)
Our outer loop controller and reference sliding mode surface are defined as:s = a2eposition + eposition
uθ = k3 · s+ k4 · |e|+K1 · xT
(7.3)
61
CHAPTER 7. COMPARISON AND CONCLUSION
7.1.3 System and controller parameters
On Table 7.1 we list the system parameters, uncertainties and disturbances used in time
simulations:
Parameter name symbol Value Uncertainty boundary Unit
Distance from propeller to drone center l 0.25 + l(x) |l(x)| ≤ 0.05 mDrone mass m 1 +m(x) |m(x)| ≤ 0.5 kg
Moment of inertia of z-axis Jz 0.09 None kg ·m2
Moment of inertia of x-axis Jx 0.05 + Jx(x) |Jx(x)| ≤ 0.03 kg ·m2
Moment of inertia of y-axis Jy 0.05 + Jy(y) |Jy(x)| ≤ 0.03 kg ·m2
Air resistance coefficient for x K1 0.01 None Ns ·m−1Air resistance coefficient for y K1 0.01 None Ns ·m−1Air resistance coefficient for z K1 0.01 None Ns ·m−1