See discussions, stats, and author profiles for this publication at: https://www.researchgate.
net/publication/334965830
Modeling, Simulation and Control of Quadcopter using PID Controller
Conference Paper · August 2019
CITATIONS READS
3 8,128
2 authors:
Mohammed Hamdy Abdelrady Okasha Elnady
British University in Egypt October 6 University
1 PUBLICATION 3 CITATIONS 50 PUBLICATIONS 151 CITATIONS
SEE PROFILE SEE PROFILE
All content following this page was uploaded by Abdelrady Okasha Elnady on 05 August 2019.
The user has requested enhancement of the downloaded file.
Modeling, Simulation and Control of Quadcopter
using PID Controller
Osama Mohammed Hamdy, Hassan Talal Hassan
October 6th University, Egypt, osmahamdy@gmail.com,Hassanhetta96@hotmail.com
Supervisor: Abdelrady Okasha Elnady, Associated Professor
Faculty of Engineering, Mechatronics Department, October 6th University, Egypt, rady_nady@yahoo.com
Abstract–Quadcopter also called Quadrotor helicopter, is popular The research field is still facing some challenges in the control
as unmanned aerial vehicle (UAV). Quadcopter are widely used for field because the quad rotor is a highly nonlinear,
variety of applications due to its small size. Quadrotor control is multivariable system and since it has six degrees of freedom
very important as the research field still facing challenges because (DOF) but only four actuators, it is an underacuated system
the quadrotor is highly non-linear, multivariable system and since
[2]. Underacuated systems are those having a less number of
it has six degrees of Freedom but only four actuators .The
motivation for this paper is to apply PID methodologies for control inputs compared to the system’s degrees of freedom.
quadcopter control system .The dynamic model is formulated using They are very difficult to control due to the nonlinear coupling
the Newton-Euler method. The derivation of mathematical model is between the actuators and the degrees of freedom.
followed by Development of Linear Proportional-Derivative- In the current work, quad copter prototype is designed and
Integral (PID) controller to control altitude, attitude, heading, and developed using PID controller. IMU is used to determine the
position of quadcopter in space. The developed control system is for system orientation. In this work, mathematical modeling of
both the rectangular position (x, y) and altitude (z) as well as the quad copter is done using MATLAB Simulink model using
orientation (attitude angles around the axes )based on 6-Degree of PID controller for stabilized operation of quad copter.
freedom (3 linear and 3 angular motions).The contributions of this
work are: (1) deriving a detailed mathematical model of the II. SYSTEM MODELING
quadrotor UAV, developing linear and nonlinear control
algorithms and applying those on the derived mathematical model The kinematics and dynamics model of a quad rotor will be
in computer based simulations.(2) comparison between the derived based on Newton-Euler formalism with the following
developed control algorithms in terms of their dynamic assumptions:
performance and their ability to stabilize the system under the effect
of possible disturbances. Simulation of quadcopter is carried out
1) The structure is rigid and symmetrical.
using MATLAB Simulink.
Keywords-- Quadcopter, UAV, PID, MATLAB Simulink. 2) The center of gravity of the quad rotor coincides with the
body fixed frame origin.
3) The propellers are rigid.
I. INTRODUCTION 4) Thrust and drag are proportional to the square of
One of the popular area of research is UAV. In the mid-1800s, propeller’s speed.
researchers started in unmanned aerial vehicle and Drones
started in the early 1900s and it became more popular in the A. Kinematic model
world war-I. Most popular UAV is Quad copter (QC) and is We first define the coordinate frames that will be used:
preferred due to small size and high stability. It can vertically 1) Earth frame or inertial frame (it uses the N-E-D).
take off and land(VTOL). Quadcopter can change the 2) Body frame at the center of quad rotor body (it uses X-Y-
direction immediately to reach the unreachable areas. Mostly Z).
quad copter is used in military applications: to identify the As shown in Fig.1.
unknown objects, enemies, boarder patrolling etc. recently,
quadcopters are used in small goods transportation [1].
Quadcopter can either be remotely operated by a human or
Quadcopter can be autonomous; autonomous vehicles are
controlled by an onboard computer that can be programmed to
perform a specific task or a broad set of tasks.
4th IUGRC International Undergraduate Research Conference,
Military Technical College, Cairo, Egypt, July 29th – Aug 1st, 2019.
The general formalism of rotational equation of motion is to
be:
𝐽𝜔̇ + 𝜔 × 𝐽𝜔 + 𝑀 = 𝑀 (4).
Where:
J quadrotors diagonal inertia matrix
ω angular body rates
𝑀 Gyroscopic moments due to rotor’s inertia
𝑀 Moments acting on quadrotor on the body frame
The rotational equation of motion can be rewritten as[3],
Jω̇ + ω × Jω + [0 0 𝐽 Ω ] =𝑀 (5).
Fig.1 Quadrotor reference frames Where:
The distance between the earth frame and the body frame Jr rotor’s inertia
describes the absolute position of the center of mass of the Ω rotor’srelative speed Ω = −Ω +Ω − Ω + Ω
quad rotor r = [x y z]T . And the inertia matrix to be:
The orientation of the quad rotor is describes using roll, pitch, 𝐼 0 0
yaw angles (ϕ, θ and ψ) representing rotations about the X, Y 𝐽= 0 𝐼 0 (6).
and Z- axes respectively.Assuming the order of rotation to be 0 0 𝐼
roll, pitch then yaw, the rotation matrix R will be:
2) Moments acting on the quad rotor (MB):
𝑐𝜃𝑐𝜓 𝑠𝜙𝑠𝜃𝑐𝜓 𝑐𝜙𝑠𝜃𝑐𝜓 + 𝑠𝜙𝑠𝜓
R = 𝑐𝜃𝑠𝜓 𝑠𝜙𝑠𝜃𝑠𝜓 + 𝑐𝜙𝑐𝜓 𝑐𝜙𝑠𝜃𝑠𝜓 − 𝑠𝜃𝑠𝜓 (1). 𝐹 = 𝜌𝐴𝐶 𝑟 𝛺 (7).
−𝑠𝜃 𝑠𝜙𝑐𝜃 𝑐𝜙𝑐𝜃
𝑀 = 𝜌𝐴𝐶 𝑟 𝛺 (8).
Where:
Where c and s denote cos and sin respectively. ρ air density
To acquire information about the angular velocity of the quad A blade area
rotor, typically an on-board inertial measurement unit (IMU) 𝐶 ,𝐶 aerodynamic coefficients
Is used which will in turn give the velocity in the body r radius of blade
coordinate frame. To relate the Euler rates ὴ = [ϕ̇ 𝜃̇ 𝜓̇] , 𝛺 angular velocity of rotor i
A transformation is needed as follows: Thesetwo Equations can be simplified to,
𝐹 =𝐾 𝛺 (9).
𝜔 = Rr ὴ (2). 𝑀 =𝐾 𝛺 (10).
Where:
Where 𝐾 and 𝐾 are the aerodynamic force and moment
1 0 −𝑠𝑖𝑛𝜃
constant respectively.
𝑅𝑟 = 0 𝑐𝑜𝑠𝜙 𝑠𝑖𝑛𝜙𝑐𝑜𝑠𝜃 (3).
Equations (8) and (9) describe the Forces and the moments
0 −𝑠𝑖𝑛𝜙 𝑐𝑜𝑠𝜙𝑐𝑜𝑠𝜃
acting on quad rotor as shown in Fig.2.
B. Dynamic model
The motion of the quad rotor can be divided into two
subsystem; rotational subsystem and translational subsystem
the rotational subsystem is fully actuated while the
translational subsystem is underacuated.
1)Rotational equations of motion:
4th IUGRC International Undergraduate Research Conference,
Military Technical College, Cairo, Egypt, July 29th – Aug 1st, 2019.
2) Translational equations of motion:
The general form of translational equation of motion is to be
[33]:
0
m𝑟̈ = 0 + R𝐹 (14),
𝑚𝑔
Where:
𝑟 = [𝑥 𝑦 𝑧] quad rotor’s distance from the inertial frame
m quad rotor’s mass
ggravitational acceleration g = (9.81 m/s )
𝐹 non-gravitational forces acting on the quad rotor
in the body frame.
Non-gravitational forces acting on the quad rotor can be
expressed as:
0
𝐹 = 0 (15).
−𝐾 (𝛺 −𝛺 +𝛺 −𝛺 )
In the previous dynamics formulation, the aerodynamic
effects where neglected. However, in order to have an
accurate model to be used in simulation, aerodynamic effects
should be included, there are namely two types of
Fig.2 Forces and moments acting on the quadrotor. aerodynamic effects:
We then calculate the moments about the axis: 1) Drag force
1) The total moment about the X-axis can be expressed as Where,
𝑀 = 𝑙(𝐹 + 𝐹 ) 𝐾 is a constant matrix called the aerodynamic translation
= −(𝐾 𝛺 ) + (𝐾 𝛺 ) coefficient matrix,
=𝑙𝐾 (𝛺 −𝛺 ) (11).
𝑟 ̇ is the time derivative of the position vector r.
2) The total moment about the Y-axis can be expressed as
𝑀 = 𝑙(𝐹 + 𝐹 ) The translational equation of motionshould be rewritten to be:
= (𝐾 𝛺 ) − (𝐾 𝛺 )
0
=𝑙𝐾 (𝛺 −𝛺 ) (12).
m𝑟̈ = 0 + R𝐹 (16).
𝑚𝑔
3) The total moment about the x-axis can be expressed as,
𝑀 =𝑀 +𝑀 +𝑀 +𝑀 = 2) Drag moments :
(𝐾 𝛺 ) − (𝐾 𝛺 ) + (𝐾 𝛺 ) − (𝐾 𝛺 )= 𝑀 = Kr ὴ
Where
𝐾 (𝛺 −𝛺 +𝛺 −𝛺 ) (13). Kr is a constant matrix called the aerodynamic rotation
coefficient matrix
By combining (10),(11) and (12) in vector form we get: ὴ The Euler rates.
𝑙𝐾 (𝛺 − 𝛺 )
𝑀 = 𝑙𝐾 (𝛺 −𝛺 ) The rotational equation of motion should be rewritten to be:
𝐾 (𝛺 −𝛺 +𝛺 −𝛺 ) 𝐽𝜔̇ + 𝜔 × 𝐽𝜔 + [0 0 𝐽𝑟𝛺𝑟] = 𝑀𝑏 − 𝑀𝑎 (17).
4th IUGRC International Undergraduate Research Conference,
Military Technical College, Cairo, Egypt, July 29th – Aug 1st, 2019.
𝛺 = 𝑈 − 𝑈 − 𝑈 (27).
III. STATE SPACE MODEL
𝛺 = 𝑈 − 𝑈 + 𝑈 (28).
Formulating the mathematical model into a state space model
will help make the control problem easier to tackle 𝛺 = 𝑈 + 𝑈 − 𝑈 (29).
A. State vector X
Defining the state vector of the quad rotor to be: C. Rotational equation of motion
𝑋 = [𝑥 𝑥 𝑥 𝑥 𝑥 𝑥 𝑥 𝑥 𝑥 𝑥 𝑥 𝑥 ] (18). The equation of the total moments acting on the
Which is mapped to the degree of freedom of the quad rotor in quadrotor becomes
the following manner:
𝑙𝑈
𝑀 = 𝑙𝑈 (30)
𝑋 = 𝜙 𝜙̇ 𝜃 𝜃̇ 𝜓 𝜓̇ 𝑧 𝑧̇ 𝑥 𝑥̇ 𝑦 𝑦̇ (19).
𝑈
The state vector defines the position of the quad rotor in space
By expanding the rotational equation of motion
and its angular and linear velocities.
B. Control input vector u 𝐼 0 0 ф̈ ф̇ 𝐼 0 0 ф̇ ф̇
0 𝐼 0 Ӫ + Ө̇ × 0 𝐼 0 Ө̇ + Ө̇ ×
A control input vector U consisting of four inputs 𝑈 through 0 0 𝐼 𝜓̈ 𝜓̇ 0 0 𝐼 𝜓̇ 𝜓̇
𝑈 is defined as,𝑈 = [𝑈 𝑈 𝑈 𝑈 ]. 0 𝑙𝑈
Where 0 = 𝑙 𝑈 (31).
𝐽𝛺 𝑈
𝑈 = 𝐾 (𝛺 + 𝛺 + 𝛺 + 𝛺 ) (20). Expanding that leads to
𝑈 = 𝐾 (−𝛺 + 𝛺 ) (21).
𝑈 = 𝐾 (𝛺1 − 𝛺3 ) (22).
𝐼 ф̈ Ө̇𝐼 𝜓̇ − 𝜓̇𝐼 Ө̇ 𝐽 𝛺 Ө̇ 𝑙𝑈
𝑈 =𝐾 𝛺 −𝛺 +𝛺 −𝛺 (23).
̈
𝐼 Ө + 𝜓̇𝐼 ф̇ − ф̇𝐼 ф̇ + −𝐽 𝛺 ф̇ = 𝑙 𝑈 (32).
Through these Equations from () to () it can be arranged in 𝐼 𝜓̈ ф̇𝐼 Ө̇ − Ө̇𝐼 ф̇ 0 𝑈
matrix form as follows:
𝑈 𝐾 𝐾 𝐾 𝐾
⎡ ⎤
𝑈 0 −𝐾 0 𝐾 To simplify, define,
= ⎢ ⎥ (24).
𝑈 ⎢𝐾 0 −𝐾 0 ⎥
𝑈 ⎣𝐾 −𝐾 𝐾 −𝐾 ⎦ 𝑎 = 𝑏 =
𝑎 = 𝑏 =
The rotor velocities can be calculated from control inputs as
follows∶
1 1 1 𝑎 = 𝑏 =
⎡ 0 ⎤
⎢ 4𝐾 2𝐾 4𝐾 ⎥
𝛺 ⎢ 1 1 1 ⎥ 𝑈 𝑎 =
⎡ ⎤ ⎢4𝐾 − 2𝐾 0 −
⎢𝛺 ⎥ 4𝐾 ⎥ 𝑈
= ⎢ ⎥ (25).
⎢𝛺 ⎥ ⎢ 1 1 1 ⎥ 𝑈
⎢ ⎥ 0 − 𝑎 =
⎢𝛺 ⎥ ⎢4𝐾 2𝐾 4𝐾 ⎥ 𝑈
⎢ 1 1 1 ⎥
⎢ 0 − ⎥ ф̈ = 𝑏 𝑈 − 𝑎 𝑥 𝛺 + 𝑎 𝑥 𝑥 (33).
⎣4𝐾 2𝐾 4 ⎦
Ӫ = 𝑏 𝑈 + 𝑎 𝑥 𝛺 + 𝑎 𝑥 𝑥 (34).
𝜓̈ = 𝑏 𝑈 + 𝑎 𝑥 𝑥 (35).
Taking the square root of that the rotor’svelocities can be
D. Translational equation of motion:
calculated from control input as follows∶
𝛺 = 𝑈 + 𝑈 + 𝑈 (26). The equation of the total moments acting on the
quadrotor becomes
4th IUGRC International Undergraduate Research Conference,
Military Technical College, Cairo, Egypt, July 29th – Aug 1st, 2019.
A. Open-loop simulation
0 An open-loop simulation was carried out using MATLAB
𝐹 = 0 (36). simulink as shown in Fig.3.
−𝑈
By expanding the translational equation of motion:
𝑥̈ 0
𝑚 𝑦̈ = 0 +
𝑧̈ 𝑚𝑔
𝑐𝜃𝑐𝜓 𝑠𝜙𝑠𝜃𝑐𝜓 𝑐𝜙𝑠𝜃𝑐𝜓 + 𝑠𝜙𝑠𝜓 0
𝑐𝜃𝑠𝜓 𝑠𝜙𝑠𝜃𝑠𝜓 + 𝑐𝜙𝑐𝜓 𝑐𝜙𝑠𝜃𝑠𝜓 − 𝑠𝜃𝑠𝜓 0 (37). Fig.3open loop block diagram.
−𝑠𝜃 𝑠𝜙𝑐𝜃 𝑐𝜙𝑐𝜃 −𝑈
B. Closed-loopsimulation
Rewriting equations we get,
The open loop simulation is extended to be a closed-loop
to control altitude, attitude, heading and position. As
𝑥̈ = (𝑠𝑖𝑛ф 𝑠𝑖𝑛𝜓 + 𝑐𝑜𝑠ф 𝑐𝑜𝑠𝜓 𝑠𝑖𝑛Ө) (38).
shown in Fig.4, Fig.5 and Fig.6.
𝑦̈ = (𝑐𝑜𝑠ф 𝑠𝑖𝑛𝜓 𝑠𝑖𝑛Ө − 𝑠𝑖𝑛ф 𝑐𝑜𝑠𝜓 ) (39). 1) altitude controller
𝑧̈ = (𝑐𝑜𝑠ф 𝑐𝑜𝑠Ө) (40).
Rewriting in terms of state variable X,
𝑥̈ = (sin 𝑥 𝑠𝑖𝑛 𝑥 + cos 𝑥 cos 𝑥 sin 𝑥 ) (41).
𝑦̈ = (cos 𝑥 cos 𝑥 sin 𝑥 − sin 𝑥 cos 𝑥 ) (42).
𝑧̈ = 𝑔 − (cos 𝑥 cos 𝑥 ) (43).
E. State space representation: Fig.4 Block diagram for altitude controller.
The quad rotor can be written in State space representation as 2) position controller
follows,
𝑥
⎡ 𝑏 𝑈 − 𝑎 𝑥 𝛺 + 𝑎 𝑥 𝑥 ⎤
⎢ 𝑥 ⎥
⎢ 𝑏 𝑈 + 𝑎 𝑥 𝛺 + 𝑎 𝑥 𝑥 ⎥
⎢ ⎥
⎢ 𝑥 ⎥
⎢ 𝑏 𝑈 + 𝑎 𝑥 𝑥 ⎥
f(X,U) = ⎢ 𝑥 ⎥ (45).
⎢ 𝑔 − (cos 𝑥 cos 𝑥 ) ⎥
⎢ ⎥
⎢ 𝑥 ⎥
⎢ (cos 𝑥 cos 𝑥 sin 𝑥 − sin 𝑥 cos 𝑥 )⎥
⎢ 𝑥 ⎥ Fig.5 Block diagram for altitude and Heading controller.
⎢ ⎥
⎣ (sin 𝑥 𝑠𝑖𝑛 𝑥 + cos 𝑥 cos 𝑥 sin 𝑥 )⎦
3) complete system block diagram
IV. SYSTEM CONTROL
The formulated quadrotor model will be used in open-loop
simulation and controller design.
4th IUGRC International Undergraduate Research Conference,
Military Technical College, Cairo, Egypt, July 29th – Aug 1st, 2019.
Fig.8 Complete system using MATLAB simulink
VI. RESULTS ANALYSIS
The Quadcopter Dynamic Motion are simulated by using
MATLAB software using PID controller. The MATLAB
results are shown are shown in Figures 9,10,11,12 which are
x,y(Position), z(altitude),psi(Heading) respectively.
VII. CONCLUSIONS
This paper Studied mathematical modelling and control of a
quadcopter. The mathmatical model of quadcopter dynamics
Fig .6 Position controller block diagram (complete system). was presented and differential equations were derived from
Newton-Euler equations. working and implementation of
And the PID controller as shown in Fig.7, altitude, heading and position of quadcopter based on PID
logic controller is presented in mathematical modeling of
quadcopter is done using MATLAB Simulink model. For
stabilization of quadcopter, PID controller was chosen, PID
controller was implemented successfully
Fig.7 PID Controller Block Diagram.
V. MTALAB SIMULINK
The Simulink Blocks that describe the system as shown in
Fig.8,
4th IUGRC International Undergraduate Research Conference,
Military Technical College, Cairo, Egypt, July 29th – Aug 1st, 2019.
View publication stats
VIII. RESULTS DISCUSSION
Fig.9 Altitude response
ACKNOWLEDGMENT
We would like to thank Dr.AbdelradyOkasha supervisor of the
project for all his support, guidance and following on every
step during the project.
. REFRENCES
Fig.10 Heading response
[1] Viswanadhapalli Praveen and Anju S. pillai. “Modeling and
simulation of Quadcopter using PID controller,” in press, 2015, pp.
7151-7158.
[2] HongningHou, Jian Zhuang, Hu Xia, Guanwei Wang, and Dehong
Yu. “A simple controller of mini-size quad-rotor vehicle,” In press,
2010.
[3] Amr Nagaty, SajadSaeedi, Carl Thibault, Mae Seto and Howard
Li. “Control and navigation framework for quadrotor helicopters,”
in press, http://dx.doi.org/10.1007/s10846-012-9789-z , 2013.
[4] Jinhyun Kim, Min-Sung Kang, and
SangdeokPark.”Accuratemodeling and robust hovering control for
quadrotor vtol aircraft,” Journal of Intelligent and Robotic
Systems, http://dx.doi.org/10.1007/s10846-009-9369-z ,
2010.
[5] Gergely Regula, “Formation control of autonomous aerial
Fig.11 Pitch angle response vehicles”. Phd thesis,
Budapest University of Technology and Economics, 2013.
[6] Elkholy, Hebatalla Mohamed Nabil. “Dynamic modeling and
control of a Quadcoper using linear and nonlinear
approaches,”http://dar.aucegypt.edu/handle/10526/3965 , in press,
may 2014.
[7] Azzam and Xinhua Wang. “Quad rotor aerial robot dynamic
modeling and configuration stabilization.” In press, 2010.
Fig.12Roll angle response
4th IUGRC International Undergraduate Research Conference,
Military Technical College, Cairo, Egypt, July 29th – Aug 1st, 2019.