An introduction to using dual quaternions to study kinematics

We advocate for the use of dual quaternions to represent poses, twists, and wrenches.

• 2 publications
• 2 publications
02/16/2022

Using dual quaternions in robotics

We advocate for the use of dual quaternions to represent poses and twist...
02/14/2018

Attack RMSE Leaderboard: An Introduction and Case Study

In this manuscript, we briefly introduce several tricks to climb the lea...
04/15/2021

On the existence of quaternary Hermitian LCD codes with Hermitian dual distance 1

For k ≥ 2 and a positive integer d_0, we show that if there exists no qu...
05/17/2020

Dual Learning: Theoretical Study and an Algorithmic Extension

Dual learning has been successfully applied in many machine learning app...
12/31/2020

The Dual Matrix Algorithm for Linear Programming

The Dual Matrix Algorithm, variations of which were proposed in [A.Yu.Le...
11/01/2018

Unsupervised Dual-Cascade Learning with Pseudo-Feedback Distillation for Query-based Extractive Summarization

We propose Dual-CES -- a novel unsupervised, query-focused, multi-docume...
01/11/2018

Note on usage and theory of hyper-dual numbers for first and second order automatic differentiation

Similar to dual numbers, hyper-dual numbers are extended numbers that ca...

1. Introduction

We assume that the reader is familiar with the notion of pose and rigid motion, and the use of quaternions to represent rotations. We use the terms pose and rigid motion interchangeably, since a pose can be considered as a rigid motion relative to a fixed reference frame, and the mathematical operations to manipulate them are identical. Thus we also use the terms rotation and orientation interchangeably, and similarly with translation and position. We refer the reader to [4, 6].

The use of dual quaternions to represent poses is well established, especially in the graphic card industry: [1, 7, 5, 9, 10, 11, 16, 17, 18, 20]

. However, in the robotics industry, it is more common to represent a pose using a quaternion (for the rotation) and a three dimensional vector (for the translation). In this paper, we advocate for the use of dual quaternions.

Let us start with a general discussion of why people might want to represent rotations by unit quaternions instead of three by three orthogonal matrices with determinant . One reason given is that quaternions can be represented with only four numbers, whereas the matrix representation requires nine numbers. Another representation commonly used are Euler angles, and these only require three numbers. However, with Euler angles, the formula for composition of rotations is difficult to calculate. Also, Euler angles suffer from gimbal lock, in which if the rotation takes certain values, the choice of Euler angles isn’t unique, and discontinuities and singularities arise. Quaternions suffer from no such problems.

But in modern times, computer memory is very cost effective, and communication is fast, thus the aformentioned advantages might seem trivial at first. This begs the question: what other advantages do quaternions offer over matrices? Quaternions represent a quantity with three degrees of freedom by a four dimensional vector, whereas matrices use a nine dimensional vector. Suppose one obtains an approximation to a matrix or quaternion? For example, this would be common when using Newton-Raphson to find a rotation satisfying some formula, or to interpolate between rotations. So then one has to find a projection which takes the vector to an admissible vector, that is, a vector that actually represents a rotation. And projecting from a nine dimensional quantity to a three dimensional quantity is going to be much harder than the similarly projection from the four dimensional vector. (The projection from quaternions to unit quaternions is called the

normalization, and is defined in Section2. A suggestion of what such a projection would be for matrices is given at the end of Section 10.)

For representing poses, the usual representation is by a three by three orthogonal matrix with determinant

for the rotation, and a three dimensional vector for the translation, twelve dimensional in all. This has a natural representation as a four by four matrix, as we explain Section 4. A great advantage of this representation is the relationship between pose and twist:

 ddt(pose)=(pose)×(twist). (1)

where the multiplication is matrix multiplication, and a twist is a combination of angular velocity and translational velocity measured with respect to the moving frame.

Another natural representation used a lot is to use a quaternion and a three dimensional vector. But this new representation has problems in that it is not clear how the above equation would work in this situation. However, if one introduces the notion of the dual quaternion, which is an eight dimensional vector, equation (1) is still valid if one uses dual quaternion multiplication.

A challenge with dual quaternions is that they are abstract, which can make them harder to understand. Mathematicians find value behind abstract computational ideas, but Engineers usually find the end result, ‘black box approach,’ more useful.

A useful approach to developing intuition for dual quaternions is to understand the rules with their structure, and the mathematical operations needed to manipulate them, (that is, normalization, basis vector multiplication, pose differentiation). Once one becomes comfortable with their form and function, the advantage of duel quaternions over other methods becomes more apparant. For example, one realizes that computing the projection of an eight dimensional vector to the six degrees of freedom of a pose, is also quite simple. (This projection is also called the normalization, and is defined in Section 3.)

This makes it very useful if one is using the Newton-Raphson Method to find a pose satisfying certain properties. We show how the dual quaternion representation efficiently solves the forward kinematics problem.

Finally we consider the dynamics of poses, that is, the equations of motion of a rigid spinning body. In any representation this can be quite difficult, because of both centripetal and precessional effects. But from a theoretical perspective, using the dual quaternion representation is quite slick.

In summary, while the usual representation using Euler angles and translations is conceptually easy to understand, performing calculations can be difficult. Whereas with dual quaternions, while the are initially conceptually hard to understand, when it comes to calculations they are much easier to work with.

2. Motivation

A pose, or rigid motion, is a rotation followed by a translation. (Semantically, a pose is the position of the end effector of the robot, and thus different from a rigid motion, but mathematically they are the same if we consider a pose to be a rigid motion with respect to the stationary reference frame.) The rotation is represented by a orthogonal matrix with determinant . A translation is a vector in . These represent the pose :

 r↦Rr+t. (2)

Composition of poses is written from right to left. Thus

 (R1,t1)∘(R2,t2)=(R1R2,t1+R1t2). (3)

One way to represent a pose is using a four by four matrix

 [Rt01]=⎡⎢ ⎢ ⎢⎣R11R12R13t1R21R22R23t2R31R32R33t30001⎤⎥ ⎥ ⎥⎦ (4)

Then composition of poses may be computed simply by multiplying matrices of the form (4). In the literature, the Lie group of rotations is often denoted . The Lie group of poses is often denoted .

The problem with this representation is that twelve numbers are required to represent a pose. Other problems, which we discuss below, is that of interpolating a sequence of poses, and of computing forward kinematics.

One common way to solve both of these problems is to represent the rotation by a unit quaternion [2, 13], which we briefly describe here. A quaternion is a quadruple of real numbers, written as , with the algebraic operations . Its conjugate is , its norm is , its normalization is , its real part is , and its imaginary part is . It is called a unit quaternion if , a real quaternion if , and a pure quaternion if . Note the multiplicative inverse is given by .

We identify three dimensional vectors with pure quaternions, by identifying , , and with the three standard unit vectors. A unit quaternion represents the rotation . A rotation by angle about an axis , where , has two unit quaternion representations: . Composition of rotations corresponds to multiplication of unit quaternions. With some practice, it becomes easier to read a rotation from a quaternion than it does from Euler angles, the standard method of representing rotations.

We can represent quaternions as four dimensional vectors, and give it the inner product

 A⋅B=Re(A¯¯¯¯B)=Re(¯¯¯¯AB). (5)

Then a way to represent poses is as a pair . This is the way poses are represented internally in the Robotic Operating System [15]. Then the composition rule is

 (Q1,t1)∘(Q2,t2)=(Q1Q2,t1+Q1t2¯¯¯¯Q1). (6)

A difficulty with this is that the composition is not a bilinear operation as it was with the representation (4). (This lack of bilinear representation becomes particularly problematic when representing twists, which we describe below.) However there is a way to resolve this as follows. Write and . Then equation (6) can be rewritten as

 (Q1,2B1Q−11)∘(Q2,2B2Q−12) (7) =(Q1Q2,2B1Q−11+2Q1B2Q−12Q−11) =(Q1Q2,2(B1Q2+Q1B2)(Q1Q2)−1).

This leads to representing the pose by a unit dual quaternion, which we now describe.

3. Dual quaternions to represent poses

A dual quaternion is a pair of quaternions, written as , with the extra algebraic operation .

The conjugate dual quaternion of is . Conjugation reverses the order of multiplication:

 ¯¯¯¯¯¯¯¯¯¯η1η2=¯¯¯η2¯¯¯η1. (8)

There is another conjugation for dual quaternions: , but we have no cause to use it in this paper, except in equation (19) below.

A unit dual quaternion is a dual quaternion such that , equivalently, that is a unit quaternion and . A pure dual quaternion is a dual quaternion such that both and are pure quaternions.

If is a dual quaternion with , then its multiplicative inverse can be calculated using the formula

 η−1=Q−1−ϵQ−1BQ−1. (9)

If is a unit dual quaternion, then there is a computationally much faster formula:

 η−1=¯¯¯η. (10)

For a dual quaternion , it is not really possible to mix and additively. The quaternion is unitless, whereas the quaternion has units of length. For this reason, when measuring how large a dual quaternion is, everything must be with respect to , the characteristic length scale. The size of a dual quaternion is defined to be

 ∥A+ϵB∥=(|A|2+l−2|B|2)1/2. (11)

A dual number is anything of the form , where and are real numbers. The norm of a dual quaternion is the dual number defined by the two steps:

 |η|2=¯¯¯ηη=η¯¯¯η=|Q|2+2ϵ(B⋅Q), (12) |η|=√|η|2=|Q|+ϵ(B⋅Q)/|Q|. (13)

The norm preserves multiplication, that is, if and are two dual quaternions, then

 |η1η2|=|η1||η2|. (14)

If is any dual quaternion with , then we define its normalization to be the unit dual quaternion

 ˆη=|η|−1η=η|η|−1=Q/|Q|+ϵ(B−(B⋅Q)Q/|Q|2). (15)

(We remark that the normalization of a dual quaternion is used in the computer graphics industry [9, 10].) While this normalization formula might seem initially quite complicated, after thinking about it one can see that it is the simplest projection that enforces and .

The normalization also satisfies the following properties.

• If is a unit dual quaternion, then .

• Normalization preserves multiplication, that is, if and are two dual quaternions, then

 ˆη1η2=ˆη1ˆη2. (16)

Note that

 η−1=|η|−2¯¯¯η, (17)

and this could have been the definition of the multiplicative inverse of a dual quaternion, except that this definition is circular.

We set for the set of dual quaternions, for the set of unit dual quaternions, and for the set of pure dual quaternions.

If we are given a pose represented by , then the pose is also represented by the unit dual quaternion

 η=Q+12ϵtQ. (18)

As we have shown above, composition of poses corresponds to multiplication of unit dual quaternions. If is a 3-vector, and is the image of under the action of the pose , then

 1+ϵs=η(1+ϵr)¯¯¯η∗, (19)

but generally it is easier to use the formula

 s=Qr¯¯¯¯Q+2B¯¯¯¯Q=(Qr+2B)¯¯¯¯Q. (20)

The introduction of the factors and is unnecessary, but it slightly improves formulas for the twist, as we see below.

It is difficult for a human to look at the second part of a unit dual quaternion, and from that read what the translational part of the pose should be. So dual quaternions work better for an internal representations of poses rather than human readable representations.

4. Kinematics: dual quaternions to represent twists

The translational velocity of a translating reference frame is given by . The angular velocity of a rotating frame is given by the differential equation

 ˙R=Rw⋆, (21)

or , where is the Hodge star operator of [19]:

 w⋆=⎡⎢⎣0−w3w2w30−w1−w2w10⎤⎥⎦. (22)

(Equation (21) gives the angular velocity with respect to the rotating reference frame. If one wants the angular velocity with respect to the stationary reference frame, use instead .)

Note that

 (w⋆)r=w×r, (23)

where denotes the cross product.

A twist is the pair of vectors that describe the change of pose in the moving reference frame, that is:

 ddt[Rt01]=[Rt01][w⋆v00]. (24)

(Note in particular that , so that a continual application of a twist can result in a motion following a straight line, an arc of a circle, or a spiral.) The set of angular velocities, and the set of twists are both Lie algebras, often denoted by and in the literature.

The quaternion-translation formulation doesn’t have a representation like equation (1):

 ddt(Q,t)=(12Qw,Qv¯¯¯¯Q). (25)

But with the unit dual representation, because the composition of poses is given by a bilinear multiplication, it follows that the twist is represented by the dual quaternion satisfying the differential equation.

 φ=η−1˙η,or˙η=ηφ. (26)

It will be shown in Section 9 (see also [7, 18]) that is the pure dual quaternion

 φ=12w+12ϵv. (27)

Note that if is a unit dual quaternion that is a function of time , then is always a pure dual quaternion. (Note that is a pure dual quaternion equal to the twist relative to the fixed frame of reference. Note also that the factor attached to in equation (27) is a consequence of the introduction of the factor in equation (18), and thus is essentially arbitrary.)

5. Dual quaternions to represent wrenches

Let the pose represent the reference frame that moves with the end effector. It is not necessary (although it can simplify things) that the center of mass of the end effector coincides with the origin of the moving frame.

The wrench dual quaternion is defined to be

 τ=2q+2ϵp, (28)

where and are the torque and force, respectively, applied to the end effector at the origin of the moving frame, measured with respect to the moving frame.

If is the center of mass of the end effector in the moving frame, then the twist about the center of mass is given by

 φ0=φ+12ϵw×r0, (29)

where , and the wrench applied about the center of mass is

 τ0=τ+2p×r0. (30)

The reason for introducing the factor in definition (28) is so that the rate of change of work done to the end effector is given by

 ddt(work done)=τ⋅φ=τ0⋅φ0. (31)

See [3] for the origins of the term twist and wrench as pairs of 3-vectors, which are examples of screws.

6. Interpolation of poses

Suppose that we are given a sequence of times and rotations, and . We would like to find a function from to rotations such that the third derivative of is bounded, and . If the quantities were merely vectors, we could use cubic splines. But if we perform a similar calculation on the matrices, we cannot guarantee that the matrix is a rotation matrix.

So what we want is to find a map that projects general matrices onto rotation matrices. But it is not obvious how to find such a map that is computationally efficient. It is here that using quaternions really has great advantages over matrices, because an obvious map from general quaternions to unit quaternions is to normalize.

Let be the quaternion representation of respectively. Let be the cubic spline interpolation such that . Then

 F(t)=1|G(t)|G(t) (32)

provides a computationally fast, low jerk, method of interpolating the rotations.

This can be extended to interpolate poses. Given times and unit dual quaternions , first interpolate to get a function such that , and then normalize it to get a function . This gives a computationally fast, low jerk, method for interpolating poses.

It is perhaps better to interpolate the rotation quaternions and the translations separately. This is because the center of gravity typically travels in a straight line rather than the arc of a curve, but naive interpolation of dual quaternions follows arcs of curves if the angular rotation is non-zero. (Interpolation of dual quaternions is more appropriate for ‘skinning’ [9, 10].)

If one wants to find a function that passes through these points, and has low jerk even at the end points and , this can be done by adding a ‘ramp up’ and ‘ramp down’ at the ends of the trajectory. Create a free cubic spline on and . Then define a function

 s(t)=⎧⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎨⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪ ⎪⎩12(t0+t1)if t

where

 f(t)=12+12(2−t)t3. (34)

Since , , and , it follows that has bounded third derivative, for , for , and for . Thus

 η(t)=ˆγ(s(t)) (35)

provides a low jerk function, even at the end points, that passes through the appropriate points. it is important that and be large enough to allow the trajectory to ‘ramp up’ and ‘ramp down’ smoothly.

7. Perturbations of poses

Suppose one has a pose that varies in time, and a fixed time . Then we would like to find a good representation of the perturbation of from a reference pose when is close to . One way to do this is to choose a new reference frame in which , the identity pose, or rather, to think about how behaves.

It can be seen that for close to that there is a pure dual quaternion such that

 η=ηrˆ(1+θ)≈ηr(1+θ). (36)

Thus

 θ≈η−1rη−1=¯¯¯ηrη−1 (37)

gives a great way to measure the perturbation.

We prefer instead to use what we shall call the Lie difference, which we denote using , which is close to (37), but is always a pure dual quaternion:

 θ≈η△ηr=12(¯¯¯ηrη−¯¯¯ηηr)=Im(¯¯¯ηrη). (38)

Note that if and are pure dual quaternions, and is an invertible dual quaternion, then

 (η(1+θ1))△(η(1+θ2))=θ1−θ2+O(|θ1|2+|θ2|2). (39)

This gives a great way to map perturbations of non-linear poses to linear twists. These can be very effective in control theory.

8. Spherical linear interpolation of dual quaternions

Suppose we are given two unit dual quaternions, and ? The problem is to find the dual quaternion valued function of time, denoted , such that at , it takes the value , that at , it takes the value , and such that its twist, , is a constant pure dual quaternion. The name of the function, ‘slerp’, comes from the equivalent problem for orientations [14].

This requires two functions. The first is the exponential function:

 exp(θ)=∞∑k=0θkk!, (40)

The function as function of time is the pose traveled if it is the identity pose at , and maintains a constant twist , that is

 ddtexp(tθ)=θexp(tθ)=exp(tθ)θ. (41)

The second is a logarithm function, which given a unit dual quaternion , finds such that . There are infinitely many possibilities for , so we will just describe the principal value, that is, the one for which the norm of the angular velocity is minimized. Then

 slerp(η1,η2,t) =η1exp(tlog(¯¯¯η1η2)) (42) =exp(tlog(η2¯¯¯η1))η1.

If one is merely interested in interpolating between the poses represented by these unit dual quaternions, multiply one of them by so that non-dual part of has non-negative real part.

The results of this section may be found in [12]. We have seen similar results in [18], but we believe our formulas to be more explicit.

Given any dual quaternion

 η=c+d+ϵ(x+y), (43)

by decomposing into a vector parallel to and perpendicular to

, we can suppose without loss of generality that there exists orthonormal vectors

and such that is a linear combination of , , , , and .

If and are orthonormal vectors, then if

 exp(12wta+ϵ(12v1ta+12v2tb)) (44) =(cos(12wt)+sin(12wt)a)(1+12ϵv1ta) =+ϵv2wsin(12wt)b,

and if

 exp(12ϵvta)=1+12ϵvta. (45)

If , this represents a pose that rotates counterclockwise with angular velocity around , and translates by

 t=v1ta+v2w(sin(wt)b+(1−cos(wt))(a×b)), (46)

that is, the sum of a point on a line in the direction of moving with speed , and a point on a circle in the plane perpendicular to of radius which is traversed once every time units. If , this represents a pose with the identity rotation and translating in a straight line with velocity .

Suppose and are orthonormal vectors, and that

 η=c+sa+ϵ(x+y1a+y2b) (47)

is a unit dual quaternion (so and ), with . Let

 t=\rm atan2(s,c), (48)

that is, the angle part of the polar coordinates of , with . Then if then

 log(η)=ta+ϵ(cy1−sx)a+ϵty2sb, (49)

where if we assume , and we set .

It is not possible to assign a canonical principal value for , because it could be for any unit vector .

9. Proofs

Proof of Equations (14) and (16).

First note that any dual number commutes with any dual quaternion. Thus

 |η1η2|2=¯¯¯η2¯¯¯η1η1η2=¯¯¯η2|η1|2η2=|η1|2¯¯¯η2η2=(|η1||η2|)2, (50)

and

 ˆη1η2=|η1η2|−1η1η2=|η1|−1|η2|−1η1η2=|η1|−1η1|η2|−1η2=ˆη1ˆη2. (51)

Proof of Equation (27).

First, if we differentiate , we obtain , that is, is pure.

Suppose the position is the image of the constant position under the pose represented by and also represented by . Differentiating equation (2) we obtain

 ˙s=Rw⋆r+Rv=R(w×r+v). (52)

Differentiating equation (19) we obtain

 ϵ˙s=ddt(η(1+ϵr)¯¯¯η∗)=η(φ(1+ϵr)+(1+ϵr)¯φ∗)¯¯¯η∗. (53)

After some manipulation, and setting , we obtain

 ˙s=Q(a×r+b)¯¯¯¯Q. (54)

Comparing equations (52) and (54), we obtain

 w×r+v=a×r+b, (55)

and since this holds for all , the result follows. ∎

10. Projection from matrices to orthogonal matrices

What would be a good projection of matrices onto rotation matrices? One suggestion is , which works if we have

. One way to compute it is via the singular value decomposition

, when . However this is computationally expensive. See [8].