82
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

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

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: 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

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

Page 2: 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

Contents

List of Figures iii

List of Tables v

List of Acronyms vi

Abstract of the Thesis vii

1 Introduction 11.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Research status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Research content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Dynamic Analysis 62.1 Euler angles and rotation matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2 Dynamic equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.2.1 Translational dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.2.2 Rotational dynamics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.3 Simplified formula for controller design . . . . . . . . . . . . . . . . . . . . . . . 102.4 Other kinetic factors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

2.4.1 Air drag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.4.2 Ground effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

3 PID Controller Design 143.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2 Control system structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.3 System linearization and transfer function . . . . . . . . . . . . . . . . . . . . . . 163.4 Inner loop controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.5 Outer loop controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.6 Time simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

4 Sliding Mode Control 274.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.2 Example for sliding mode control . . . . . . . . . . . . . . . . . . . . . . . . . . 28

i

Page 3: 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

4.2.1 Controller design and stability analysis . . . . . . . . . . . . . . . . . . . 284.2.2 Time simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

4.3 Sliding mode controller for drone inner loop . . . . . . . . . . . . . . . . . . . . . 344.3.1 Controller design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354.3.2 Stability analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364.3.3 Time simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

5 Continuous Sliding Mode Control 475.1 Chattering problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475.2 Controller with saturation function . . . . . . . . . . . . . . . . . . . . . . . . . . 495.3 Stability analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505.4 Time simulations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

6 Continuous Sliding Mode Controller for Outer Loop 586.1 Controller design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586.2 Stability analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

7 Comparison and Conclusion 617.1 Simulation parameters and control laws . . . . . . . . . . . . . . . . . . . . . . . 61

7.1.1 PID control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617.1.2 Sliding mode control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617.1.3 System and controller parameters . . . . . . . . . . . . . . . . . . . . . . 62

7.2 Controller robustness comparison . . . . . . . . . . . . . . . . . . . . . . . . . . 637.3 Agile maneuver simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 667.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687.5 Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Bibliography 71

ii

Page 4: 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

List of Figures

2.1 Earth coordinate and body coordinate, modified from [13] . . . . . . . . . . . . . 6

3.1 Complete control system structure . . . . . . . . . . . . . . . . . . . . . . . . . . 153.2 Simplified control system structure . . . . . . . . . . . . . . . . . . . . . . . . . . 153.3 Simulink model of the drone system in Figure 3.2 . . . . . . . . . . . . . . . . . . 163.4 Entire system model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.5 PID tuning model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.6 Comparison of linear and nonlinear drone response under PID controller . . . . . . 213.7 Robust PID controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.8 Aggressive PID controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.9 Two characteristics of PID controller . . . . . . . . . . . . . . . . . . . . . . . . . 243.10 Comparison of PID controllers without uncertainties . . . . . . . . . . . . . . . . 253.11 Comparison of PID controllers with uncertainties . . . . . . . . . . . . . . . . . . 26

4.1 Sliding mode surface tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.2 Comparison for example SMC and PID without uncertainty and disturbance . . . . 324.3 Comparison for example SMC and PID with bounded uncertainty and disturbance . 334.4 Phase diagram for example SMC . . . . . . . . . . . . . . . . . . . . . . . . . . . 344.5 System response for k=2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404.6 Phase diagram for k=2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404.7 System response for k =0.02, 0.05, 0.1, 0.25, 0.5, 1, 2 . . . . . . . . . . . . . . . 414.8 System response and Phase diagram for k=2 and 1 . . . . . . . . . . . . . . . . . . 424.9 System response and Phase diagram for k=0.5 and 0.25 . . . . . . . . . . . . . . . 424.10 System response and Phase diagram for k=0.1, 0.05, 0.02 . . . . . . . . . . . . . . 434.11 System response with disturbance and uncertainty, k1 = 0.5, k2 = 0.4 . . . . . . . 444.12 System response with disturbance and uncertainty, k1 = 0.7,k2 = 0.4 . . . . . . . 454.13 System response with disturbance and uncertainty, k1 = 1 , k2 = 0.4 . . . . . . . . 45

5.1 Chattering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475.2 Sign function and Saturation function with ε = 0.2 and ε = 1 . . . . . . . . . . . . 495.3 Error output for ε = 0.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535.4 Phase diagram for saturation function with ε = 0.00125 . . . . . . . . . . . . . . . 545.5 System response for mixed function with disturbances and uncertainties . . . . . . 555.6 Phase diagram for mixed function with disturbances and uncertainties . . . . . . . 55

iii

Page 5: 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

5.7 Phase diagram for mixed function with no disturbance and uncertainties . . . . . . 56

7.1 System response comparison without uncertainty and disturbance . . . . . . . . . 637.2 SMC phase diagram without uncertainty and disturbance . . . . . . . . . . . . . . 647.3 System response comparison with bounded uncertainty and disturbance . . . . . . 657.4 SMC phase diagram with bounded uncertainty and disturbance . . . . . . . . . . . 657.5 Agile maneuver comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

iv

Page 6: 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

List of Tables

3.1 Inner loop PID controller parameters . . . . . . . . . . . . . . . . . . . . . . . . . 193.2 Inner loop system parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.3 Inner/Outer loop PID controller parameters . . . . . . . . . . . . . . . . . . . . . 213.4 Robust PID controller parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 223.5 Aggressive PID controller parameters . . . . . . . . . . . . . . . . . . . . . . . . 233.6 PID controller parameters balanced for robustness and aggressiveness . . . . . . . 25

4.1 Example sliding mode controller parameters without model uncertainties . . . . . . 324.2 Example sliding mode controller parameters with uncertainties . . . . . . . . . . . 334.3 Inner loop system parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

7.1 Inner/Outer loop simulation settings . . . . . . . . . . . . . . . . . . . . . . . . . 627.2 Inner/Outer loop sliding mode controller parameters . . . . . . . . . . . . . . . . . 627.3 Inner/Outer loop PID controller parameters . . . . . . . . . . . . . . . . . . . . . 637.4 Agile sliding mode controller parameters . . . . . . . . . . . . . . . . . . . . . . . 67

v

Page 7: 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

List of Acronyms

SMC Sliding mode control.

CSMC Continuous sliding mode control.

ASMC Adaptive sliding mode control.

PID Proportional-Integral-Derivative.

LQR Linear-Quadratic Regulator.

vi

Page 8: 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

Abstract of the Thesis

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

Page 9: 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

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

Page 10: 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

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

Page 11: 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

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

Page 12: 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

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

Page 13: 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

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

Page 14: 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

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

Page 15: 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

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

Page 16: 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

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

Page 17: 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

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

Page 18: 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

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

Page 19: 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

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

Page 20: 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

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

Page 21: 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

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

Page 22: 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

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

Page 23: 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

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

Page 24: 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

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

Page 25: 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

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

Page 26: 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

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

Page 27: 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

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.2):

Controller Kp Ki Kd

θ angle controller 0.8 0 0.6φ angle controller 0.8 0 0.6ψ angle controller 0.8 0 0.6

Table 3.1: Inner loop PID controller parameters

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 3.2: Inner loop system parameters

Then we can simplify the formula (3.13) and formula (3.14) to:

T φinner =0.15s+ 0.2

0.05s2 + 0.15s+ 0.2(3.15)

T θinner =0.15s+ 0.2

0.05s2 + 0.15s+ 0.2(3.16)

We next to include the inner loop transfer function into the entire system transfer function, see

Figure 3.4.

19

Page 28: 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

CHAPTER 3. PID CONTROLLER DESIGN

Figure 3.4: Entire system model

So far, we have successfully expressed the entire system, which contains the parameters of

each PID controller. Then we can use various open-loop and closed-loop analysis methods in the

Laplace domain to analyze the system. According to the properties of Laplacian domain analysis,

we can know that changing the PID parameters can change the coefficients of the denominator and

numerator of the transfer function, even the order of system, which makes the system to have different

performance. Here, the design and optimization of PID control is not the focus of this thesis, so the

analysis of the transfer function will not be expanded here. Another method is that we can directly

use the PID tuning block in simulink for PID parameter design, which will provide us with great

convenience. We will talk about details in the simulation section. Here we first show the simulink

linear model, see Figure 3.5:

Figure 3.5: PID tuning model

In the above system, we added two step signals as disturbances. In reality, this disturbance in the

inner loop is a kind of torque, but for simplicity, we can use acceleration instead. In the outer loop,

the disturbance is actually a force, but again we can directly simplify it to acceleration.

3.6 Time simulations

First of all, we use a model-free method to manually select PID controller parameters, and

the scenario we discussed is the system without disturbance and uncertainty, mainly to verify the

20

Page 29: 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

CHAPTER 3. PID CONTROLLER DESIGN

correctness of the model simplification and the basic control capabilities of the PID controller for the

drone system.

Table 3.3 is the selection of all controller parameters, while the drone parameter selection

is shown in Table 3.2.

Controller Kp Ki Kd

Roll angle 0.8 0 0.6Pitch angle 0.8 0 0.6Yaw angle 0.8 0 0.6X position 0.1 0 0.1Y position 0.1 0 0.1Z position 0.1 0 0.1

Table 3.3: Inner/Outer loop PID controller parameters

Here we can see that the Ki parameter is actually 0, because the system does not have a steady-state

error, and there is no need to add an integral term to eliminate the steady-state error. So more

rigorously, here we use a PD controller, simulations are given in Figure 3.6. Moreover, we provided

the reference as:

xref = 0.5 (3.17)

Figure 3.6: Comparison of linear and nonlinear drone response under PID controller

21

Page 30: 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

CHAPTER 3. PID CONTROLLER DESIGN

From the comparison of the simulation results, we first verified the correctness of the

model after linearization and Laplacian transformation. Secondly, we can see that when the Euler

angle is not large, the error between linearized model and non-linear model is negligible. It can be

considered that under many cases, it is advisable to design and analyze the PID controller of the

drone by linearization. This may also explain why most drones still use PID controllers today.

As just mentioned, our focus here is not the parameter optimization of the PID controller,

so we will not do much analysis on the closed-loop PID control, but in order to make the subsequent

comparison with the sliding mode control more convincing, we use the PID tuning block in Simulink

to carry out the tuning of the PID parameters on linear model. Then adjust and set according to the

limitations in the nonlinear model to get final PID controller parameters. The model used in the

above steps is shown in Figure 3.5.

There are two points we mainly focus in the PID tuning block. The first point is the

response time, and the second point is the transient behavior. We need to set the response time

of the system to a reasonable value to reduce system oscillation, and also take into account drone

model limitations. Regarding the transient behavior, this refers to the two performances of the PID

controller, aggressive and robust. Increasing the aggressiveness of the PID controller will improve

the system’s response speed and resistance to disturbances, but the disadvantage is that it will cause

oscillation, and will make it difficult for the controller to resist the uncertainties of system parameters.

On the contrary, increasing the robustness of the PID controller will increase the system’s resistance

to uncertainty, but it will reduce the response speed of the system and also reduce the resistance of

the system to disturbances. Specific analysis and selection of controller gains will be discussed in

detail after the simulation results. Here we firstly show the two PID controllers:

Controller Kp Ki Kd

Roll angle 0.6 0.05 1Pitch angle 0.6 0.05 1Yaw angle 0.6 0.05 1

Table 3.4: Robust PID controller parameters

22

Page 31: 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

CHAPTER 3. PID CONTROLLER DESIGN

Controller Kp Ki Kd

Roll angle 10 1.5 0.5Pitch angle 10 1.5 0.5Yaw angle 10 1.5 0.5

Table 3.5: Aggressive PID controller parameters

Next we show the comparison of the effects of the two PID controllers without uncertainty and with

uncertainty in the inner loop of the drone model, see Figure 3.7 and Figure 3.8

Figure 3.7: Robust PID controller

23

Page 32: 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

CHAPTER 3. PID CONTROLLER DESIGN

Figure 3.8: Aggressive PID controller

Figure 3.9: Two characteristics of PID controller

Through comparison, we can clearly see that the aggressive PID controller has a fast response speed

and a short settling time. The disadvantage is that the resistance to uncertainty is poor, and at the

same time there is large system oscillations. The robust PID controller is more resistant to uncertainty,

24

Page 33: 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

CHAPTER 3. PID CONTROLLER DESIGN

and the curve is very smooth. But the response time and settling time are poor. So we can find that

the design of PID controller needs to make a compromise between robustness and aggressiveness.

Here we will try to design a new controller that take into account both robustness and aggressiveness.

Here are the revised parameters and the comparison between the revised PID controller and the above

two PID controllers, see Figure 3.10 and Figure 3.11.

Controller Kp Ki Kd

Roll angle 2 0.05 0.1Pitch angle 2 0.05 0.1Yaw angle 2 0.05 0.1

Table 3.6: PID controller parameters balanced for robustness and aggressiveness

Figure 3.10: Comparison of PID controllers without uncertainties

25

Page 34: 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

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

Page 35: 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

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

Page 36: 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

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

Page 37: 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

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

Page 38: 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

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

Page 39: 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

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

selected as follows in Table 4.1:

31

Page 40: 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

CHAPTER 4. SLIDING MODE CONTROL

Parameter symbol Value

SMC controller parameter k1 1SMC controller parameter k2 5PID controller parameter KP -4PID controller parameter KI -2PID controller parameter KD -2.5

System parameter A1 1System parameter A2 1

System disturbance d 0

Table 4.1: Example sliding mode controller parameters without model uncertainties

Here is the effect of the two controllers without disturbance and model uncertainty, see Figure 4.2:

Figure 4.2: Comparison for example SMC and PID without uncertainty and disturbance

Here we can see that both PID and sliding mode controller can make the system stable without the

presence of disturbances and uncertainties. Then we add the disturbances and uncertainties and

simulate the dynamics as shown in Figure 4.3:

32

Page 41: 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

CHAPTER 4. SLIDING MODE CONTROL

Parameter symbol Value

SMC controller parameter k1 1SMC controller parameter k2 5PID controller parameter KP -4PID controller parameter KI -2PID controller parameter KD -2.5

System parameter A1 1System parameter A2 1 +A(x) |A(x)| ≤ 0.5

System disturbance d 5

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

Page 42: 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

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

Page 43: 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

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

Page 44: 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

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

Page 45: 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

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

Page 46: 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

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

Page 47: 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

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

Page 48: 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

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

Page 49: 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

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

Page 50: 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

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

Page 51: 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

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

Page 52: 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

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

Page 53: 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

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

Page 54: 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

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

Page 55: 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

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

Page 56: 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

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

Page 57: 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

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

Page 58: 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

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

Page 59: 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

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

Page 60: 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

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

Page 61: 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

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

Page 62: 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

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

Page 63: 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

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

Page 64: 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

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

Page 65: 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

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

Page 66: 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

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

Page 67: 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

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

Page 68: 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

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

Page 69: 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

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

Page 70: 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

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

Outer loop disturbance d1 0.2 + d1(x, y) |d2(x, y)| ≤ 0.5 m · s−2Inner loop disturbance d2 1 + d2(θ, φ) |d2(θ, φ)| ≤ 0.5 rad · s−2

Table 7.1: Inner/Outer loop simulation settings

Here, we also provide the parameters of the sliding mode controller and PID controller (Table 7.2). It

is worth mentioning that the parameters here do not represent the comparison of the best performances

of the two controllers, but just to represent some scenarios.

Parameter name symbol Value

Inner loop sliding mode surface parameter a1 6Inner loop controller parameter1 k1 10Inner loop controller parameter2 k2 2.4

Outer loop sliding mode surface parameter a2 1.5Outer loop controller parameter1 k3 0.6Outer loop controller parameter2 k4 2.25

Table 7.2: Inner/Outer loop sliding mode controller parameters

62

Page 71: 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

CHAPTER 7. COMPARISON AND CONCLUSION

Controller name Kp Ki Kd

Roll angle -2 -0.5 -1Pitch angle -2 -0.5 -1Yaw angle -2 -0.5 -1X position 0.2 0.05 0.1Y position 0.2 0.05 0.1Z position 0.2 0.05 0.1

Table 7.3: Inner/Outer loop PID controller parameters

7.2 Controller robustness comparison

In this section, we mainly focus on whether the two controllers are sufficiently robust

when facing the above-defined uncertainty and disturbance. First we will test the response of the two

controllers without uncertainty and disturbance, see Figure 7.1 and Figure 7.2

Figure 7.1: System response comparison without uncertainty and disturbance

63

Page 72: 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

CHAPTER 7. COMPARISON AND CONCLUSION

Figure 7.2: SMC phase diagram without uncertainty and disturbance

Here we can see that although the response of the system is different due to controller characteristics

and parameter selection differences, it is clear that both controllers can effectively bring the drone to

the reference position.

At the same time, we also plot the phase diagram of our system under the control of the

sliding mode controller. We can see here that although the state of our system is actually running

according to the reference sliding surface we designed, and finally reaching the sliding surface, this

time the tracking of reference sliding mode surface is not as perfect as the angle controller we plot in

Figure 5.7. This is because the nonlinear drone dynamics is limited, such as the maximum speed of

the propellers. In other words, we cannot get the desired Euler angles instantly, which affects the

performance of the outer loop controller.

Next we will show the system response and phase diagram of the sliding mode controller

after adding disturbance and uncertainty (see Figure 7.3 and Figure 7.4):

64

Page 73: 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

CHAPTER 7. COMPARISON AND CONCLUSION

Figure 7.3: System response comparison with bounded uncertainty and disturbance

Figure 7.4: SMC phase diagram with bounded uncertainty and disturbance

From the comparison of results, we clearly see that at this time, the PID controller can no longer

control our drone system well. But the sliding mode controller is hardly affected by uncertainties and

disturbances. We can also conclude this from the phase diagram that the tracking effect at this time

65

Page 74: 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

CHAPTER 7. COMPARISON AND CONCLUSION

is basically unaffected compared to the situation that there are no disturbances and uncertainties.

Here we can first draw the conclusion that sliding mode controllers are extremely robust to

uncertainties and disturbances with a known upper boundary. But it should be pointed out that here

we are not saying that the PID controller is not robust at all, through our research in Chapter 3, in

fact, we can find that the PID controller can be robust, but the problem is that first of all, the robust

type of the PID controller needs to sacrifice certain performance, and secondly compared to sliding

mode controller, the robustness of the PID controller is not easy to guarantee, especially for the PID

controller tuned without the presence of a model. Therefore, we can consider that sliding mode

controller can be better suited than PID controller when controlling drones.

It is also worth mentioning that both the phase diagram and the system response diagram

show that at this time our sliding mode controller has a small steady-state error, it is about est−st =

0.5cm = 1% · eref . This is because we have adopted a continuous sliding mode controller for both

the inner and outer loops, instead of a discontinuous sliding mode controller composed of classical

sign function.

This continuous controller will indeed make our system have steady state errors, but it

will perfectly eliminate the chattering problem of classical sliding mode controller. This chattering

problem is especially important for drones, because the propeller and motor systems are greatly

affected by chattering. We do not want to see propeller speed change at a very high frequency. Also,

a centimeter-level error is acceptable for drone control.

7.3 Agile maneuver simulation

In this section, we will explore how to use a sliding mode controller to achieve agile

maneuvering of drones. In fact, the word agile is a very broad adjective, then here we define agile

as having a short settling time and rise time. We will compare the adaptive coefficient sliding

mode controller shown in Section 7.3 with the sliding mode controller and the PID controller in the

Section 7.2 for analysis. Of course, since the PID controller will be affected by the uncertainties and

disturbances we defined, and also the robustness of sliding mode control has been discussed in the

previous section, so we will not consider the uncertainty and robustness in this section.

Here we first show the new outer loop sliding mode controller for agile maneuvering target:s = (

1

|e|+ a2+ a3) · e+ e

u = (1

|s|+ k3+ k4) · s+

m

T[e(|e|+ a2)− ee

(e+ a2)2+ a3e]−

K1 · xT

(7.4)

66

Page 75: 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

CHAPTER 7. COMPARISON AND CONCLUSION

Here we have redesigned the sliding mode surface of the outer loop controller, by changing the

sliding mode surface coefficient a2 to a function of errorx. This means that when the errorx is very

large, the coefficient is close to its lower boundary a3, and as errorx decreases, the coefficient is

increased accordingly. It can be seen that when errorx approaches 0, the coefficient will get closer

to its upper boundary ( 1a2

+ a3).

The main purpose of this design is to enable the coefficients of the sliding surface to

become adaptive coefficients, so that the drone can maintain a high speed when the error is small,

while maintaining the stability of the system. This design idea is also used in the controller to

make the system better track the expected sliding mode surface. Thus agile sliding mode controller

coefficients are selected as in Table 7.4:

Parameter name symbol Value

Inner loop sliding mode surface parameter a1 6Inner loop controller parameter 1 k1 10Inner loop controller parameter 2 k2 2.4

Outer loop sliding mode surface parameter a2 0.2Outer loop sliding mode surface parameter 2 a3 1

Outer loop controller parameter 1 k3 8Outer loop controller parameter 2 k4 0.1

Table 7.4: Agile sliding mode controller parameters

The comparison of drone dynamics using either the new adaptive sliding mode controller and the

two controllers studied in Section 7.2 under the same conditions is presented in Figure 7.5:

67

Page 76: 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

CHAPTER 7. COMPARISON AND CONCLUSION

Figure 7.5: Agile maneuver comparison

According to time simulations, we can see that compared with the previous sliding mode controller,

the new sliding mode controller mainly improves the speed when approaching the target position. In

order to make the drone have a smaller rise time, of course, this also brings some level of oscillations.

7.4 Conclusion

The main contribution of this thesis is the design, analysis and optimization of PID con-

troller, sliding mode controller, continuous sliding mode controller and adaptive continuous sliding

mode controller for the linearized drone dynamics. This thesis has also performed corresponding

modeling and simulation calculations in Matlab/Simulink. According to the results of time simu-

lations, it can be clearly seen that, for uncertainties with defined boundaries, all types of sliding

mode controllers can maintain the stability of the system, and at the same time, make the state of the

system slide to the expected sliding mode surface. In contrast, the PID controller is very difficult to

ensure the robustness of the drone system wihtout sacrificing fast response. The PID parameters we

designed based on the estimated system parameters cannot overcome the uncertainties. Therefore,

we believe that the sliding mode controller is more robust than the drone controller.

For the discontinuity and chattering problems caused by the sign function applied in

traditional sliding mode controller, we designed several kinds of control laws to deal with it, including

68

Page 77: 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

CHAPTER 7. COMPARISON AND CONCLUSION

continuous function control law, continuous function and discontinuous function mixed control law,

and state feedback equivalent compensation function. Among them, the state feedback equivalent

compensation method generally used together with the other two control laws. The continuous

function control law can minimize the chattering and keep the drone at a high performance, but the

system has a certain amount of steady-state error. Also the tracking of the sliding mode surface is

approximate at this time. The continuous function and discontinuous function mixed control law

can reduce the system’s chattering under the premise of ensuring that the system does not have any

steady-state error. But at this time, the effect of reducing chattering is not as good as the continuous

function control law alone. The application of the control law will depend on the system and the

scenarios. This thesis considers that for drones, compared with high-frequency chattering, a smaller

steady-state error is acceptable.

Finally, for the sliding mode controller, in the case that the controller we designed can

effectively track the sliding mode surface, the sliding mode surface actually represents the perfor-

mance of system. So we can change the design method and parameter adjustment of the sliding mode

surface to improve the system performance. Regarding the improvement of system performance,

different from the traditional linear sliding mode surface design, this thesis proposes an adaptive

coefficients sliding mode surface design method in order to achieve a more agile maneuvering speed

for the drone.

7.5 Future work

Future work can be divided into two parts. One part is a deeper exploration based on the

main work of this thesis, and the other part is to improve some of the limitations in the research of

this thesis.

For the first part, it actually refers to further improving the sliding mode controller and

conducting experiments on real drone. For example, design different sliding mode surfaces and

adjust them according to the actual conditions of the drone and task. At the same time, our sliding

mode controller is based on uncertainty boundaries, and if the boundaries change, we can consider

using observers to compensate.

For the second part, it mainly refers to that we have ignored coupling and nonlinear terms

of the drone model, because my main goal in this thesis is to demonstrate how to design a sliding

mode controller for drone to resist model uncertainties. But in fact, the sliding mode controller

can also solve the coupling effects and nonlinearities in the model, therefore, we can further design

69

Page 78: 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

CHAPTER 7. COMPARISON AND CONCLUSION

sliding mode controllers based on a fully nonlinear and coupled models, this will make our controller

more accurate, and also make our stability analysis more consistent with reality. We note however

that the controllers in Chapter 4, Chapter 5 and Chapter 6 are implemented on the full nonlinear

drone model including propeller saturation, which already indicate promising results for our main

goal of controlling drones in the presence of nonlinearities, disturbances, and uncertainties.

70

Page 79: 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

Bibliography

[1] E. Altug, J. P. Ostrowski, and R. Mahony. Control of a quadrotor helicopter using visual

feedback. In IEEE Robotics and Automation Magazine. vol.1, pp.72-77, 2002.

[2] J. Alvarenga, N. I. Vitzilaios, and M. J. Rutherford K. P. Valavanis. Survey of unmanned

helicopter model-based navigation and control techniques. In IEEE Robotics and Automation

Magazine. vol.80, pp.87–138, 2015.

[3] Amazon. Prime air. https://www.amazon.com/Amazon-Prime-Air/b?ie=

UTF8&node=8037720011 Accessed on 4/21/2020.

[4] R. D. Andrea. The astounding athletic power of quadcopters. https://www.ted.

com/talks/raffaello_d_andrea_the_astounding_athletic_power_of_

quadcopters Accessed on 4/21/2020.

[5] K. H. Ang, G. Chong, and Y. Li. PID control system analysis, design, and technology. In

International Symposium on Systems and Control in Aerospace and Astronautics. vol. 13, no. 4,

pp. 559-576, 2005.

[6] V. M. Babu. Designing of self tuning PID controller for ar drone quadrotor. In International

Conference on Advanced Robotics, 2017.

[7] T. Baca, D. Hert, G. Loianno, M. Saska, and V. Kumar. Model predictive trajectory tracking and

collision avoidance for reliable outdoor deployment of unmanned aerial vehicles. In IEEE/RSJ

International Conference on Intelligent Robots and Systems (IROS). pp.6753-6760, 2018.

[8] S. Bambang, U. Naoki, and S. Shigenori. Least square based sliding mode control for a

quad-rotor helicopter and energy saving by chattering reduction. In Mechanical Systems and

Signal Processin. vol.66-67, pp.769-784, 2016.

71

Page 80: 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

BIBLIOGRAPHY

[9] G. Cai. A brief overview on miniature fixed-wing unmanned aerial vehicles. In IEEE Interna-

tional Conference on Control and Automation, pp.285-290, 2010.

[10] G. Cai. Autopilots for small unmanned aerial vehicles: A survey. In International Journal of

Control, Automation, and Systems, vol.8, pp.36–44, 2010.

[11] J. Dentler, S. Kannan, M. A. O. Mendez, and H. Voos. A real-time model predictive position

control with collision avoidance for commercial low-cost quadrotors. In 2016 IEEE Conference

on Control Applications (CCA). pp.519-525, 2016.

[12] H. Eisenbeiss. A mini unmanned aerial vehicle (UAV): system overview and image acquisition.

In International Workshop on ’Processing and Visualization using high-resolution Imagery’,

pp.1-7, 2004.

[13] G.Ducard. Fault-tolerant flight control and guidance systems: Practical methods for small

unmanned aerial vehicles. Springer-Verlag, 2009.

[14] J. P. How, B. Behihke, D. Dale A. Frank, and J. Vian. Real-time indoor autonomous vehicle

test environment. In IEEE Control Systems Magazine. vol. 28, no. 2, pp. 51-64, 2008.

[15] P. Jetley, P. B. Sujit, and S. Saripalli. Safe landing of fixed wing UAVs. In 47th Annual

IEEE/IFIP International Conference on Dependable Systems and Networks Workshops (DSN-

W), 2017.

[16] Z. Jiang, J. Han, Y. Wang, and Q. Song. Enhanced lqr control for unmanned helicopter in hover.

In International Symposium on Systems and Control in Aerospace and Astronautics. pp.1443,

2006.

[17] H.K. Khalil. Nonlinear Systems. Michigan State University, 2002.

[18] V. Kumar. Robots that fly and cooperate. https://www.ted.com/talks/vijay_

kumar_robots_that_fly_and_cooperate Accessed on 4/21/2020.

[19] J. Li. Dynamic analysis and PID control for a quadrotor. In IEEE International Conference on

Mechatronics and Automation, 2011.

[20] H. Liu, W. Zhao, S. Hong, F. L. Lewis, and Y. Yu. Robust backstepping-based trajectory

tracking control for quadrotors with time delays. In IET Control Theory and Applications. vol.

13, no. 12, pp.1945-1954, 2019.

72

Page 81: 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

BIBLIOGRAPHY

[21] B. Lu, Y. Fang, and N. Sun. Continuous sliding mode control strategy for a class of nonlinear

underactuated systems. In IEEE Transactions on Automatic Control. vol.63, no.10, pp.3471-

3478, 2018.

[22] G. Martin. Modelling and control of the parrot ar.drone. Final Project Report 2012, The

University of New South Wales, Canberra.

[23] N. Michael, D. Mellinger, V. Kumar, and Q. Lindsey. The grasp multiple micro-UAV testbed.

In IEEE Robotics and Automation Magazine. vol.17, no.3, pp.56-65, 2010.

[24] M. W. Mueller, R. D. Andrea, and M. Hehn. A computationally efficient motion primitive for

quadrocopter trajectory generation. In IEEE Transactions on Robotics. vol. 31, no. 6, 2015.

[25] A. J. Munoz-Vazque, V. Parra-Vega, and A. Sanchez-Orta. Continuous fractional-order sliding

pi control for nonlinear systems subject to non-differentiable disturbances. In Asian Journal of

Control. vol.19(1), pp.279-288, 2017.

[26] G. Perozzi, D. Efimov, J. M. Biannic, L. Planckaert, and P. Coton. Wind rejection via quasi-

continuous sliding mode technique to control safely a mini drone. 7th European Conference for

Aeronautics and Space Science, 2017.

[27] Q. Quan. Introduction to Multicopter Design and Control. Springer, 2017.

[28] V. Raghuraman. Modeling and H-infinity loop shaping control of a vertical takeoff and landing

drone. Master’s thesis, Arizona State University, 2018.

[29] H. Rıos, S. J. Gonzalez, and A. Dzul. Robust tracking output-control for a quad-rotor: A

continuous sliding-mode approach. In Journal of the Franklin Institute. vol.354(15), pp.6672-

6691, 2017.

[30] F. Santoso, M. A. Garratt, and S. G. Anavatti. State-of-the-art intelligent flight control systems

in unmanned aerial vehicles. In IEEE Transactions on Automation Science and Engineering.

vol. 15, no. 2, pp. 613-627, 2018.

[31] T. Sato. Adaptive PID control system with assigned robust stability. In IEEJ Transactions on

Electrical and Electronic Engineering, vol.13, pp.1169-1181, 2017.

73

Page 82: 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

BIBLIOGRAPHY

[32] V. Spurny. Cooperative autonomous search, grasping, and delivering in a treasure hunt scenario

by a team of unmanned aerial vehicles. In Journal of Field Robotics. vol.36(1), pp.125(24),

2019.

[33] Y. Sun. Modeling, identification and control of a quad-rotor drone using low-resolution sensing.

Master’s thesis, University of Illinois at Urbana-Champaign, 2012.

[34] S. Sweden. Quadrotor control: modeling, nonlinear control design, and simulation. Master’s

thesis, KTH Royal Institute of Technology, 2015.

[35] S. Vaidyanathan. Applications of sliding mode control in science and engineering. Springer,

2017.

[36] S. Wang, S. Habibi, R. Burton, and E. Sampson. Sliding mode control for a model of an

electrohydraulic actuator system with discontinuous nonlinear friction. In 2006 American

Control Conference. pp.8, 2006.

[37] G. Xia and Z. Liu. Quadrotor unmanned helicopter attitude control based on improved adrc. In

Proceedings of 2014 IEEE Chinese Guidance, Navigation and Control Conference. pp. 916-921,

2014.

[38] R. Xu and U. Ozguner. Sliding mode control of a class of underactuated systems. In Automatica.

vol.44(1), pp.233-241, 2008.

[39] D. Zhang, G. Jiang, Y. Zhou, Y. Wan, and Z. Jia. Fixed-time nonsingular terminal sliding mode

control for unmanned aerial vehicles. In 2018 33rd Youth Academic Annual Conference of

Chinese Association of Automation (YAC), pp.220–225, 2018.

[40] W. Zhao, H. Liu, F. L. Lewis, K. P. Valavanis, and X. Wang. Robust visual servoing control for

ground target tracking of quadrotors. In IEEE Transactions on Control Systems Technology.

pp.1-8, 2019.

[41] E. Zheng and J. Xiong. Quad-rotor unmanned helicopter control via novel robust terminal slid-

ing mode controller and under-actuated system sliding mode controller. In Optik - International

Journal for Light and Electron Optics. vol.125(12), pp.2817-2825, 2014.

[42] N. M. Zimmerman. Flight control and hardware design of multi-rotor systems. Master’s thesis,

Marquette University, 2016.

74