Upload
others
View
14
Download
0
Embed Size (px)
Citation preview
Chapter 2 Math Fundamentals
Part 5 2.8 Quaternions
Mobile Robotics - Prof Alonzo Kelly, CMU RI 1
Outline • 2.8.1 Representations and Notation • 2.7.2 Quaternion Multiplication • 2.7.3 Other Quaternion Operations • 2.7.4 Representing 3D Rotations • 2.7.5 Attitude and Angular Velocity • Summary
Mobile Robotics - Prof Alonzo Kelly, CMU RI 2
Outline • 2.8.1 Representations and Notation • 2.7.2 Quaternion Multiplication • 2.7.3 Other Quaternion Operations • 2.7.4 Representing 3D Rotations • 2.7.5 Attitude and Angular Velocity • Summary
Mobile Robotics - Prof Alonzo Kelly, CMU RI 3
Smart Irishman: Hamilton • Quaternions
– Probably the most powerful number system in common use.
• Hamiltonian mechanics – Generalization of Lagrange
Mechanics – Which was a generalization of
Newton-Euler Mechanics. – Which was a generalization of
Newtonian Mechanics.
Mobile Robotics - Prof Alonzo Kelly, CMU RI 4 4
5
Was It All the Guinness?
Mobile Robotics - Prof Alonzo Kelly, CMU RI 5
6
Core Problem and Properties
• How can we divide a vector by a vector? • Answer. Need to have “principle imaginaries”:
• Quaternions: – are generalizations of complex numbers which do not
commute (complex #s do). – can represent every transformation that an HT can
represent.
i2 j2 k2 ijk 1–= = = =
Mobile Robotics - Prof Alonzo Kelly, CMU RI 6
7
Why Use Em?
• Only way to solve some problems – like the problem of generating regularly spaced 3D
angles. • Best way to solve some problems.
– No “gimbal lock” at Euler angle singularity. – Still not a unique representation though.
• Simplest way to solve some problems. – Some problems in registration can be solved in closed
form. • Fastest way to solve some problems.
– “Quaternion loop” in an inertial navigation system updates vehicle attitude 1000 times a second.
Mobile Robotics - Prof Alonzo Kelly, CMU RI 7
8
Intuition from Complex Numbers
• Use a second “imaginary” dimension.
• Permits manipulation of rotations like a vector. – Remember
“phasors” in EE.
i
θ
Mobile Robotics - Prof Alonzo Kelly, CMU RI 8
9
Notations
• 4-tuples • Hypercomplex
numbers • Sum of real and
imaginary parts • Ordered doublet
• Exponential
q0 q1 q2 q3, , ,( )
q q0 q1i q2j q3 k+ + +=
Manipulate like Polynomials
q q q+=
q q,( )
q e12---θw
=
I will use these two
Mobile Robotics - Prof Alonzo Kelly, CMU RI 9
10
My Preference
• Mostly use the scalar-vector sum form:
• Occasionally write it out to get hypercomplex form:
q q0 q1i q2j q3 k+ + +=
q q q+=
~ means quaternion means 3D normal vector means scalar
Mobile Robotics - Prof Alonzo Kelly, CMU RI 10
Outline • 2.8.1 Representations and Notation • 2.7.2 Quaternion Multiplication • 2.7.3 Other Quaternion Operations • 2.7.4 Representing 3D Rotations • 2.7.5 Attitude and Angular Velocity • Summary
Mobile Robotics - Prof Alonzo Kelly, CMU RI 11
12
Multiplication • Quaternions are elements of a vector space endowed
with multiplication. – Just Like Complex Numbers
• The expression:
• Gives the sum of all these elements:
• So, we need to define what i*i etc mean…
pq p0 p1i p2j p3k+ + +( ) q0 q1i q2j q3k+ + +( )=
Mobile Robotics - Prof Alonzo Kelly, CMU RI 12
13
Multiplication Rule • Two goals:
– 1) Manipulate like polynomials – 2) Product of two quaternions is a quaternion.
• To get things to work as Hamilton intended we need to have:
• Or, more compactly:
i2 j2 k2 ijk 1–= = = =
Diagonals work like complex numbers. Off diagonals work like vector cross product.
Mobile Robotics - Prof Alonzo Kelly, CMU RI 13
14
Product • In hypercomplex (polynomial) form:
• In vector form:
• The last term can be written in terms of familiar vector products.
• Convenient to summarize like so:
pq p0 p1i p2j p3k+ + +( ) q0 q1i p2j p3k+ + +( )=
pq p0q0 p1 q1– p2q2– p3q3–( ) …( ) i …+ +=
pq p p+( ) q q+( )=pq pq pq qp pq+ + +=
pq p q p q•–×=
pq pq p q•– pq qp p q×+ + +=
?
Not the same thing
2 common vector products
Mobile Robotics - Prof Alonzo Kelly, CMU RI 14
15
Non-Commutativity • The vector cross product does not commute. Therefore:
pq q p≠
What is the source of this property?
Mobile Robotics - Prof Alonzo Kelly, CMU RI 15
Outline • 2.8.1 Representations and Notation • 2.7.2 Quaternion Multiplication • 2.7.3 Other Quaternion Operations • 2.7.4 Representing 3D Rotations • 2.7.5 Attitude and Angular Velocity • Summary
Mobile Robotics - Prof Alonzo Kelly, CMU RI 16
17
Addition • Works just like vectors, polynomials, and complex
numbers…. p q+ p0 q0+( ) p1 q1+( ) i p2 q2+( )j p3 q3+( )k+ + +=
Mobile Robotics - Prof Alonzo Kelly, CMU RI 17
18
Distributivity • Works just like vectors, polynomials, and complex
numbers…. p q+( ) r p r qr+=
p q r+( ) p q p r+=
Mobile Robotics - Prof Alonzo Kelly, CMU RI 18
19
Dot Product and Norm • Works just like vectors, polynomials, and complex
numbers….
• Can now define a length (norm):
• Unit quaternions have a norm of unity.
p q• pq p q•+=
q q q•=
Not the same thing
Mobile Robotics - Prof Alonzo Kelly, CMU RI 19
20
Conjugate • Works just like complex numbers….
• Product with conjugate equals dot product:
• Another way to get the norm is then:
q* q q–=
qq* qq q q•+( ) q q•= =
q qq*=Mobile Robotics - Prof Alonzo Kelly, CMU RI 20
21
Quaternion Inverse • The Big Kahuna. Since we have:
• By definition of inverse:
• So….
• That’s how you divide a vector by a vector!
q q* q 2⁄ 1=
q 1– q* q 2⁄=
pq--- pq 1– p q*
q 2--------= =
Mobile Robotics - Prof Alonzo Kelly, CMU RI 21
Outline • 2.8.1 Representations and Notation • 2.7.2 Quaternion Multiplication • 2.7.3 Other Quaternion Operations • 2.7.4 Representing 3D Rotations • 2.7.5 Attitude and Angular Velocity • Summary
Mobile Robotics - Prof Alonzo Kelly, CMU RI 22
23
Vectors as Quaternions • “Quaternionize”:
x 0 x+=
Mobile Robotics - Prof Alonzo Kelly, CMU RI 23
24
Rotations as Quaternions • The unit quaternion:
• Represents the operator which rotates by the
angle θ around the axis whose unit vector is 𝑤𝑤� .
• The inverse is clearly:
q θ2---cos w θ
2---sin+=
θ 2 2 q q,( )atan=
w q q⁄=
Real vectors are just quaternions 0+xi+yj+zk
Mobile Robotics - Prof Alonzo Kelly, CMU RI 24
25
Rotating a Vector (Point) • Use the quaternion sandwich:
x '˜ qx q*=w
θ
x x’
Mobile Robotics - Prof Alonzo Kelly, CMU RI 25
26
Composite Rotations • Use the composite quaternion sandwich….
• Recall:
• Thus:
x ''˜ px '˜ p* pq( ) x q*p*( )= =
x '˜ qx q*=
Composition of operations equals multiplication.
Conjugate of a product works like matrices!
Mobile Robotics - Prof Alonzo Kelly, CMU RI 26
27
Quaternion to Rot() Matrix • For the quaternion:
• The equivalent Rot() matrix is:
q q0 q1i q2j q3 k+ + +=
R
2 q02 q1
2+[ ] 1– 2 q1q2 q0q3–[ ] 2 q1q3 q0q2+[ ]
2 q1q2 q0q3+[ ] 2 q02 q2
2+[ ] 1– 2 q2q3 q0q1–[ ]
2 q1q3 q0q2–[ ] 2 q0q1 q2q3+[ ] 2 q02 q3
2+[ ] 1–
=
Mobile Robotics - Prof Alonzo Kelly, CMU RI 27
28
Rot() Matrix to Quaternion • For the Rot() matrix:
• The equivalent quaternion is determined from:
Rr11 r12 r13
r21 r22 r23
r31 r32 r33
=
r11 r22 r33+ + 4q02 1–=
r11 r22– r33– 4q12 1–=
r11– r22 r33–+ 4q22 1–=
r11– r22– r33+ 4q32 1–=
Mobile Robotics - Prof Alonzo Kelly, CMU RI 28
Are quaternions unique for a given rotation?
Calculus (wrt scalars) • Derivatives work like you would expect:
• Integrals work like you would expect:
29
tddq
tddq
tddq
+=
q td0
t
∫ q td0
t
∫ q td0
t
∫+=
Mobile Robotics - Prof Alonzo Kelly, CMU RI 29
Outline • 2.8.1 Representations and Notation • 2.7.2 Quaternion Multiplication • 2.7.3 Other Quaternion Operations • 2.7.4 Representing 3D Rotations • 2.7.5 Attitude and Angular Velocity • Summary
Mobile Robotics - Prof Alonzo Kelly, CMU RI 30
Angular Velocity • Define the angular velocity:
• For a unit quaternion representation of
orientation: • Its time derivative is:
31
q t( ) θ t( )2
----------cos w θ t( )2
----------sin+=
tddq t( ) 1
2---ωn t( ) q t( )=
ωn t( ) ω0 ω1i ω2j ω3k+ + +( )=
dubyaQ
Mobile Robotics - Prof Alonzo Kelly, CMU RI 31
Recall the skew matrix derivative of a rotation matrix.
Angular Velocity • That was for angular velocity represented in
navigation coordinates: • If you have it in body coordinates, just use the
instantaneous value of itself to convert:
• Substituting:
32
ωn t( ) ω0 ω1i ω2j ω3k+ + +( )=
ωn t( ) q t( )ωb t( ) q t( )*=
q t( )
tddq t( )
12---q t( )ωb t( )=
Qdubya
Mobile Robotics - Prof Alonzo Kelly, CMU RI 32
“Quaternion Loop” • Runs at 10 kHz inside an INS:
• 16 * 2 = 32 flops
33
q t( ) 12--- q t( )ωb t( ) td
0
t∫=
Mobile Robotics - Prof Alonzo Kelly, CMU RI 33
“Quaternion Loop” • For highest accuracy, we can use Jordan’s trick:
• Define the skew matrix of a quaternion:
34 Mobile Robotics - Prof Alonzo Kelly, CMU RI 34
“Quaternion Loop” • But such matrices have closed form exponentials:
• Where:
• After more manipulation
35 Mobile Robotics - Prof Alonzo Kelly, CMU RI 35
Outline • 2.8.1 Representations and Notation • 2.7.2 Quaternion Multiplication • 2.7.3 Other Quaternion Operations • 2.7.4 Representing 3D Rotations • 2.7.5 Attitude and Angular Velocity • Summary
Mobile Robotics - Prof Alonzo Kelly, CMU RI 38
39
Summary • Quaternions are hypercomplex numbers with an
i,j,and k that act like the i in complex numbers. • Notation is half the battle. • Provide elegant and efficient ways to model 3D
transformations of points (and hence 3D coordinate system conversions).
Mobile Robotics - Prof Alonzo Kelly, CMU RI 39