Teppo Luukkonen
Teppo Luukkonen
Teppo Luukkonen
Mat-2.4108
Independent research project in applied mathematics
Espoo, August 22, 2011
A?
Aalto University
School of Science
This document can be stored and made available to the public on the
open internet
pages of Aalto University. All other rights are reserved.
ii
Contents
Contents ii
1 Introduction 1
2 Mathematical model of quadcopter 2
2.1 Newton-Euler equations . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Euler-Lagrange equations . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Aerodynamical effects . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3 Simulation 7
4 Stabilisation of quadcopter 10
5 Trajectory control 13
5.1 Heuristic method for trajectory generation . . . . . . . . . . . . . . . 14
5.2 Integrated PD controller . . . . . . . . . . . . . . . . . . . . . . . . . 18
6 Conclusion 21
References 23
1 Introduction
more complex aerodynamic properties has been introduced as well [1, 2].
Different
control methods has been researched, including PID controllers [3, 4, 5,
6], backstepping
control [7, 8], nonlinear H1 control [9], LQR controllers [6], and nonlinear
controllers with nested saturations [10, 11]. Control methods require
accurate information
from the position and attitude measurements performed with a gyroscope,
an accelerometer, and other measuring devices, such as GPS, and sonar
and laser
sensors [12, 13].
The purpose of this paper is to present the basics of quadcopter modelling
and
control as to form a basis for further research and development in the
area. This
is pursued with two aims. The first aim is to study the mathematical model
of the
quadcopter dynamics. The second aim is to develop proper methods for
stabilisation
and trajectory control of the quadcopter. The challenge in controlling a
quadcopter
is that the quadcopter has six degrees of freedom but there are only four
control
inputs.
This paper presents the differential equations of the quadcopter dynamics.
They are
derived from both the Newton-Euler equations and the Euler-Lagrange
equations
which are both used in the study of quadcopters. The behaviour of the
model is
examined by simulating the flight of the quadcopter. Stabilisation of the
quadcopter
is conducted by utilising a PD controller. The PD controller is a simple
control
method which is easy to implement as the control method of the
quadcopter. A
simple heuristic method is developed to control the trajectory of the flight.
Then
a PD controller is integrated into the heuristic method to reduce the effect
of the
fluctuations in quadcopter behaviour caused by random external forces.
The following section presents the mathematical model of a quadcopter. In
the
third section, the mathematical model is tested by simulating the
quadcopter with
given control inputs. The fourth section presents a PD controller to
stabilise the
quadcopter. In the fifth section, a heuristic method including a PD
controller is
yB xB
zB
f1
_M1
!1
f2
_M2
!2
f3
_M3
!3
f4
_M4
!4
Figure 1: The inertial and body frames of a quadcopter
The absolute linear position of the quadcopter is defined in the inertial
frame x,y,zaxes
with _. The attitude, i.e. the angular position, is defined in the inertial
frame
with three Euler angles _. Pitch angle _ determines the rotation of the
quadcopter
around the y-axis. Roll angle _ determines the rotation around the x-axis
and yaw
angle around the z-axis. Vector q contains the linear and angular position
vectors
_=
x
y
z
,_=
_
_
,q=
_
_
_
_
. (1)
The origin of the body frame is in the center of mass of the quadcopter. In
the body
frame, the linear velocities are determined by VB and the angular
velocities by _
VB =
vx,B
vy,B
vz,B
,_=
p
q
r
. (2)
The rotation matrix from the body frame to the inertial frame is
R=
C C_ C S_S_ S C_ C S_C_ + S S_
S C_ S S_S_ + C C_ S S_C_ C S_
S_ C_S_ C_C_
, (3)
in which Sx = sin(x) and Cx = cos(x). The rotation matrix R is orthogonal
thus
R1 = RT which is the rotation matrix from the inertial frame to the body
frame.
3
The transformation matrix for angular velocities from the inertial frame to
the body
frame is W_, and from the body frame to the inertial frame is W1
_ , as shown in
[14],
_ =W1
_ _,
_ =W_ _ ,
_
_
1 S_T_ C_T_
0 C_ S_
0 S_/C_ C_/C_
p
q
r
p
q
r
1 0 S_
0 C_ C_S_
0 S_ C_C_
_
_
,
(4)
in which Tx = tan(x). The matrix W_ is invertible if _ 6= (2k 1)_/2, (k Z).
The quadcopter is assumed to have symmetric structure with the four
arms aligned
with the body x- and y-axes. Thus, the inertia matrix is diagonal matrix I in
which
Ixx = Iyy
I=
Ixx 0 0
0 Iyy 0
0 0 Izz
. (5)
The angular velocity of rotor i, denoted with !i, creates force fi in the
direction of
the rotor axis. The angular velocity and acceleration of the rotor also
create torque
_Mi around the rotor axis
f i = k !2
i , _Mi = b !2
i + IM ! i, (6)
in which the lift constant is k, the drag constant is b and the inertia
moment of the
rotor is IM. Usually the effect of ! i is considered small and thus it is
omitted.
The combined forces of rotors create thrust T in the direction of the body
z-axis.
Torque _B consists of the torques __, __ and _ in the direction of the
corresponding
body frame angles
T=
X4
i=1
fi = k
X4
i=1
!2
i , TB =
0
0
T
, (7)
_B =
__
__
_
l k (!2
2 + !2
4)
l k (!2
1 + !2
3)
X4
i=1
_Mi
, (8)
in which l is the distance between the rotor and the center of mass of the
quadcopter.
Thus, the roll movement is acquired by decreasing the 2nd rotor velocity
and increasing the 4th rotor velocity. Similarly, the pitch movement is
acquired by
decreasing the 1st rotor velocity and increasing the 3th rotor velocity. Yaw
movement
is acquired by increasing the the angular velocities of two opposite rotors
and
decreasing the velocities of the other two.
4
x
y
z
= g
0
0
1
+ Tm
C S_C_ + S S_
S S_C_ C S_
C_C_
.
(10)
In the body frame, the angular acceleration of the inertia I_ , the
centripetal forces
_ (I_) and the gyroscopic forces are equal to the external torque _
I_ + _ (I_) + = _ ,
_ = I1
p
q
r
Ixx p
Iyy q
Izz r
Ir
p
q
r
0
0
1
! + _
p
q
r
Ir
q/Ixx
p/Iyy
0
! +
__/Ixx
__/Iyy
_ /Izz
,
(11)
in which ! = !1!2 +!3 !4. The angular accelerations in the inertial frame
are
then attracted from the body frame accelerations with the transformation
matrix
W1
_ and its time derivative
_ = d
dt
W1
__
_
=d
dt
W1
_
_ +W1
_ _
=
0 _C_T_ + _S_/C2
_ _S_C_ + _C_/C2
_
0 _S_ _C_
0 _ C_/C_ + _S_T_/C_ _S_/C_ + _C_T_/C_
_ +W1
_ _ .
(12)
5
@L
@q
. (14)
The linear and angular components do not depend on each other thus
they can be
studied separately. The linear external force is the total thrust of the
rotors. The
linear Euler-Lagrange equations are
f = RTB = m_ + mg
0
0
, (15)
which is equivalent with Equation (10).
The Jacobian matrix J (_) from _ to _ is
J (_) = J =WT
_ IW_,
=
Ixx 0 IxxS_
0 IyyC2
_ + IzzS2
_ (Iyy Izz)C_S_C_
IxxS_ (Iyy Izz)C_S_C_ IxxS2
_ + IyyS2
_C2
_ + IzzC2
_C2
_
.
(16)
Thus, the rotational energy Erot can be expressed in the inertial frame as
Erot = (1/2) _T I _ = (1/2) _T J _. (17)
The external angular force is the torques of the rotors. The angular EulerLagrange
equations are
_ = _B = J _ +
d
dt
(J) _
1
2
@
@_
_T J _
_
= J _ + C (_, _ ) _ . (18)
,
in which the matrix C (_, _ ) is the Coriolis term, containing the gyroscopic
and
centripetal terms.
6
The matrix C (_, _ ) has the form, as shown in [9],
C (_, _ ) =
,
C11 = 0
C12 = (Iyy Izz)(_ C_S_ + S2
_C_) + (Izz Iyy) C2
_C_ Ixx C_
C13 = (Izz Iyy) C_S_C2
_
x
y
z
= g
0
0
1
+
T
m
C S_C_ + S S_
S S_C_ C S_
C_C_
1
m
Ax 0 0
0 Ay 0
0 0 Az
x
y
z
, (21)
in which Ax, Ay and Az are the drag force coefficients for velocities in the
corresponding
directions of the inertial frame.
Several other aerodynamical effects could be included in the model. For
example,
dependence of thrust on angle of attack, blade flapping and airflow
distruptions have
been studied in [1] and [2]. The influence of aerodynamical effects are
complicated
and the effects are difficult to model. Also some of the effects have
significant effect
only in high velocities. Thus, these effects are excluded from the model
and the
presented simple model is used.
7
3 Simulation
The mathematical model of the quadcopter is implemented for simulation
in Matlab
2010 with Matlab programming language. Parameter values from [3] are
used in the
simulations and are presented in Table 1. The values of the drag force
coefficients
Ax, Ay and Az are selected such as the quadcopter will slow down and stop
when
angles _ and _ are stabilised to zero values.
Table 1: Parameter values for simulation
Parameter Value Unit
g 9.81 m/s2
m 0.468 kg
l 0.225 m
k 2.980 106
b 1.140 107
IM 3.357 105 kg m2
Parameter Value Unit
Ixx 4.856 103 kg m2
Iyy 4.856 103 kg m2
Izz 8.801 103 kg m2
Ax 0.25 kg/s
Ay 0.25 kg/s
Az 0.25 kg/s
The mathematical model is tested by simulating a quadcopter with an
example case
as following. The quadcopter is initially in a stable state in which the
values of all
positions and angles are zero, the body frame of the quadcopter is
congruent with
the inertial frame. The total thrust is equal to the hover thrust, the thrust
equal to
gravity. The simulation progresses at 0.0001 second intervals to total
elapsed time
of two seconds. The control inputs, the angular velocities of the four
rotors, are
shown in Figure 2, the inertial positions x, y and z in Figure 3, and the
angles _, _
and in Figure 4.
For the first 0.25 seconds the quadcopter ascended by increasing all of
the rotor
velocities from the hover thrust. Then, the ascend is stopped by
decreasing the rotor
velocities significantly for the following 0.25 seconds. Consequently the
quadcopter
ascended 0.1 meters in the first 0.5 seconds. After the ascend the
quadcopter is
stable again.
Next the quadcopter is put into a roll motion by increasing the velocity of
the
fourth rotor and decreasing the velocity of the second rotor for 0.25
seconds. The
acceleration of the roll motion is stopped by decreasing the velocity of the
fourth
and increasing the velocity of the second rotor for 0.25 seconds. Thus,
after 0.5
seconds in roll motion the roll angle _ had increased approx. 25 degrees.
Because
of the roll angle the quadcopter accelerated in the direction of the
negative y-axis.
Then, similar to the roll motion, a pitch motion is created by increasing the
velocity
of the third rotor and decreasing the velocity of the first. The motion is
stopped
by decreasing the velocity of the third rotor and increasing the velocity of
the first
rotor. Due to the pitch movement, the pitch angle _ had increased
approximately
8
22 degrees. The acceleration of the quadcopter in the direction of the
positive x-axis
is caused by the pitch angle.
Finally, the quadcopter is turned in the direction of the yaw angle by
increasing
the velocities of the first and the third rotors and decreasing the velocities
of the
second and the fourth rotors. The yaw motion is stopped by decreasing
the velocities
of the first and the third rotors and increasing the velocities of the second
and the
fourth rotors. Consequently the yaw angle increases approximately 10
degrees.
During the whole simulation the total thrust of the rotors had remained
close to the
initial total thrust. Thus, the deviations of the roll and pitch angles from
the zero
values decrease the value of the thrust in the direction of the z-axis.
Consequently
the quadcopter accelerates in the direction of the negative z-axis and is
descending.
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
550
575
600
625
650
675
700
Time t (s)
Control input !i (rad/s)
!1
!2
!3
!4
1
0.5
0
0.5
1
1.5
Time t (s)
Position (m)
Position x
Position y
Position z
Time t (s)
Angle (deg)
Angle
Angle
Angle
4 Stabilisation of quadcopter
e(_ ) d _ + KD
d e(t)
dt
, [16]
(22)
in which u(t) is the control input, e(t) is the difference between the desired
state
xd(t) and the present state x(t), and KP , KI and KD are the parameters for
the
proportional, integral and derivative elements of the PID controller.
In a quadcopter, there are six states, positions _ and angles _, but only
four control
inputs, the angular velocities of the four rotors !i. The interactions
between the
states and the total thrust T and the torques _ created by the rotors are
visible from
the quadcopter dynamics defined by Equations (10), (11), and (12). The
total thrust
T affects the acceleration in the direction of the z-axis and holds the
quadcopter in
the air. Torque __ has an affect on the acceleration of angle _, torque __
affects the
acceleration of angle _, and torque _ contributes in the acceleration of
angle .
Hence, the PD controller for the quadcopter is chosen as, similarly as in
[4],
_
4b
!2
2= T
4k
__
2kl
+
_
4b
!2
3= T
4k
+ __
2kl
_
4b
!2
4= T
4k
+
__
2kl
+
_
4b
(24)
The performance of the PD controller is tested by simulating the
stabilisation of
a quadcopter. The PD controller parameters are presented in Table 2. The
initial
condition of the quadcopter is for position _ = [0 0 1]T in meters and for
angles
11
_ = [10 10 10]T in degrees. The desired position for altitude is zd = 0. The
purpose
of the stabilisation is stable hovering, thus _d = [0 0 0]T.
Table 2: Parameters of the PD controller
Parameter Value
Kz,D 2.5
K_,D 1.75
K_,D 1.75
K ,D 1.75
Parameter Value
Kz,P 1.5
K_,P 6
K_,P 6
K ,P 6
The control inputs !i, the positions _ and the angles _ during the simulation
are
presented in Figures 5, 6, and 7. The altitude and the angles are stabilised
to zero
value after 5 seconds. However, the positions x and y deviated from the
zero values
because of the non-zero values of the angles. Before the quadcopter is
stabilised
to hover, it has already moved over 1 meters in the direction of the
positive x axis
and 0,5 meters in the direction of the negative y axis. This is because the
control
method of the PD contoller does not consider the accelerations in the
directions of
x and y. Thus, another control method should be constructed to give a
control on
all of positions and angles of the quadcopter.
0123456
550
560
570
580
590
600
610
620
630
Time t (s)
Control input !i (rad/s)
!1
!2
!3
!4
Time t (s)
Position (m)
Position x
Position y
Position z
Time t (s)
Angle (deg)
Angle
Angle
Angle
5 Trajectory control
The purpose of trajectory control is to move the quadcopter from the
original location
to the desired location by controlling the rotor velocities of the
quadcopter.
Finding optimal trajectory for a quadcopter is a difficult task because of
complex
dynamics. However, a simple control method is able to control the
quadcopter
adequately. Thus, a heuristic approach is studied and developed here.
The basis of the development of a control method is the study of the
interactions and
dependances between states, state derivatives and control inputs. These
interactions
and dependances are defined by Equations (7), (8), (20) and (21) and
presented in
Figure 8.
The given control inputs !i define the total thrust T and the torques __, __
and _ .
The torques affect the angular accelerations depending on the current
angles and
angular velocities. The angles _ can be integrated from the angular
velocities _ ,
which are integrated from the angular accelerations _. The linear
accelerations _
depend on the total thrust T, the angles _ and the linear velocities _. The
linear
position _ is integrated from the linear accelerations _ through the linear
velocities
_.
Hence, to find proper control inputs !i for given states _ this line of thought
has to
be done in reverse.
!
___*
HHHj
T
_
-
_ - _ - _
IK
_ - _ - _
@
@
@I
0
0
T
= RT
_ +
0
0
g
Ax 0 0
0 Ay 0
0 0 Az
. (25)
in which _, _, and are desired trajectory values as well as angles _ and _
and total
thrust T are unknown values to be solved.
From this equation, the required angles _ and _ and the total thrust T for
each time
t can be calculated, as shown in [5],
14
_ = arcsin
dx S dy C
d2
x + d2
y + (dz + g)2
!
,
_ = arctan
_
dx C + dy S
dz + g
_
,
T = m(dx (S_C C_ + S S_) + dy (S_S C_ C S_)+( dz + g )C_C_) ,
(26)
in which
dx = x + Axx/m,
dy = y+ Ayy/m,
dz = z+ Azz/m.
(27)
When the values of the angles _ and _ are known, the angular velocities
and accelerations
can be calculated from them with simple derivation. With the angular
a sin
1
b_ t
_
, 0 t b,
a sin
1
b_ t _
_
, b t 3b,
a sin
1
b _ t 3_
_
, 3b t 4b.
(28)
The structure of the function is visualised in Figure 9. The sine functions
are used
to give a smooth function. These three sine functions form a function in
which
the first half increases acceleration to certain value and then the second
half of the
function decreases it back to zero. This acceleration generates constant
velocity.
Mirror image of the function can be used to decelerate the velocity back
to zero.
0.2
0.4
0.6
0.8
1
Time t (s)
Jounce (m/s4)
(a) Jounce
01234567
0.4
0.3
0.2
0.1
0
0.1
0.2
0.3
0.4
Time t (s)
Jerk (m/s3)
(b) Jerk
01234567
0.2
0.15
0.1
0.05
0
0.05
0.1
0.15
0.2
Time t (s)
Acceleration (m/s2)
(c) Acceleration
01234567
0.02
0
0.02
0.04
0.06
0.08
0.1
0.12
0.14
0.16
0.18
Time t (s)
Velocity (m/s)
(d) Velocity
01234567
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
Time t (s)
Position (m)
(e) Position
Figure 10: Planned position x and its derivatives with given jounce
The simulation of the example case is performed with previously given
accelerations
and velocities of position x. The planned value of angle is zero for each
time t.
First, the required angles _ and _ and thrust T are solved from Equation
(26) for
each time t. The angular velocities and accelerations are calculated from
the solved
angles with derivation. Then, the torques are solved using the angular
velocities
and accelerations. Finally, the control inputs are solved. Then, the
simulation is
performed with given control inputs.
The calculated control inputs are presented in Figure 11. The simulated
positions
_ are presented in Figure 12 and the simulated angles _ in Figure 13.
According
to Figure 12, the simulated position x is the same as the planned position
x in
Figure 10(e) and the values of the positions y and z stay as zeroes. The
angle _
increases during the acceleration and then stabilises to a constant value
to generate
the constant acceleration required to compensate the drag force caused
by the
planned constant velocity. Finally, the angle is changed to the opposite
direction to
decelerate the quadcopter to a halt.
The shape of the calculated control inputs !1 and !3 in Figure 11 are similar
to
planned jounce in Figure 10(a). The shape of the simulated angle _ follows
the
shape of the planned acceleration x. The shapes of the control inputs and
the
angles differ from the planned values of the jounce and the acceleration
because the
drag force, caused by the velocity, has to be compensated.
17
01234567
620.3
620.4
620.5
620.6
620.7
620.8
620.9
621
Time t (s)
Control input !i (rad/s)
!1
!2
!3
!4
Time t (s)
Position (m)
Position x
Position y
Position z
Time t (s)
Angle (deg)
Angle
Angle
Angle
_
K_,P (_c _) + K_,D
_
_
c _
__
Ixx,
__ =
_
K_,P (_c _) + K_,D
_
_
c _
__
Iyy,
_ =
_
K ,P ( d ) + K ,D
_
d
__
Izz.
(30)
The performance of the PD controller is demonstrated with an example
case in
which for all positions x, y and z and their derivatives the values are same
as in
Figure 10. The simulation is performed with the PD parameters presented
in Table
3.
Table 3: Parameters of the PD controller
Variable Parameter value
i Ki,P Ki,D Ki,DD
x 1.85 0.75 1.00
y 8.55 0.75 1.00
z 1.85 0.75 1.00
_ 3.00 0.75 _ 3.00 0.75 3.00 0.75 The results of the simulation are presented Figures 15 - 17. The simulated
control
inputs are presented in Figure 15, the simulated positions in Figure 16 and
the
simulated angles in Figure 17. The position of the quadcopter is close to
the planned
position after 6 seconds but the position keeps fluctuating close to the
planned values
for several seconds. The angles variate greatly during the simulation to
achieve the
wanted positions, velocities, and accelerations. The values of the control
inputs
oscillated during the acceleration but then their behaviour became more
stable.
0 2 4 6 8 10 12 14
618
619
620
621
622
623
624
625
626
Time t (s)
Control input !i (rad/s)
!1
!2
!3
!4
Time t (s)
Position (m)
Position x
Position y
Position z
Time t (s)
Angle (deg)
Angle
Angle
Angle
6 Conclusion
This paper studied mathematical modelling and control of a quadcopter.
The mathematical
model of quadcopter dynamics was presented and the differential
equations
were derived from the Newton-Euler and the Euler-Lagrange equations.
The model
was verified by simulating the flight of a quadcopter with Matlab.
Stabilisation of
attitude of the quadcopter was done by utilising a PD controller. A
heuristic method
was developed to control the trajectory of the quadcopter. The PD
contoller was
integrated into the heuristic method for better response to disturbances in
the flight
conditions of the quadcopter.
The simulation proved the presented mathematical model to be realistic in
modelling
the position and attitude of the quadcopter. The simulation results also
showed
that the PD controller was efficient in stabilising the quadcopter to the
desired
altitude and attitude. However, the PD controller did not considered
positions x
and y. Thus, the values of x and y variated from their original values
during the
stabilisation process. This was a result of the deviation of the roll and pitch
angles
from zero values.
According to the simulation results, the proposed heuristic method
produced good
flight trajectories. The heuristic method required only three parameters to
generate
the values for the jounce of the position. The position and its other
derivatives were
calculated from the jounce values. The total thrust and the pitch and roll
angles to
achieve given accelerations were solved from the linear differential
equations. Then,
the torques were determined by the angular accelerations and angular
velocities
calculated from the angles. Finally, the required control inputs were solved
from the
total thrust and the torques. The simulation results indicated that the
quadcopter
could be controlled accurately with the control inputs given by the
method.
The proposed heuristic method does not consider unmodelled
disturbances, such
as wind, and thus the PD controller was integrated into the control
method. The
integrated PD controller operated well in the example simulation. The
quadcopter
followed the given trajectory and began to stabilise after reaching the
final destination.
However, the PD controller can perform poorly if the parameter values are
not properly selected and are too small or high.
The presented mathematical model only consists of the basic structures of
the quadcopter
dynamics. Several aerodynamical effects were excluded which can lead to
unrealiable behaviour. Also the electric motors spinning the fours rotors
were not
modelled. The behaviour of a motor is easily included in the model but
would require
estimation of the parameter values of the motor. The position and attitude
information was assumed to be accurate in the model and the simulations.
However,
the measuring devices in real life are not perfectly accurate as random
variations
and errors occur. Hence, the effects of imprecise information to the flight
of the
quadcopter should be studied as well. Also methods to enhance the
accuracy of the
measurements should be researched and implemented to improve all
aspects required
22
for robust quadcopter manoeuvres.
The presented model and control methods were tested only with
simulations. Real
experimental prototype of a quadcopter should be constructed to achieve
more realistic
and reliable results. Even though the construction of a real quadcopter
and the
estimation of all the model parameters are laborious tasks, a real
quadcopter would
bring significant benefits to the research. With a real propotype, the
theoretical
framework and the simulation results could be compared to real-life
measurements.
This paper did not include these higlighted matters in the study but
presented
the basics of quadcopter modelling and control. This paper can thus be
used as a
stepping-stone for future research in more complex modelling of the
quadcopter.
23
References