Robotics: Science and Systems
Zhibin (Alex) LiSchool of Informatics
University of Edinburgh
Coordinate Transformation
Slide Credit: Prof. Sethu Vijayakumar
Recap: What Tools Do We Need?
2
Coordinate Transformation(Where am I in relation to the
world?)
World Frame
Local Frame
Coordinate definitionThe common definition of the x-y-z coordinate used in robotics: a Cartesian coordinate system that defines our 3-dimensional space (right-hand rule).A position in space is therefore defined by a vector:
The distance between points and is: x y
z
Representation of positionA position is space is therefore defined by a vector:
Hence, two points and can be represented by vectors:
Quiz: what is a mathematically neatway to represent the spatial relation between these two points?
x y
z
r1
r2
Coordinate transformationLet two vectors and be the origins of two coordinates , what the coordinate transformation would be with respect to the global coordinate ? For example, how to represent a vector in coordinate in the global coordinate ?
x y
z
r1
r2
O2 O1
O
Coordinate transformationExample: represent a vector in local coordinate in the global coordinate . Position of a point in local coordinate Position of local coordinate in global coordinate
So position of in
O2
O
v
x y
z
r2
Representation of spatial relation
The coordinates in previous examples have all axes aligned. So what is still missing in a more general case?
Rotational representation
Rigid Body Position & Pose
Pose = Position + OrientationPosition
Prof. Sethu Vijayakumar // R:SS 2017 8
Rotation Matrices• Properties
orthonormal matrix(orthogonal vectors stay orthogonal, normal vectors stay normal)
columns and rows are orthogonal unit vectors
Let the new basis vectors be (e.g.)Then, the coordinate transformation from frame is:
Prof. Sethu Vijayakumar // R:SS 2017
9
Coordinate Transform
Prof. Sethu Vijayakumar // R:SS 2017 10
Simple Rotation Matrices• 2D • 3D
Prof. Sethu Vijayakumar // R:SS 2017
11
Example: a 2D Rotation MatrixHow the rotational matrix is formulated?
How this matrix is used?
or Note: is in a global coordinate, is in a local coordinate.Quiz: a whiteboard exercise to derive these equations
x
y
x’
y’
Rotation Matrix: Good & Bad
• Pros– Rotates vectors
directly– Easy
composition
• Cons– 9 numbers– Difficult to
enforce constraints
Degrees of Freedom (DOF) of a Rotation Matrix• R3x3 has 9 numbers• 6 constraints ( 3 orthogonal, 3 normal)• only 3 degrees of freedom (DOF)Can we represent with minimal (=3) independent parameters?
Prof. Sethu Vijayakumar // R:SS 2017
13
Rotation: Euler Angles• Describe rotations by consecutive rotations about
different axes:
• Z-Y-Z (3-1-3) representation• yaw-pitch-roll or Z-Y-X (3-2-1) ….used in flight!
Prof. Sethu Vijayakumar // R:SS 2017 14
Euler Angles and Gimbal Lock
• Euler angles have a severe problem:– If two axes align: blocks 1 DOF – ‘singularity’ of Euler angles
• Pros– minimal
representation– human readable
• Cons– Gimbal lock– must convert to
matrix to rotate vector
– no easy compositionProf. Sethu Vijayakumar // R:SS 2017 15
Coordinate definitionA GUI that helps to understand the properties, click here
Rotation: Rotation Vector• Using 3 numbers…
• Pros– minimal
representation– human readable
• Cons– singularity for small
rotations– must convert to matrix to
rotate vector– no easy composition
Prof. Sethu Vijayakumar // R:SS 2017 17
Quaternions: extension of complex numbers from 2 dimensions, into 4 dimensions.Complex numbers: Quaternions:
-Recall representation by the rotational Vector: 1) 3d rotation axis is define by a vector (position in [m]); 2) rotational angle is defined by radians. → discrepancy and ambiguity.Quaternions, however, represent all 4dimensions coherently.
Quarternion
Rotation: Quarternion• Math tells: all schemes with 3 numbers will have a
singularity
Prof. Sethu Vijayakumar // R:SS 2017 19
Quarternion: Composition• Conversion to/from matrix
• CompositionProf. Sethu Vijayakumar // R:SS 2017 20
Quaternions: Pros and Cons• Pros
– no singularity– almost minimal
representation– easy to enforce constraints– easy composition– easy interpolation
• Cons– somewhat
confusing– not quite minimal– must convert to
matrix to rotate vector
• Summary of Rotation representations– need rotation matrix to rotate vectors– Quarternions good for free rotations– Euler angles OK for small angular deviations
– but beware singularities!Prof. Sethu Vijayakumar // R:SS 2017 21
Homogeneous Transformations
Definition: position vector in a global coordinate; position vector in a local coordinate;
: rotational matrix
Hence, the transformation is
: offset vector between origins : vector is local frametransformed by
x’
y’
x
y p
r’
Homogeneous Transformations
A compact way of representing coordinate transformations between two frames
in homogeneous transformations, we append 1 to all coordinate vectorsProf. Sethu Vijayakumar // R:SS 2017 23
Composition of transforms
Prof. Sethu Vijayakumar // R:SS 2017 24