You are on page 1of 47

Randal W. Beard
Brigham Young University
October 3, 2008
1 Reference Frames
This section describes the various reference frames and coordinate systems that
are used to describe the position of orientation of aircraft, and the transformation
between these coordinate systems. It is necessary to use several different coordi-
nate systems for the following reasons:
Newtons equations of motion are given the coordinate frame attached to
Aerodynamics forces and torques are applied in the body frame.
On-board sensors like accelerometers and rate gyros measure information
with respect to the body frame. Alternatively, GPS measures position,
ground speed, and course angle with respect to the inertial frame.
Most mission requirements like loiter points and ight trajectories, are spec-
ied in the inertial frame. In addition, map information is also given in an
inertial frame.
One coordinate frame is transformed into another through two basic opera-
tions: rotations and translations. Section 1.1 develops describes rotation matrices
and their use in transforming between coordinate frames. Section 1.2 describes
the specic coordinate frames used for micro air vehicle systems. In Section 1.3
we derive the Coriolis formula which is the basis for transformations between
between between translating and rotating frames.
1
1.1 Rotation Matrices
We begin by considering the two coordinate systems shown in Figure 1. The
Figure 1: Rotation in 2D
vector p can be expressed in both the F
0
frame (specied by (

i
0
,

j
0
,

k
0
)) and in
the F
1
frame (specied by (

i
1
,

j
1
,

k
1
)). In the F
0
frame we have
p = p
0
x

i
0
+ p
0
y

j
0
+ p
0
z

k
0
.
Alternatively in the F
1
frame we have
p = p
1
x

i
1
+ p
1
y

j
1
+ p
1
z

k
1
.
Setting these two expressions equal to each other gives
p
1
x

i
1
+ p
1
y

j
1
+ p
1
z

k
1
= p
0
x

i
0
+ p
0
y

j
0
+ p
0
z

k
0
.
Taking the dot product of both sides with

i
1
,

j
1
, and

k
1
respectively, and stacking
the result into matrix form gives
p
1

=
_
_
p
1
x
p
1
y
p
1
z
_
_
=
_
_

i
1

i
0

i
1

j
0

i
1

k
0

j
1

i
0

j
1

j
0

j
1

k
0

k
1

i
0

k
1

j
0

k
1

k
0
_
_
_
_
p
0
x
p
0
y
p
0
z
_
_
.
From the geometry of Figure 1 we get
p
1
= R
1
0
p
0
, (1)
2
where
R
1
0

=
_
_
cos() sin() 0
sin() cos() 0
0 0 1
_
_
.
The notation R
1
0
is used to denote a rotation matrix from coordinate frame F
0
to
coordinate frame F
1
.
Proceeding in a similar way, a right-handed rotation of the coordinate system
R
1
0

=
_
_
cos() 0 sin()
0 1 0
sin() 0 cos()
_
_
,
and a right-handed rotation of the coordinate system about the x-axis resultes in
R
1
0

=
_
_
1 0 0
0 cos() sin()
0 sin() cos()
_
_
.
As pointed out in [1], the negative sign on the sin term appears above the line with
only ones and zeros.
The matrix R
1
0
in the above equations are examples of a more general class of
rotation matrices that have the following properties:
P.1. (R
b
a
)
1
= (R
b
a
)
T
= R
a
b
.
P.2. R
c
b
R
b
a
= R
c
a
.
P.3. det R
b
a
= 1.
In the derivation of Equation (1) note that the vector p remains constant and
the new coordinate frame F
1
was obtained by rotating F
0
through a righted-
handed rotation of angle .
We will now derive a formula, called the rotation formula that performs a
left-handed rotation of a vector p about another vector n by an angle of . Our
derivation follows that given in [1]. Consider Figure 2 which is similar to Figure
1.2-2 in [1]. The vector p is rotated, in a left-handed sense, about a unit vector n
by an angle of to produce the vector q. The angle between p and n is . By
geometry we have that
q =

ON +

NW +

WQ. (2)
3
Figure 2: Left-handed rotation of a vector p about the unit vector n by an angle
of to obtain the vector q.
The vector

ON can be found by taking the projection of p on the unit vector n in
the direction of n:

ON = (p n) n.
The vector

NW is in the direction of p

ON with a length of NQcos . Noting
that the length NQ equals the length NP which is equal to
_
_
_p

ON
_
_
_ we get
that

NW =
p (p n) n
p (p n) n
NQcos
= (p (p n) n) cos .
The vector

WQis perpendicular to both p and n and has length NQsin . Noting
that NQ = p sin we get

WQ =
p n
p sin
NQsin
= n psin .
Therefore Equation (2) becomes
q = (1 cos ) (p n) n + cos p sin ( n p) , (3)
4
Figure 3: Rotation of p about the z-axis.
which is called the rotation formula.
As an example of the application of Equation (3) consider a left handed rota-
tion of a vector p
0
in frame F
0
about the z-axis as shown in Figure 3.
Using the rotation formula we get
q
0
= (1 cos )(p n) n + cos p sin n p
= (1 cos )p
0
z
_
_
0
0
1
_
_
+ cos
_
_
p
0
x
p
0
y
p
0
z
_
_
sin
_
_
p
0
y
p
0
x
0
_
_
=
_
_
cos sin 0
sin cos 0
0 0 1
_
_
p
0
= R
1
0
p
0
.
Note that the rotation matrix R
1
0
can be interpreted in two different ways. The
rst interpretation is that it transforms the xed vector p from an expression in
frame F
0
to an expression in frame F
1
where F
1
has been obtained from F
0
by a right-handed rotation. The second interpretation is that it rotates a vector
p though a left-handed rotation to a new vector q in the same reference frame.
Right-handed rotations of vectors are obtained by using (R
1
0
)
T
.
5
For quadrotors there are several coordinate systems that are of interest. In this
section we will dene and describe the following coordinate frames: the inertial
frame, the vehicle frame, the vehicle-1 frame, the vehicle-2 frame, and the body
frame. Throughout the book we assume a at, non-rotating earth: a valid assump-
1.2.1 The inertial frame F
i
.
The inertial coordinate system is an earth xed coordinate system with origin at
the dened home location. As shown in Figure 4, the unit vector

i
i
is directed
North,

j
i
is directed East, and

k
i
is directed toward the center of the earth.
Figure 4: The inertial coordinate frame. The x-axis points North, the y-axis points
East, and the z-axis points into the Earth.
1.2.2 The vehicle frame F
v
.
The origin of the vehicle frame is at the center of mass of the quadrotor. However,
the axes of F
v
are aligned with the axis of the inertial frame F
i
. In other words,
the unit vector

i
v
points North,

j
v
points East, and

k
v
points toward the center of
the earth, as shown in Figure 5.
1.2.3 The vehicle-1 frame F
v1
.
The origin of the vehicle-1 frame is identical to the vehicle frame, i.e, the the
center of gravity. However, F
v1

k
v
by the yaw angle
so that if the airframe is not rolling or pitching, then

i
v1
would point out the nose
6
Figure 5: The vehicle coordinate frame. The x-axis points North, the y-axis points
East, and the z-axis points into the Earth.
Figure 6: The vehicle-1 frame. If the roll and pitch angels are zero, then the x-axis
points out the nose of the airframe, the y-axis points out the right wing, and the
z-axis points into the Earth.
of the airframe,

j
v1
points out the right wing, and

k
v1
is aligned with

k
v
and points
into the earth. The vehicle-1 frame is shown in Figure 6.
The transformation from F
v
to F
v1
is given by
p
v1
= R
v1
v
()p
v
,
where
R
v1
v
() =
_
_
cos sin 0
sin cos 0
0 0 1
_
_
.
7
1.2.4 The vehicle-2 frame F
v2
.
The origin of the vehicle-2 frame is again the center of gravity and is obtained by
rotating the vehicle-1 frame in a right-handed rotation about the

j
v1
axis by the
pitch angle . If the roll angle is zero, then

i
v2
points out the nose of the airframe,

j
v2
points out the right wing, and

k
v2
points out the belly, a shown in Figure 7.
Figure 7: The vehicle-2 frame. If the roll angel is zero, then the x-axis points out
the nose of the airframe, the y-axis points out the right wing, and the z-axis points
out the belly.
The transformation from F
v1
to F
v2
is given by
p
v2
= R
v2
v1
()p
v1
,
where
R
v2
v1
() =
_
_
cos 0 sin
0 1 0
sin 0 cos
_
_
.
1.2.5 The body frame F
b
.
The body frame is obtained by rotating the vehicle-2 frame in a right handed

i
v2
by the roll angle . Therefore, the origin is the center-of-gravity,

i
b
points out the nose of the airframe,

j
b
points out the right wing, and

k
b
points
out the belly. The body frame is shown in Figure 8.
The transformation from F
v2
to F
b
is given by
p
b
= R
b
v2
()p
v2
,
8
Figure 8: The body frame. The x-axis points out the nose of the airframe, the
y-axis points out the right wing, and the z-axis points out the belly.
where
R
b
v2
() =
_
_
1 0 0
0 cos sin
0 sin cos
_
_
.
The transformation from the vehicle frame to the body frame is given by
R
b
v
(, , ) = R
b
v2
()R
v2
v1
()R
v1
v
()
=
_
_
1 0 0
0 cos sin
0 sin cos
_
_
_
_
cos 0 sin
0 1 0
sin 0 cos
_
_
_
_
cos sin 0
sin cos 0
0 0 1
_
_
=
_
_
cc cs s
ssc cs sss + cc sc
csc + ss css sc cc
_
_
,
where c

= cos and s

= sin .
1.3 Equation of Coriolis
In this section we provide a simple derivation of the famous equation of Coriolis.
We will again follow the derivation given in [1].
Suppose that we are given two coordinate frames F
i
and F
b
as shown in Fig-
ure 9. For example, F
i
might represent the inertial frame and F
b
might represent
the body frame of a quadrotor. Suppose that the vector p is moving in F
b
and that
F
b
is rotating and translating with respect to F
i
. Our objective is to nd the time
derivative of p as seen from frame F
i
.
We will derive the appropriate equation through two steps. Assume rst that
F
b
is not rotating with respect to F
i
. Denoting the time derivative of p in frame
9
Figure 9: Derivation of the equation of Coriolis.
F
i
as
d
dt
i
p we get
d
dt
i
p =
d
dt
b
p. (4)
On the other hand, assume that p is xed in F
b
but that F
b
is rotating with respect
to F
i
, and let s be the instantaneous axis of rotation and the (right-handed)
rotation angle. Then the rotation formula (3) gives
p + p = (1 cos()) s( s p) + cos()p sin() s p.
Using a small angle approximation and dividing both sides by t gives
p
t

t
s p.
Taking the limit as t 0 and dening the angular velocity of F
b
with respect to
F
i
as
b/i

= s

we get
d
dt
i
p =
b/i
p. (5)
Since differentiation is a linear operator we can combine Equations (4) and (5) to
obtain
d
dt
i
p =
d
dt
b
p +
b/i
p, (6)
which is the equation of Coriolis.
10
2 Kinematics and Dynamics
In this chapter we derive the expressions for the kinematics and the dynamics of a
rigid body. While the expressions derived in this chapter are general to any rigid
body, we will use notation and coordinate frames that are typical in the aeronautics
literature. In particular, in Section 2.1 we dene the notation that will be used for
the state variables of a quadrotor. In Section 2.2 we derive the expressions for the
kinematics, and in Section 2.3 we derive the dynamics.
The state variables of the quadrotor are the following twelve quantities
p
n
= the inertial (north) position of the quadrotor along

i
i
in F
i
,
p
e
= the inertial (east) position of the quadrotor along

j
i
in F
i
,
h = the altitude of the aircraft measured along

k
i
in F
i
,
u = the body frame velocity measured along

i
b
in F
b
,
v = the body frame velocity measured along

j
b
in F
b
,
w = the body frame velocity measured along

k
b
in F
b
,
= the roll angle dened with respect to F
v2
,
= the pitch angle dened with respect to F
v1
,
= the yaw angle dened with respect to F
v
,
p = the roll rate measured along

i
b
in F
b
,
q = the pitch rate measured along

j
b
in F
b
,
r = the yaw rate measured along

k
b
in F
b
.
The state variables are shown schematically in Figure 10. The position (p
n
, p
e
, h)
of the quadrotor is given in the inertial frame, with positive h dened along the
negative Z axis in the inertial frame. The velocity (u, v, w) and the angular veloc-
ity (p, q, r) of the quadrotor are given with respect to the body frame. The Euler
angles (roll , pitch , and yaw ) are given with respect to the vehicle 2-frame,
the vehicle 1-frame, and the vehicle frame respectively.
11
Figure 10: Denition of Axes
The state variables p
n
, p
e
, and h are inertial frame quantities, whereas the ve-
locities u, v, and w are body frame quantities. Therefore the relationship between
position and velocities is given by
d
dt
_
_
p
n
p
e
h
_
_
= R
v
b
_
_
u
v
w
_
_
= (R
b
v
)
T
_
_
u
v
w
_
_
=
_
_
cc ssc cs csc + ss
cs sss + cc css sc
s sc cc
_
_
_
_
u
v
w
_
_
.
The relationship between absolute angles , , and , and the angular rates p,
q, and r is also complicated by the fact that these quantities are dened in different
coordinate frames. The angular rates are dened in the body frame F
b
, whereas
the roll angle is dened in F
v2
, the pitch angle is dened in F
v1
, and the yaw
angle is dened in the vehicle frame F
v
.
We need to relate p, q, and r to

,

, and

. Since

,

,

are small and noting
that
R
b
v2
(

) = R
v2
v1
(

) = R
v1
v
(

) = I,
12
we get
_
_
p
q
r
_
_
= R
b
v2
(

)
_
_

0
0
_
_
+ R
b
v2
()R
v2
v1
(

)
_
_
0

0
_
_
+ R
b
v2
()R
v2
v1
()R
vv1
(

)
_
_
0
0

_
_
=
_
_

0
0
_
_
+
_
_
1 0 0
0 cos sin
0 sin cos
_
_
_
_
0

0
_
_
+
_
_
1 0 0
0 cos sin
0 sin cos
_
_
_
_
cos 0 sin
0 1 0
sin 0 cos
_
_
_
_
0
0

_
_
=
_
_
1 0 s
0 c sc
0 s cc
_
_
_
_

_
_
. (7)
Inverting we get
_
_

_
_
=
_
_
1 sin() tan() cos() tan()
0 cos() sin()
0 sin() sec() cos() sec()
_
_
_
_
p
q
r
_
_
. (8)
2.3 Rigid Body Dynamics
Let v be the velocity vector of the quadrotor. Newtons laws only hold in inertial
frames, therefore Newtons law applied to the translational motion is
m
dv
dt
i
= f ,
where m is the mass of the quadrotor, f is the total applied to the quadrotor, and
d
dt
i
is the time derivative in the inertial frame. From the equation of Coriolis we
have
m
dv
dt
i
= m
_
dv
dt
b
+
b/i
v
_
= f , (9)
where
b/i
is the angular velocity of the airframe with respect to the inertial frame.
Since the control force is computed and applied in the body coordinate system,
and since is measured in body coordinates, we will express Eq (9) in body
coordinates, where v
b

= (u, v, w)
T
, and
b
b/i

= (p, q, r)
T
. Therefore, in body
coordinates, Eq. (9) becomes
_
_
u
v
w
_
_
=
_
_
rv qw
pw ru
qu pv
_
_
+
1
m
_
_
f
x
f
y
f
z
_
_
, (10)
13
where f
b

= (f
x
, f
y
, f
z
)
T
.
For rotational motion, Newtons second law states that
dh
b
dt
i
= m,
where h is the angular momentum and mis the applied torque. Using the equation
of Coriolis we have
dh
dt
i
=
dh
dt
b
+
b/i
h = m. (11)
Again, Eq. (11) is most easily resolved in body coordinates where h
b
= J
b
b/i
where J is the constant inertia matrix given by
J =
_
_
_
(y
2
+ z
2
) dm
_
xy dm
_
xz dm

_
xy dm
_
(x
2
+ z
2
) dm
_
yz dm

_
xz dm
_
yz dm
_
(x
2
+ y
2
) dm
_
_

=
_
_
J
x
J
xy
J
xz
J
xy
J
y
J
yz
J
xz
J
yz
J
z
_
_
.
Figure 11: The moments of inertia for the quadrotor are calculated assuming a
spherical dense center with mass M and radius R, and point masses of mass m
located at a distance of from the center.
As shown in Figure 11, the quadrotor is essentially symmetric about all three
axes, therefore J
xy
= J
xz
= J
yz
= 0 which implies that
J =
_
_
J
x
0 0
0 J
y
0
0 0 J
z
_
_
.
14
Therefore
J
1
=
_
_
1
J
x
0 0
0
1
J
y
0
0 0
1
J
z
_
_
.
The inertia for a solid sphere is given by J = 2MR
2
/5[2]. Therefore
J
x
=
2MR
2
5
+ 2
2
m
J
y
=
2MR
2
5
+ 2
2
m
J
z
=
2MR
2
5
+ 4
2
m.
Dening m
b

= (

)
T
we can write Eq. (11) in body coordinates as
_
_
p
q
r
_
_
=
_
_
1
J
x
0 0
0
1
J
y
0
0 0
1
J
z
_
_
_
_
_
_
0 r q
r 0 p
q p 0
_
_
_
_
J
x
0 0
0 J
y
0
0 0 J
z
_
_
_
_
p
q
r
_
_
+
_
_

_
_
_
_
=
_
_
_
J
y
J
z
J
x
qr
J
z
J
x
J
y
pr
J
x
J
y
J
z
pq
_
_
_
+
_
_
1
J
x

1
J
y

1
J
z

_
_
.
The six degree of freedom model for the quadrotor kinematics and dynamics
can be summarized as follows:
_
_
p
n
p
e

h
_
_
=
_
_
cc ssc cs csc + ss
cs sss + cc css sc
s sc cc
_
_
_
_
u
v
w
_
_
(12)
_
_
u
v
w
_
_
=
_
_
rv qw
pw ru
qu pv
_
_
+
1
m
_
_
f
x
f
y
f
z
_
_
, (13)
_
_

_
_
=
_
_
1 sin tan cos tan
0 cos sin
0
sin
cos
cos
cos
_
_
_
_
p
q
r
_
_
(14)
_
_
p
q
r
_
_
=
_
_
_
J
y
J
z
J
x
qr
J
z
J
x
J
y
pr
J
x
J
y
J
z
pq
_
_
_
+
_
_
1
J
x

1
J
y

1
J
z

_
_
. (15)
15
3 Forces and Moments
The objective of this section is to describe the forces and torques that act on the
quadrotor. Since there are no aerodynamic lifting surfaces, we will assume that
the aerodynamic forces and moments are negligible.
The forces and moments are primarily due to gravity and the four propellers.
front
right
back
left
Figure 12: The top view of the quadrotor. Each motor produces an upward force
F and a torque . The front and back motors spin clockwise and the right and left
motors spin counterclockwise.
Figure 13: Denition of the forces and torques acting on the quadrotor.
Figure 12 shows a top view of the quadrotor systems. As shown in Figure 13,
each motor produces a force F and a torque . The total force acting on the
16
F = F
f
+ F
r
+ F
b
+ F
l
.
The rolling torque is produced by the forces of the right and left motors as

= (F
l
F
r
).
Similarly, the pitching torque is produced by the forces of the front and back
motors as

= (F
f
F
b
).
Due to Newtons third law, the drag of the propellers produces a yawing torque
on the body of the quadrotor. The direction of the torque will be in the oppositive
direction of the motion of the propeller. Therefore the total yawing torque is given
by

=
r
+
l

f

b
.
The lift and drag produced by the propellers is proportional to the square of the
angular velocity. We will assume that the angular velocity is directly proportional
to the pulse width modulation commend sent to the motor. Therefore, the force
and torque of each motor can be expressed as
F

= k
1

= k
2

,
where k
1
and k
2
are constants that need to be determined experimentally,

is the
motor command signal, and represents f, r, b, and l.
Therefore, the forces and torques on the quadrotor can be written in matrix
form as
_
_
_
_
F

_
_
_
_
=
_
_
_
_
k
1
k
1
k
1
k
1
0 k
1
0 k
1
k
1
0 k
1
0
k
2
k
2
k
2
k
2
_
_
_
_
_
_
_
_

l
_
_
_
_

= M
_
_
_
_

l
_
_
_
_
.
The control strategies derived in subsequent sections will specify forces and
torques. The actual motors commands can be found as
_
_
_
_

l
_
_
_
_
= M
1
_
_
_
_
F

_
_
_
_
.
17
Note that the pulse width modulation commands are required to be between zero
and one.
In addition to the force exerted by the motor, gravity also exerts a force on the
quadrotor. In the vehicle frame F
v
, the gravity force acting on the center of mass
is given by
f
v
g
=
_
_
0
0
mg
_
_
.
However, since v in Equation (13) is expressed in F
b
, we must transform to the
body frame to give
f
b
g
= R
b
v
_
_
0
0
mg
_
_
=
_
_
mg sin
mg cos sin
mg cos cos
_
_
.
Therefore, equations (12)(15) become
_
_
p
n
p
e

h
_
_
=
_
_
cc ssc cs csc + ss
cs sss + cc css sc
s sc cc
_
_
_
_
u
v
w
_
_
(16)
_
_
u
v
w
_
_
=
_
_
rv qw
pw ru
qu pv
_
_
+
_
_
g sin
g cos sin
g cos cos
_
_
+
1
m
_
_
0
0
F
_
_
, (17)
_
_

_
_
=
_
_
1 sin tan cos tan
0 cos sin
0
sin
cos
cos
cos
_
_
_
_
p
q
r
_
_
, (18)
_
_
p
q
r
_
_
=
_
_
_
J
y
J
z
J
x
qr
J
z
J
x
J
y
pr
J
x
J
y
J
z
pq
_
_
_
+
_
_
1
J
x

1
J
y

1
J
z

_
_
. (19)
4 Simplied Models
Equations (16)(19) are the equations of motion to be used in our six degree-
of-freedom simulator. However, they are not appropriate for control design for
18
several reasons. The rst reason is that they are too complicated to gain signicant
insight into the motion. The second reason is that the position and orientation
are relative to the inertial world xed frame, whereas camera measurements will
measure position and orientation of the target with respect to the camera frame.
4.1 Model for estimation
For the quadrotor, we are not able to estimate the inertial position or the heading
angle . Rather, we will be interested in the relative position and heading of the
quadrotor with respect to a ground target. The relative position of the quadrotor
will be measured in the vehicle-1 frame, i.e., the vehicle frame after it has been
rotated by the heading vector . The vehicle-1 frame is convenient since x, y,
and z positions are still measured relative to a at earth, but they are vehicle
centered quantities as opposed to inertial quantities. Let p
x
, p
y
, and p
z
denote
the relative position vector between the target and the vehicle resolved in the v1
frame. Therefore Eq (16) becomes
_
_
p
x
p
y
p
z
_
_
=
_
_
c ss cs
0 c s
s sc cc
_
_
_
_
u
v
w
_
_
. (20)
4.2 Model for control design
Assuming that and are small, Equation (18) can be simplied as
_
_

_
_
=
_
_
p
q
r
_
_
. (21)
Similarly, Equation (19) is simplied by assuming that the Coriolis terms qr, pr,
and pq, are small to obtain
_
_
p
q
r
_
_
=
_
_
1
J
x

1
J
y

1
J
z

_
_
. (22)
Combining Eq. (21) and (22) we get
_
_

_
_
=
_
_
1
J
x

1
J
y

1
J
z

_
_
. (23)
19
Differentiating Eq. (16) and neglecting

R
v
b
gives
_
_
p
n
p
e
p
d
_
_
=
_
_
cc ssc cs csc + ss
cs sss + cc css sc
s sc cc
_
_
_
_
u
v
w
_
_
. (24)
Neglecting the Coriolis terms and plugging Eq. (17) into Eq. (24) and simplifying
gives
_
_
p
n
p
e
p
d
_
_
=
_
_
0
0
g
_
_
+
_
_
csc ss
css + sc
cc
_
_
F
m
. (25)
Therefore, the simplied inertial model is given by
p
n
= (cos sin cos sin sin )
F
m
(26)
p
e
= (cos sin sin + sin cos )
F
m
(27)
p
d
= g (cos cos )
F
m
(28)

=
1
J
x

(29)

=
1
J
y

(30)

=
1
J
z

. (31)
(32)
The dynamics given in Equations (26)(31) are expressed in the inertial frame.
This is necessary for the simulator. However, we will be controlling position,
altitude, and heading using camera frame measurements of a target position. In
dynamics in the inertial frame, we will express them in the vehicle-1 frame F
v1
,
which is equivalent to the inertial frame after rotating by the heading angle.
Differentiating Eq. (20) and neglecting

R
v1
b
gives
_
_
p
x
p
y
p
z
_
_
=
_
_
c ss cs
0 c s
s sc cc
_
_
_
_
u
v
w
_
_
. (33)
20
Neglecting the Coriolis terms and plugging Eq. (17) into Eq. (33) and simplifying
gives
_
_
p
x
p
y
p
z
_
_
=
_
_
0
0
g
_
_
+
_
_
cs
s
cc
_
_
F
m
. (34)
Therefore, the simplied model in the vehicle-1 frame is given by
p
x
= cos sin
F
m
(35)
p
y
= sin
F
m
(36)
p
z
= g cos cos
F
m
(37)

=
1
J
x

(38)

=
1
J
y

(39)

=
1
J
z

. (40)
(41)
5 Sensors
5.1 Rate Gyros
A MEMS rate gyro contains a small vibrating lever. When the lever undergoes
an angular rotation, Coriolis effects change the frequency of the vibration, thus
detecting the rotation. A brief description of the physics of rate gyros can be
found at RateSensorAppNote.pdf.
The output of the rate gyro is given by
y
gyro
= k
gyro
+
gyro
+
gyro
,
where y
gyro
is in Volts, k
gyro
is a gain, is the angular rate in radians per second,

gyro
is a bias term, and
gyro
is zero mean white noise. The gain k
gyro
should be
given on the spec sheet of the sensor. However, due to variations in manufacturing
it is imprecisely known. The bias term
gyro
is strongly dependent on temperature
and should be calibrated prior to each ight.
21
If three rate gyros are aligned along the x, y, and z axes of the quadrotor, then
the rate gyros measure the angular body rates p, q, and r as follows:
y
gyro,x
= k
gyro,x
p +
gyro,x
+
gyro,x
y
gyro,y
= k
gyro,y
q +
gyro,y
+
gyro,y
y
gyro,z
= k
gyro,z
r +
gyro,z
+
gyro,z
.
MEMS gyros are analog devices that are sampled by the on-board processer.
We will assume that the sample rate is given by T
s
. The Kestrel autopilot samples
the gyros at approximately 120 Hz.
5.2 Accelerometers
A MEMS accelerometer contains a small plate attached to torsion levers. The
plate rotates under acceleration and changes the capacitance between the plate
and the surrounding walls [3].
The output of the accelerometers is given by
y
acc
= k
acc
A +
acc
+
acc
,
where y
acc
is in Volts, k
acc
is a gain, Ais the acceleration in meters per second,
acc
is a bias term, and
acc
is zero mean white noise. The gain k
acc
should be given
on the spec sheet of the sensor. However, due to variations in manufacturing it is
imprecisely known. The bias term
acc
is strongly dependent on temperature and
should be calibrated prior to each ight.
Accelerometers measure the specic force in the body frame of the vehicle. A
physically intuitive explanation is given in [1, p. 13-15]. Additional explanation
is given in [4, p. 27]. Mathematically we have
_
_
a
x
a
y
a
z
_
_
=
1
m
(F F
gravity
)
= v +
b
b/i
v
1
m
F
gravity
.
In component form we have
a
x
= u + qw rv + g sin
a
y
= v + ru pw g cos sin
a
z
= w + pv qu g cos cos .
22
Using Eq (17) we get
a
x
= 0
a
y
= 0
a
z
= F/m,
where F is the total thrust produced by the four motors. It is important to note
that for the quadrotor, the output of the accelerometers is independent of angle.
This is in contrast to the unaccelerated ight for xed wing vehicles where the
accelerometers are used to measure the gravity vector and thereby extract roll and
pitch angles.
MEMS accelerometers are analog devices that are sampled by the on-board
processer. We will assume that the sample rate is given by T
s
. The Kestrel autopi-
lot samples the accelerometers at approximately 120 Hz.
5.3 Camera
The control objective is to hold the position of the quadrotor over a ground based
target that is detected using the vision sensor. In this section we will briey de-
scribe how to estimate p
x
and p
y
in the vehicle 1-frame.
We will assume that the camera is mounted so that the optical axis of the
camera is aligned with the body frame z-axis and so that the x-axis of the camera
points out the right of the quadrotor and the y-axis of the camera points to the
The camera model is shown in Figure 14. The position of the target in the
vehicle-1 frame is (p
x
, p
y
, p
z
). The pixel location of the target in the image is
(
x
,
y
).
The geometry for p
y
is shown in Figure 15. From the geometry shown in
Figure 15, we can see that
p
y
= p
z
tan
_

x

M
y
_
, (42)
where is the camera eld-of-view, and M
y
is the number of pixels along the
camera y-axis. In Figure 15, both p
y
and
x
are negative. Positive values are
toward the right rotor. A similar equation can be derived for p
x
as
p
x
= p
z
tan
_

y

M
y
_
. (43)
23
Figure 14: Camera model for the quadrotor.
6 State Estimation
The objective of this section is to describe techniques for estimating the state of the
quadrotor from sensor measurements. We need to estimate the following states:
p
x
, p
y
, p
z
, u, v, w, , , , p, q, r.
The angular rates p, q, and r can be obtained by low pass ltering the rate
gyros. The remain states require a Kalman lter. Both are discussed below.
6.1 Low Pass Filters
The Laplace transforms representation of a simple low-pass lter is given by
Y (s) =
a
s + a
U(s),
24
Target
Optical
Axis
Figure 15: The geometry introduced by the vision system. The height above
ground is given by p
z
, the lateral position error is p
y
, the roll angle is , the
eld-of-view of the camera is , the lateral pixel location of the target in the image
is
x
, and the total number of pixels along the lateral axis of the camera is M
x
.
were u(t) is the input of the lter and y(t) is the output. Inverse Laplace trans-
forming we get
y = ay + au. (44)
Using a zeroth order approximation of the derivative we get
y(t + T) y(t)
T
= ay(t) + au(t),
where T is the sample rate. Solving for y(t + T) we get
y(t + T) = (1 aT)y(t) + aTu(t).
For the zeroth order approximation to be valid we need aT 1. If we let = aT
then we get the simple form
y(t + T) = (1 )y(t) + u(t).
25
Note that this equation has a nice physical interpretation: the new value of y
(ltered value) is a weighted average of the old value of y and u (unltered value).
If u is noisy, then [0, 1] should be set to a small value. However, if u is
relatively noise free, then should be close to unity.
In the derivation of the discrete-time implementation of the low-pass lter, it is
possible to be more precise. In particular, returning to Equation (44), from linear
systems theory, it is well known that the solution is given by
y(t + T) = e
aT
y(t) + a
_
T
0
e
a(T)
u() d.
Assuming that u(t) is constant between sample periods results in the expression
y(t + T) = e
aT
y(t) + a
_
T
0
e
a(T)
du(t)y(t + T)
= e
aT
y(t) + (1 e
aT
)u(t). (45)
Note that since e
x
= 1+x+
x
2
2!
+. . . we have that e
aT
1aT and 1e
aT

aT.
Therefore, if the sample rate is not xed (common for micro controllers), and
it is desired to have a xed cut-off frequency, then Equation (45) is the preferable
way to implement a low-pass lter in digital hardware.
We will use the notation LPF() to represent the low-pass lter operator.
Therefore x = LPF(x) is the low-pass ltered version of x.
6.2 Angular Rates p, q, and r.
The angular rates p, q, and r can be estimated by low-pass ltering the rate gyro
signals:
p = LPF(y
gyro,x
) (46)
q = LPF(y
gyro,y
) (47)
r = LPF(y
gyro,z
). (48)
6.3 Dynamic Observer Theory
The objective of this section is to briey review observer theory.
26
Suppose that we have a linear time-invariant system modeled by the equations
x = Ax + Bu
y = Cx.
A continuous-time observer for this system is given by the equation

x = A x + Bu
. .
+ L(y C x)
. .
, (49)
copy of the model correction due to sensor reading
where x is the estimated value of x. Letting x = x x we observer that

x = (A LC) x
which implies that the observation error decays exponentially to zero if L is cho-
sen such that the eigenvalues of A LC are in the open left half of the complex
plane.
In practice, the sensors are usually sampled and processed in digital hardware
at some sample rate T
s
. How do we modify the observer equation shown in Equa-
tion (49) to account for sampled sensor readings?
The typical approach is to propagate the system model between samples using
the equation

x = A x + Bu (50)
and then to update the estimate when a measurement is received using the equation
x
+
= x

+ L(y(t
k
) C x

),
where t
k
is the instant in time that the measurement is received and x

is the
state estimate produced by Equation (50) at time t
k
. Equation (50) is then re-
instantiated with initial conditions given by x
+
. The continuous-discrete observer
is summarized in Table 6.3.
The observation process is shown graphically in Figure 16. Note that it is not
necessary to have a xed sample rate. The continuous-discrete observer can be
implemented using Algorithm 1.
Note that we did not use the fact that the process was linear. Suppose instead
that we have a nonlinear system of the form
x = f(x, u) (51)
y = c(x) (52)
, then the continuous discrete observer is given in table 6.3.
The real question is how to pick the observer gain L.
27
Figure 16: sdf
Algorithm 1 Continuous-Discrete Observer
1: Initialize: x = 0.
2: Pick an output sample rate T
out
which is much less than the sample rates of
the sensors.
3: At each sample time T
out
:
4: for i = 1 to N do {Prediction: Propagate the state equation.}
5: x = x +
_
T
out
N
_
(A x + Bu)
6: end for
7: if A measurement has been received from sensor i then {Correction: Mea-
surement Update}
8: x = x + L
i
(y
i
C
i
x)
9: end if
28
System model:
x = Ax + Bu
y(t
k
) = Cx(t
k
)
Initial Condition x(0).
Assumptions:
Knowledge of A, B, C, u(t).
No measurement noise.
Prediction: In between measurements (t [t
k1
, t
k
)):
Propagate

x = A x + Bu.
Initial condition is x
+
(t
k1
).
Label the estimate at time t
k
as x

(t
k
).
Correction: At sensor measurement (t = t
k
):
x
+
(t
k
) = x

(t
k
) + L(y(t
k
) C x

(t
k
)) .
Table 1: Continuous-Discrete Linear Observer.
6.4 Essentials from Probability Theory
Let X = (x
1
, . . . , x
n
)
T
be a random vector whose elements are random variables.
The mean, or expected value of X is denoted by
=
_
_
_

1
.
.
.

n
_
_
_
=
_
_
_
E{x
1
}
.
.
.
E{x
n
}
_
_
_
= E{X},
where
E{x
i
} =
_
f
i
() d,
and f() is the probability density function for x
i
. Given any pair of components
x
i
and x
j
of X, we denote their covariance as
cov(x
i
, x
j
) =
ij
= E{(x
i

i
)(x
j

j
)}.
The covariance of any component with itself is the variance, i.e.,
var(x
i
) = cov(x
i
, x
i
) =
ii
= E{(x
i

i
)(
i
)}.
The standard deviation of x
i
is the square root of the variance:
stdev(x
i
) =
i
=
_

ii
.
29
System model:
x = f(x, u)
y(t
k
) = c(x(t
k
))
Initial Condition x(0).
Assumptions:
Knowledge of f, c, u(t).
No measurement noise.
Prediction: In between measurements (t [t
k1
, t
k
)):
Propagate

x = f( x, u).
Initial condition is x
+
(t
k1
).
Label the estimate at time t
k
as x

(t
k
).
Correction: At sensor measurement (t = t
k
):
x
+
(t
k
) = x

(t
k
) + L(y(t
k
) c( x

(t
k
))) .
Table 2: Continuous-Discrete Nonlinear Observer.
The covariances associated with a random vector X can be grouped into a matrix
known as the covariance matrix:
=
_
_
_
_
_

11

12

1n

21

22

2n
.
.
.
.
.
.
.
.
.

n1

n2

nn
_
_
_
_
_
= E{(X )(X )
T
} = E{XX
T
}
T
.
Note that =
T
so that is both symmetric and positive semi-denite, which
implies that its eigenvalues are real and nonnegative.
The probability density function for a Gaussian random variable is given by
f
x
(x) =
1

2
x
e

(x
x
)
2

2
x
,
where
x
is the mean of x and
x
is the standard deviation. The vector equivalent
is given by
f
X
(X) =
1

2 det
exp
_

1
2
(X )
T

1
(X )
_
,
in which case we write
X N (, ) ,
30
Figure 17: Level curves for the pdf of a 2D Gaussian random variable.
and say that X is normally distributed with mean and covariance .
Figure 17 shows the level curves for a 2D Gaussian random variable with
different covariance matrices.
6.5 Derivation of the Kalman Filter
In this section we assume the following state model:
x = Ax + Bu + G
y
k
= Cx
k
+
k
,
where y
k
= y(t
k
) is the k
th
sample of y, x
k
= x(t
k
) is the k
th
sample of x,
k
is
the measurement noise at time t
k
, is a zero-mean Gaussian random process with
covariance Q, and
k
is a zero-mean Gaussian random variable with covariance
R. Note that the sample rate does not need to be be xed.
The observer will therefore have the following form:
31
Prediction: In between measurements: (t [t
k1
, t
k
])
Propagate

x = A x + Bu.
Initial condition is x
+
(t
k1
).
Label the estimate at time t
k
as x

(t
k
).
Correction: At sensor measurement (t = t
k
):
x
+
(t
k
) = x

(t
k
) + L(y(t
k
) C x

(t
k
)) .
Our objective is to pick L to minimize tr(P(t)).
6.5.1 Between Measurements.
Differentiating x we get

x = x

x
= Ax + Bu + G A x Bu
= A x + G.
Therefore we have that
x(t) = e
At
x
0
+
_
t
0
e
A(t)
G() d.
We can therefore compute the evolution for P as

P =
d
dt
E{ x x
T
}
= E{

x x
T
+ x

x
T
}
= E
_
A x x
T
+ G x
T
+ x x
T
A
T
+ x
T
G
T
_
= AP + PA
T
+ GE{ x
T
}
T
+ E{ x
T
}G
T
.
As in the previous section we get
E{ x
T
} = E
_
(t) x
0
e
A
T
t
+
_
t
0
(t)
T
()G
T
e
A
T
(t)
d
_
=
1
2
QG
T
,
which implies that

P = AP + PA
T
+ GQG
T
.
32
6.5.2 At Measurements.
At a measurement we have that
x
+
= x x
+
= x x

L
_
Cx + C x

_
= x

LC x

L.
Therefore
P
+
= E{ x
+
x
+T
}
= E
_
_
x

LC x

L
_ _
x

LC x

L
_
T
_
= E
_
x

x
T
x

x
T
C
T
L
T
x

T
L
T
LC x

x
T
+ LC x

x
T
C
T
L
T
+ LC x

T
L
T
= L x
T
+ L x
T
C
T
L
T
+ L
T
L
T
_
= P

C
T
L
T
LCP

+ LCP

C
T
L
T
+ LRL
T
. (53)
Our objective is to pick L to minimize tr(P
+
). A necessary condition is

L
tr(P
+
) = P

C
T
P

C
T
+ 2LCP

C
T
+ 2LR = 0
=2L(R + CP

C
T
) = 2P

C
T
=L = P

C
T
(R + CP

C
T
)
1
.
Plugging back into Equation (53) give
P
+
= P

+ P

C
T
(R + CP

C
T
)
1
CP

C
T
(R + CP

C
T
)
1
CP

+ P

C
T
(R + CP

C
T
)
1
(CP

C
T
+ R)(R + CP

C
T
)
1
CP

= P

C
T
(R + CP

C
T
)
1
CP

= (I P

C
T
(R + CP

C
T
)
1
C)P

= (I LC)P

.
For linear systems, the continuous-discrete Kalman lter is summarized in
Table 6.5.2
If the system is nonlinear, then the Kalman lter can still be applied but we
need to linearize the nonlinear equations in order to compute the error covariance
matrix P and the Kalman gain L. The extended Kalman lter (EKF) is given in
Table 6.5.2, and an algorithm to implement the EKF is given in Algorithm 2.
33
System model:
x = Ax + Bu +
y
i
(t
k
) = C
i
x(t
k
) +
k
Initial Condition x(0).
Assumptions:
Knowledge of A, B, C
i
, u(t).
Process noise satises N(0, Q).
Measurement noise satises
k
N(0, R).
Prediction: In between measurements (t [t
k1
, t
k
)):
Propagate

x = A x + Bu.
Propagate

P = AP + PA
T
+ Q.
Correction: At the i
th
sensor measurement (t = t
k
):
L
i
= P

C
T
i
(R
i
+ C
i
PC
T
i
)
1
,
P
+
= (I L
i
C
i
)P

,
x
+
(t
k
) = x

(t
k
) + L(y(t
k
) C x

(t
k
)) .
Table 3: Continuous-Discrete Kalman Filter.
In this section we will discuss the application of Algorithm 2 to the quadrotor.
We would like to estimate the state
x =
_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
p
x
p
y
p
z

p
x

p
y

p
z

_
_
_
_
_
_
_
_
_
_
_
_
_
_
_
,
where the rate gyros and accelerometers will be used to drive the prediction step,
and an ultrasonic altimeter and camera will be used in the correction step.
34
System model:
x = f(x, u) +
y
i
(t
k
) = c
i
(x(t
k
)) +
k
Initial Condition x(0).
Assumptions:
Knowledge of f, c
i
, u(t).
Process noise satises N(0, Q).
Measurement noise satises
k
N(0, R).
Prediction: In between measurements (t [t
k1
, t
k
)):
Propagate

x = f( x, u),
Compute A =
f
x

x= x(t)
,
Propagate

P = AP + PA
T
+ Q.
Correction: At the i
th
sensor measurement (t = t
k
):
C
i
=
c
i
x

x= x

L
i
= P

C
T
i
(R
i
+ C
i
PC
T
i
)
1
,
P
+
= (I L
i
C
i
)P

,
x
+
(t
k
) = x

(t
k
) + L(y(t
k
) c
i
( x

(t
k
))) .
Table 4: Continuous-Discrete Extended Kalman Filter.
The propagation model is obtained from Equations (35)(37), and (18) as
f(x, u) =
_
_
_
_
_
_
_
_
_
_
_
_
_
_
p
x
p
y
p
z
cos sin a
z
sina
z
g + cos cos a
z
p + q sin tan + r cos tan
q cos r sin
q
sin
cos
+ r
cos
cos
_
_
_
_
_
_
_
_
_
_
_
_
_
_
,
where we have used the fact that the z-axis of the accelerometer measures a
z
=
35
Algorithm 2 Continuous-Discrete Extended Kalman Filter
1: Initialize: x = 0.
2: Pick an output sample rate T
out
which is much less than the sample rates of
the sensors.
3: At each sample time T
out
:
4: for i = 1 to N do {Prediction: Propagate the equations.}
5: x = x +
_
T
out
N
_
(f( x, u))
6: A =
f
x
7: P = P +
_
T
out
N
_ _
AP + PA
T
+ GQG
T
_
8: end for
9: if A measurement has been received from sensor i then {Correction: Mea-
surement Update}
10: C
i
=
c
i
x
11: L
i
= PC
T
i
(R
i
+ C
i
PC
T
i
)
1
12: P = (I L
i
C
i
)P
13: x = x + L
i
(y
i
c
i
( x)).
14: end if
F/m. Differentiating we obtain
A =
_
_
_
_
_
_
_
_
_
_
_
_
_
_
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 s

a
z
c

a
z
0
0 0 0 0 0 0 c

a
z
0 0
0 0 0 0 0 0 s

a
z
c

a
z
0
0 0 0 0 0 0 qct rst (qs + rc)/c
2
0
0 0 0 0 0 0 qs rc 0 0
0 0 0 0 0 0
qcrs
c
(qs + rc)
t
c
0
_
_
_
_
_
_
_
_
_
_
_
_
_
_
Note that it may be adequate (not sure) to use a small angle approximation in
36
the model resulting in
f(x, u) =
_
_
_
_
_
_
_
_
_
_
_
_
_
_
p
x
p
y
p
z
a
z
a
z
g + a
z
p
q
r
_
_
_
_
_
_
_
_
_
_
_
_
_
_
,
and
A =
_
_
_
_
_
_
_
_
_
_
_
_
_
_
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 a
z
0
0 0 0 0 0 0 a
z
0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
_
_
_
_
_
_
_
_
_
_
_
_
_
_
.
If this form works, then the update equation for P can be coded by hand, signif-
icantly reducing the computational burden. Note also that f(x, u) does not take
into account the motion of the target. A feedforward term can be added to f to
account for the target motion as
f(x, u) =
_
_
_
_
_
_
_
_
_
_
_
_
_
_
p
x
m
x
p
y
m
y
p
z
a
z
m
x
a
z
m
y
g + a
z
p
q
r
_
_
_
_
_
_
_
_
_
_
_
_
_
_
,
where ( m
x
, m
y
) is the velocity of the target in the vehicle-1 frame, and ( m
x
, m
y
)
is the acceleration of the target in the vehicle-1 frame.
37
Let the relative position between the quadrotor and the target be denoted by
p
v1
= (p
x
, p
y
, p
z
)
T
. We can tranform to the camera frame as
p
c
= R
c
g
R
g
b
R
b
v1
p
v1
,
where
R
c
g
=
_
_
0 1 0
0 0 1
1 0 0
_
_
is the rotation matrix from gimbal coordinates to camera coordinates,
R
g
b
=
_
_
0 0 1
0 1 0
1 0 0
_
_
transforms body coordinates to gimbal coordinates, and
R
b
v1
=
_
_
cc ssc cs csc + ss
cs sss + cc css sc
s sc cc
_
_
transforms vehicle-1 coordinates to body coordinates. Using the small angle ap-
proximation for and we get
p
c
=
_
_
p
x
+ p
y
+ p
z
p
x
+ p
z
p
x
p
y
+ p
z
_
_
.
The model for the pixel coordinates are therefore computed as

x
= c

x
(x)

= f
p
x
+ p
y
+ p
z
p
x
p
y
+ p
z

2
= c

y
(x)

= f
p
x
+ p
z
p
x
p
y
+ p
z
.
We therefore have the following sensors available to correct the state estimate:
sensor 1: altimeter y
1
= c
alt
(x)

= p
z
+
1
[k] (54)
sensor 2: vision x-pixel y
2
= c

x
(x) +
2
[k]. (55)
sensor 3: vision y-pixel y
3
= c

y
(x) +
3
[k] (56)
4
= c

(x)

= /2 + +
4
[k]. (57)
38
The linearization of the rst and fourth output functions are given by
C
1
=
_
0 0 1 0 0 0 0 0
_
(58)
C
4
=
_
0 0 0 0 0 0 0 1
_
. (59)
The linearization of the expression for the pixel coordinates is messy and can
easily be computed numerically using the approximation
f(x
1
, , x
i
,
.
.
.
, x
n
)
x
i

f(x
1
, , x
i
+ , , x
n
) f(x
1
, , x
i
, , x
n
)

,
where is a small constant.
7 Control Design
The control design will be derived directly from Equations (35)(40). Equa-
tions (38)(40) are already linear. To simplify Equations (35)(37) dene
u
x

= cossin
F
m
(60)
u
y

= sin
F
m
(61)
u
z

= g cos cos
F
m
, (62)
to obtain
p
x
= u
x
(63)
p
y
= u
y
(64)
p
z
= u
z
. (65)
The control design proceeds by developing PID control strategies for u
x
, u
y
, and
u
z
. After u
x
, u
y
, and u
z
have been computed, we can compute the desired force
F, and the commanded roll angle
c
and the commanded pitch angle
c
from
Equations (60)(62) as follows. From Equation (62) solve for F/m as
F
m
=
g u
z
cos cos
. (66)
39
Substituting (66) into (61) gives
u
y
=
g u
z
cos
tan .
Solving for and letting this be the commanded roll angle gives

c
= tan
1
_
u
y
cos
g u
z
_
. (67)
Similarly, we can solve for the commanded pitch angle as

c
= tan
1
_
u
x
u
z
g
_
. (68)
7.1 Vision Based Altitude Hold
For the altitude hold we need to develop an expression for u
z
to drive p
z
to a
desired altitude based on the size of the object in the image. We will assume that
the camera returns the size of the object in the image plane in pixels, which is
denoted by
s
. Figure 18 shows the geometry of the quadrotor hovering over a
Target
Figure 18: The size of the target is S in meters, and the size of the target in the
image plane is denoted by
s
in pixels. The focal length is f, and the height above
the target is p
z
.
target of size S. From similar triangles we have that
p
z
S
=
f

s
.
40
Solving for p
z
an differentiating we obtain
p
z
=
fS
s

2
s
. (69)
Differentiating again gives
p
z
=
fS
s

2
s
2fS

2
s

3
s
.
Substituting u
z
= p
z
and solving for
s
gives

s
=
_

2
s
fS
_
u
z
+ 2

2
s

s
.
Dening
u
s

=
_

2
s
fS
_
u
z
+ 2

2
s

s
, (70)
we get

s
= u
s
.
We can now derive a PID controller to drive
s

d
s
as
u
s
= k
p
s
(
d
s

s
) k
d
s

s
+ k
i
s
_
t
0
(
d
s

s
) d.
Solving (70) for u
z
we get
u
z
=
fS

2
s
k
p
s
(
d
s

s
)
_
k
d
s
fS

2
s
+ 2
fS
s

3
s
_

s
+ k
i
s
fS

2
s
_
t
0
(
d
s

s
) d. (71)
The downside to this equation is that it requires knowledge of the target size S and
the focal length f. This requirement can be removed by incorporating fS into the
PID gains by dening

k
p
s

= fSk
p
s

k
i
s

= fSk
i
s

k
d
s

= fSk
d
s
,
and by noting from Equation (69) that
fS
s

2
s
= w. Therefore Equation (71) be-
comes
u
z
=

k
p
s
(
d
s

s
)

2
s

k
d
s

2
s
+ 2
w

s
_

s
+

k
i
s

2
s
_
t
0
(
d
s

s
) d. (72)
41
7.2 Roll Attitude Hold
The equation of motion for roll is given by Eq. (38) as

=
p
/J
x
. We will use a
PID controller to regulate the roll attitude as

p
= k
p

(
c
) k
d

p + k
i

_
t
0
(
c
) d.
A block diagram of the control structure is shown in Figure 19.
Figure 19: A block diagram of the roll attitude hold loop.
The gains k
p

, k
i

, and k
d

are selected one at a time using a method called

successive loop closure. To pick k
p

note that if the input command

c
is a step of
value A, then at time t = 0, before the integrator has time to begin winding up,
x
is given by

x
(0) = k
p

A.
Therefore, setting k
p

= M/A will just saturate the actuators when a step value

of A is placed on
c
.
To select k
d

, let k
p

i

= 0, and solve for the characteristic

equation in Evans form verses k
d

to obtain
1 + k
d

1
J
x
s
s
2
+
k
p

J
x
= 0.
The derivative gain k
d

is selected to achieve a damping ratio of = 0.9.

The characteristic equation including k
i

in Evans form verses k

i

is given by
1 + k
i

1
J
x
s
3
+
k
d

J
x
s
2
+
k
p

J
x
s
= 0.
42
The integral gain k
i

can be selected so that damping ratio is not signicantly

changed.
7.3 Pitch Attitude Hold
The equation of motion for pitch is given by Eq. (39) as

=
q
/J
y
. Similar to the
roll attitude hold, we will use a PID controller to regulate pitch as

q
= k
p

(
c
) k
d

q + k
i

_
t
0
(
c
) d.
7.4 Vision Based Position Tracking
From Equation 64 the lateral dynamics are given by p
y
= u
y
, where p
y
is the
relative lateral position which we drive to zero using the PID strategy
u
y
= k
p
y
p
y
k
d
y
v + k
i
y
_
t
0
p
y
d.
The relative position error p
y
is given by Equation (42).
From Equation 63 the longitudinal dynamics are given by p
x
= u
x
, where p
x
is the relative lateral position which we drive to zero using the PID strategy
u
x
= k
p
x
p
x
k
d
x
u + k
i
x
_
t
0
p
x
d.
The relative position error p
x
is given by Equation (43).
The heading dynamics are given in Equation (40) as

=
r
/J
z
. Dene
d
as the
inertial heading of the target, and dene

=
d
camera directly measures

. Assuming that
d
is constant we get

=
r
/J
z
. We
regulate the relative heading with the PID strategy

r
= k
p

k
d

r k
i

_
t
0
d.
43
7.6 Feedforward
When the quadrotor is tracking a ground robot, the motion of the robot will cause
tracking errors due to the delayed response of the PID controller. If we can com-
municate with the robot, and we know its intended motion, we should be able to
use that information to help the quadrotor predict where the robot is moving.
To motivate our approach, lets consider a simple example to gain intuition.
Consider the double integrator system
y = u,
where y is position, and u is commanded acceleration. If r is the reference signal
then the standard PD loop is shown in Figure 20.
Figure 20: Standard PD loop
Let e = r y, then
e = r y
= r u
= r k
p
e + k
d
y
= r k
p
e k
d
e + k
d
r.
In other words we have
e + k
d
e + k
p
e = r + k
d
r.
Therefore, the signal r + k
d
r drives the error transfer function
1
s
2
+k
d
s+kp
and if w
is not zero, the tracking error will not go to zero.
44
From the expression e = r u we see that if instead of u = k
p
e k
d
y, we
u = r + k
p
e + k
d
e,
then we get
e + k
d
e + k
p
e = 0,
which ensures that e(t) 0 independent of r(t). The associated block diagram
is shown in Figure 21.
Figure 21: Feedforward term is added to a standard PD loop.
Now consider the lateral motion of the quadrotor in the cage where
y = g tan ,
where y is the position of the quadrotor, g is the gravity constant, and is the roll
angle. Let m(t) be the position of the target and dene y

= mr as the relative
position. Then
y = m r
= mg tan .
If by some means we know the target velocity m and the target acceleration m,
then we should pick such that
g tan = m + k
p
y + k
d
y,
or
= tan
1
_
m + k
p
y + k
d
y
g
_
.
45
Given the decoupling terms described at the beginning of this section, the
motion model for the quadrotor in the vehicle-1 frame is given by
p
x
= u
x
p
y
= u
y

= u

.
Let the position of the target in the vehicle-1 frame be given by (m
x
, m
y
) and let
it orientation be given by
t
, and dene
p
x
= m
x
p
x
p
y
= m
y
p
y

=
t
.
Differentiating twice we get

p
x
= m
x
u
x

p
y
= m
y
u
y

t
u

.
Therefore, adding a feedforward term we have
u
x
= m
x
+ PID
x
u
y
= m
y
+ PID
y
u

t
+ PID

where PID

are the PID controllers derived earlier in this chapter.

The motion model for the target is given by
m
n
= V
t
cos
t
m
e
= V
t
sin
t

V
t
= u
1

t
= u
2
,
where (m
n
, m
e
) is the inertial position of the target, V
t
is the ground speed of the
target, and u
1
and u
2
are robot control signals. In the vehicle-1 frame we have
_
m
x
m
y
_
=
_
cos sin
sin cos
__
V
t
cos
t
V
t
sin
t
_
=
_
V
t
cos

V
t
sin

_
,
46
where the camera measures the relative heading

=
t
. Differentiating we
obtain
_
m
x
m
y
_
=
_
cos

sin

sin

cos

__
u
1
u
2

_
.
To implement feedforward on the quadrotors, we must communicate with the
robot to obtain V
t
, u
1
, and u
2
.
References
[1] B. L. Stevens and F. L. Lewis, Aircraft Control and Simulation. Hoboken, NewJersey:
John Wiley & Sons, Inc., 2nd ed., 2003.
[2] D. Halliday and R. Resnick, Fundamentals of Physics. John Wiley & Sons, 3rd ed.,
1988.
[3] http://www.silicondesigns.com/tech.html.
[4] M. Rauw, FDC 1.2 - A SIMULINK Toolbox for Flight Dynamics and Control Analy-
sis, February 1998. Available at http://www.mathworks.com/.
47