fused angles: a representation of body orientation for balancepallgeuer/fusedanglesmanual.pdf ·...

19
Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and Sven Behnke Abstract— The parameterisation of rotations in three dimen- sional Euclidean space is an area of applied mathematics that has long been studied, dating back to the original works of Euler in the 18 th century. As such, many ways of parameterising a rotation have been developed over the years. Motivated by the task of representing the orientation of a balancing body, the fused angles parameterisation is developed and introduced in this paper. This novel representation is carefully defined both mathematically and geometrically, and thoroughly investigated in terms of the properties it possesses, and how it relates to other existing representations. A second intermediate representation, tilt angles, is also introduced as a natural consequence thereof. I. I NTRODUCTION Numerous ways of representing a rotation in three- dimensional Euclidean space have been developed and re- fined over the years. Many of these representations, also re- ferred to as parameterisations, arose naturally from classical mathematics and have found widespread use in areas such as physics, engineering and robotics. Prominent examples of such representations include rotation matrices, quaternions and Euler angles. In this paper, a new parameterisation of the manifold of all three-dimensional rotations is proposed. This parameterisation, referred to as fused angles, was motivated by the analysis and control of the balance of bodies in 3D, and the shortcomings of the various existing rotation representations to describe the state of balance in an intuitive and problem-relevant way. More specifically, the advent of fused angles was to address the problem of representing the orientation of a body in an environment where there is a clear notion of what is ‘up’, defined implicitly, for example, through the presence of gravity. An orientation is just a rotation relative to some global fixed frame however, so fused angles can equally be used to represent any arbitrary three- dimensional rotation, much like Euler angles, for instance, can be used for both purposes. The shortcomings of Euler angles, however, that make them unsuitable for this balance- inspired task are discussed in detail in Section II-D. When analysing the balance state of a body, such as for example of a humanoid robot, it is very helpful to be able to work with a parameterisation of the orientation that yields information about the components of the rotation within each of the three major planes, i.e. within the xy, yz and xz planes (see Fig. 1). These components of rotation can be con- ceptually thought of as a way of simultaneously quantifying the ‘amount of rotation’ about the individual axes. It is desir- able for these components to each offer a useful geometric All authors are with the Autonomous Intelligent Systems (AIS) Group, Computer Science Institute VI, University of Bonn, Germany. Email: [email protected]. This work was partially funded by grant BE 2556/10 of the German Research Foundation (DFG). yz xz xy Fig. 1. Fused angles are a way of decomposing a rotation into three concurrently acting components, in such a way that it gives insight into how rotated a body is in each of the three major planes. interpretation, and behave intuitively throughout the rotation space, most critically not sacrificing axisymmetry within the horizontal xy plane by the introduction of a clear sequential order of rotations. The notion of fusing individual rotation components in a way that avoids such an order motivated the term ‘fused angles’. Quaternions, a common choice of parameterisation in computational environments, clearly do not address these requirements, as elucidated in Section II-C. The fused angles rotation representation has to date found a number of uses. Most recently in work published by the same authors, an attitude estimator was formulated that internally relied on the concept of fused angles [1]. The open source ROS software for the NimbRo-OP humanoid robot [2], developed by the University of Bonn, also relies on the use of fused angles, most notably in the areas of state estimation and walking. Furthermore, a Matlab and Octave library [3] targeted at the numerical and computa- tional handling of all manners of three-dimensional rotation representations, including fused angles, has been released. 1 This library is intended to serve as a common reference for the implementation in other programming languages of a wide range of conversion and computation functions. It is seen by the authors as a test bed to support the development of new rotation-related algorithms. The convention that the global z-axis points in the ‘up’ direction relative to the environment is used in this paper. As mentioned previously, this accepted ‘up’ direction will almost always be defined as the antipodal direction of gravity. This ensures that definitions such as that of fused yaw make 1 https://github.com/AIS-Bonn/matlab_octave_rotations_lib Also C++ Library: https://github.com/AIS-Bonn/rot_conv_lib

Upload: others

Post on 18-Jun-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

Fused Angles: A Representation of Body Orientation for Balance

Philipp Allgeuer and Sven Behnke

Abstract— The parameterisation of rotations in three dimen-sional Euclidean space is an area of applied mathematics thathas long been studied, dating back to the original works of Eulerin the 18th century. As such, many ways of parameterising arotation have been developed over the years. Motivated by thetask of representing the orientation of a balancing body, thefused angles parameterisation is developed and introduced inthis paper. This novel representation is carefully defined bothmathematically and geometrically, and thoroughly investigatedin terms of the properties it possesses, and how it relates to otherexisting representations. A second intermediate representation,tilt angles, is also introduced as a natural consequence thereof.

I. INTRODUCTION

Numerous ways of representing a rotation in three-dimensional Euclidean space have been developed and re-fined over the years. Many of these representations, also re-ferred to as parameterisations, arose naturally from classicalmathematics and have found widespread use in areas suchas physics, engineering and robotics. Prominent examples ofsuch representations include rotation matrices, quaternionsand Euler angles. In this paper, a new parameterisation of themanifold of all three-dimensional rotations is proposed. Thisparameterisation, referred to as fused angles, was motivatedby the analysis and control of the balance of bodies in3D, and the shortcomings of the various existing rotationrepresentations to describe the state of balance in an intuitiveand problem-relevant way. More specifically, the advent offused angles was to address the problem of representing theorientation of a body in an environment where there is aclear notion of what is ‘up’, defined implicitly, for example,through the presence of gravity. An orientation is just arotation relative to some global fixed frame however, so fusedangles can equally be used to represent any arbitrary three-dimensional rotation, much like Euler angles, for instance,can be used for both purposes. The shortcomings of Eulerangles, however, that make them unsuitable for this balance-inspired task are discussed in detail in Section II-D.

When analysing the balance state of a body, such as forexample of a humanoid robot, it is very helpful to be able towork with a parameterisation of the orientation that yieldsinformation about the components of the rotation within eachof the three major planes, i.e. within the xy, yz and xzplanes (see Fig. 1). These components of rotation can be con-ceptually thought of as a way of simultaneously quantifyingthe ‘amount of rotation’ about the individual axes. It is desir-able for these components to each offer a useful geometric

All authors are with the Autonomous Intelligent Systems (AIS) Group,Computer Science Institute VI, University of Bonn, Germany. Email:[email protected]. This work was partially fundedby grant BE 2556/10 of the German Research Foundation (DFG).

yz

xz

xy

Fig. 1. Fused angles are a way of decomposing a rotation into threeconcurrently acting components, in such a way that it gives insight intohow rotated a body is in each of the three major planes.

interpretation, and behave intuitively throughout the rotationspace, most critically not sacrificing axisymmetry within thehorizontal xy plane by the introduction of a clear sequentialorder of rotations. The notion of fusing individual rotationcomponents in a way that avoids such an order motivatedthe term ‘fused angles’. Quaternions, a common choice ofparameterisation in computational environments, clearly donot address these requirements, as elucidated in Section II-C.

The fused angles rotation representation has to date founda number of uses. Most recently in work published bythe same authors, an attitude estimator was formulated thatinternally relied on the concept of fused angles [1]. Theopen source ROS software for the NimbRo-OP humanoidrobot [2], developed by the University of Bonn, also relieson the use of fused angles, most notably in the areas ofstate estimation and walking. Furthermore, a Matlab andOctave library [3] targeted at the numerical and computa-tional handling of all manners of three-dimensional rotationrepresentations, including fused angles, has been released.1

This library is intended to serve as a common reference forthe implementation in other programming languages of awide range of conversion and computation functions. It isseen by the authors as a test bed to support the developmentof new rotation-related algorithms.

The convention that the global z-axis points in the ‘up’direction relative to the environment is used in this paper.As mentioned previously, this accepted ‘up’ direction willalmost always be defined as the antipodal direction of gravity.This ensures that definitions such as that of fused yaw make

1 https://github.com/AIS-Bonn/matlab_octave_rotations_libAlso C++ Library: https://github.com/AIS-Bonn/rot_conv_lib

Page 2: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

terminological sense in consideration of the true rotationof a body relative to its environment. All derived formulasand results could easily be rewritten using an alternativeconvention if this were to be desired.

The contribution of this paper lies in the introduction ofthe novel concept of fused angles for the representationof rotations. A further contribution is the concept of tiltangles (see Section III-A), an intermediary representationthat emerges naturally from the derivation of the former.

II. REVIEW OF EXISTING ROTATION REPRESENTATIONS

Many ways of representing 3D rotations in terms of afinite set of parameters exist. Different representations havedifferent advantages and disadvantages, and which represen-tation is suitable for a particular application depends on awide range of considerations. Such considerations include:• Ease of geometric interpretation, in particular in a form

that is relevant to the particular problem,• The range of singularity-free behaviour,• Computational efficiency in terms of common opera-

tions such as rotation composition and vector rotation,• Mathematical convenience, in terms of numeric and

algebraic complexity and manipulability, and• Algorithmic convenience, in the sense of a represen-

tation potentially possessing properties that can conve-niently be exploited for a particular algorithm.

A wide range of existing rotation representations are re-viewed in this section as a basis for comparison. Due to thedimensionality of the space of 3D rotations, a minimum ofthree parameters is required for any such representation. Arepresentation with exactly three parameters is referred to asminimal, while other representations with a greater numberof parameters are referred to as redundant.

A. Rotation MatricesA rotation can be represented as a linear transformation

of coordinate frame basis vectors, expressed in the form ofan orthogonal matrix of unit determinant. Due to the stronglink between such transformation matrices and the theory ofdirection cosines, the name Direction Cosine Matrix is alsosometimes used. The space of all rotation matrices is calledthe special orthogonal group SO(3), and is defined as

SO(3) = R ∈ R3×3 : RTR = I, det(R) = 1. (1)

Rotation of a vector v ∈ R3 by a rotation matrix is given bymatrix multiplication. For a rotation from coordinate frameG to B, we have that

RGB =[

xG B yG B zG B

]=[

xB G yB G zB G

]T, (2)

where yG B , for example, is the column vector correspondingto the y-axis of frame B, expressed in the coordinates offrame G. The notation RGB refers to the relative rotationfrom G to B. With nine parameters, rotation matrices areclearly a redundant parameterisation of the rotation space.They are quite useful in that they are free of singularitiesand trivially expose the basis vectors of the fixed and rotatedframes, but for many tasks they are not as computationallyand numerically suitable as other representations.

B. Axis-Angle and Rotation Vector Representations

By Euler’s rotation theorem [4], every rotation in the three-dimensional Euclidean space R3 can be expressed as a singlerotation about some axis. As such, each rotation can bemapped to a pair (u, θ) ∈ S2 × R, where u is a unit vectorcorresponding to the axis of rotation, and θ is the magnitudeof the rotation. Note that S2 = v ∈ R3 : ‖v‖ = 1, the 2-sphere, is the set of all unit vectors in R3. A closely relatedconcept is that of the rotation vector, given by u = θu,which encodes the angle of rotation as the magnitude ofthe vector defining the rotation axis. Both the axis-angleand rotation vector representations suffer from a generalimpracticality of mathematical and numerical manipulation.For example, no formula for rotation composition exists thatis more direct than converting to quaternions and back. TheSimultaneous Orthogonal Rotations Angle (SORA) vector,a slight reformulation of the rotation vector concept interms of virtual angular velocities and virtual time, waspresented by Tomažic and Stancin in [5]. This formulationsuffers from drawbacks similar to those of the rotation vectorrepresentation, which includes a discontinuity at rotations of180, and a general lack of geometric intuitiveness.

C. Quaternions

The set of all quaternions H, and the subset Q thereof ofall quaternions that represent pure rotations, are defined as

H = q = (q0,q) ≡ (w, x, y, z) ∈ R4,Q = q ∈ H : ‖q‖ = 1. (3)

Quaternion rotations can be related to the axis-angle repre-sentation, and thereby visualised to some degree, using

q = (q0,q) =(cos θ2 , u sin θ

2

)∈ Q, (4)

where (u, θ) ∈ S2×R is any axis-angle rotation pair, and q isthe equivalent quaternion rotation. The use of quaternions toexpress rotations generally allows for very computationallyefficient calculations, and is grounded by the well-establishedfield of quaternion mathematics. A crucial advantage of thequaternion representation is that it is free of singularities. Onthe other hand however, it is not a one-to-one mapping ofthe special orthogonal group, as q and −q both correspondto the same rotation. The redundancy of the parameters alsomeans that the unit magnitude constraint has to explicitlyand sometimes non-trivially be enforced in numerical com-putations. Furthermore, no clear geometric interpretation ofquaternions exists beyond the implicit relation to the axis-angle representation given in (4). For applications related tothe balance of a body, where questions arise such as ‘howrotated’ a body is in total or within a particular major plane,the quaternion representation yields no direct insight.

D. Euler Angles

A step in the right direction of understanding the differentcomponents of a rotation is the notion of Euler angles. In thisrepresentation, the total rotation is split into three individualelemental rotations, each about a particular coordinate frameaxis. The three Euler angles (α, β, γ) describing a rotation

Page 3: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

are the successive magnitudes of these three elemental rota-tions. Many conventions of Euler angles exist, dependingon the order in which the elemental axis rotations arechosen and whether the elemental rotations are taken to beintrinsic (about the rotating coordinate frame) or extrinsic(about the fixed coordinate frame). Extrinsic Euler anglescan easily be mapped to their equivalent intrinsic Eulerangles representations, and so the two types do not exhibitfundamentally different behaviour. If all three coordinateaxes are used in the elemental rotations, the representationis alternatively known as Tait-Bryan angles, and the threeparameters are referred to as yaw, pitch and roll, respectively.Tait-Bryan angles, although promising at first sight, do notsuffice for the representation of the orientation of a body inbalance-related scenarios. The main reasons for this are:• The proximity of the gimbal lock singularity to nor-

mal working ranges, leading to unwanted artefacts dueto increased local parameter sensitivity in a widenedneighbourhood of the singularity,

• The fundamental requirement of an order of elementalrotations, leading to asymmetrical definitions of pitchand roll that do not correspond in behaviour, and

• The asymmetry introduced by the use of a yaw def-inition that depends on the projection of one of thecoordinate axes onto a fixed plane, leading to unintuitivenon-axisymmetric behaviour of the yaw angle.

The first listed point is a problem in real life, if for example abipedal robot falls down, and thereby comes near the Eulerangle singularity. As an example of the last of the listedpoints, consider the intrinsic ZYX Euler angles representa-tion, recalling that the global z-axis points ‘upwards’ (seeSection I). Consider a body in space, assumed to be in itsidentity orientation, and some arbitrary rotation of the bodyrelative to its environment. It would be natural and intuitiveto expect that the yaw of this relative rotation is independentof the chosen definition of the global x and y-axes. This isbecause the true rotation of the body is always the same,regardless of the essentially arbitrary choice of the global xand y-axes, and one would expect a well-defined yaw to be aproperty of the rotation, not the axis convention. This is notthe case for ZYX Euler yaw however, as can be verified bycounterexample with virtually any non-degenerate case. Theyaw component of the fused angles representation, definedin Section III-A, can be proven to satisfy this property.

E. Vectorial Parameterisations

Parameterisations are sometimes developed specifically toexhibit certain properties that can be exploited to increase theefficiency of an algorithm. A class of such generally moremathematical and abstract rotation representations is the fam-ily of vectorial parameterisations. Named examples of theseinclude the Gibbs-Rodrigues parameters [6] and the Wiener-Milenkovic parameters [7], also known as the conformalrotation vector (CRV). Such parameterisations derive frommathematical identities such as the Euler-Rodrigues formula[8], and as such do not in general have any useful geometricinterpretation, and find practical use in only very specific

zB

yB

γ

yA

α

zG, zA

v

ψ

yG

xB

xG

xA

Fig. 2. Definition of the tilt rotation and tilt angles parameters of therotation from G to B. ψ is the fused yaw, γ is the tilt axis angle,α is the tilt angle and v is the tilt axis. The intermediate frame A isconstructed by rotating B such that zB rotates directly onto zG.

applications. Detailed derivations and analyses of vectorialparameterisations can be found in [6] and [7].

III. FUSED ANGLES

Fused angles were motivated by the lack of an existing 3Drotation formalism that naturally deals with the dissolutionof a complete rotation into parameters that are specificallyand geometrically relevant to the balance of a body, and thatdoes not introduce order-based asymmetry in the parameters.None of the representations discussed in Section II satisfythis property. The unwanted artefacts in the existing notionsof yaw (see Section II-D) also led to the need for a moresuitable, stable and axisymmetric definition of yaw.

A. Geometric Definition of Tilt Angles

We begin by defining an intermediate rotation represen-tation, referred to as tilt angles. The tilt angles parameterdefinitions are illustrated in Fig. 2. Note that we follow theconvention that, for example,

zG B =(zG Bx, zG By, zG Bz

)(5)

denotes the unit vector corresponding to the positive z-axisof a frame B, expressed in the coordinates of a frameG. The absence of a coordinate basis qualifier, such asfor example in the notation ‘zB’, implies that a vector is bydefault expressed relative to the global fixed frame.

Let G denote the global fixed frame, defined with theconvention that the global z-axis points upwards in theenvironment, as discussed in Section I. We define B to bethe body-fixed coordinate frame. For an identity orientationof the body, the frames G and B should clearly coincide.

As zG and zB are vectors in R3, a rotation about anaxis perpendicular to both vectors exists that maps zG ontozB . Note that this is a different condition to mapping Gonto B. We choose an axis-angle representation (v, α) (seeSection II-B) of this tilt rotation such that α ∈ [0, π]. The

Page 4: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

vy

−1

φ

zG, zA

+1

h

θ

zB

vx

xB

xA

yA

yB

Fig. 3. Definition of the fused angles parameters (θ, φ, h) that describethe tilt rotation component of the rotation from G to B. A is thesame intermediate frame as from the geometric definition of tilt angles(see Fig. 2). The xG and yG axes are not shown in the figure for visualsimplicity. θ is the fused pitch, φ is the fused roll, h is the hemisphere,vx is the projection of zG onto the yBzB plane, and vy is the projectionof zG onto the xBzB plane. Geometrically it can be seen that (θ, φ, h)depends only on the direction of zG relative to B, that is, zB G.

angle α is referred to as the tilt angle of B, and the vectorv is referred to as the tilt axis of B. We define coordinateframe A to be the frame that results when we apply theinverse of the tilt rotation to B. By definition zA = zG,so it follows that v—and trivially also xA—must lie in thexAyA plane. The angle γ about zA from xA to v (see Fig. 2)is referred to as the tilt axis angle of B. It is easy to seethat the tilt rotation from A to B is completely definedby the parameter pair (γ, α).

We now note that the rotation from G to A is one ofpure yaw, that is, a pure z-rotation, and so define the angleψ about zG from xG to xA (see Fig. 2) as the fused yawof B. It is important to note that the choice of using thex-axes in this definition of yaw is arbitrary, and a similardefinition using the y-axes would be completely equivalent.The complete tilt angles representation of the rotation fromG to B is now defined as

TGB = (ψ, γ, α) ∈ (−π, π]× (−π, π]× [0, π] ≡ T. (6)

The identity tilt angles rotation is given by (0, 0, 0) ∈ T.It can be seen from the method of construction that all

rotations possess a tilt angles representation, although it isnot always necessarily unique. Most notably, when α = 0,the γ parameter can be arbitrary with no effect.

B. Geometric Definition of Fused Angles

To remedy the possible ambiguity in the tilt angles param-eters and work towards a more robust rotation representation,we introduce the concepts of fused pitch and fused roll. Forreference, the relevant fused angles parameter definitions areillustrated in Fig. 3.

Let vx and vy be the projections of the zG vector onto thebody-fixed yBzB and xBzB planes respectively. We definethe fused pitch of B as the angle θ between zG and vx,of sign −sgn

(zB Gx

). By logical completion, the magnitude

of θ is taken to be π2 if vx = 0. We similarly define the

fused roll of B as the angle φ between zG and vy , of signsgn(

zB Gy

). The magnitude of φ is taken to be π

2 if vy = 0.Conceptually, fused pitch and roll can be thought of simplyas the angles between zG and the yBzB and xBzB planesrespectively. Note that this definition of fused pitch and rollis invariant to the entire body-fixed frame B being yawed,as one would expect.

From inspection of the geometric definitions, it can beseen that the fused pitch and roll only uniquely specify atilt rotation up to the z-hemisphere, that is, whether zB andzG are mutually in the same hemisphere or not. To resolvethis ambiguity, the hemisphere of a rotation (see Fig. 3) isdefined as sign

(zB Gz

)≡ sign

(zG Bz

), where we define

sign(x) =

1 if x ≥ 0,

−1 if x < 0.(7)

Note that sign differs to the normal definition of a signfunction in that sign(0) = 1, whereas sgn(0) = 0. Thismodified sign function is used throughout the remainder ofthis paper wherever clear distinction from the normal signfunction is required.

Using the concept of the hemisphere of a rotation, (θ, φ, h)becomes a complete description of the tilt rotation compo-nent of a rotation. As such, together with the fused yaw ψ,the complete fused angles representation of the rotation fromG to B can now be defined as

FGB = (ψ, θ, φ, h)

∈ (−π, π]× [−π2 , π2 ]× [−π2 , π2 ]× −1, 1 ≡ F. (8)

The identity fused angles rotation is given by (0, 0, 0, 1) ∈ F.The (θ, φ, h) triplet in (8) replaces the (γ, α) pair in (6) todefine the tilt rotation component of a general rotation.

It can be observed from the geometric definitions abovethat the tilt rotation depends only on the direction of zGrelative to frame B—that is, only on zB G. This, forexample, means that the bottom row of the rotation matrixRGB (representing the rotation from G to B) can be

completely identified with the tilt rotation component of thatrotation. Interestingly, it can also be seen that the direction ofzG relative to frame B is precisely what an accelerometerattached to the body would measure under the assumption ofquasi-static conditions. In this way, accelerometer measure-ments can easily be mapped to measurements of (θ, φ, h)and/or (γ, α).

C. Mathematical Definition of Fused Angles and Tilt AnglesBased on the given geometric definitions, the following

expressions can be derived as an alternative mathematicaldefinition of the tilt angles tilt rotation parameters:

γ = atan2(− zB Gx, zB Gy

)∈ (−π, π], (9)

α = acos(zB Gz

)∈ [0, π]. (10)

Page 5: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

-2 -1.5 -1 -0.5 0 0.5 1 1.5 2Pitch 3 (rad)

-1.5

-1

-0.5

0

0.5

1

1.5Rol

l?

(rad

)

0.2

0.2

0.4

0.4

0.4

0.6

0.6

0.6

0.8

0.8

0.8

0.81

11

1

1

1

1

1

1.2

1.21.2

1.2

1.2

1.2 1.2

1.2

1.4

1.4

1.4

1.4

1.6

1.6

1.6

1.6

1.8

1.8

1.8

1.8

:2! :

2

:2

! :2

Fig. 4. Level sets of the function fs(θ, φ) = sin2θ+sin2φ, demonstratingthat the sine sum criterion fs(θ, φ) ≤ 1 is equivalent to the simplerinequality |θ| + |φ| ≤ π

2, indicated by the shaded region in the plot. The

shaded region is the domain of (θ, φ) for the fused angles representation.

Similarly, alternative mathematical definitions for the fusedangles tilt rotation parameters can be derived to be

θ = asin(− zB Gx

)∈ [−π2 , π2 ], (11)

φ = asin(zB Gy

)∈ [−π2 , π2 ], (12)

h = sign(zB Gz

)∈ −1, 1. (13)

The analysis for the fused yaw parameter is slightly morecomplex, but with the use of cases one can nonethelessmathematically define it as

ψ =

wrap

(atan2

(zG Bx,− zG By

)− γ)

if α 6= 0,

atan2(xG By, xG Bx

)if α = 0,

(14)

where wrap is a function that wraps an angle to (−π, π].An alternative mathematical definition for fused yaw, namely(36), is presented later in Section IV.

It can be seen from (11–13) and the unit norm conditionthat zB G is given by a well-defined multivariate functionfz : (θ, φ, h) 7→ zB G, described by

zB G =(− sin θ, sinφ, h

√1− sin2 θ − sin2 φ

), (15)

where for obvious reasons we must have sin2 θ+sin2 φ ≤ 1.This inequality is referred to by the authors as the sine sumcriterion, and is precisely equivalent to

|θ|+ |φ| ≤ π2 . (16)

Given that by definition θ, φ ∈ [−π2 , π2 ], this equivalence canbe seen by plotting the level sets of the multivariate function

fs(θ, φ) = sin2 θ + sin2 φ, (17)

and finding the region where fs(θ, φ) ≤ 1. The resultingplot is shown in Fig. 4. The domain of fz is the restrictionof [−π2 , π2 ] × [−π2 , π2 ] × −1, 1 to |θ| + |φ| ≤ π

2 , and theuniversal set of all fused angles, F, is a similar restriction ofF—that is, a restriction by the sine sum criterion.

D. Visualisation of Fused Angles

The fused yaw parameter ψ is best visualised precisely asdefined and illustrated in Fig. 2. The remaining fused anglesparameters, (θ, φ, h), are also well visualised based on theirgeometric definition shown in Fig. 3, but can alternativelybe envisioned as loci of zB G. Fig. 5 shows surface plots ofthe manifolds that are generated by independently taking theimage of fz(θ, φ, h) for constant fused pitch θ, fused roll φand hemisphere h. The surfaces that result can be seen tobe single-ended cones and hemispheres. It is important tonote that the plots are in the body-fixed frame B, andnot in the global fixed frame G. Fig. 5c and Fig. 5fshow how combining specifications of θ, φ and h actsto resolve a unique zB G based on the intersection of thevarious hemisphere and cone loci. The failure of two conesto intersect is precisely equivalent to a violation of the sinesum criterion, and hence an invalid specification of θ andφ. The hemisphere parameter h essentially decides which ofthe two cone intersections is used for zB G.

IV. CONVERSIONS TO OTHER REPRESENTATIONS

Fused angles serve well in the analysis of body orienta-tions, but even so, conversions to other representations are of-ten required for mathematical computations such as rotationcomposition. The equations required for the conversion of thefused angles representation F = (ψ, θ, φ, h) ∈ F to and fromtilt angles, rotation matrix and quaternion representationsare presented in this section. Similar conversions are alsoprovided for the tilt angles representation T = (ψ, γ, α) ∈ T.The proofs of the conversion equations are generally notdifficult, but beyond the scope of this paper.

1) Fused angles↔ Tilt angles: The yaw parameters ψ ofthese two representations are equal, so the conversion fromfused angles to tilt angles is completely summarised by

γ = atan2(sin θ, sinφ), (18)

α = acos(h

√1− sin2 θ − sin2 φ

), (19)

where for numerical computation one may use the identity

1− sin2 θ − sin2 φ ≡ cos(θ + φ) cos(θ − φ). (20)

We interestingly note from (19) that

sin2 θ + sin2 φ = sin2 α. (21)

The conversion from tilt angles to fused angles is given by

θ = asin(sinα sin γ),

φ = asin(sinα cos γ),h =

1 if α ≤ π

2 ,−1 otherwise.

(22)

2) Tilt angles↔ Rotation matrix: Based on the geometricdefinition of tilt angles given in Section III-A, the rotationmatrix equivalent to T = (ψ, γ, α) ∈ T can be seen to be

R =

cγcβ + cαsγsβ sγcβ − cαcγsβ sαsβcγsβ − cαsγcβ sγsβ + cαcγcβ −sαcβ−sαsγ sαcγ cα

, (23)

where β = ψ + γ, sx ≡ sinx and cx ≡ cosx.

Page 6: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

−0.5

0

0.5

−0.8−0.6−0.4−0.200.20.40.60.8

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

θ

zB

xB

yB

(a) Constant fused pitch cone for θ = 50

−0.5

0

0.5

−0.8−0.6−0.4−0.200.20.40.60.8

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8zB

φxB

yB

(b) Constant fused roll cone for φ = 32

−0.5

0

0.5

−0.8−0.6−0.4−0.200.20.40.60.8

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

θ

zB

φxB

h = −1

h = +1

yB

(c) Intersection of fused pitch and roll cones

−0.5

0

0.5

−0.8−0.6−0.4−0.200.20.40.60.8

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8zB

xB

h = +1

yB

(d) Constant hemisphere locus for h = +1

−0.5

0

0.5

−0.8−0.6−0.4−0.200.20.40.60.8

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8zB

xB

h = −1

yB

(e) Constant hemisphere locus for h = −1

−0.5

0

0.5

−0.8−0.6−0.4−0.200.20.40.60.8

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

θ

zB

φxB

zG

yB

(f) Intersection of cones and hemisphere locus

Fig. 5. Plots of the 3D locus of zB G for (a) constant fused pitch θ, (b) constant fused roll φ, (d) constant hemisphere h = +1, and (e) constanthemisphere h = −1. (c) shows how loci of constant fused pitch and roll intersect at (at most) two points, illustrating how (θ, φ) specifies zB G up totwo possible choices. (f) shows how intersecting again with the applicable hemisphere locus uniquely resolves zB G. Note that the locus of constant fusedpitch in (a) is a cone with its opening facing out of the page, much like the opening of the cone of constant fused roll in (b) is facing towards the left.

The inverse conversion from a rotation matrix R to thecorresponding tilt angles representation T is given by

γ = atan2(−R31, R32), α = acos(R33), (24)

where the fused yaw ψ is calculated using (26–27), aspresented below for the fused angles case.

3) Fused angles ↔ Rotation matrix: The conversion offused angles to a rotation matrix requires conversion via thetilt angles representation, using (18–19). Equation (23) canthen be used with slight simplification as follows:

R =

cγcβ + cαsγsβ sγcβ − cαcγsβ sαsβcγsβ − cαsγcβ sγsβ + cαcγcβ −sαcβ

−sθ sφ cα

. (25)

The conversion from R back to F follows from (11–13). IfRm = maxR11, R22, R33 and Rz = 1−R11−R22 +R33,then the rotation matrix to fused angles conversion is mostrobustly given by the following:

ψ =

atan2(R21 −R12, 1 + tr(R)) if tr(R) ≥ 0

atan2(Rz, R21 −R12) if Rm = R33

atan2(R32 +R23, R13 −R31) if Rm = R22

atan2(R13 +R31, R32 −R23) if Rm = R11

(26)

ψ = wrap(2ψ), θ = asin(−R31), (27)φ = asin(R32), h = sign(R33). (28)

Although it is possible to construct a much simpler expres-sion for ψ using (14), this is not recommended due to theresulting numerical sensitivity near α = 0.

4) Tilt angles ↔ Quaternion: The conversion of a tiltangles rotation T = (ψ, γ, α) ∈ T to the correspondingquaternion representation is robustly given by

q = (cαcψ, sαcψ+γ , sαsψ+γ , cαsψ), (29)

where α = 12α and ψ = 1

2ψ. In combination with (36) forcalculating the fused yaw ψ, the inverse conversion from

Page 7: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

quaternion q to tilt angles T is given by

γ = atan2(wy − xz,wx+ yz), (30)

α = acos(2(w2 + z2)− 1

). (31)

5) Fused angles ↔ Quaternion: The conversion fromfused angles to quaternions is robustly given by

q =

qp‖qp‖

if h = 1,

qn‖qn‖

if h = −1,(32)

qp =(cψC

+α , sφcψ − sθsψ, sφsψ + sθcψ, sψC

), (33)

qn =(sαcψ, cψ+γC

−α , sψ+γC

−α , sαsψ

), (34)

where C+α = 1 + cα and C−α = 1 − cα. The respective

quaternion norms are analytically given by

‖qp‖ =√

2C+α = 2cα, ‖qn‖ =

√2C−α = 2sα. (35)

Note that α does not need to be computed in order to evaluate(32–34), just cα and sα. These can be obtained directly from(19) and (21). Using (27–29), the fused angles representationof a quaternion q = (w, x, y, z) ∈ Q can be shown to be

ψ = wrap(2 atan2(z, w)

), θ = asin

(2(wy − xz)

), (36)

h = sign(w2 + z2 − 12 ), φ = asin

(2(wx+ yz)

). (37)

Note that this expression for ψ is insensitive to the quaternionmagnitude, and far more direct than an expression derivedfrom (26) would be. In fact, (36) can conveniently be takenas the mathematical definition of fused yaw. Note that theangle wrapping of ψ is at most by a single multiple of 2π.

V. SINGULARITY ANALYSIS

When examining rotation representations, it is important toidentify and precisely quantify any singularities. Singularitiesare unavoidable in any minimal parameterisation, and mayoccur in the form of:

(i) A rotation that cannot unambiguously be resolved intothe required set of rotation parameters,

(ii) A rotation for which there is no equivalent parame-terised representation that is unambiguous,

(iii) A rotation in the neighbourhood of which the sensitivityof the rotation to parameters map is unbounded.

The entries of a rotation matrix are a continuous functionof the underlying rotation and lie in the interval [−1, 1]. Assuch, from (27–28) and the continuity of the appropriatelydomain-restricted arcsine function, it can be seen that thefused pitch and fused roll are continuous over the entirerotation space. Furthermore, the hemisphere parameter of thefused angles representation is uniquely and unambiguouslydefined over the rotation space. As a result, despite itsdiscrete and thereby technically discontinuous nature, thehemisphere parameter is not considered to be the cause ofany singularities in the fused angles representation.

The fused yaw parameter, on the other hand, can be seenfrom (36) to have a singularity at w = z = 0, due to thesingularity of atan2 at (0, 0). From (29), this condition can

be seen to be precisely equivalent to α = π, the definingequation of the set of all rotations by 180 about axes inthe xy plane. The fused yaw singularity is a singularity oftype (ii) and (iii) as per the characterisation given above, andcorresponds to an essential discontinuity of the fused yawmap. Moreover, given any fused yaw singular rotation R,and any neighbourhood U of R in the rotation space SO(3),for every ψ ∈ (−π, π] there exists a rotation in U with afused yaw of ψ. Conceptually, the fused yaw singularity canbe seen as being as ‘far away’ from the identity rotation aspossible. This is by contrast not the case for Euler angles.

The tilt angles representation trivially has the same singu-larity in the fused yaw as the fused angles representation. Inaddition to this however, from (24), the tilt axis angle γ alsohas a singularity when R31 = R32 = 0. This correspondsto θ = φ = 0, or equivalently, α = 0 or π—that is, eitherrotations of pure yaw, or rotations by 180 about axes inthe xy plane. The tilt angle parameter α is continuous by(10) and the continuity of the arccosine function, and as suchdoes not contribute any further singularities.

VI. RESULTS AND PROPERTIES OF FUSED ANGLES

The fused angles representation possesses a remarkablenumber of subtle properties that turn out to be quite usefulboth mathematically and geometrically when working withthem. One of these properties, relating to the axisymmetryof the representation, has already been stated without proofin Section II-D. Other—more complex—properties of fusedangles, involving for example the matching of fused yawsbetween coordinate frames, were invoked in [1] to derive acomputationally efficient algorithm to calculate instantaneousmeasurements of the orientation of a body from sensor data.Some of the more basic but useful properties of fused anglesare presented in this section.

A. Fundamental Properties of Fused Angles

The following fundamental properties of fused angleshold, and form a minimum set of axiomatic conditions onthe fused angles parameters.• A pure x-rotation by β ∈ [−π2 , π2 ] is given by the fused

angles representation (0, 0, β, 1) ∈ F.• A pure y-rotation by β ∈ [−π2 , π2 ] is given by the fused

angles representation (0, β, 0, 1) ∈ F.• A pure z-rotation by β ∈ (−π, π] is given by the fused

angles representation (β, 0, 0, 1) ∈ F.• Applying a pure z-rotation to an arbitrary fused angles

rotation is purely additive in fused yaw.Further fundamental properties of fused angles include:• The parameter set (ψ, θ, φ, h) ∈ F is valid if and only

if |θ|+ |φ| ≤ π2 , i.e. the sine sum criterion is satisfied.

• The parameter set (ψ, θ, φ, h) ∈ F can be put intostandard form by setting h = 1 if |θ| + |φ| = π

2 , andψ = 0 if θ = φ = 0 and h = −1 (i.e. α = π).

• Two fused angles rotations are equal if and only if theirstandard forms are equal. Note that this identifies theα = π rotations due to the fused yaw singularity there.

Page 8: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

B. Inverse of a Fused Angles Rotation

The fused angles representation of the inverse of a rotationis intricately linked to the fused angles parameters of arotation. This is an almost unexpected result when comparedto, for example, Euler angles, but follows trivially from theformulas and properties presented in this paper thus far. Con-sider a fused angles rotation (ψ, θ, φ, h) with an equivalenttilt angles representation (ψ, γ, α). The parameters of theinverse rotation are given by

ψinv = −ψ, γinv = wrap(ψ + γ − π), (38)

αinv = α, θinv = asin(− sinα sin(ψ + γ)

), (39)

hinv = h, φinv = asin(− sinα cos(ψ + γ)

). (40)

The leftmost equation in (38) represents a remarkable prop-erty of fused yaw, one that other definitions of yaw such asZYX Euler yaw do not satisfy. This property is referred to asnegation through rotation inversion. It is worth noting that ifa rotation has zero fused yaw, i.e. it is a pure tilt rotation, theinverse fused pitch and roll also satisfy the negation throughrotation inversion property. That is,

ψ = 0 ⇐⇒ψinv = −ψ, θinv = −θ,hinv = h, φinv = −φ. (41)

C. Characterisation of the Fused Yaw of a Quaternion

For rotations away from the singularity α = π, that is,for rotations where the fused yaw is well-defined and unam-biguous, inspection of (29) reveals that the z-component ofa quaternion q = (w, x, y, z) ∈ Q is zero if and only if thefused yaw is zero. That is,

z = 0 ⇐⇒ ψ = 0. (42)

Furthermore, it can be seen that the quaternion correspondingto the fused yaw of the rotation can be constructed by zeroingthe x and y-components of q and renormalising. That is,

qyaw = 1√w2+z2

(w, 0, 0, z). (43)

This leads to one way of removing the fused yaw componentof a quaternion—something that is a surprisingly commonoperation—using the expression

qtilt = q∗yawq = 1√w2+z2

(wq + z(z, y,−x,−w)

). (44)

The fused yaw can also be computed using (36) and manuallyremoved. Equations (43–44) fail only if w = z = 0, whichis precisely equivalent to α = π, the fused yaw singularity.

D. Metrics over Fused Angles

For the design of rotation space trajectories and otherpurposes, it is useful to be able to quantify the distancebetween two rotations using a metric. Assuming two fusedangle rotations F1 and F2, and their corresponding tilt anglesrepresentations T1 = (ψ1, γ1, α1) and T2 = (ψ2, γ2, α2), twonaturally arising metrics [9] are ( · is the dot product):

dR(F1, F2) = ‖log(RT1R2)‖F = 2 acos(|q1 · q2|

)= θ, (45)

dL(F1, F2) = 1− cos(θ2

)= 1− |q1 · q2|, (46)

where q1, q2 are the corresponding quaternions, θ is the anglemagnitude of the relative axis-angle rotation (u, θ), and

q1 · q2 = cα1cα2

c∆ψ + sα1sα2

c∆ψ+∆γ , (47)

where ∆ψ = 12 (ψ1 − ψ2), ∆γ = γ1 − γ2, α1 = 1

2α1 andα2 = 1

2α2. Note that the Riemannian metric dR relatesclosely to spherical linear interpolation (slerp) [10], and assuch serves as a metric of first choice. Actual computation ofslerp is however still most efficiently done in the quaternionspace. Direct interpolation of fused angles can give unex-pected results in the general case, but for two rotations in thepositive hemisphere it is a viable alternative, that for manyapplications will produce completely satisfactory results.

VII. CONCLUSIONS

Two novel ways of parameterising a rotation were formallyintroduced in this paper. The main contribution of these,the fused angles representation, was developed to be ableto describe a rotation in a way that yields insight into thecomponents of the rotation in each of the three major planesof the Euclidean space. The second parameterisation thatwas introduced, tilt angles, was defined as an intermedi-ate representation between fused angles and other existingrepresentations. Nevertheless, the tilt angles representationproves to be geometrically, conceptually and mathematicallyuseful. Many properties of the fused angles and tilt anglesrepresentations were derived, often in highlight of theirsimplicity, and the relations of these two representations toother commonly used representations were explicitly given.The computational efficiency of the two representations canbe seen by inspection of our open-source implementation [3].Due to their many special properties, fused angles fill a nichein the area of rotation parameterisation that is left vacant byalternative constructs such as Euler angles and quaternions,and are expected to yield valuable information and results,in particular in applications that involve balance.

REFERENCES

[1] P. Allgeuer and S. Behnke, “Robust sensor fusion for biped robotattitude estimation,” in Proceedings of 14th IEEE-RAS Int. Conferenceon Humanoid Robotics (Humanoids), Madrid, Spain, 2014.

[2] P. Allgeuer, M. Schwarz, J. Pastrana, S. Schueller, M. Missura, andS. Behnke, “A ROS-based software framework for the NimbRo-OP humanoid open platform,” in Proceedings of 8th Workshop onHumanoid Soccer Robots, IEEE-RAS Int. Conference on HumanoidRobots, Atlanta, USA, 2013.

[3] P. Allgeuer. (2014, Oct) Matlab/Octave Rotations Library. [Online].Available: https://github.com/AIS-Bonn/matlab_octave_rotations_lib/

[4] B. Palais, R. Palais, and S. Rodi, “A disorienting look at Euler’stheorem on the axis of a rotation,” The American MathematicalMonthly, pp. 892–909, 2009.

[5] S. Tomažic and S. Stancin, “Simultaneous orthogonal rotations angle,”Electrotechnical Review, no. 78, pp. 7–11, 2011.

[6] O. Bauchau and L. Trainelli, “The vectorial parameterization ofrotation,” Nonlinear Dynamics, vol. 32, no. 1, pp. 71–92, 2003.

[7] L. Trainelli and A. Croce, “A comprehensive view of rotation param-eterization,” in Proceedings of ECCOMAS, 2004.

[8] J. Argyris, “An excursion into large rotations,” Computer Methods inApplied Mechanics and Engineering, vol. 32, pp. 85–155, 1982.

[9] D. Huynh, “Metrics for 3D rotations: Comparison and analysis,” J. ofMath. Imaging and Vision, vol. 35, no. 2, pp. 155–164, 2009.

[10] K. Shoemake, “Animating rotation with quaternion curves,” in ACMSIGGRAPH computer graphics, vol. 19, no. 3, 1985, pp. 245–254.

Page 9: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

VIII. ADDENDUM

Some additional properties and results of rotations havebeen added in this section, post-publication of the paper.

A. Rotations About Local and Global Axes

Suppose we have the rotation from G to B in one ofthe four representations (e.g. RGB or FGB ). Then,• Rotation of B about a local axis vB corresponds to

post-multiplication by the axis rotation, and,• Rotation of B about a global axis vG corresponds to

pre-multiplication by the axis rotation.If frame C results from the rotation in each case, this canbe expressed mathematically as:

Local: RGC = RGB R vB (θ) (48)

Global: RGC = R vG (θ) RGB (49)

B. Referenced Rotations

Given frames A and B relative to a global frame G,the global rotation that maps A onto B is given by

RGAB = RGB RAG . (50)

This is referred to as the rotation from frame A to B,referenced by G. Alternative mathematical formulations forreferenced rotations are given by

RGAB = RGB RGA

T (51)

= RGB RAB RGBT (52)

= RGA RAB RGAT. (53)

Basic identities involving referenced rotations include

RGAB RGA = RGB , (54)

RBG RGAB = RAG , (55)

RGAT RGA

B RGA = RAB , (56)

RGBT RGA

B RGB = RAB . (57)

The simplification of trivial cases is given by

RGAA = I, (58)

RGGB = RGB , (59)

RGAG = RAG . (60)

Composition of referenced rotations is given by

RGAC = RGB

C RGAB . (61)

A change of referenced frame is given by

RHAB = RHG RGA

B RHGT. (62)

All of these definitions and results clearly also have equiva-lent forms in the other rotation representations. While normalrotation identities can often be thought of as ‘cancelling’frames along the forward diagonal of successive terms, thereferenced rotation identities can often be thought of as‘cancelling’ frames along the backward diagonal.

C. Fundamentals of Rotation Matrices

The set of all rotation matrices is called the specialorthogonal group SO(3), and is defined as

SO(3) = R ∈ R3×3 : RTR = I, det(R) = 1. (63)

In particular, note that R is an orthogonal matrix, so therows and columns of R have to be mutually orthogonal unitvectors (i.e. an orthonormal basis of R3), and

RT = R−1. (64)

For a rotation from coordinate frame G to frame B,

RGB =

↑ ↑ ↑xG B yG B zG B

↓ ↓ ↓

=

← xB G →← yB G →← zB G →

(65)

=

xB · xG yB · xG zB · xGxB · yG yB · yG zB · yGxB · zG yB · zG zB · zG

(66)

=

cos(θxx) cos(θyx) cos(θzx)cos(θxy) cos(θyy) cos(θzy)cos(θxz) cos(θyz) cos(θzz)

, (67)

where for example yG B is the vector corresponding to they-axis of frame B, expressed in the coordinates of G,and θzx is the angle between zB and xG. Given that weare using right-handed coordinate systems, if x, y and z areeither the rows or columns of R, then

x · y = 0, x× y = z,

y · z = 0, y × z = x,

z · x = 0, z× x = y.

(68)

The composition of rotations is given by matrix multiplica-tion. Rotation matrix reorthogonalisation (finding the closestvalid rotation matrix R to an arbitrary matrix R) is given by

R = R(RTR

)− 12 . (69)

If R is a rotation matrix then clearly RTR = I, so R = R.RTR is a real symmetric positive semidefinite matrix, soit is diagonalisable by a real orthogonal matrix P (i.e. forwhich PT = P−1) to a diagonal matrix D with non-negativeentries. That is, for such matrices P and D,

RTR = PDP−1. (70)

Let D−12 be the diagonal matrix with the positive inverse

square roots of the diagonal of D on its diagonal. Then,(RTR

)− 12 = PD−

12P−1. (71)

Care has to be taken regarding possibly obtaining complexnumbers in the result for singular R matrices (i.e. formachine precision non-positive entries on the diagonal ofD). The reorthogonalisation may also result in a left-handedcoordinate system (det(R) = −1). In each case, R can forlack of a better option just be set to I.

Page 10: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

The CCW rotation about the unit vector v = (vx, vy, vz)by an angle of θ is given by the rotation matrix

Rv(θ)=

v2xCθ+cθ vxvyCθ−vzsθ vxvzCθ+vysθ

vxvyCθ+vzsθ v2yCθ+cθ vyvzCθ−vxsθ

vxvzCθ−vysθ vyvzCθ+vxsθ v2zCθ+cθ

(72)

where Cθ = 1− cθ. For any rotation matrix R ∈ SO(3), thetranspose rotation matrix RT ∈ SO(3) satisfies

RRT = RTR = I, (73)

(RS)T = STRT. (74)

Rotation of a column vector v ∈ R3 by a rotation matrix isgiven by matrix pre-multiplication, that is

vG rotated = RGB vG . (75)

Considering (59), this is in fact a special case of the moregeneral expression for vector rotation, namely

vG rotated = RGAB vG . (76)

This applies the rotation that maps A onto B to thevector vG , producing a vector that is also relative to G. Ifwe have a frame C, then matrix pre-multiplication rotatesthe entire frame. If the resulting frame is D, then

RGD = RGB RGC , (77)

or more generally for referenced rotations,

RGD = RGAB RGC . (78)

An alternative way of interpreting rotation matrix pre-multiplication is as a change of reference frame, given by

vG = RGB vB , (79)

or for a frame C,

RGC = RGB RBC . (80)

Suppose R ≡ RGB ∈ SO(3) is a rotation matrix, and Ω is anarbitrary 3D angular velocity (rad s−1). Then, applying theangular velocity to R gives

R =dR

dt=[

ΩG]×R = R

[ΩB]×, (81)

where[·]× is the skew-symmetric matrix representation of

the cross product, given for v = (vx, vy, vz) by

[v]×=

0 −vz vyvz 0 −vx−vy vx 0

. (82)

Note that for any vector w ∈ R3,

v ×w =[v]×w. (83)

(81) can alternatively be written as

R =

↑ ↑ ↑ΩG × xG B ΩG × yG B ΩG × zG B

↓ ↓ ↓

(84)

=

← − ΩB × xB G →← − ΩB × yB G →← − ΩB × zB G →

, (85)

so a necessary condition for R is that all rows and columnshave a dot product of zero with the corresponding rows andcolumns in R. Given a valid R, the corresponding angularvelocity Ω can be read from[

ΩG]×= RRT,

[ΩB]×= RTR. (86)

For any rotation matrix RGB , the corresponding axis-anglerepresentation is (u, θ) ∈ S2 × R for

θ = acos(

12 (tr(R)− 1)

), (87)

u = 12 sin θ (R32 −R23, R13 −R31, R21 −R12). (88)

If θ = 0, then one can define u = 0. Strictly speaking0 /∈ S2, but the axis u is not uniquely defined if θ = 0,and 0 turns out to be a convenient value for numericalimplementations. Uniformly rotating by RGB over time ∆tcorresponds to a constant angular velocity of

ΩG = θ∆t u. (89)

D. Fundamentals of Quaternion Rotations

The set of all quaternions H, and the subset Q thereof, ofall quaternions that represent pure rotations, are defined as

H = q = (q0,q) ≡ (w, x, y, z) ∈ R4,Q = q ∈ H : ‖q‖ = 1. (90)

In particular, note that we have

w2 + x2 + y2 + z2 = 1. (91)

Quaternion renormalisation (finding the closest valid quater-nion rotation q to an arbitrary quaternion q) is given by

q =q

‖q‖ . (92)

The CCW rotation about the unit vector v = (vx, vy, vz) byan angle of θ is given by the quaternion (taking w ≥ 0)

qv(θ) =(cos θ2 , v sin θ

2

)=(cos θ2 , vx sin θ

2 , vy sin θ2 , vz sin θ

2

).

(93)

For u ∈ R, and θ ∈ [−π, π] (choose (θ,v) that satisfies this),

qu =(cos uθ2 , v sin uθ

2

). (94)

In terms of the rotations that the two quaternions represent,

q ≡ −q. (95)

Given the quaternions p = (p0,p) = (w1, x1, y1, z1) andq = (q0,q) = (w2, x2, y2, z2), multiplication is defined by

pq = (p0q0 − p · q, p0q + q0p + p× q) (96)= (w1w2 − x1x2 − y1y2 − z1z2,

w1x2 + x1w2 + y1z2 − z1y2,

w1y2 − x1z2 + y1w2 + z1x2,

w1z2 + x1y2 − y1x2 + z1w2).

(97)

Page 11: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

For any rotation q ∈ Q, the conjugate q∗ satisfies

q∗ = q−1 = (w,−x,−y,−z), (98)qq∗ = q∗q = (1, 0, 0, 0), (99)

(pq)∗ = q∗p∗. (100)

The rotation of a vector v ∈ R3 by the quaternion q =(q0,q) ∈ Q is given by Lq(v) : R3 → R3, defined as

Lq(v) = qvq∗ = q(0,v)q∗ (101)

= (q20 − ‖q‖2)v + 2(q · v)q + 2q0(q× v) (102)

= v + q0t + q× t, where t = 2(q× v). (103)

Note that (103) provides the computationally most efficientmethod for calculating Lq(v). Just like (75–80), we have

vG rotated = L qGB( vG ), (104)

vG rotated = L qGAB

( vG ), (105)

qGD = qGB qGC , (106)

qGD = qGAB qGC , (107)

vG = L qGB( vB ), (108)

qGC = qGB qBC . (109)

Rotation composition works as expected:

Lp(Lq(v)) = Lpq(v). (110)

Suppose q ≡ qGB ∈ Q is a quaternion rotation, and Ω is anarbitrary 3D angular velocity (rad s−1). Then, applying theangular velocity to q gives

q =dq

dt= 1

2 (0, ΩG )q = 12q(0, ΩB ). (111)

Note that Ω is being turned into a quaternion by the additionof a zero w-component, and quaternion multiplication isbeing used. The output quaternion derivative q will alwaysbe perpendicular to the original quaternion q in 4D space.That is (where · is the dot product),

q · q = 0. (112)

Given a quaternion derivative ˜q, we first convert it into a validquaternion derivative q that corresponds to rotating q ∈ Qby some angular velocity, using

q = ˜q − (˜q · q)q. (113)

Then, the corresponding angular velocity Ω can be read from

(0, ΩG ) = 2qq∗, (0, ΩB ) = 2q∗q. (114)

(113) ensures that the w-components are indeed zero.For any quaternion qGB = (w, x, y, z) ∈ Q, the correspond-

ing axis-angle representation is (u, θ) ∈ S2 × R for

n = ‖(x, y, z)‖,

θ =

2 atan2(n,w) if w ≥ 0,

2 atan2(n,w)− 2π otherwise,(115)

u =

1n (x, y, z) if n 6= 0,

0 otherwise.(116)

Strictly speaking 0 /∈ S2, but the axis u is not uniquelydefined if n = 0, and 0 turns out to be a convenient valuefor numerical implementations. Uniformly rotating by qGBover time ∆t corresponds to a constant angular velocity of

ΩG = θ∆t u. (117)

E. Conversion Between Quaternions and Rotation Matrices

Given q = (w, x, y, z) ∈ Q, the equivalent rotation matrixis given by

R =

1− 2(y2 + z2) 2(xy − wz) 2(xz + wy)2(xy + wz) 1− 2(x2 + z2) 2(yz − wx)2(xz − wy) 2(yz + wx) 1− 2(x2 + y2)

.(118)

Depending on how the rotation matrix R is subsequentlyused, it may be necessary to coerce each of the matrixentries to [−1, 1]. Although for ‖q‖ = 1 it is impossible ina mathematical sense for one of the entries to exceed unityin magnitude, it can happen in practice due to floating pointarithmetic. In such cases, subsequent calculations such asα = acos(R33) can lead to unwanted numerical problems.

The reverse conversion is more difficult and is split intofour cases, where each case corresponds to one of thefour quaternion parameters being taken as the base of theconversion. Given a rotation matrix R ∈ SO(3) with matrixentries Rij , if tr(R) ≥ 0,

r = 1 +R11 +R22 +R33,

q =(r,R32 −R23, R13 −R31, R21 −R12

),

(119)

else if R33 ≥ R22 and R33 ≥ R11,

r = 1−R11 −R22 +R33,

q =(R21 −R12, R13 +R31, R32 +R23, r

),

(120)

else if R22 ≥ R11,

r = 1−R11 +R22 −R33,

q =(R13 −R31, R21 +R12, r, R32 +R23

),

(121)

and otherwise,

r = 1 +R11 −R22 −R33,

q =(R32 −R23, r, R21 +R12, R13 +R31

).

(122)

The output quaternion is then obtained via normalisation:

q =q

‖q‖ . (123)

This implementation of the rotation matrix to quaternionconversion is extremely robust, as it always chooses thequaternion parameter that provides the most well-conditionedproblem to solve as the base of the conversion.

F. Tilt phase space

When working with tilt rotations (as opposed to orienta-tions) and how to combine them, tilt angles are frequently therepresentation of choice. Tilt angles have a few limitations inthis field of application however, such as for example that tiltrotations of more than 180 cannot naturally be represented.The essential discontinuity of the tilt axis angle γ and thenon-differentiability (cusp) of the tilt angle α at the identity

Page 12: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

rotation also present numerical and algorithmic difficulties.To overcome these issues, the tilt phase space can be usedinstead as the representation of choice. Given the tilt anglesrepresentation T = (ψ, γ, α) of a rotation, the equivalent 3Dtilt phase space representation is given by

P = (px, py, pz) = (α cos γ, α sin γ, ψ)

∈ R2 × (−π, π] ≡ P3. (124)

In general, when working with tilt rotations the fused yawcomponent is not required. In such cases, the abridged 2Dtilt phase space representation can be used, given by

P = (px, py) = (α cos γ, α sin γ) ∈ R2 ≡ P2. (125)

This is the predominant formulation of the tilt phase spacethat is used in general. Note that in (124–125) a domain ofR has been specified for px and py , to naturally be able torepresent tilt rotations of more than 180. The conversionfrom tilt phase space to tilt angles is given by

ψ = pz, (126)γ = atan2(py, px), (127)

α =√p2x + p2

y . (128)

It should be noted that the tilt phase variables are continuousand smooth functions of the underlying rotation, at least awayfrom the fused yaw singularity in the case of pz ≡ ψ. In fact,for rotations with small tilt rotation components, we havesinα ≈ α, sin θ ≈ θ and sinφ ≈ φ, where θ and φ are thefused pitch and roll respectively, so from (22),

px = α cos γ ≈ φ,py = α sin γ ≈ θ. (129)

As such, for rotations with small tilt rotation components, the2D tilt phase variables mimic fused angles, whilst far from itthey continue linearly to infinity with increasing magnitudeof tilt rotation. This is unlike the fused pitch and rollvariables, which quickly loop around to correctly representthe resulting orientation. This emphasises the advantage ofthe tilt phase space for working with tilt rotations.

Although the composition of tilt rotations is not commuta-tive and does not in general produce a tilt rotation as output,the 2D tilt phase space provides a way of defining a usefuland meaningful addition operator for tilt rotations that isclosed, commutative and associative. The sum of two tiltrotations P1, P2 ∈ P2 is defined to be

P1 ⊕ P2 = (px1 + px2, py1 + py2)

= (α1cγ1 + α2cγ2 , α1sγ1 + α2sγ2).(130)

If the resulting tilt rotation P1 ⊕ P2 corresponds to the tiltangles (γs, αs), then the sum can also be written as

(γ1, α1)⊕ (γ2, α2) = (γs, αs). (131)

It is easy to see that (P2,⊕) is an abelian group, and defining

λP = (λpx, λpy), (132)

for all λ ∈ R, completes P2 as a vector space over R. Thisis referred to as the vector space of tilt rotations.

G. Spherical Linear Interpolation (Slerp)

Spherical linear interpolation (slerp) is a way of interpo-lating rotations that is torque-minimal (shortest path throughthe space of rotations, i.e following a geodesic) and con-stant velocity (constant speed in following the path). Givenquaternions q0, q1 ∈ Q and u ∈ [0, 1], slerp is given by

slerp(q0, q1, u) = (q1q−10 )uq0 = q0(q−1

0 q1)u. (133)

Refer to (94) for details on taking powers of quaternions.q1q−10 is the relative rotation from q0 to q1, and taking it to

the power of u is like linearly interpolating the angle param-eter of the corresponding relative axis-angle representation.An alternative formulation of slerp is given by

Ω = acos(q0 · q1),

slerp(q0, q1, u) =

[sin((1− u)Ω)

sin Ω

]q0 +

[sinuΩ

sin Ω

]q1.

(134)

Due to the duality q ≡ −q, this formulation is only valid ifq0 and q1 are in the same 4D hemisphere as each other. Thatis, the hemisphere centred at either quaternion contains theother. This is equivalent to the condition that

q0 · q1 ≥ 0. (135)

For numeric computations, first compute d = q0 ·q1. If d < 0then negate both d and q1. Then,

Ω = acos(d),

q =

(1− u)q0 + uq1, if d ≥ 1− ε,sin((1− u)Ω)q0 + sin(uΩ)q1, otherwise,

slerp(q0, q1, u) =q

‖q‖ .

(136)

For double precision floating point numbers, ε = 5e−9 isappropriate. For any quaternion q ∈ Q,

slerp(qq0, qq1, u) = q slerp(q0, q1, u). (137)

Refer to Section IX-A for a proof.

H. Slerp Between Rotations of Equal Fused Yaw

Performing spherical linear interpolation (slerp) betweentwo rotations of equal fused yaw always produces an outputrotation of exactly the same fused yaw. As a corollary, thismeans that slerp between two tilt rotations always producesa tilt rotation. Therefore, tilt rotations can be cleanly inter-polated, without affecting the fused yaw. As an equation,

Ψ(q0

)= Ψ

(q1

)= ψ =⇒ Ψ

(slerp(q0, q1, u)

)= ψ. (138)

Refer to Section IX-B for a proof.

I. Format of Pure XYZ Rotations

A rotation about the x-, y- or z-axis is referred to as a pureaxis rotation. Pure axis rotations as tilt angles are given by:

Tx(β) = (0, 0, β),

Ty(β) = (0, π2 , β),

Tz(β) = (β, 0, 0).

(139)

Page 13: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

Pure axis rotations as fused angles are given by:

Fx(β) = (0, 0, β, 1),

Fy(β) = (0, β, 0, 1),

Fz(β) = (β, 0, 0, 1).

(140)

Pure axis rotations as quaternions are given by:

qx(β) = (cβ , sβ , 0, 0),

qy(β) = (cβ , 0, sβ , 0),

qz(β) = (cβ , 0, 0, sβ).

(141)

Pure axis rotations as rotation matrices are given by:

Rx(β) =

1 0 00 cβ −sβ0 sβ cβ

,Ry(β) =

cβ 0 sβ0 1 0−sβ 0 cβ

,Rz(β) =

cβ −sβ 0sβ cβ 00 0 1

.(142)

J. Format of Pure Tilt Rotations

Pure tilt rotations are rotations with zero fused yaw, i.e.for which ψ = 0. This results in the following formats ineach of the respective rotation representations:

Tt = (0, γ, α), (143)Ft = (0, θ, φ, h), (144)qt = (cα, sαcγ , sαsγ , 0). (145)

Note that for the quaternion representation z = 0, andtherefore w2 + x2 + y2 = 1. For rotation matrices:

Rt =

R11 R12 −R31

R12 R22 −R32

R31 R32 R33

(146)

=

1− 2y2 2xy 2wy2xy 1− 2x2 −2wx−2wy 2wx 2w2 − 1

(147)

=

c2γ + cαs2γ cγsγ(1− cα) sαsγ

cγsγ(1− cα) s2γ + cαc

2γ −sαcγ

−sαsγ sαcγ cα

(148)

=

1− s2γ(1− cα) cγsγ(1− cα) sαsγ

cγsγ(1− cα) 1− c2γ(1− cα) −sαcγ−sαsγ sαcγ cα

(149)

=

· · sθ· · −sφ−sθ sφ h

√1− s2

θ − s2φ

. (150)

In axis-angle format, a pure tilt rotation is a rotation by αabout the axis (cγ , sγ , 0).

K. Format of Fused Yaw Singularity

The fused yaw ψ is singular for 180 rotations aboutvectors in the xy-plane, that is, for 180 tilt rotations. Theserotations are essential discontinuities, and are by conventiondefined to have a fused yaw of zero. The fused yaw singu-larity corresponds exactly to the following conditions:

Singular ψ ⇐⇒ α = π

⇐⇒ θ = φ = 0, h = −1

⇐⇒ w = z = 0

⇐⇒ R33 = −1

⇐⇒ zG Bz ≡ zB Gz = −1.

(151)

The format of the ψ singularity in each representation is:

Tsing = (ψ, γ, π), (152)Fsing = (ψ, 0, 0,−1), (153)qsing = (0, x, y, 0) = (0, cγ , sγ , 0). (154)

Strictly speaking, for the representations above to be valid weshould have ψ = 0. The use of a generic ‘ψ’ is to representthat the set of singular ψ rotations is invariant under arbitraryz-rotations. For rotation matrices the ψ singularity is:

Rsing =

R11 R12 0R12 −R11 00 0 −1

(155)

=

x2 − y2 2xy 02xy y2 − x2 00 0 −1

(156)

=

c2γ − s2γ 2cγsγ 0

2cγsγ s2γ − c2γ 0

0 0 −1

. (157)

Note in (155) that R211 + R2

12 = 1, and in particular thatx2 + y2 = 1 in (156).

L. Format of Rotation Inverses

Given a tilt angles rotation, the inverse is given by

Tinv = (−ψ,wrap(ψ + γ − π), α) (158)= (−ψ,ψ + γ,−α), (159)

where (159) is a shortcut if the domain of the tilt anglesparameters is not important. Given a fused angles rotation,the inverse is given by

Finv = (−ψ, θinv, φinv, h),

θinv = − asin(cψsθ + sψsφ

),

φinv = asin(sψsθ − cψsφ

).

(160)

In terms of the tilt angles parameters (ψ, γ, α), θinv and φinvare equivalently given by

θinv = − asin(sαsψ+γ

),

φinv = − asin(sαcψ+γ

).

(161)

For the special case of a pure tilt rotation, i.e. zero fusedyaw, the inverse is given by

ψ = 0 ⇐⇒ Finv = (0,−θ,−φ, h). (162)

Page 14: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

Given a quaternion or rotation matrix, the correspondinginverse rotations are given by

qinv = q∗,

Rinv = RT.(163)

M. Rotation Decomposition into Fused Yaw and Tilt Rota-tion

Rotations can be broken up into their fused yaw and tiltrotation components, as follows:

T = Tf Tt = T (ψ, 0, 0) T (0, γ, α), (164)F = Ff Ft = F (ψ, 0, 0, 1) F (0, θ, φ, h), (165)q = qfqt = (cψ, 0, 0, sψ)(cα, sαcγ , sαsγ , 0). (166)

Also, for rotation matrices:

R = RfRt,

=

cψ −sψ 0sψ cψ 00 0 1

c2γ + cαs2γ cγsγ(1−cα) sαsγ

cγsγ(1−cα) s2γ + cαc

2γ −sαcγ

−sαsγ sαcγ cα

. (167)

Note that Tf , Ff , qf and Rf are by definition all pure z-rotations, so we have that

Tf = Tz(ψ), Ff = Fz(ψ),

qf = qz(ψ), Rf = Rz(ψ).(168)

N. Rotation Composition from Fused Yaw and Tilt Rotation

Given two frames, G and H, in general there is aunique frame B that has a desired fused yaw ψG relativeto G, and a desired tilt rotation component qH t relative toH. Cases where there are multiple solutions are discussedlater. Suppose we are given ψG , qGH = (wG, xG, yG, zG) andany rotation qHC = (wC , xC , yC , zC) that has the requiredtilt rotation component qH t relative to H. The fused yawof qHC relative to H is irrelevant, and qHC can often becalculated directly from a tilt angles specification T (0, γ, α).We first calculate the cross terms

a = xGxC + yGyC , b = xGyC − yGxC ,c = wGzC + zGwC , d = wGwC − zGzC .

(169)

Then, using the abbreviated notation cψ = cos( 12 ψG ) and

sψ = sin( 12 ψG ), we compute the following terms:

A = d− a, B = b− c,C = b+ c, D = d+ a,

G = Dcψ −Bsψ, H = Asψ − Ccψ.(170)

The required yaw rotation relative to H from C to Bis then

F =√G2 +H2, (171)

qHCB =

(GF , 0, 0,

HF ), if F 6= 0,

(1, 0, 0, 0), otherwise.(172)

Relative to frames H and G, frame B is then givenby either of the expressions

qHB = qHCB qHC , (173)

qGB = qGH qHCB qHC . (174)

The derivation of the above equations comes from settingqHC

B = (cφ, 0, 0, sφ), expanding (174), and solving

Ψ(qGB)

= ψG . (175)

There are multiple solutions if F = 0, which is the casewhen the following two conditions hold simultaneously:

αG + αC = π, (176)

ψG = 2 atan2(C,A). (177)

Computationally, there is also a problem with F = 0 whenqGH and qHC are, either way around, (1, 0, 0, 0) and (0, 0, 1, 0),

or (0, 1, 0, 0) and (0, 0, 0, 1). In this case there appears to bemultiple solutions for every ψG , because of a fused yawsingularity. Note however that through a better choice ofqHC , it is possible to avoid the singularity and nonetheless

successfully calculate the desired solution.

O. Effect of Pure Z-rotations on Fused Yaw

Composition of any rotation with a pure z-rotation is addi-tive in terms of fused yaw, irrespective whether the z-rotationis local (post-multiplication) or global (pre-multiplication):

Ψ(T Tz(ψz)

)= Ψ

(Tz(ψz) T

)= Ψ(T ) + ψz

Ψ(F Fz(ψz)

)= Ψ

(Fz(ψz) F

)= Ψ(F ) + ψz

Ψ(qqz(ψz)

)= Ψ

(qz(ψz)q

)= Ψ(q) + ψz

Ψ(RRz(ψz)

)= Ψ

(Rz(ψz)R

)= Ψ(R) + ψz

(178)

For global z-rotations, the tilt rotation also turns out to beuntouched, so for example:

Tz(ψz) T (ψ, γ, α) = T (ψ + ψz, γ, α),

Fz(ψz) F (ψ, θ, φ, h) = F (ψ + ψz, θ, φ, h).(179)

Refer to Section IX-C for proofs.

P. Link Between Fused Angles and Rotation Matrices

The correct and most efficient conversions between thefused angles and rotation matrix representations are given inSection IV. There are some other links between fused anglesand rotation matrices however, that may be useful in otherscenarios. For instance, the rotation matrix R correspondingto the fused angles rotation F = (ψ, θ, φ, h) can be written

R =

cγcβ + cαsγsβ sγcβ − cαcγsβ sψsφ + cψsθcγsβ − cαsγcβ sγsβ + cαcγcβ sψsθ − cψsφ

−sθ sφ cα

, (180)

where β = ψ + γ, and T = (ψ, γ, α) is the correspondingtilt angles rotation. Recall at this point that

cα = h√

1− s2θ − s2

φ. (181)

Converting R back to F yields

θ = asin(−R31), θ = asin(cψR13 + sψR23),

φ = asin(R32), φ = asin(sψR13 − cψR23),

h = sign(R33).

(182)

(26) remains the only robust expression for ψ based on R.

Page 15: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

Q. Constructing a Rotation from ψ and zB G

Suppose we are given the desired ψ and zB G of a rotation,and wish to calculate the full representation of the rotation.

1) Tilt angles: Using (24), the tilt angles parameters are

γ = atan2(− zB Gx, zB Gy), α = acos( zB Gz). (183)

This yields the tilt angles representation T = (ψ, γ, α).2) Fused angles: Using (27–28), the fused angles are

θ = asin(− zB Gx),

φ = asin( zB Gy),h = sign( zB Gz). (184)

This yields the fused angles representation F = (ψ, θ, φ, h).3) Quaternion: The w- and z-components are given by

Nwz = 12 (1 + zB Gz),

w = cψ√Nwz,

z = sψ√Nwz.

(185)

The x- and y-components are then given by

x = zB Gxz + zB Gyw,

y = zB Gyz − zB Gxw,(186)

A =

√1−Nwzx2 + y2

,x = Ax,

y = Ay.(187)

Being careful of the ψ singularity, the final quaternion is then

q =

(0, 1, 0, 0) if x = y = 0,(w, x, y, z) otherwise.

(188)

For the special case that ψ = 0, we have

w =√Nwz, x = zB Gy

z = 0, y = − zB Gx

(189)

Equations (187–188) are then used as before.4) Rotation matrix: The most numerically safe way of

constructing R from ψ and zB G is to go via the quaternionrepresentation. If ψ = 0 however, and we are not close tothe fused yaw singularity zB Gz = −1, we can use

R11 = 1− zB Gx2

1 + zB Gz

,

R22 = 1−zB Gy

2

1 + zB Gz

,

R12 = −zB Gx zB Gy

1 + zB Gz

.

(190)

The complete rotation matrix representation is then

R =

R11 R12 − zB Gx

R12 R22 − zB Gy

zB Gx zB Gy zB Gz

. (191)

R. Constructing a Rotation from ψ and zG B

Suppose we are given the desired ψ and zG B of a rotation,and wish to calculate the full representation of the rotation.

1) Tilt angles: The tilt angles parameters are

γ = atan2( zG Bx,− zG By)− ψ, α = acos( zG Bz). (192)

This yields the tilt angles representation T = (ψ, γ, α).

2) Fused angles: The fused angles parameters are

θ = asin(zG Bxcψ + zG Bysψ

),

φ = asin(zG Bxsψ − zG Bycψ

),

h = sign( zG Bz)

(193)

This yields the fused angles representation F = (ψ, θ, φ, h).3) Quaternion: The w- and z-components are given by

Nwz = 12 (1 + zG Bz),

w = cψ√Nwz,

z = sψ√Nwz.

(194)

The x- and y-components are then given by

x = zG Bxz − zG Byw,

y = zG Byz + zG Bxw,(195)

A =

√1−Nwzx2 + y2

,x = Ax,

y = Ay.(196)

Being careful of the ψ singularity, the final quaternion is then

q =

(0, 1, 0, 0) if x = y = 0,(w, x, y, z) otherwise.

(197)

For the special case that ψ = 0, we have

w =√Nwz, x = − zG By

z = 0, y = zG Bx

(198)

Equations (196–197) are then used as before.4) Rotation matrix: The most numerically safe way of

constructing R from ψ and zG B is to go via the quaternionrepresentation. If ψ = 0 however, and we are not close tothe fused yaw singularity zG Bz = −1, we can use

R11 = 1− zG Bx2

1 + zG Bz

,

R22 = 1−zG By

2

1 + zG Bz

,

R12 = −zG Bx zG By

1 + zG Bz

.

(199)

The complete rotation matrix representation is then

R =

R11 R12 zG Bx

R12 R22 zG By

− zG Bx − zG By zG Bz

. (200)

S. Fundamentals of Intrinsic ZYX Euler Angles

Intrinsic ZYX Euler angles is a rotation representationthat models a complete rotation as the combination of threesuccessive relative rotations—first by the ZYX yaw ψE aboutthe z-axis, then by the Euler pitch θE about the new y-axis,and then by the Euler roll φE about the newest x-axis. Thecomplete ZYX Euler rotation from G to B is given by

EGB = (ψE , θE , φE)

∈ (−π, π]×[−π2 , π2 ]×(−π, π] ≡ E.(201)

Page 16: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

The representation is unique, except at gimbal lock, which iswhen θE =±π2 . For ε ∈ R, the following equivalences hold:

(ψE , θE , φE) ≡ (π + ψE , π − θE , π + φE), (202)(ψE ,

π2 , φE) ≡ (ψE − ε, π2 , φE − ε), (203)

(ψE ,−π2 , φE) ≡ (ψE − ε,−π2 , φE + ε). (204)

The rotation matrix R corresponding to the Euler anglesrotation E = (ψE , θE , φE) is given by (the ‘E’ subscriptshave been omitted for notation brevity)

R = Rz(ψE)Ry(θE)Rx(φE) (205)

=

cψcθ cψsθsφ − sψcφ cψsθcφ + sψsφsψcθ sψsθsφ + cψcφ sψsθcφ − cψsφ−sθ cθsφ cθcφ

E

. (206)

The conversion from R back to E is given by

ψE = atan2(R21, R11),

θE = asin(−R31),

φE = atan2(R32, R33).

(207)

The conversion from E to quaternion q is given by

q = (cφEcθEcψE + sφEsθEsψE ,

sφEcθEcψE − cφEsθEsψE ,cφEsθEcψE + sφEcθEsψE ,

cφEcθEsψE − sφEsθEcψE ).

(208)

The conversion from q back to E is given by

ψE = atan2(xy + wz, 12 − y2 − z2),

θE = asin(2(wy − xz)),φE = atan2(yz + wx, 1

2 − x2 − y2).

(209)

It can be seen from (207) and (209) that ZYX Euler pitchθE and fused pitch θF are the same mathematical quantity,so we identify them as

θE ≡ θF ≡ θ. (210)

Furthermore, the following relations tie together the ZYXEuler, fused and tilt angles parameters:

φE = atan2(sφF , cα), γ = atan2(sθ, cθsφE ),

φF = asin(cθsφE ), α = acos(cθcφE ),(211)

h = sign(cφE ) =

1 if |φE | ≤ π

2 ,−1 otherwise.

(212)

Away from the fused yaw and ZYX yaw singularities, therelationship between the two yaws is given by

ψE = wrap(ψF + γ − atan2(cαsγ , cγ)), (213)ψF = wrap(ψE − atan2(sθ, sφF ) + atan2(sθcφE , sφE )

= wrap(ψE − atan2(sθ, cθsφE ) + atan2(sθcφE , sφE ).

The relationship between having zero Euler and fused rollcomponents in a rotation is given by

φE = 0 =⇒ φF = 0, (214)φF = 0 =⇒ φE = 0, π. (215)

The implications of having zero Euler pitch are

θ = 0 =⇒

ψE = ψF ,

φE =

φF if h = 1,wrap(π − φF ) if h = −1.

(216)

The implications of having zero Euler roll are

φE = 0 =⇒ ψE = ψF . (217)

T. Axisymmetry of the Fused Angles Representation

When using the fused angles representation in balance-related applications, by design the z-axis should be chosento point in the direction opposite to gravity. This ensures thatthe concepts of ‘roll’, ‘pitch’, and in particular ‘yaw’, lineup with what one would intuitively expect, e.g. that yaw is arotation about a vertical axis that changes ‘heading’ but not‘tilt’. The choice of z-axis however still leaves one degree ofrotational freedom open in the choice of the x and y-axes.More specifically, for right-handed coordinate systems, they-axis must be a 90 clockwise rotation of the x-axis aboutthe z-axis, but otherwise the axes can be freely chosen. Theconcept of axisymmetry refers to the property that one ormore rotation parameters are either invariant to this freedomof choice in the axes, or vary in an intuitive rotational mannerproportional to the choice. More carefully, axisymmetry inthis context refers to the notion that the rotation parameters,for reasons of self-consistency, should be symmetrical aboutthe well-defined z-axis.

1) Fused Yaw: The fused yaw is axisymmetric in thesense that it is invariant to the choice of x and y-axes.Consider a robot that is upright, and thereby considered tohave an identity orientation relative to its environment. If therobot undergoes any rotation, the above statement of fusedyaw axisymmetry asserts that the fused yaw of this rotationis the same no matter what choice of x and y-axes is made.This is an important and reassuring property of the fusedyaw as, given that the z-axis is unambiguously defined, anyconcept of yaw about the z-axis should clearly be a propertyof the actual physical rotation, not some arbitrary choiceof a virtual reference frame made solely for the purpose ofmathematical analysis. It can easily be demonstrated withvirtually any non-degenerate example that Euler yaw is notaxisymmetric, and for different choices of axes can readilyproduce deviations up to 180.

Let U be any global coordinate frame such that zUpoints in the direction opposite to gravity, as required, andsuppose that the rotation that is undergone by the robot isgiven by RUA . This is a fixed physical rotation of the robotrelative to its environment, so it should have a unique well-defined fused yaw according to axisymmetry. As the z-axisis fixed, every valid global coordinate system G that canbe used as a reference frame to quantify RUA (including Uitself) is a pure z-rotation of U. That is, for some angle β,

RUG = Rz(β).

Given any choice of G, a body-fixed frame B is attachedto the robot in such a way that it coincides with G when

Page 17: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

-1 -0.5 0 0.5 1Fused roll ratio (sin?)

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8Fuse

dpitch

ratio

(sin3)

.

sin?

sin 3sin,

- = 0/

- = 45/

- = 90/

- = 135/- = 180/

- = 225/

- = 270/

- = 315/

Fig. 6. Locus of the sine ratios (sinφβ , sin θβ) as β varies (i.e. for allpossible choices of x and y-axes), for (θ0, φ0) = (0.6, 0.4). The triangledemonstrates the decomposition of sinα into the quadrature sinusoidcomponents sin θ and sinφ, and how β can be seen as an offset to γ.

the robot is initially upright, and rotates with the robot. Therotation RUA maps frame G onto frame B, so by (53)

RUA = RUGB = RUG RGB RUG

T. (218)

Taking the fused yaw of both sides and using (178) gives

Ψ(RUA)

= Ψ(RUG RGB RUG

T)

= Ψ(RUG)

+ Ψ(RGB RUG

T)

= Ψ(RUG)

+ Ψ(RGB)−Ψ

(RUG)

= Ψ(RGB).

We note that Ψ(RUA)

is clearly independent of the choiceof G, so Ψ

(RGB)

must also be. This demonstrates that thefused yaw of the rotation is invariant to the choice of x andy-axes (i.e. G), as required.

To show that Euler yaw violates axisymmetry, consider

RUA = Rx( 3π4 ), RUG = Rz(

π2 ).

The Euler yaw of RUA is clearly 0, but from (218),

RGB = RUGT RUA RUG (219)

= ER(π,−π4 , π),

where ER(·) is notation for the rotation matrix correspondingto the given Euler angles parameters. Thus, the Euler yawof RGB is π 6= 0, and as U and G are both valid choicesof axes, it follows that Euler yaw cannot be axisymmetric.The asymmetry of Euler yaw is clearly illustrated for anotherexample in the bottom plot in Fig. 9.

2) Fused Pitch and Roll: The fused pitch and roll areaxisymmetric in the sense that their sine ratios circumscribea uniform circle as a function of the choice of x and y-axes.That is, the locus of (sinφ, sin θ) over all possible choicesof axes is a circle, and this circle is traversed uniformly asthe choice varies.

-1 -0.5 0 0.5 1Fused roll ratio (sin?)

-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

Fuse

dpitch

ratio

(sin3)

0.2

0.4

0.4

0.4

0.6

0.6 0.6

0.6

0.8

0.8

0.8

0.8

0.8

1

1

11

1

1

Fig. 7. Level sets of constant sinα (i.e. the sine of the magnitude of the tiltrotation component of a rotation) in the fused pitch ratio (sin θ) vs. fusedroll ratio (sinφ) cartesian space. The shaded region is the valid domain of(sinφ, sin θ) for the fused angles representation. The circular nature of theplot visually illustrates the axisymmetry of fused pitch and roll.

The fused pitch θ and fused roll φ come together withthe hemisphere h to define the tilt rotation component of arotation. The magnitude of this tilt rotation is given by the tiltangle α, and the relative direction of this tilt rotation is givenby the tilt axis angle γ. φ and θ can be thought of as a way of‘splitting up’ the action of α into its orthogonal components.More precisely, the sine ratios sinφ and sin θ are in fact adecomposition of sinα into quadrature sinusoid components,as illustrated in Fig. 6 and Fig. 9, and as embodied by

sin2 α = sin2 θ + sin2 φ,

γ = atan2(sin θ, sinφ).

The axisymmetry property is equivalent to stating that thechoice of x and y-axes simply results in a fixed phase shift tothe quadrature components. This suggests that the nature offused pitch and roll in expressing a tilt rotation component ismore a property of the actual physical rotation than whateverarbitrary reference frame is chosen to quantify it numerically.It can easily be demonstrated that Euler pitch and roll arenot axisymmetric.

Consider the same robot undergoing a rotation as inSection VIII-T.1, where we had

RUG = Rz(β).

We now introduce the notationRUA = TR(ψ0, γ0, α0)

= FR(ψ0, θ0, φ0, h0),

RGB = FR(ψβ , θβ , φβ , hβ),

(220)

where FR(·) and TR(·) are respectively the rotation matricescorresponding to the given fused and tilt angles parameters.Using this notation, the axisymmetry of fused yaw is equiv-alent to the statement

ψβ = ψ0.

Page 18: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

-1 -0.5 0 0.5 1Fused/Euler roll ratio (sin?/sin?E)

-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1Fuse

d/E

ulerpitch

ratio

(sin3/s

in3 E

)

- = 0/

- = 45/

- = 90/

- = 135/

- = 180/

- = 225/

- = 270/

- = 315/

Fused anglesEuler angles

Fig. 8. Loci of the sine ratios (sinφβ , sin θβ) as β varies (i.e. for allpossible choices of x and y-axes), once for fused pitch θF and roll φF(inner curve), and once for Euler pitch θE and roll φE (outer curve). Thebase rotation RUA used for both loci is FR(−1.2, 0.2,−1.3,−1). The non-circularity of the Euler locus, as well as the non-uniformity of the associatedkeypoints, demonstrate the violation of axisymmetry for Euler pitch and roll.

From (219–220), (25) and (142),

RGB = Rz(β)T RUA Rz(β)

=

· · ·· · ·

sβsφ0 − cβsθ0 cβsφ0 + sβsθ0 cα0

(221)

where the ‘·’ entries are omitted for brevity. Using (25) toexpand the left-hand side and comparing matrix entries gives

−sθβ = sβsφ0− cβsθ0 ,

sφβ = cβsφ0+ sβsθ0 .

This can be written as the matrix equation[sinφβsin θβ

]=

[cβ sβ−sβ cβ

][sinφ0

sin θ0

].

By identifying the middle matrix as a 2D rotation matrix, thisequation can be seen to be the mathematical expression ofthe axisymmetry of fused pitch and roll. The effect of varyingβ, and how this leads to a uniform circular locus is shownin Fig. 6. The phase shift to the quadrature components canbe seen to just be −β.

One can observe that choosing arbitrary x and y-axesis equivalent to choosing an arbitrary β, which in turn isequivalent to adding an arbitrary offset to γ0. In fact, it canbe seen from the phase shift that

γβ = γ0 − β.

As such, all possible loci of sine ratios can be visualised atonce by plotting the contours of constant α while γ varies.This is equivalent to generating the level sets of constantsinα in the fused pitch ratio vs. fused roll ratio plane, theresult of which is shown in Fig. 7. The axisymmetry of fused

0 1 2 3 4 5 6

-1

0

1

Fuse

dan

gle

par

amet

ers A

-

sin 3-

sin ?-

0 1 2 3 4 5 6- (rad)

-2

0

2

Euleran

gle

par

amet

ers A

-

sin 3-

sin ?-

Fig. 9. Plots of pitch and roll sine ratios and yaw against β for both fusedangles (top) and Euler angles (bottom). The base rotation RUA used for bothplots is FR(−1.2, 0.2,−1.3,−1), as in Fig. 8. The invariance of the fusedyaw, as well as the exact quadrature nature of the fused pitch and roll canbe clearly identified. The non-axisymmetry of Euler pitch and roll, and inparticular the irregularity of Euler yaw, can be seen in the bottom plot.

pitch and roll can be clearly visually identified in the figure.An analogous figure for Euler angles is provided in Fig. 10.

The non-axisymmetry of all three Euler angles parametersis visualised in Fig. 8 and Fig. 9. The two figures also clearlyvisualise the corresponding axisymmetry of fused angles forthe same base rotation RUA . Conceptually, the problem ofEuler pitch and roll is the fundamental requirement of anorder of rotations. This leads to definitions of pitch and rollthat do not correspond to each other in behaviour, as onethen implicitly depends on the other.

3) Hemisphere: The hemisphere is axisymmetric in thesense that it is invariant to the choice of x and y-axes. Asthe (3, 3) entry of RGB is cαβ , it can be seen from (221) that

αβ = α0.

The hemisphere in general is a function only of α, as shownin (22), so it immediately follows that

hβ = h0.

This demonstrates that both the tilt angle α and hemisphereh are axisymmetric.

IX. SUPPORTING PROOFS

A. Proof of Section VIII-GRecall from (133) that for q0, q1 ∈ Q and u ∈ R, slerp isgiven by the equation

slerp(q0, q1, u) = (q1q−10 )uq0 = q0(q−1

0 q1)u.

So for any q ∈ Q,

slerp(qq0, qq1, u) = qq0

((qq0)−1qq1

)u= qq0

(q−10 q−1qq1

)u= q[q0(q−1

0 q1)u]

= q slerp(q0, q1, u).

Page 19: Fused Angles: A Representation of Body Orientation for Balancepallgeuer/FusedAnglesManual.pdf · Fused Angles: A Representation of Body Orientation for Balance Philipp Allgeuer and

-1 -0.5 0 0.5 1Euler roll ratio (sin?E)

-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1Eulerpitch

ratio

(sin3 E

)

0.2

0.4

0.4

0.4

0.6

0.6 0.6

0.60.8

0.8

0.8

0.8

0.8

11

1

1

1

1

1 1

Fig. 10. Level sets of constant sinα in the Euler pitch ratio (sin θE ) vs.Euler roll ratio (sinφE ) cartesian space.

B. Proof of Section VIII-H

If Ψ(q0

)= Ψ

(q1

)= ψ, we know from Section VIII-M that

q0 = qf0qt0

q1 = qf1qt1

for qf0 = qf1 = qz(ψ),

where qt0, qt1 are tilt rotations. Thus from (137),

slerp(q0, q1, u) = qz(ψ) slerp(qt0, qt1, u).

If slerp(qt0, qt1, u) is a tilt rotation (the assertion of the resultbeing proven), then

Ψ(slerp(q0, q1, u)

)= ψ.

Therefore, the result holds for all ψ if it holds for tilt rotations(i.e. ψ = 0). Suppose Ψ

(q0

)= Ψ

(q1

)= 0. Then, from (42)

the z-components of q0 and q1 are zero. Recall from (134)that an equivalent definition of slerp is given by

slerp(q0, q1, u) =

[sin((1− u)Ω)

sin Ω

]q0 +

[sin(uΩ)

sin Ω

]q1.

As the output quaternion is just a linear combination of q0

and q1, it is clear that the output quaternion must also havea zero z-component. Therefore, from (42),

Ψ(slerp(q0, q1, u)

)= 0,

and the proof is complete.

C. Proof of Section VIII-O

To see why (178–179) are true, consider

Rz(ψz)R = Rz(ψz)RfRt

= Rz(ψz)Rz(ψ)Rt

= Rz(ψ + ψz)Rt

=⇒ Ψ(Rz(ψz)R

)= ψ + ψz.

Note that the resulting tilt rotation component of Rz(ψz)Ris unchanged from R, demonstrating (179). Now recall thatΨ(R−1

)= −Ψ

(R), define R ≡ R−1, and consider

(RRz(ψz))−1 = Rz(ψz)

−1R

= Rz(−ψz)Rf Rt= Rz(−ψz)Rz(−ψ)Rt

= Rz(−ψ − ψz)Rt=⇒ Ψ

(RRz(ψz)

)= −Ψ

((RRz(ψz))

−1)

= −Ψ(Rz(−ψ − ψz)Rt

)= ψ + ψz.

The remaining results follow trivially from rotation repre-sentation conversions.