ETH Library

Nonlinear Quadrocopter Attitude
ControlTechnical Report

ReportAuthor(s):Brescianini, Dario; Hehn, Markus; D'Andrea, RaffaelloPublication date:
2013
Permanent link:
https://doi.org/10.3929/ethz-a-009970340
Rights / license:
In Copyright - Non-Commercial Use PermittedThis page was generated automatically upon download from the ETH Zurich Research Collection.
For more information, please consult the Terms of use.

Nonlinear Quadrocopter Attitude Control
Technical Report
Dario Brescianini, Markus Hehn and Raffaello D’Andrea{bdario,hehnm,rdandrea}@ethz.ch
Institute for Dynamic Systems and Control (IDSC)ETH Zürich
October 10, 2013

Abstract
This report addresses the issue of nonlinear attitude control for quadrocopters. A globallystable attitude controller based on unit quaternions is proposed and its stability and robustness
is proven. In addition, a method to prioritize the control of the crucial pitch and roll angles overyaw is introduced. Finally, experiments with the proposed nonlinear controller are conductedwhich demonstrate its performance.

1

Introduction

Quadrocopters are a popular research subject and a vast variety of literature on quadrocopter
attitude control exists. Often, the attitude is described using Euler angles, which is a very
natural way of describing orientation, especially for fixed-wing aircrafts. Controllers are thenderived from linearizations of the nonlinear attitude control problem around hover conditions.
This yields reasonable results for small pitch and roll angles. More recently, the research has
been directed towards high maneuverability. For aggressive maneuvers, i.e. extreme changes in
attitude, however, these locally stable controllers have significant deficiencies which yield poor
performance or even worse, failure to stabilize the vehicle.
In order to exploit the full potential of quadrocopters, globally stable attitude controllers should
be applied. Furthermore, Euler angles give rise to singularities which have to be avoided. This
limits the set of all possible motions for purely mathematical reasons which have nothing to
do with the physical constraints of the quadrocopter and thus Euler angles are not appropriate
for global attitude control. It is crucial for global attitude control that a parameterization ischosen which is able to represent attitudes globally and is neither geometrically nor kinematically
singular. In [2], a survey of attitude descriptions with their suitability for rigid body attitudecontrol is given. Commonly, globally stable attitude controllers are based on unit quaternions[14, 4, 13, 12], but there exist also some controllers representing the attitude using rotation
matrices [2, 9, 10].
This report is the result of a semester project carried out in fall 2011, with the objective ofdeveloping and implementing a globally stable attitude controller for the quadrocopters used in
the Flying Machine Arena1 . It is now published as a technical report to serve as a reference forthe applied attitude controller in the Flying Machine Arena.
The remainder of this report is organized as follows: In Section 2, background material on
attitude representation and the quadrocopter setup is provided. A globally asymptotically stable
control law is then proposed in Section 3. Finally, experimental results for the proposed controller
are shown in Section 4 and the report is concluded in Section 5.

2

Preliminaries

2.1

Attitude Representation

The attitude of a rigid body can be described by a rotation between a reference coordinate frame
and a body-fixed coordinate frame. There exist several rotation parametrizations such as Euler
angles (3 parameters), unit quaternions (4 parameters) and rotation matrices (9 parameters).
All three-parameter representations suffer from singularities and all k-parameter representations(k > 3) have k − 3 constraints [11].
2.1.1

Rotation Matrix

A rotation RBI is a linear transformation which maps the linear space I =b R3 to the linear spaceB=b R3 while preserving length and right-handedness. From these properties, it follows directlythat RBI ∈ SO(3). Consider the orthogonal bases ~ēI ∈ I and ~ēB ∈ B, where ~ēI is defined as~ēI := ~eIx , ~eIy , ~eIz
(1)

and a vector ~r expressed in the coordinate frames I and B, i.e. I ~r and B ~r, respectively. Thenthe linear transformation RBI that maps a vector I ~r to B ~r
r = RBI I ~r,
B~1

http://www.flyingmachinearena.org

2(2)

is given by a 3 × 3 matrix
RBI =eIx , B ~eIy , B ~eIz
B~



.

(3)

The column vectors of RBI are the three orthogonal unit basis vectors of frame I represented inframe B. Similarly, the three row vectors correspond to the basis vectors of frame B represented
in frame I.
2.1.2

Euler Angles

Euler angles are based on the fact that any rotation matrix can be constructed by consecutively
applying three elementary rotation matrices. The nine entries of the rotation matrix can then be
parametrized by the rotation angles of the three elementary rotations. A very common rotation
sequence for aircraft applications is the ZYX-sequence (Fig. 1):
1. Rotation about the initial z-axis by yaw angle ψ (I → K).
2. Rotation about the new (rotated) y-axis by pitch angle θ (K → L).
3. Rotation about the new (rotated) x-axis by roll angle φ (L → B).
RBI can be written as
RBI= RBL RLK RKI



1
0
0
cθ 0 −sθcψ= 0 cφ sφ   0 1
0  −sψ
0 −sφ cφsθ 0 cθ
0

cθ cψ
cθ sψ

=
−cφ sψ + sφ sθ cψ cφ cψ + sφ sθ sψ
sφ sψ + cφ sθ cψ −sφ cψ + cφ sθ sψ


sψ 0
cψ 0
0 1

−sθ
sφ cθ 
cφ cθ

(4)
(5)

(6)

where c(·) and s(·) are abbreviations for cos(·) and sin(·) respectively. The inverse mapping fromrotation matrix to Euler angles is thenφ = arctan2 (R23 , R33 )(7)

θ = − arcsin (R13 )(8)

ψ = arctan2 (R12 , R11 )(9)with Rij the entry in the i-th row and j-th column of RBI .
~eB
z

~eL
z

~eIz =~eK
z

~eIx

~eB
y
eB
~eL
x
x =~

φ

θ
ψ

~eK
x

eL
~eK
y
y =~

~eIy

Figure 1: ZYX-Euler angles.
32.1.3

Unit quaternion

Every rotation can be parametrized by a single rotation about a fixed axis described by the unit
vector ~k and a rotation angle α. This is known as eigenaxis rotation and embodies the shortest
rotation between two orientations. Based on this, a unit quaternion is defined as


 
⊤

cos( α2 )
q0
.
(10)
= ~
q = q0 q1 q2 q3 =q1:3
k sin( α2 )The adjoint, norm and inverse of a quaternion q are


q0
q̄ =
,
−q1:3
q
kqk =
q02 + q12 + q22 + q32 ,
q̄
.
q−1 =
kqk

(11)
(12)
(13)

The multiplication of two quaternions q and p is then defined2 by

where

q · p := Q(q)p

(14)



(15)


q0 −q1 −q2 −q3
q1 q0 −q3 q2 .
Q(q) := q2 q3q0 −q1 q3 −q2 q1
q0

Note that the quaternion, which corresponds to a rotation matrix I is given by
 
1
0

qI = 
0 .
0

(16)

The rotation of a vector ~r by a quaternion q is computed byp(~rr ) = q · p(~r) · q̄

(17)where ~rr is the rotated vector and p(·) is the quaternion representation of a vector: 
0p(~r) =.
~r
The mapping from Euler angles to unit quaternions for the ZYX-sequence is
cφ cθ cψ + sφ sθ sψ
2 2 2

 2 2 2−c φ s θ s ψ + c θ c ψ s φ 
2 2
2 2
.
2
2

q (ψ, θ, φ) =  c φ2 c ψ2 s 2θ + s φ2 c ψ2 s ψ2 cφ cθ sψ − sφ cψ sθ
2

2

2

2

2

(18)

(19)

2

2
Note: For ease of interpretation, the quaternion multiplication used in this report differs from the one definedin [3]. With the definition in (14), the quaternion multiplication q · p corresponds to first a rotation of q andafterwards a rotation of p in the new coordinate system.

42.1.4

Remarks on attitude representation

Both, rotation matrices and unit quaternions, offer singularity-free representations of attitude.
Note however, that the space of unit quaternions S3 double covers the space of physical attitudes SO(3). Hence, unit quaternions are not unique. In fact, each pair of antipodal unit
quaternions ±q ∈ S3 corresponds to the same physical attitude [2]. For attitude control tasks
in S3 , this implies that a controller has to be designed which stabilizes a disconnected set of
equilibrium points. Nevertheless, unit quaternions are often the chosen parametrization in practise for attitude control (including this report) since they are a minimal globally non-singularparametrization. Furthermore, unit quaternions offer an easy insight on what is happening on
a geometrical level.

2.2

Quadrocopter

In the following, we consider a quadrocopter with a body-fixed frame B and an inertial frame
I as shown in Fig. 2. The inputs to the quadrocopter are the four motor thrust forces. The
~eB
z

~eB
x

B
~eB
y

~eIz
~eIy
I
~eIx

Figure 2: Quadrocopter with the body-fixed coordinate frame B and a reference frame I.
outputs are the position, velocity and acceleration as well as the attitude and angular body rate.
As the model has more outputs than inputs, it is clear that not all outputs can be controlled
independently. In the FMA, a cascaded control structure is used to control the quadrocopters,with a position controller as the outermost control loop (Fig. 3). This control approach isFeedforward~
rcmd
DesiredTrajectory

~vff

~aff

~acmd

PositionController

~ ff
Ω

~ cmd
Ω

AttitudeController
collcmdψcmd~
r, ~v , ~a

~cmd
Onboard F
Quadrocopter
Controllerq~ΩState feedback (position, velocity, acceleration, attitude, angular body rate)

Figure 3: Cascaded control architecture.
known as time-scale separation and is valid as long as the inner loops are significantly fasterthan the outer loops. In this report, only the attitude control loop is taken into consideration.
It is assumed that the dynamics of the onboard control loop and the quadrocopter are much
faster such that the system to be controlled can be modelled as a rigid body with the desired5

~ as direct input. The quadrocopter dynamics can then be modelled as
angular body rate Ω
#
"


 
1 ⊤ ~
1
q
Ω
−
q˙0
1:3
2
~ =
(20)
q̇ =
= q·p Ω
1~q̇1:3
2
(S (q1:3 ) + q0 I) Ω
2with S(q1:3 ) denoting the skew-matrix of q1:3



0 −q3 q2
0 −q1  .
S(q1:3 ) =  q3
−q2 q10

3(21)

Attitude Control Design

As a first step, the commanded acceleration from the position loop and the commanded yaw
angle have to be converted into a desired attitude qcmd (Section 3.2). The objective is thento design a feedback law which stabilizes the quadrocopter at any desired physical attitude.
Since any physical attitude in SO(3) corresponds to two antipodal quaternions in S3 , this canbe achieved by stabilizing the attitude q at ±qcmd . When neglecting this fact, quaternion-based
controllers can cause undesirable phenomena such as unwinding, where the rigid body rotates
unnecessarily through a full rotation [7, 2]. To solve the problem of unwinding, the controller
must satisfy~ cmd (q) = Ω~ cmd (−q).
Ω(22)
This can easily be seen, since q and −q represent the same physical attitude, the control output
should be the same as well. This issue can be solved by changing the sign of q whenever q0 < 0.
Changing the sign however results in a discontinuous controller. Interestingly, this is not a
drawback since it can be shown that all continuous state-feedback control laws are at mostalmost globally stabilizing.

3.1

Control Law

Consider the following control law:(1,
sgn(qe,0 ) =−1,~ cmd (q) = 2 sgn(qe,0 )qe,1:3 ,Ωτqe,0 ≥ 0
qe,0 < 0

(23)

where
 τ = first-order system time constant [s],
 qe := q−1 · qcmd error measure, representing the rotation from q to qcmd .

Then, ±qcmd is a globally asymptotically stable equilibrium point of (20).
Proof. Without loss of generality, set qcmd = qI . Define an autonomous hybrid automaton [6]H = (Z, Q, f, Init, Dom, E, G, R) with
 Z = {z1 , z2 }, two discrete states, corresponding to the upper and lower hemisphere of S3 .
 Q = S3 ⊂ R4 , continuous state q, which lies in the three-sphere and represents the current
attitude.

6 A vector field

with




~ cmd (z, q) ,
1q · p Ω2
f (z, q) =~ cmd (z, q) ,− 1 q · p Ω2~ cmd (z, q) =
Ω

(

2
2
τ qe,1:3 = − τ q1:3 ,− τ2 qe,1:3 = τ2 q1:3 ,if z = z1(24)

if z = z2
if z = z1
if z = z2(25)

describing the evolution of q in time when the quaternion is in the upper hemisphere z1
or in the lower hemisphere z2 respectively.
 Domains Dom(z1 ) = Dom(z2 ) = S3 .
 Edges E = {(z1 , z2 ), (z2 , z1 )}, representing the possibility to go from z1 to z2 and viceversa.
 Guards G(z1 , z2 ) = {q ∈ S3 |q0 < 0}, and G(z2 , z1 ) = {q ∈ S3 |q0 < 0}
 Reset maps R(z1 , z2 , q) = R(z2 , z1 , q) = −q, since a rotation of 180◦ about an axis is equal
to a rotation of −180◦ about the same axis.

Now, consider the following Lyapunov candidate function:2
V (z, q) = q⊤
1:3 q1:3 + (q0 − 1)∀z ∈ Z(26)

Differentiating (26) with respect to time and inserting (24) and (20) yields∂V (z, q)f (z, q)∂q⊤
= 2 (q0 − 1) 2q1:3(27)

V̇ (z, q) =1 ⊤ 2
2 q1:3 τ q1:3
1
− 2 (S (q1:3 ) + q0 I) τ2 q1:3



(28)

2
2 ⊤
(q0 − 1) q⊤(29)
1:3 q1:3 − q1:3 (S(q1:3 ) + q0 I) q1:3
ττ2
= − q⊤(S(q1:3 ) + I)q1:3
(30)
τ 1:3
2
= − q⊤
q1:3 ∀z ∈ Z
(31)
τ 1:3
By Lyapunovs stability theorem for hybrid systems [6], the attitude qI is a stable equilibrium
because:=

1. V (z, ·) = 0 if and only if q = qI ,2. V (z, q) > 0 ∀q, (z, q) ∈ Dom(z)\{qI }, and(z,q)
f (z, q) ≤ 0 ∀q, (z, q) ∈ Dom(z).
3. V̇ (z, q) = ∂V∂q

Furthermore, V̇ (z, q) < 0 ∀z ∈ Z, ∀q ∈ Dom(z)\{qI } and V̇ (z, qI ) = 0 ∀z ∈ Z. Note that
V (z, q) does not jump when z changes its state, therefore V (z, q) is strictly decreasing, meaningthat qI is a globally asymptotically stable equilibrium point.
Remark 1. The error measure qe represents the rotation from the current attitude q to thedesired attitude qcmd . By taking the sign of qe , it is ensured that the rotation angle is always
less or equal to 180◦ . This means that the controller always rotates the rigid body in such a waythat the rotation angle is minimal. Note however, a minimal rotation angle does in general not
imply a time-optimal rotation maneuver [1, 5]. This can easily be seen if the angular body rates
are limited, i.e. |Ωi | ≤ Ωi,max , i ∈ {x, y, z} and Ωi,max 6= Ωj,max for i 6= j.
7q⊤
1:3 q1:3

1~ cmd = 2 sgn (qe,0 ) qe,1:3Ω
τ~ cmd = 2 qe,1:3
Ω
τ
−1

1

q0

Figure 4: The proposed control law stabilizes the attitude to q0 = 1 or q0 = −1. However, there
is a discontinuity at q0 = 0. If the sign of qe,0 is not taken into consideration, the controller
would only be almost globally asymptotically stable with q0 = −1 as an unstable equilibrium
point [8].
Remark 2. A visual interpretation of the control law (23) for qcmd = qI is shown in Fig. 4.
Remark 3. By definition, kqk = 1 ∀q ∈ S3 , and therefore kqe,1:3 k ≤ 1. The maximum possible~ cmd k ≤ 2 . This is especially an advantage for systems with
control output is thus limited to kΩτsaturations.
Remark 4. Assume, without loss of generality, that qcmd = qI . Inserting the control law (23)
into the state equation (20) yields
 2

 
q1 + q22 + q32
q̇0
q̇1  1  −q0 q1 q̇ = 
(32)
q̇2  = τ  −q0 q2  .
−q0 q3q̇3
For small deviations from the equilibrium qI (q0 ≈ 1, q1:3 ≪ 1), (32) simplifies to

 

0
q̇0
q̇1  1 −q1 q̇ = 
q̇2  = τ −q2  ,
−q3
q̇3

(33)

which is an uncoupled first-order system with time-constant τ 3 .
3.1.1

Robustness

Although the proposed controller achieves global asymptotic stability of any desired attitude, it
can be shown that the controller is not robust to arbitrarily small measurement noise. Following
closely the proof in [8], a noise signal qnoise can be constructed such that when starting arbitrarilyclose to the discontinuity, then q stays close to the discontinuity for all time.
Let the current attitude q be
cos α2
 .
(34)
q= ~
k sin α2Define qnoise to be







β(q)
 2  ,qnoise (q) := ~k sin β(q)
2

cos

(35)

3
Note that τ represents the time when the quaternion error decays to 1e and not when the error in terms ofEuler angles decays to 1e .

8where ~k is eigenaxis of the attitude q andβ0 ,if 0 < α ≤ π



−β ,
if π < α < 2π0
β (q) =
,

−β
,
if
0
≥
α
>
−π
0



β ,
if − π ≥ α > −2π0with 0 < β0 < π.

e is the current attitude rotated by the noise signal, i.e.
If the measured attitude q
α+β(q)cos 2 ,e = q · qnoise (q) = q~k sin α+β(q)2then, the kinematic equation for qcmd = qI is(
1
q · p (sgn(q0 )e
q1:3 ) ,q̇ = τ 1− τ q · p (sgn(q0 )e
q1:3 ) ,if |π − α| ≤ β0
if |π − α| > β0 .

(36)

(37)

(38)

Define the set of all discontinuities M := {q ∈ S3 : q0 = 0}, which corresponds to all attitudes
that are 180◦ rotation from qcmd . Now consider the Lyapunov candidate function VM (q) = q02 ,with VM (S3 \M) > 0 and VM (M) = 0. Then, for |π − α| ≤ β0 ,V̇M (q) = 2q0 q̇01
e1:3= − |q0 | q⊤
1:3 q
τ


α
α + β(q)1⊤~~sin= − |q0 | k k sin
τ
2
2
≤ 0.

(39)
(40)
(41)
(42)

Thus, starting from any attitude with |π − α| ≤ β0 , the system does not converge to the desired
attitude.
In [8], a discontinuous controller with a hysteric memory state is proposed to avoid this unwanted
equilibrium. The hysteric memory state defines the rotation direction and is always chosen suchthat the body rotates in direction of the shortest transition. If |π − α| ≤ β0 , the hysteric memory
state does not get updated and the rotation direction remains constant, thus leaving the region
where an arbitrarily small noise signal can destabilize the controller. In practice, a hystericmemory state is not necessary if the control law is implemented on a discrete-time controller.
Since the output of a discrete-time controller is constant between two updates, the rotation
direction does not get changed during that time period and hence, a discrete-time controller
behaves like a continuous-time controller with hysteresis.

3.2

Desired Attitude

Given the quadrocopter setup in Fig. 2 with the body-fixed frame B, it is clear that thequadrocopter can only accelerate in direction of ~eBz . Therefore, the commanded acceleration~acmd has to be transformed into a target orientation qcmd such that the corresponding z-axis isaligned with the desired acceleration. As with every pointing application, the rotation about the
pointing direction is irrelevant, i.e. the rotation about the thrust direction ~eBz has no influenceon the translational behaviour of the quadrocopter. It makes therefore sense to split up thecontrol task into two parts:
9 Reduced attitude control: Only the crucial pointing direction of the thrust is controlled. The yaw angle is not controlled directly, but qcmd is always chosen such that norotation about the yaw axis is induced.
 Full attitude control: The pointing direction of the thrust vector as well as the yaw
angle is controlled. qcmd is chosen such that the corresponding z-axis is aligned with ~eB
cmd,zand ψ = ψcmd .

3.2.1

Reduced Attitude Control

Given any desired acceleration ~acmd , the desired thrust and direction can be computed by
eB
I~
cmd,z

acmd
I~

,
kI ~acmd k= kI ~acmd k.

=collcmd(43)(44)

The reduced error quaternion qe,red (Fig. 5), which rotates the quadrocopter from the current
attitude to the desired attitude is then





cos α2
α 


cos 2
,
 I ~eB =
eB
qe,red = ~(45)
z ×I ~
cmd,z
sin α2k sin α2BBk ~e × ~ek
I z

I cmd,zwhere I eBz is the corresponding z-axis of the current attitude q and α is the angle between thecurrent thrust direction and the desired thrust direction:


⊤ B
(46)
α = arccos I ~eB
ecmd,z .
z I~Finally, the desired attitude can be produced by

qcmd,red = q · qe,red .

(47)

Note that last entry of qe,red is always zero because ~k ⊥ ~eB
z , which implies that Ωcmd,z = 0.
Due to the structure of the Euler angles, this does not mean that the yaw angle ψ is constant.

~eB
cmd,z

~eB
z

~eIz
α

~eB
x
~eIx

~k
~eIy

~eB
y

Figure 5: Geometric interpretation of qe,red .

10

3.2.2

Full Attitude Control

A desired yaw angle ψcmd and thrust direction ~eB
cmd,z fully define the attitude. Pitch and rollangles, θcmd and φcmd , can thus be recovered from ψcmd and ~eB
eB
cmd,z using projections of ~cmd,zonto the intermediate coordinate frames K and L.
First, the desired pointing direction ~eB
cmd,z is expressed in the K-frame, which is rotated by ψcmd
about the initial z-axis:
cos (ψcmd ) sin (ψcmd ) 0

 eB
eB
eB
(48)
K~
cmd,z = − sin (ψcmd ) cos (ψcmd ) 0 I ~cmd,z = RKI I ~cmd,z .
0
0
1

The pitch angle θcmd can then easily be reconstructed by projecting the pointing vector ontothe ~eKeKx ,~z -plane (Fig. 6):!
eBK~
cmd,z,1.
(49)
θcmd = arctaneBK~
cmd,z,3eK
Expressing ~eB
y by the newly computed computed
cmd,z in the L-frame, which is rotated about ~pitch angle θcmd yieldscos (θcmd ) 0 − sin (θcmd ) K ~eB
0
1
0
eB
eB
(50)
L~
cmd,z =
cmd,z = RLK K ~cmd,z .
sin (θcmd ) 0 cos (θcmd )eLeL
Again, projecting ~eBy ,~z -plane, it can be seen from Fig. 7 that the roll angle
cmd,z onto the ~φcmd is given by


(51)
eB
φcmd = arctan2 −L~eB
cmd,z,3 .
cmd,z,2 , L~
Finally, the desired attitude can be constructed using (19):qcmd,full = q (ψcmd , θcmd , φcmd ) .

~eB
cmd,z
~eIz =~eK
z

~eL
z

θ
~eIx

ψ

~eK
x

eL
~eK
y
y =~

~eIy

eK
Figure 6: Projection onto the ~eKz -plane.
x ,~

11

(52)

~eB
cmd,z
~eIz =~eK
z
φ

~eIx

~eL
z

~eB
y
~eL
eB
x =~
x

θ
ψ

~eK
x

eL
~eK
y
y =~

~eIy

Figure 7: Projection onto the ~eLeLy ,~z -plane.
3.2.3

Mixing Full and Reduced Attitude Control

Although it is not necessary that yaw is controlled in order to follow any desired trajectory, it isnevertheless sometimes desirable. In practice, using full attitude control (qcmd = qcmd,full ) does
not yield good results. The dynamics of Ωz are much slower than for Ωx and Ωy . The reason
for this is that Ωz can not be controlled by applying differential thrust but only by exploiting
the air drag of the propellers. When controlling all angular rates with the same gain τ1 , either
the controller is very slow for the pitch and roll angles or there is a lot of overshoot in yaw.
~ cmd k is limited, a lot of control effort might be
Furthermore, since with the control structure kΩ
wasted to control yaw although it is not crucial for the quadrocopter motion. This can become
important for very aggressive maneuvers. One possibility to overcome these issues is to mix
reduced and full attitude control. Define qmix := q−1
cmd,red · qcmd,full to be the rotation between
qcmd,red and qcmd,full . By definition, qmix always has the form
cos αmix
2


0
,

(53)
qmix = 0 
sin αmix
2
where αmix is the rotation angle between qcmd,red and qcmd,full about B ~eB
z . Choosing qcmd tolie anywhere in between the two attitudes qcmd,red and qcmd,full , i.e.

cos pα2mix
0,
qcmd = qcmd,red · with p ∈ [0, 1] ,
(54)


0

sin pαmix
2then it is guaranteed that the resulting rotation yields correct pitch and roll angles. Although
the controller does only correct p-fraction of the actual yaw error, it nevertheless converges tothe desired yaw angle as t → ∞. Ωcmd,z is now limited to
2 sin pπ2|Ωcmd,z | ≤
.
(55)
τ
12

3.2.4

Limiting Maximum Tilt Angle

For some applications, e.g. carrying loads, it might be wanted that the quadrocopter can only
tilt up to some maximum tilt angle αmax . This can be implemented right after the step in (43).
First, the tilt angle αtilt is defined as the angle between ~eIz and ~eB
cmd,z :
αtilt = arccos



eIz
I~

⊤

eB
I~
cmd,z



(56)

If |αtilt | > αmax , the angle can be limited using (17). First, the rotation axis is computed,~eI × ~eB~k = I z I cmd,z ,⊤kI ~eIz I ~eB
cmd,z kand a tilt rotation is defined:
cos αtilt
2 .
qtilt = ~k sin αtilt
2


(57)

(58)

The new target thrust direction, which lies within a cone with an aperture of 2αmax , is then




B
(59)
=
q
·
p
~
e
p I ~eBI
tilt
cmd,z · q̄tilt .
new cmd,z

It is worth mentioning that this does not prevent the quadrocopter from flipping over. Although
the reachable set of attitudes is now constrained, the quadrocopter might get rotated by someexternal momentum to an extreme attitude. The shortest angular rotation to recover to thecommanded attitude can then still involve performing a flip.

3.3

Heuristic

The proposed control law (23) always stabilizes the quadrocopter to the desired orientation with~the shortest possible rotation. This is a very desirable result, however, it was assumed that Ω
can be controlled directly and infinitely fast, which is in practise not true. Imagine the casewhere the quadrocopter has a yaw error of almost 180◦ . It does not make a big difference intime if the quadrocopter rotates about ~k or −~k. However, if |Ωz | is large, it is obviously fasterto rotate in the same direction as Ωz than to accelerate in the opposite direction. The question,
whether it is faster to undertake the longer rotation or not, is not trivial. In fact, the rise time
~ depends on many parameters, e.g. thrust magnitude and the value of Ω
~ itself and noof Ω
algebraic expression exists to answer this question. To keep the computational effort small, a
simple heuristic is used.
Here, only the heuristic for errors in yaw is introduced, however, it works the same way for pitch~ The rotation
and roll angles. Assume that the quadrocopter has an angular body rate of Ω.
⊤⊤~~
axis of qmix is either k = (0, 0, 1) or k = (0, 0, −1) . If the quadrocopter already rotates in~ ≥ 0, then obviously nothing has to be changed.
the same direction as commanded, i.e. ~k⊤ Ω~ < 0, it might be faster, depending on the error in yaw, to undertake the
Otherwise, if ~k⊤ Ωlonger rotation. The decision criterion is~k⊤ Ω~ < 0 AND~k⊤ Ω~ ≥ threshold (αmix ) .

(60)

For errors in yaw of almost 180◦ , the threshold should be close to 0 and should strictly increase
for smaller error angles. A good threshold was found experimentally to be
threshold (αmix ) =13

π − αmixΩz,min .
π(61)

~ is above the threshold, it is better to continue in this direction. To gain as
Whenever ~k⊤ Ωmuch time as possible, the rotation until an error angle of 180◦ should be conducted with fullspeed, i.e.
 
cos pπ2 .
(62)qe,full = qe,red · ~−k sin pπ2Note that it has to be ensured that once the rotation direction is decided, it does not get changed
anymore. Therefore, the commanded rotation rate should be well above the threshold which
implies that
2 sin pπ2
Ωz,min <.
(63)
τBecause unit quaternions are normalized and large errors in pitch and roll can decrease theΩcmd,z , this is not ensured when Ωz,min = 2 sin (pπ/2) /τ .
Remark 1. The above heuristic also works for Ωx,y . However, Ωx,y can be controlled much
faster and therefore the time earning is not that large anymore. Experiments have shown thatthe heuristic is only beneficial for extremely large angular rates in pitch and roll, which arealmost out of the measurement range of the gyroscopic sensors. Furthermore, the heuristic is
designed for a single rotation about a principle axis of the quadrocopter. It is not totally clear
what happens in the 3D case. It is therefore recommended to only apply the heuristic to the yaw
axis, which can be controlled only slowly and therefore the time earnings are the highest.
Remark 2. Instead of the heuristic (60), it was also attempted to solve the problem by simulating
the state equation (20) forward in time, once with a rotation in the shorter direction and oncein opposite direction. However, the results were not any better than with the above heuristic.
Moreover, the simulation was computationally very expensive which made it useless for real-timeuses.
Remark 3. If using the above heuristic, then stability and robustness of the controller would
have to be proven again. Although the results are quite intuitive, the proof is not done here.

4

Results

4.1

Time constant~ can be controlled directly.
The proposed controller (23) is based upon the assumption that ΩThis assumption certainly holds for large τ . In order to determine how small τ can be chosensuch that the above assumption still holds, a series of step responses in attitude are analyzed.
4.1.1

Step in Pitch Angle

Starting from hovering, a step of 45◦ in pitch angle φ is commanded. As the problem is symmetricin pitch and roll, only the step response for pitch is analyzed. Fig. 8 shows the result for various
τ and p such that τyaw = 0.02s (64).
~ can beFor τ ≥ 0.1s, q2 behaves like a first order system. For τ < 0.1s, the assumption that Ω
controlled directly does not hold anymore. At time t = 0.2s, the commanded angular pitch rate
Ωcmd,y is equal to zero, but Ωy (t = 0.2s) ≫ 0rad/s and hence, the system exhibits even overshoot.
Therefore, fast responses with almost no overshoot can be achieved with τ ∈ [0.08s, 0.15s].

14

0.5

8

0.4

6

4

Ωy

q2

s

 rad 0.3
0.2
τ = 0.08s
τ = 0.1sτ = 0.15s
τ = 0.2s

0.1
0
0

0.2

0.4
Time [s]

2

0

0.6

0

0.2

0.4
Time [s]0.6

Figure 8: Step response of q2 and Ωy . The dotted lines are the corresponding Ωcmd,y .
4.1.2

Step in Yaw Angle

A step input of magnitude 180◦ in yaw is given into the attitude controller at t = 0s, startingfrom hovering with ψ = 0◦ . The results for different τ (p = 1) are shown in Fig. 9.
For τ ≥ 0.2s, q3 certainly behaves very similar to a first-order system. For smaller τ , the system
begins to show overshoot since the fundamental assumption is hurt. This can also be seen in
Fig. 9, where Ωz reached saturation for τ = 0.1s even when decelerating. For controlling yaw,τ should therefore lie in the range of [0.2s, 0.4s].
Remark 1. In Fig. 9, the response of q3 for τ = 0.5s does oscillate slightly. This is due to thesmall control gain of this time constant which cannot prevent the quadrocopter from oscillating
about its pitch and roll axis.
Remark 2. The above results strongly depend on the total thrust. For both experiments, τ wasanalyzed with a collective thrust that allows to maintain altitude.

1

8

0.8

6
4

0.2
0
0

1

2

s

τ = 0.1sτ = 0.2sτ = 0.3s
τ = 0.4s
τ = 0.5s

0.4

2

Ωz

q3

 rad 

0.6

0
−2
−4

3

−6

Time [s]

0

1

2

3

Time [s]Figure 9: Step response of q3 and Ωz . The dotted lines are the corresponding Ωcmd,z .
15

4.2

Mixing Full and Reduced Attitude Control

The experiments in Section 4.1 have shown that a good controller gain for the yaw axis issignificantly smaller than for roll and pitch axis. One method to implement this is to mix fulland reduced attitude control and to choose the prioritization factor p of (54) to be
p=

τ
,
τyaw

(64)

where τyaw is a time constant which attains good responses in yaw and τ is the desired time constant of the overall controller (for pitch and roll). Equation (64) originated from a linearizationof the control law with mixed attitude control for small errors in yaw. If p is chosen according
to (64), then for small errors in yaw, the controller behaves just like one with a time constantof τyaw instead of τ . For a very aggressive controller with τ = 0.08s and τyaw = 0.2s, p is
p=

0.08s
= 0.4.
0.2s(65)

In Fig 10, an experiment with different values for p and τ = 0.08s is shown. Starting from a
position with Euler angles (ψ, θ, φ) = (180◦ , 45◦ , 0◦ ), a step of 180◦ in yaw is commanded at
t = 0s.
As a benchmark, the results with p = 0 are plotted in Fig. 10a. The rotation about the pitch
angle does not change significantly for different values of p and the correct tilt angle is achievedin all cases shortly after 0.2s. But examining Fig. 10 more carefully, it can be seen that withincreasing p, the pitch angle is corrected slightly slower. This is due to the increasing amountof control power that is taken up by yaw with larger p. Remarkable is that the larger p is, thefaster yaw is controlled. For p = 0.4, the correct attitude is achieved at t = 0.88s whereas for
p = 0.267 and p = 0.133, the desired attitude is not yet achieved at t = 1s.
Remark 1. For extremely large angular rates about ~eB
z , mixed attitude control achieves again
better results than pure reduced attitude control. If |Ωz | is large, than the eigenaxis ~k of qe,redrotates with a speed of Ωz in the ~eBeB
x ,~y -plane. This implies that the rotational velocity of the
motors increase and decrease constantly. However, there are limits on the motor dynamics andthe motor speed can not be controlled infinitely fast. Further, since Ωcmd,z = 0, a lot of control
effort is used by the onboard controller to break down Ωz , leaving almost no control power torotate the quadrocopter about its pitch and roll axis.

16

~eIz
~eIx 0

0.1

0.2

0.3

0.4

0.1

0.2

0.3

0.4

0.1

0.2

0.3

0.4

0.1

0.2

0.3

0.4

0.1

0.2

0.3

0.4

0.1

0.2

0.3

0.4

0.1

0.2

0.3

0.4

0.5
0.6
Time [s]
a)

0.7

0.8

0.9

1

0.6

0.7

0.8

0.9

1

0.5
0.6
Time [s]
b)

0.7

0.8

0.9

1

0.6

0.7

0.8

0.9

1

0.5
0.6
Time [s]
c)

0.7

0.8

0.9

1

0.6

0.7

0.8

0.9

1

0.5
0.6
Time [s]
d)

0.7

0.8

0.9

1

~eIz
~eIx 00.5~eIy~eIx 0~eIz~eIx 00.5~eIy~eIx 0~eIz~eIx 00.5~eIy~eIx 0Figure 10: View of the quadrocopter in the xz-plane and xy-plane respectively for different
prioritization factors: a) p = 0.0, b) p = 0.133, c) p = 0.267 and d) p = 0.4.

17

4.3

Heuristic

8

90

4

s

 rad 180

0
Heuristic on
Heuristic off

−90
−180

0

0.5

1 1.5 2Time [s]Ωz

Yaw angle ψ [◦ ]An experiment with the heuristic (60) enabled is carried out to show its effectiveness. Startingfrom hovering, the quadrocopter rotates about its yaw axis with different angular rates. Oncethe yaw angle ψ reaches 90◦ , the quadrocopter is commanded to return to ψcmd = 0◦ . The
control parameters for this experiment are τ = 0.1s, p = 0.3 and Ωz,min = 4 rad
s . The results areshown in Fig. 11.

0

−4
−8
0

2.5

0.5

1 1.5 2Time [s]2.5

0.5

1 1.5 2Time [s]2.5

0.5

1 1.5 2Time [s]

2.5

8

90

4

s

 rad 

180

Ωz

0
−90
−180

0

−4
−8

0

0.5

1 1.5 2Time [s]

2.5

0
b)
8

90

4

s

 rad 

180

0

Ωz

Yaw angle ψ [◦ ]Yaw angle ψ [◦ ]

a)

−90
−180

0

−4
−8

0

0.5

1 1.5 2Time [s]

2.5

0
c)

Figure 11: Experiment testing the heuristic for different angular rates: a) Ωz = 1.5 rads , b)radradΩz = 4 s and c) Ωz = 6.5 s .
Clearly, for slow angular rates, there is no difference if the heuristic is enabled or not (Fig. 11a).
But if Ωz is beyond a certain threshold, it is faster to undertake the longer rotation and hence,the controller with the heuristic enabled attains better results.

5Conclusion

A nonlinear attitude controller based on unit quaternions for the quadrocopters in the Flying
Machine Arena has been developed. The control inputs are a desired acceleration and yaw
angle, which are then converted to a commanded target orientation. It was assumed that the18

onboard controller and quadropcopter dynamics are much faster than the attitude control loop
~ The stability and robustness ofand hence, the quadrocopter can be controlled directly by Ω.
the controller were then proven.
By experiments, the performance of the nonlinear controller was demonstrated. The proposed
attitude controller has many benefits, especially for aggressive maneuvers. Due to the global
asymptotic stability, the proposed controller is able to recover the quadrocopter to hoveringfrom arbitrary attitudes and can track any feasible trajectory. Furthermore, it was shown thatthe control of the crucial pitch and roll angles can be prioritized by mixing full and reduced
attitude control. The proposed heuristic is able improve the time to reach a desired attitude,
however, it only yields good results for rotations about the yaw axis.
~ depends
Nevertheless, there are still many problems to be solved. Currently, the rise time of Ωon the commanded thrust. This can cause very slow rotation rates if the commanded thrust is
low although the whole rotation would take only a few tenths of a second and thus, a large thrust
would have only minor influence on the translational motion. Furthermore, it would be nice if
the prioritization factor p is adapted dynamically depending on the attitude error. Large errors
in pitch and roll should be controlled first, but if no errors in pitch and roll occur, then p canbe large such that errors in yaw are corrected in a reasonable time. Experiments also revealed
that a yaw Euler angle ψ is not well suited to define a desired rotation about the quadrocopter’sπz-axis. Due to the pitch angle θ, which is only defined in a range of [ −π2 , 2 ], jumps in ψ occur if
the pitch angle would exceed its range. If these jumps are not considered in the input trajectory,
the quadrocopter may rotate unintentionally about its yaw axis.
Currently, the proposed controller is model independent and can therefore be used for various
flying vehicles. However, it might be beneficial in terms of time to combine the attitude andonboard controller and take model parameters such as moments of inertia into consideration.

19

References[1] K. Bilimoria and B. Wie. Time-optimal three-axis reorientation of a rigid spacecraft. Journal of Guidance Control and Dynamics, 16(3):446–452, 1993.
[2] N.A. Chaturvedi, A.K. Sanyal, and N.H. McClamroch. Rigid-body attitude control. Control
Systems, IEEE, 31(3):30 –51, june 2011.
[3] J. Diebel. Representing attitude: Euler angles, unit quaternions, and rotation vectors, 2006.
[4] J. Dvorak, M. de Lellis, and Z. Hurak. Advanced control of quadrotor using eigenaxis
rotation. In Control Applications (CCA), 2011 IEEE International Conference on, pages
153 –158, sept. 2011.
[5] T. Lee, M. Leok, and N.H. McClamroch. Time optimal attitude control for a rigid body.
In American Control Conference, 2008, pages 5210 –5215, june 2008.
[6] J. Lygeros, S. Sastry, and C. Tomlin. Hybrid systems: Foundations, advanced topics andapplications.
[7] C.G. Mayhew, R.G. Sanfelice, and A.R. Teel. On quaternion-based attitude control and theunwinding phenomenon. In American Control Conference (ACC), 2011, pages 299 –304,
29 2011-july 1 2011.
[8] C.G. Mayhew, R.G. Sanfelice, and A.R. Teel. Quaternion-based hybrid control for robust
global attitude tracking. Automatic Control, IEEE Transactions on, 56(11):2555 –2566,
nov. 2011.
[9] D. Mellinger and V. Kumar. Minimum snap trajectory generation and control for quadrotors. In ICRA, pages 2520–2525. IEEE, 2011.
[10] K Rudin, M.-D. Hua, G. Ducard, and S. Bouabdallah. A robust attitude controller and its
application to quadrotor helicopters. In 18th IFAC World Congress, 2011.
[11] J. Stuelpnagel. On the parametrization of the three-dimensional rotation group. SIAM
Review, 6(4):pp. 422–430, 1964.
[12] A. Tayebi. Unit quaternion-based output feedback for the attitude tracking problem. Automatic Control, IEEE Transactions on, 53(6):1516 –1520, july 2008.
[13] A. Tayebi and S. McGilvray. Attitude stabilization of a vtol quadrotor aircraft. Control
Systems Technology, IEEE Transactions on, 14(3):562 – 571, may 2006.
[14] J.T.-Y. Wen and K. Kreutz-Delgado. The attitude control problem. Automatic Control,
IEEE Transactions on, 36(10):1148 –1162, oct 1991.

20