Quaternions and E*gen!
robotics focus group #3
Output a real-time map of surroundings
Today:
visual odometry: movement between camera frames
+
3d rigid body motion: fundamentals of understanding how robot mathematically represents space
Why does all this rotation stuff matter?
rosrun tf static_transform_publisher 0 0 0 0 0 0 world laser 100
Robot Discussion
Hardware
Software
Euler Angles
Problems:
3x3 Rotation Matrix
Each column represents result of rotation x/y/z axes, respectively
0.32 = x-component of transformed x-axis in terms of original x-axis
0.46 = y-component of transformed y-axis in terms of original x-axis
-0.83 = z-component of transformed z-axis in terms of original x-axis
Alternatives to Quaternions
3x3 Rotation Matrix (X/Y/Z)
Euler Angles
Why Quaternions?
z1=a+bi
z2=c+di
what is a quaternion?
where
it’s very similar to complex numbers that you are familiar with
another representation
“ordered pair”
real quaternions
pure quaternions
binary form (uses unit quaternion)
onto the fun stuff! rotations
rotating pure quaternions orthogonal to q is ok!
but happens with quaternions not orthogonal to q?
we no longer get a pure quaternion :(
genius method:
we post multiply the result by the inverse of q
this gives us a pure quaternion!
but now we’ve rotated by double…
so we halve the angle, and use
interpolation
quaternions overcome gimbal lock!
we use something called SLERP, spherical linear interpolation
allows us to smoothly interpolate through space
linear interpolation
spherical interpolation
we can use exactly this, just with quaternions
we find the angle by using regular formula between vectors, just with two quaternions
things to note:
conversion to and from Euler angles
Conversion_between_quaternions_and_Euler_angles
cameras
in 3d engines, we can encode the direction (“look at”) as a quaternion
we can transform world coordinates to camera coordinates and vice versa
by using quaternions!
trivia
Why Quaternions?
z1=a+bi
z2=c+di
Eigen!
some helpful library links:
AngleAxis<float> aa(angle_in_radian, Vector3f(ax,ay,az));
Quaternion<float> q; q = AngleAxis<float>(angle_in_radian, axis);
Most common Eigen structures for rotations
• Rotation matrix ( 3 × 3 ): Eigen::Matrix3d.� • Rotation vector ( 3 × 1 ): Eigen::AngleAxisd.� • Euler angle ( 3 × 1 ): Eigen::Vector3d.� • Quaternion ( 4 × 1 ): Eigen::Quaterniond.� • Euclidean transformation matrix ( 4 × 4 ): Eigen::Isometry3d. • Affine transform ( 4 × 4 ): Eigen::Affine3d.� • Perspective transformation ( 4 × 4 ): Eigen::Projective3d.
Let’s end off with an example
transformation that preserves distances and angles
Iteratively applies the translations
T1W and T2W are instances of Isometry3d
T1W is the transformation (rotation being q1 followed by translation by t1)
P2 is the answer, resulting transformed point
Now, let’s take a look at some basic matrix things you can do with Eigen !
Robot Discussion
Hardware
Software
Next few weeks.. the big picture