Fully Quaternion Based
Fully Quaternion Based
Position Controller
Hardik Parwana1
Kyoto University, Japan
In this paper, a novel fully quaternion based second order stable error dynamics con-
troller is developed to address the attitude tracking problem in general and the position
tracking problem of fixed pitch and variable pitch quadrotors in particular. Since the
singularity associated with Euler angle representation is avoided using a unit quater-
nion approach, our algorithm finds its advantage in controlling highly maneuverable
systems like variable pitch quadrotor which are capable of generating negative thrust
and transition to inverted flight. Our controller is also well suited for rigid systems
simulations show good tracking performance using the proposed control methods for
1 Research Student, Dept. of Mechanical Engineering and Science, Kyoto University, Japan,
[email protected]
2 Undergraduate Student, Dept. of Aerospace Engineering, Indian Institute of Technology Kanpur, India, jay-
[email protected].
3 Assistant Professor, Dept. of Aerospace Engineering, Indian Institute of Technology Kanpur, India, man-
[email protected], AIAA member
1
Nomenclature
B = Body (local) frame ζ = diag(ζ1 , ζ2 , ζ3 ) Gain matrix
w
~ = body angular velocity, rad/s d = desired quantity
~
M = moment, N m m = mass of body, kg
~r = center of mass position in World frame, m g = acceleration due to gravity, 9.81 m/s2
T = thrust of quadrotor, N
q = quaternion
2
I. Introduction
Designing smooth control inputs for rigid body attitude and translation dynamics has long
been a problem in focus. Various approaches proposed in the past to fulfilling this objective can
primarily be divided into two domains: one focusing on developing suitable control inputs, with
PID being the most applied one, and the other focused on choosing better representation of state
variables. Much of current research can be found combining these new approaches in both or
either of these domains and studying its efficacy. The synthesis of control inputs involve linear
control methods such as PID and its variants and nonlinear control methods such as Feedback
Linearization, Nonlinear Dynamic inversion, and Sliding Mode and other adpative control theories.
The translation dynamics representation has been done mostly in Euclidean space for Earth bound
systems and in Polar or spherical coordinates for outer space systems. As for the orientation
representation, the attitude of a rigid body belongs to the configuration space known as Special
Orthogonal group SO(3) and is represented in most general terms as 3 × 3 rotation matrix [1]. The
space can, however, be parameterized in terms of fewer parameters. The most used representation
is Euler angle formulation. However, it suffers from gimbal lock which results in a singularity in the
formulation. Recently quaternions and rotation matrix have become the preferred tool to overcome
the singularity of Euler angles. The applications of these approaches have been validated on various
systems such as satellites, aircrafts and more popularly on UAVs which, owing to their smaller size,
also provide the advantage of a cheap experimental platform for conceptual verification.
Among these small UAVs, quadrotors have recently gained attention for their usefulness in
multi-agent missions, mapping and localization, acrobatic performances, and as autonomous payload
delivery systems. They are mechanically simple however, their inherent instability and nonlinear
dynamics make their control challenging. Various control strategies have been designed which enable
them to perform aggressive maneuvers such as multiple flips [2], flight through narrow openings [3],
etc. Most of these approaches use hierarchical structures and divide the problem into two loops of
Emil and George [4] proposed a nonlinear P 2 controller with the commanded moment propor-
tional to the vector part of the quaternion error and actual angular velocity. Tayebi and McGilvray
3
[5] designed a similar P D2 feedback structure for the hover equilibrium point stabilization based on
quaternion, quaternion velocity and angular velocity.The stability analysis is given using a Lyapunov
function designed in a manner similar to the backstepping approach. A quaternion based nonlinear
robust feedback controller was proposed by Xian et al [6] in which they stabilize the second order
error dynamics in attitude and altitude while using filters to estimate the angular velocities. Their
controller however requires inversion of a Jacobian matrix which becomes singular if first component
of error quaternion is zero. A similar controller was also designed by Bangura and Mahony [7] with
In this paper, we impose second order stable dynamics for the error quaternion in designing
the attitude controller. Since we control second derivative instead of first, the control inputs are
expected to be smoother than first order error dynamics which directly controls the first derivative
or the direction of response. To the best of our knowledge most of the previous quaternion feedback
controllers including those mentioned above are dependent only on rate of vector part of error
quaternion vector for the feedback. However, it is our understanding that the scalar part can also
also guide how fast the error dynamics converges. We also observed experimentally that during
the gain tuning process the scalar part contribution can affect smoothness of the controller. Also,
the derivative of quaternion has a nonlinear relationship with the angular velocity and hence our
feedback, which is function of quaternion derivative rather than the angular velocity directly, is also
unlike most of the previously proposed controllers which have angular velocity feedback.
impose some fundamental constraints on its performance. These do not scale well to large size
as the stabilization of larger quadrotors become difficult through RPM control alone given the
magnitudes of the torque involved and limited control bandwidth making them unsuitable for larger
payloads. These limitations can be overcome using variable pitch quadrotors [8, 9].
Not much attention has been directed towards variable pitch quadorotors in recent history
however, they have been a subject of research in the past. Georges de Bothezat and Ivan Jerome in
1922 built and flew the "Flying Octopus" [10], a vehicle with rotors located at each end of a truss
structure of intersecting beams, placed in the shape of a cross and controlled through changing
4
pitch angle of blades. Johann Borenstein [11] at University of Michigan developed "Hoverbot",
which is the first documented effort at designing and flying a small scale quadrotor with variable
pitch control, though it never achieved flight beyond tethered hovering. Recently, many hobbysists
have demonstrated flights with small scale models. A detailed analysis of flight performance was
however undertaken by Cutler et al. [8], and some important facts were established: (i) the ability
to generate negative thrust could be used to perform inverted flight; and (ii) faster rate of change
of thrust was observed with changing pitch than with changing RPM of motors. More recently,
pointing to the fact that the linear mapping between moments in body frame and the actuator
control does not work with variable pitch quadrotor due to nonlinear actuator dynamics involved
with changing pitch angle of blades, Namrata et al [9] designed a control allocation methodology,
Our attitude controller holds in general for any rigid body and can be applied to many signif-
icant areas. For example, with the growth in number and operational requirements of rigid body
spacecraft, systems often have a need for highly accurate pointing maneuvers in numerous tasks
of practical importance like weather monitoring, communications, survey of resources etc in which
there arises a need to maintain a satellite in a fixed orientation with respect to the Earth. B.
T. Costic et al [12] have addressed the attitude tracking problem for a rigid spacecraft using unit
quaternion based adaptive approach that obtains asymptotic attitude tracking without the need for
angular velocity measurements. In this paper, we present simulation results by implementing the
proposed second order error dynamics quaternion based attitude controller for achieving the desired
satellite orientation.
The rest of the paper is organized as follows: A brief introduction to quaternion formulations
is presented in Section II. Section III presents the dynamic models of various rigid bodies for whom
the controller is being designed. Section IV describes the attitude controller, which in general
holds for any rigid body, and Section V describes the complete trajectory tracking algorithm for
the quadrotor. Simulation results are then presented in Section VI and experimental results for
the attitude and position controller are presented in Section VII. Finally, we state some important
5
II. Quaternion Preliminaries
Quaternions [13, 14] are hyper complex number of rank 4 which consists of a scalar part q0 and
vector part ~q
q0 T
= [q0 q1 q2 q3 ]
q= (1)
~q
When using them to represent the attitude of a body, they have the property of unity norm, i.e.,
|q| = 1. The quaternion q in this paper will be reserved for representing attitude except when stating
identities which may hold for more general cases. We will be following the Hamilton convention of
quaternion, according to which the transformation between body and world frame is given by
xi = q ◦ xb ◦ q∗ (2)
T
where x = 0 ~xT is the quaternion corresponding to any vector ~x. Throughout the paper the
bold counterpart of any vector will represent its corresponding quaternion. The quaternion product
operator ◦ is defined as
p0 q0 − p~ · ~q
q◦p=
(3)
q0 p~ + p0 ~q + ~q × p~
The rotation matrix REB = (R(q)), transforming a vector from body from local body frame B to
1
q̇ = q◦w (5)
2
Note that in the above equation the angular velocity is expressed in the local body frame of reference.
6
III. Dynamic Modelling for Rigid Systems
In this section, we state the dynamical model for a satellite. The dynamics of a fixed-pitch
The actuators present in a spacecraft can generate torque in the body frame B about all the
three axis by the application of a pair of forces opposite to each other but equal in magnitude and
acting in a direction normal to the line joining the actuators [12]. Given the attitude quaternion q,
~˙ = −~
Jω ~
ω × Jω + M (6)
1
q̇ = q◦w (7)
2
~ is generated by the actuators present on the spacecraft. In our work, we will not be dealing
where M
with position control of spacecrafts and hence the related dynamics are not mentioned here.
The Newton-Euler equations of motion for a rigid body can be used to describe the motion of
Quadrotor in a three dimensional space. The axis systems chosen are as shown in Fig 1 with the
body and inertial world frame Z axis directed downwards. F~ b and F~ i represent the components
T
of F~ in B and E frame respectively. Note that F~ b acts along the body z axis, i.e., F~ b = [0 0 f ]
where f is the total thrust produced by the rotors. The gravitational force is taken to act along the
positive z direction of inertial frame through the center of mass of the symmetrical quadrotor. The
1 ~i
~r¨ = F − ~g (8)
m
~˙ = M
Jω ~b−ω
~ × J~
ω (9)
where ω
~ is the angular velocity in the body frame and J is the moment of inertia tensor in the
body axis system. Given a rotation matrix, REB , which operates from Body frame to inertial Earth
7
Fig. 1: Inertial and body frame of reference
Equations of Motion
The translation and attitude kinematics and dynamics from Eqs.(8) and (9) can be recast using
1
r̈ = q ◦ Fb ◦ q∗ − g (10)
m
~˙ = M
Jω ~b−ω
~ × J~
ω (11)
1
q̇ = q◦w (12)
2
Rotor Dynamics
The control input and actuation is fundamentally of different type in a variable pitch quadrotor
than the fixed-pitch quadrotor. We choose to provide a fixed RPM and vary the pitch of the
propellers in order to change the thrust. Some previous works [8] have already elaborated on the
advantages of using this mode of actuation and thus the in-depth details are excluded here.
The thrust and torque of each rotor can be obtained from Blade Element Momentum Theory
(BEMT) as a function of the thrust coefficient. Given ρ, A, Ω, and hence the rotor tip speed
2
Vtip = ΩR, the non-dimensional coefficients are defined in the usual way as CT = T /(ρAVtip /2) and
2
CQ = Q/(ρARVtip /2). Following the same approach as in work done by Namrata et al. [9], the
8
non-dimensional coefficients for each rotor are defined in terms of rotor parameters as
1 θ0i λi
CTi = σClα − (13)
2 3 2
λ2i Clα Cd0i
1 λi Clα θ0i
CQi = σ − + (14)
2 3 2 4
Nb c
σ is defined in terms of Nb , c, and R as σ = πR . The only unknown in the above equations is
the inflow factor, λi , which can be approximated from the momentum theory for hovering flight
condition as
r
CTi
λi = (15)
2
The above substitution gives us the collective pitch input to the rotor and the torque coefficient for
The thrust and the torque for the ith rotor are given by
Ti = KCTi (18)
Qi = KRCTi (19)
the previous literature, we let CT s be negative if the thrust produced by the rotor is in the downward
T = (T1 + T2 + T3 + T4 )
The rolling and pitching moments can be obtained from contributions of each rotor. Due to the
relative sense of rotations, rotors 1 and 3 generate torque along the positive body z axis while rotors
2 and 4 generate torque about negative body z axis. The final expression for total moments acting
9
on the quadrotor are as shown in equations below.
KR
n = √ (|CT1 |3/2 − |CT2 |3/2 + |CT3 |3/2 − |CT4 |3/2 ) (23)
2
In this section, we formulate a controller to drive the vehicle configuration towards the attitude
setpoint computed by the position controller or passed on by the user. We impose second order
error stabilizing dynamics for achieving the desired attitude. The quaternion error is defined as:
qe = q∗d ◦ q (24)
where q∗ denotes the conjugate or inverse of the unit quaternion. It can be interpreted as the
rotation corresponding to transformation from local to desired frame of reference. The equilibrium
point for the error quaternion is qe = [1 0 0 0]T which corresponds to perfect overlap between desired
and actual orientations. The second order dynamics imposed on each component of qe separately
From q = qd ◦ qe , we get
10
Using Eq.(5) for both q and qd , we get
1 1
q̇e = q∗d ◦ ( q ◦ w − qd ◦ wD
d ◦ qe )
2 2
1
= qe ◦ (w − q∗e ◦ wD
d ◦ qe ) (27)
2
where wd is the desired angular velocity quaternion and D stands for desired quaternion frame.
Noting that B denotes body frame and that by definition qe operates on a vector in body (actual)
quaternion frame and maps it to desired attitude frame, the above can be simplified in terms of
wD B
d = qe ◦ wd ◦ q̄e
1 1
=⇒ q̇e = qe ◦ (w − wB
d ) = qe ◦ w̃ (28)
2 2
where w̃ denotes error in angular velocity quaternion. The second derivative of quaternion would
naturally involve angular acceleration terms. Writing Eq.(28) as w̃ = 2q∗e ◦ q̇e , we obtain
iT
~˙ in w̃
h
The vector part of the error quaternion, ω̃ ˙ = 0 ω̃
~T is therefore
−q1 q0 q3 −q2
~˙
ω̃ = 2 −q2 −q3 q0 q1
q̈e
−q3 q2 −q1 q0
e
= 2Gq̈e (30)
Controller
We can get the desired local angular acceleration from the error dynamics using Eqs.(30) and
(25) as follows
ω ~˙ + ω
~˙ D = ω̃ ~˙ dB
T
~˙ dB
= 2G(−2ζi ωni q̇e − ωn2 i qe − [1 0 0 0] ) + ω (31)
11
where ω
~ D is the desired angular velocity rate which is passed to the control allocation as the
angular acceleration to be achieved. Note that in a satellite and fixed-pitch quadrotor, this would
be the last step and the required moments and thrust can be obtained from the analysis till now
which then, in case of quaternion, can be converted to required rotor speeds directly using the
transformation matrix. However in case of variable pitch quadrotors, since we cannot directly find
CTi due to the nonlinear relationship as seen in Eq.(23), we maintain an additional loop to achieve
the angular velocity rate derived above. This will be elaborated more when we discuss variable pitch
quadrotor.Finally note that in Eq.(31), the derivative of the desired angular velocity in body frame
~˙ dB = ṘT ω
ω ~˙ dD
~ dD + RT ω (32)
A. Stability Analysis
The control input chosen satisfies the stable second order error dynamics [16] given by Eq.(25)
and is thus known to be exponentially stable. We provide Lyapunov stability analysis for proving
1~ ~T
V = α~qeT ~qe + α(qe0 − 1)2 + ω̃J ω̃
2
1~ ~T
= 2α(1 − qe0 ) + ω̃J ω̃ (33)
2
Theorem 1. Assume that the desired attitude trajectory qd is known, continuous and has bounded
first and second order derivatives. Also, assume that the gain matrices ζ and ωn are just multiples
of identity matrices. Let α > 0 be a scalar such that α = 2Jωn2 . Then the second order error
dynamics imposed on qe in Eq.(25) and the resulting control law synthesized in Eq.(31) render
the attitude dynamics almost globally asymptotically stable around the identity equilibrium error
T ~ = [0 0 0]T .
quaternion [1 0 0 0] and corresponding zero angular velocity error ω̃
We now provide a proof of the theorem. The derivative of Lyapunov function can be obtained
as
1 ~˙ ~ T 1 ~ T ~˙ T
V̇ = −2αq̇e0 + ω̃J ω̃ + ω̃ J ω̃ (34)
2 2
12
Since J is a positive definite matrix, the last two terms, both being scalar and transpose of each
~˙ T
~ T J ω̃
V̇ = −2αq̇e0 + ω̃
~ + 2ω̃JG
~ T
= α~qeT ω̃ −2ζωn q̇e − ωn2 (qe − [1 0 0 0] )
~ − 2ω̃
~ T JGζωn GT ω̃
~ − 2ω̃JGω
~ T
= α~qeT ω̃ 2
n (qe − [1 0 0 0] ) (35)
with equal diagonal entries respectively, we can replace their product by a scalar and denote it by
Λ. Also, it can be easily verified that GGT = I and therefore the above equations reduce to:
~ − 2ω̃
~ T JΛω̃
~ − 2ω̃JGω
~ T
V̇ = α~qeT ω̃ 2
n (qe − [1 0 0 0] ) (36)
T
Expanding the above equation using G matrix from Eq.(30), we can get G(qe − [1 0 0 0] ) = ~qe
(Note that G(q)q = ~03×1 ). Finally using the assumption that α = 2Jωn2 , we get
~ − 2ω̃
V̇ = α~qeT ω̃ ~ T JΛω̃
~ − 2ω̃Jω
~ n2 ~qe
~ 1 ω̃
= −ω̃Γ ~ (37)
where Γ1 = 2JΛ. Since the above expression is negative semi definite, we can conclude that V̇ is
negative semi-definite. By differentiating Eq.(37) and using boundedness of input signals through
control law, it can easily be shown that V̈ is bounded and thus V̇ is uniformly continuous. Therefore
~˙ d , ω
It can also be shown [7] using the boundedness of ω ~¨ d and using the global asymptotically
~ − ωn2 ~qe
= −2ζωn ω̃ (39)
13
where the steps are repeated as in derivation of V̇ . The above equation can be rearranged as
~˙ − 2Λω̃||
||ωn2 ~qe || = || − ω̃ ~˙ + ||2Λω̃||
~ ≤ ||ω̃|| ~ (40)
Since every term on right hand side goes to zero, it follows that ||~qe || → 0. This implies that
qeo → ±1. The asymptotic stability for qe0 = 1 can be achieved by choosing a proper value of
α so that the basin of attraction for given initial error quaternion is large and does not include
~ 0 )). For further analysis, consider an equivalent form of the above Lya-
the set (qe (t0 )qe0 =−1 , ω̃(t
1 ~T ~
punov function as V = 2(1 − qe0 ) + 2α ω̃ J ω̃. For qe0 6= −1, we can always choose α such that
~
V (qe (t), ω̃(t)) ~ 0 )) < V ([−1 0 0 0]T , ~0) ≤ V ([−1 0 0 0]T , ω̃(t
< V (qe (t0 ), ω̃(t ~ 0 ))
and hence qe (t) does not go to [−1 0 0 0]. The system is therefore almost global asymptotically
stable for this choice of α. Note that for the sake of simplicity in mathematical proof, the gain
matrices ζ and ωn have been assumed to be multiples of Identity matrix. However, the verification
of results in simulation and in experiment has been done with dissimilar diagonal entries also. This
V. Trajectory Tracking
This section develops a Nonlinear Dynamic Inversion(NDI) [18, 19] based controller for the
quadrotor. Unlike a fixed-pitch quadrotor, the controller of a variable pitch quadrotor has a wider
range of actuation to choose from, since negative thrust can also be generated. This increases the
range of feasible trajectories with higher accelerations than was possible before. However, the rotor
dynamics complexity also increases and it does not allow us to directly allocate the control input
from the moment requirements due to nonlinearities in the yawing moment term (Eq.(23)) and
the fact that CT does not remain constant for variable pitch quadrotors. We therefore propose a
controller with one outer and one middle layer loop for position and attitude control, like most
other present controllers have, and an additional third inner loop to dynamically allocate control
to determine blade pitch angles of individual rotors. Note that the first two loops for fixed-pitch
and variable pitch quadrotor largely remain the same. The following discussion thus holds valid for
14
both of them and any point of difference will be mentioned at the appropriate place.
A. Outer Loop
Since the quadrotors are differentially flat [3], the four flat outputs, which are three spatial
positions and the yaw angle, together completely determine the required four thrust command for
rotors. Let ~rd be the desired quadrotor position in the inertial frame and ~e = ~r − ~rd be the error
in position. In accordance with the NDI methodology, we choose second order error stabilizing
where ζ and ωn are design matrices. Using the fact that the only forces that act on quadrotor are
net thrust force and gravity, the above equation can be used to compute the desired attitude and
net thrust T .
Td = m|~r¨ − ~g | (43)
where Td is the desired thrust, ~g = [0 0 g] and we have used the fact that only force acting on
quadrotor besides the gravitational force is the rotor thrust. The desired quaternion now is the one
that relates the desired thrust in body and inertial frame. Following on similar lines to work done
where qd0 is the desired quaternion that orients the thrust vector with the desired inertial frame
force. It is equal to the minimum angle rotation between the two unit vectors F̂ i and F̂ b given by
[20]:
b i
1 1 + F̂ · F̂
qd0 = q
(45)
b i
2(1 + F̂ · F̂ ) b i
F̂ × F̂
where ||F~ b || = ||F~ i || = T . Note that qd0 takes into account only the roll and pitch angles since any
arbitrary yaw motion would still align the vectors in body and inertial frame. Also, F̂ b = [0 0 ± 1]
15
depending on the direction of thrust vector. In the case of fixed-pitch quadrotor, we have only
one direction and hence F̂ b = [0 0 − 1]. However in case of variable pitch quadrotor we choose the
direction of the thrust vector so that given the current orientation, the thrust has largest component
along the desired force F~ i . Also, note that due to dual covering of attitude space, that is, since q
and −q represent the same quaternion, there can be a discontinuity in the control law. Therefore we
perform a check so that current time step quaternion is closest to the previous time step quaternion,
that is, qTdt−1 qdt ≥ 0. Finally since the desired yaw angle is given as input from trajectory generation
algorithm, the desired quaternion can be obtained by complementing qd0 with ψd in following way
[8]:
B. Middle Loop
The output of the outer loop is passed to the attitude controller described in Section IV. The
required moment can now be obtained from Eq.(12). Note that the desired angular velocity rate
required in the attitude controller can be obtained numerically from desired attitude history. We
follow the same procedure as done by Cutler [8] and hence omit it here.
C. Inner Loop
In this control allocation loop, we obtain the desired thrust coefficients. Note that unlike the
fixed-pitch quadrotor, the CT s do not remain constant and hence the matrix which converts net
thrust and moments to rotor speeds, and which has been used by most of the present literature is
not valid.
Due to nonlinearities involved in the expression for yawing moment, CTi cannot be obtained
explicitly. In order to perform this operation efficiently, we propose an additional loop that computes
h i
desired rate of change of CTi , which we call the virtual control input U = ĊT1 ĊT2 ĊT3 ĊT4
that drives [T l m n] to [Td ld md nd ]. We can formulate this using Eqs.(20-23) however we would
need rate of change of thrust and moments. To this end, we again choose a second order stable
error dynamics in terms of rate of change of angular acceleration for control input synthesis. The
16
assumption, with same reasoning as the much followed approach of position and attitude loop, is
that the inner loop dynamics are fast enough so that the middle loop stability is ensured.
~¨ = ω
ω ~¨ dB + 2ζCA ωnCA (ω
~˙ dB − ω̇)
˙ + ωnCA ωnT (~
CA
ωdB − ω
~) (47)
~˙ dB are the outputs of the middle and outer loop. For simplicity, we take w
~ dB and w
where w ~¨dB to be
zero. The moment rate is now obtained by taking time derivative of Eq.(12)
~˙ = Jω
M ~¨ + ω
~˙ × J~ ~˙
~ × Jω
ω+ω (48)
For thrust derivative we choose first order error dynamics with a gain kp > 0 as
Ṫ = kp (Td − T ) (49)
where Td is obtained from position control loop. Using Eqs.(48) and (49), and taking derivative of
Once the virtual input U is obtained in the above way, it is integrated with the system dynamics
In this section, we present numerical results to show the effectiveness of the proposed algorithm.
The performance is demonstrated by three examples. First, we show results for attitude tracking by
taking example of a sample satellite attitude history. Next, we show results for trajectory tracking
of a fixed-pitch fixed pitch quadrotor. Finally to demonstrate the extended flight regime associated
17
1
Desired
Actual
0
0
q
−1
0 2 4 6 8 10 12 14 16 18 20
Time(s)
1
Desired
Actual
1
0
q
−1
0 2 4 6 8 10 12 14 16 18 20
Time (s)
1
Desired
Actual
2
0
q
−1
0 2 4 6 8 10 12 14 16 18 20
Time (s)
2
Desired
Actual
3
0
q
−2
0 2 4 6 8 10 12 14 16 18 20
Time (s)
First, the capability of the attitude controller is demonstrated by tracking a sample attitude
history. The following angular velocity is taken from work by Costic et al. [12]
2 2
0.3 cos(t)(1 − e−0.01t ) + [0.08π + 0.006 sin(t)]te−0.01t
2
2
wd (t) = 0.3 cos(t)(1 − e
−0.01t
) + [0.08π + 0.006 sin(t)]te −0.01t
−0.01t2 −0.01t2
0.3 cos(t)(1 − e ) + [0.08π + 0.006 sin(t)]te
The initial quaternion is chosen as qt=0 = [0.94846 0.1826 0.1826 0.1826]T and the desired quaternion
history is obtained from above angular velocity and taking qdt=0 as [1 0 0 0]T . The values of gain
matrices is chosen such that ζi = 0.3 and ωn = diag(0.5, 2, 21.5). Fig.2 shows the desired and actual
quaternion trajectory and Fig.3 shows the desired and actual angular velocity. It can be seen that
both the desired attitude and angular velocity is achieved within 6 seconds.Hence, the proposed
18
2 Desired
Actual
wx (rad/s)
1
−1
0 2 4 6 8 10 12 14 16 18 20
Time (s)
2 Desired
Actual
wy (rad/s)
−1
0 2 4 6 8 10 12 14 16 18 20
Time (s)
2 Desired
Actual
wz (rad/s)
−1
0 2 4 6 8 10 12 14 16 18 20
Time (s)
We demonstrate trajectory tracking for a fixed-pitch quadrotor using spiral trajectory shown
below:
sin(πt/2)
2
Xd =
cos(πt/2) (51)
2
t
the gain matrices are chosen as ζi = 0.08, ωn = diag(2, 8, 8, 6) for the attitude loop and ζpi = 0.1
and ωpn = 1. The initial state is ~rt=0 = (0 0 0)T , ~r˙ = (0 0 0)T , q = (1 0 0 0)T and ω
~ = (0 0 0)T . The
time step chosen for simulation is 0.001s and the position loop is run at 100 Hz while the attitude
loop is run at 1000Hz. Fig.4 shows the desired and actual position of the quadrotor as a function of
time. Fig.7a gives a 3 dimensional visualization of the same path. Fig.5 shows Euler angle variation
just for better understanding as they are more intuitive and gives a better idea of orientation at
any point of time. Fig.6 shows the quaternion variations, which are the actual mode or representing
attitude in our work. Finally, Fig.7b shows the thrust variation with time. From above plots, it
is clear that the proposed controller is able to track the desired trajectory effectively. The rate of
19
1
Desired
0.5 Actual
X (m)
0
−0.5
−1
0 5 10 15 20 25 30 35 40 45 50
Time (s)
1
Desired
0.5 Actual
Y (m)
0
−0.5
−1
0 5 10 15 20 25 30 35 40 45 50
Time (s)
60
Desired
Actual
40
Z (m)
20
0
0 5 10 15 20 25 30 35 40 45 50
Time (s)
30
ψ (degrees)
20
10
0
0 5 10 15 20 25 30 35 40 45 50
Time (s)
10
5
φ (degrees)
−5
−10
0 5 10 15 20 25 30 35 40 45 50
Time (s)
20
10
θ (degrees)
−10
−20
0 5 10 15 20 25 30 35 40 45 50
Time (s)
convergence is a matter of tuning and higher gains can be chosen for faster tracking.
The nonlinear control allocation methodology [9] for variable pitch actuation is adopted in this
example to demonstrate the working of this new vehicle. Since the position and attitude controller
remains the same as for a fixed-pitch quadrotor, we take this opportunity to present a special but
simple maneuver not possible in fixed-pitch quadrotors. The output of the attitude controller is fed
20
1
Desired
Actual
q0
0.98
0.96
0 5 10 15 20 25 30 35 40 45 50
Time (s)
0.2
Desired
Actual
q1
−0.2
0 5 10 15 20 25 30 35 40 45 50
Time (s)
0.1
Desired
Actual
q2
−0.1
0 5 10 15 20 25 30 35 40 45 50
Time (s)
0.4
Desired
Actual
q3
0.2
0
0 5 10 15 20 25 30 35 40 45 50
Time (s)
5.4
5.3
5.2
35
Actual
30 Desired 5.1
25
5
Thrust (N)
20
Z (m)
4.9
15
10 4.8
5
4.7
0
1
4.6
0.5 1
0.8
0.6 4.5
0 0.4
0.2
0
−0.5 −0.2
−0.4 4.4
−0.6 0 5 10 15 20 25 30 35 40 45 50
−1 −0.8
Y (m) X (m) Time (s)
(a) 3D Visualization of Quadrotor spiral path during (b) Quadrotor thrust as function of time
into the control allocation loop to achieve the desired thrust and moments for tracking.
The quadrotor is given a step input in the z direction. As already mentioned in Section III,
the positive Z is chosen downwards. It is observed in the results that the high gains result in large
21
Parameter Value Parameter Value Parameter Value Parameter Value
positive acceleration being demanded in the along the positive Z. This is achieved through creating
negative thrust. The various parameters chosen for this simulation are given in Table.1.
Fig.9 shows the trajectory of the quadrotor. Fig.8a shows the thrust variation. Note that
owing to the large initial error in position and due to the choice of gains, large acceleration is
demanded initially in the downward direction which is achieved by generating negative thrust.
After it reaches its designated point, the thrust comes back again to the hover value. Fig.8b shows
the corresponding acceleration of the quadrotor. The maximum acceleration achieved is about 20
m/s2 where 9.81 m/s2 is the contribution from gravity and rest is from rotors. Thus we have
achieved greater than g acceleration with quadrotor being in upright position. This demonstrates
the increased control bandwidth associated with variable pitch quadrotors. Finally, Fig.10 shows
the CT variation for individual rotors and a flight regime not achievable by fixed-pitch quadrotors.
Note that as mentioned previously, positive values correspond to thrust generation in the upward
body direction while negative values correspond to the thrust along downward body direction.
A large acceleration may result in a high value of advanced ratio seen by the propellors which
may lead to loss of thrust. But as the acceleration is only greater than g for a short duration (<0.5s),
speeds in excess of 3 m/s are not achieved. This restricts the advanced ratio to lower values. Also
thrust-loss associated with large deceleration maneuvers is not experimentally reported by Cutler
22
10 20
15
5 10
A (m/s2)
Thrust (N)
z
0 0
−5
−5 −10
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time (s) Time (s)
(a) Quadrotor thrust variation with time (b) Quadrotor achieved vertical acceleration
1
Desired
0.5 Actual
X (m)
−0.5
−1
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time (s)
1
Desired
0.5 Actual
Y (m)
−0.5
−1
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time (s)
8
Desired
6 Actual
Z (m)
0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
Time (s)
In this section, we discuss the experimental results using the proposed controller. The details
of experimental setup followed by results of attitude and position tracking are presented.
23
−3 −3
x 10 x 10
8 8
6 6
4 4
T1
CT2
C 2 2
0 0
−2 −2
−4 −4
0 1 2 3 4 5 0 1 2 3 4 5
Time (s) Time (s)
−3 −3
x 10 x 10
8 8
6 6
4 4
T3
CT4
2 2
C
0 0
−2 −2
−4 −4
0 1 2 3 4 5 0 1 2 3 4 5
Time (s) Time (s)
Fig. 10: Thrust coefficient variation for the four rotors of variable pitch quadrotor
A. Hardware
The proposed control algorithm is implemented on a commercially available fixed pitch H-King
Color 250 Class quadrotor shown in Fig 12a. We use PX4 [21] opensource codebase running on Pix-
hawk autopilot hardware. Pixhawk uses ST Micro L3GD20H 16 bit gyroscope, ST Micro LSM303D
sensors. These sensors are used in a non-linear filter to estimate the attitude of the quadrotor.The
codebase uses a PID controller for attitude which is totally replaced with our quaternion based
controller. The attitude loop is run as a priority thread with the actuation commands being given
to the speed controllers via a rail. The position loop is run slower and processes the estimated
position of the quadrotor to pass the computed attitude setpoint to the attitude controller. A
915MHz telemetry module is used to remotely communicate with the ground station. An FrSky
X9D transmitter is used as the radio controller with FrSky X8R receiver placed onboard the vehicle
and paired with the transmitter. The overall takeoff weight for the quadcopter is 630 gms. Moment
of Inertia along Ixx = 2.2686E-3 kgm2 , Iyy =2.24557E-3 kgm2 , Izz =3.19819E-3 kgm2 . The cross
24
*
Controller Attitude Position
Value 0.85 0.86 0.86 0.86 10.65 10.65 11 13 0.45 0.45 0.7 1 1 2
Table 2: Experimentally obtained tuning parameters for Attitude and Position Controller
moment of inertia are assumed to be zero as it is a nearly symmetrical structure. The experiments
are performed outdoor on the IIT Kanpur airstrip with wind speed of around 3m/s. The values of ζ
and ωn are tuned for both position and attitude controllers so as to achieve an acceptable tracking
performance.
The quadrotor is flown in manual mode in which the pilot, generates the (T ,θ , φ , ψ) as control
inputs using the transmitter. The control input was converted to a quaternion representation (qd ).
Although, there are no specific guidelines to tune the frequency and damping ratio in the controller,
we first try to obtain nominal values for the parameters involved (decided by the response and
sensitivity of the controller as observed virtually) followed by the damping part(ζ). The system
is able to track attitude commands with no position constraints. This is verified with a series of
test flights with manual radio controller inputs. One such flight data is shown in Fig.11. The gain
values are tabulated in Table 2. Small roll oscillations are given as input to showcase tracking.
Note that in contrast to standard PD controllers based on Euler angles which have 6 parameters
to tune, we have 8 parameters to tune corresponding to the 4 quaternion components. The tuning
is also less intuitive but we avoid the singularity problem and once tuned the controller is more
efficient computationally. For small angles, the vector part of the quaternion resembles the roll,
pitch and yaw responses of the quadrotor however, the scalar part still has an effect coupled with
all three rotational degrees of freedom. We observed that properly tuning the scalar part (q0 ) helps
in smoothing the response of the controller and reducing the tweaky response.
25
Fig. 11: Attitude controller experimental results for a fixed pitch quadrotor
The position controller simulated earlier is validated by performing waypoint navigation. The
desired trajectory consists of take-off to an altitude and then reaching 4 waypoints defining a square
along straight lines. The waypoints are input through the ground control station (QGroundControl).
The computed desired attitude is passed to the attitude controller tuned earlier. The yaw angle
is specified so that the quadrotor always faces the next waypoint. The tuning is performed in a
similar fashion to the attitude controller by performing a series of flight tests. The system is able
to successfully track the desired trajectory and the results are shown in Fig.12b. Fig.12c shows the
XY trajectory following and its convergence over time. Fig.12d shows the yaw angle tracking. The
gain values are tabulated in Table.2. Note that due to the presence of 3 m/s wind towards South,
the quadrotor has a tendency to deviate from its trajectory but our implemented controller corrects
for it eventually.
26
Actual Path
5 Desired Path
Waypoints
Z (m)
2
0
25
20
35
15 30
25
10 20
5 15
10
0 5
0
−5 −5
Y (m) X (m)
(a) Fixed pitch quadrotor used for experiments (b) Waypoint Navigation in Mission mode
300
Waypoint 4
Actual
N Setpoint
250
W E Actual Path
20
Desired Path
S 200 Waypoint 3
Wind Direction
15
ψ (degrees)
150
Y (m)
10
Waypoint 2
100
5
50
Waypoint 1
0
0
Take−off
−5 0 5 10 15 20 25 30 35
X (m)
−50
2 2.1 2.2 2.3 2.4 2.5 2.6 2.7
timestamp 8
x 10
(c) XY trajectory tracking in Waypoint Navigation (d) Yaw angle tracking in Waypoint Navigation
Fig. 12: Position controller experimental results for a fixed pitch quadrotor
VIII. Conclusions
In this paper, we have presented theory, implementation, and experimental results for a
novel second order stable error dynamics controller using a fully quaternion based approach. The
suitability of the generic controller for highly nonlinear systems like quadrotors and satellites is
examined by designing controllers that efficiently track the desired trajectories. The controller
enables the exploitation of highly maneuver systems like variable pitch quadrotors which are
capable of generating negative thrust. It also avoids the problem of singularity often encountered
in designing controllers for satellites with the added benefit of a second order system generating
smoother control inputs. A framework for designing attitude controllers for rigid bodies and
27
position controller for quadrotors is discussed and numerical simulation results are presented. The
controllers are validated through a series of flight tests performed on quadrotor platform. The
Acknowledgments
The authors would like to thank Mahathi Bhargavapuria, Graduate student, Department of
Electrical Engineering, Indian Institute of Technology for his invaluable support and inputs during
References
[1] Choset, H. M., Principles of robot motion: theory, algorithms, and implementation, MIT press, 2005.
Chapter 3.
[2] Lupashin, S., Schöllig, A., Sherback, M., and D’Andrea, R., “A simple learning strategy for high-speed
quadrocopter multi-flips,” in “Robotics and Automation (ICRA), 2010 IEEE International Conference
[3] Mellinger, D., Michael, N., and Kumar, V., “Trajectory generation and control for precise aggressive
maneuvers with quadrotors,” The International Journal of Robotics Research, Vol. 31, No. 5, 2012, pp.
664–674. DOI:10.1177/0278364911434236.
[4] Fresk, E. and Nikolakopoulos, G., “Full quaternion based attitude control for a quadrotor,” in “Control
Conference (ECC), 2013 European,” IEEE, 2013, pp. 3864–3869. ISBN: 978-3-033-03962-9, INSPEC:
13936305.
[5] Tayebi, A. and McGilvray, S., “Attitude stabilization of a four-rotor aerial robot,” in “Deci-
sion and Control, 2004. CDC. 43rd IEEE Conference on,” Ieee, Vol. 2, 2004, pp. 1216–1221.
DOI:10.1109/CDC.2004.1430207.
[6] Xian, B., Diao, C., Zhao, B., and Zhang, Y., “Nonlinear robust output feedback tracking control of
a quadrotor UAV using quaternion representation,” Nonlinear Dynamics, Vol. 79, No. 4, 2015, pp.
2735–2752. DOI:10.1007/s11071-014-1843-x.
[7] Bangura, M., Lim, H., Kim, H. J., and Mahony, R., “An open-source implementation of a unit quater-
nion based attitude and trajectory tracking for quadrotors,” in “Australasian Conference on Robotics
28
[8] Cutler, M. and How, J. P., “Analysis and control of a variable-pitch quadrotor for agile flight,”
Journal of Dynamic Systems, Measurement, and Control, Vol. 137, No. 10, 2015, p. 101002. DOI:
10.1115/1.4030676.
[9] Gupta, N., Kothari, M., et al., “Flight dynamics and nonlinear control design for variable-
pitch quadrotors,” in “American Control Conference (ACC), 2016,” IEEE, 2016, pp. 3150–3155.
DOI:10.1109/ACC.2016.7525402.
[10] Leishman, G. J., Principles of helicopter aerodynamics with CD extra, Cambridge university press,
2006. Chapter 3.
[11] Borenstein, J., “The hoverbot, an electrically powered flying robot,” Ann Arbor, Vol. 1001, 1992, pp.
[12] Costic, B., Dawson, D., De Queiroz, M., and Kapila, V., “Quaternion-based adaptive attitude tracking
controller without velocity measurements,” Journal of Guidance, Control, and Dynamics, Vol. 24, No. 6,
[13] Diebel, J., “Representing attitude: Euler angles, unit quaternions, and rotation vectors,” Matrix, Vol. 58,
[15] Sreenath, K., Lee, T., and Kumar, V., “Geometric control and differential flatness of a quadrotor UAV
with a cable-suspended load,” in “Decision and Control (CDC), 2013 IEEE 52nd Annual Conference
[16] Slotine, J.-J. E., Li, W., et al., Applied nonlinear control, Vol. 199, Prentice hall Englewood Cliffs, NJ,
1991. Chapter 6.
[17] Khalil, H. K., Noninear Systems, Prentice-Hall, New Jersey, 1996. Chapter 8.
[18] Enns, D., Bugajski, D., Hendrick, R., and Stein, G., “Dynamic inversion: an evolving methodology for
flight control design,” International Journal of control, Vol. 59, No. 1, 1994, pp. 71–91.
[19] Prabhakaran, B., Kothari, M., et al., “Nonlinear control design for quadrotors,” in “Computational
Intelligence: Theories, Applications and Future Directions (WCI), 2015 IEEE Workshop on,” IEEE,
[20] Markley, F. L., “Fast quaternion attitude estimation from two vector measurements,” Journal of Guid-
ance, Control, and Dynamics, Vol. 25, No. 2, 2002, pp. 411–414. DOI: 10.2514/2.4897.
[21] Meier, L., Honegger, D., and Pollefeys, M., “PX4: A node-based multithreaded open source robotics
framework for deeply embedded platforms,” in “Robotics and Automation (ICRA), 2015 IEEE Inter-
29