F1TENTH Autonomous Racing
�Pose Representation and Coordinate Transformation
Safe Autonomy Lab
University of Pennsylvania
Rahul Mangharam
University of Pennsylvania
rahulm@seas.upenn.edu
Acknowledgements
Except where otherwise noted, this work is licensed under
This course is a collaborative development with significant contributions from:
Hongrui Zheng (lead), Matthew O’Kelly (lead), Johannes Betz (lead), Joseph Auckley, Madhur Behl, Luca Carlone, Jack Harkins, Paril Jain, Kuk Jang, Sertac Karaman, Dhruv Karthik, Nischal KN, Thejas Kesari, Matthew Lebermann, Kim Luong, Yash Pant, Varundev Shukla, Nitesh Singh, Siddharth Singh, and many others.
We are grateful for learning from each other
Frames of Reference
What we’ll cover today
4
Frames and Transformations on
Autonomous Vehicles
x
Why do we need Frame Transformations on AV (1)
Reason 1:
Sensors provides measurement in the frame of reference specific to that sensor
www.autonomousvehicletech.com
RGBD
Tesla
Cameras! Lots of cameras!
Waymo
LIDARS! Lots of LIDARS!
Uber
Cameras and LIDAR
Navigation requires fusing multiple sensor perspectives
Each sensor
is processed
individually
Navigation requires fusing multiple sensor perspectives
Multiple sensor outputs are combined to provide a combined Birds Eye View
Input semantic segmentation images and predicted BEV map in Cam2BEV (source)
Why do we need Frame Transformations on AV (2)
Reason 2:
Mapping is usually done by tying submaps together
Coordinate Frames
x
What is a Coordinate Frame?
x
y
z
x
y
x
y
In many robotics problems,
the first step is to assign a coordinate frame to all objects of interest
Why do we need Coordinate Frames?
y
x
Absolute coordinates in World Frame Relative coordinates between robots
Why do we need Coordinate Frames?
y
x
pose = position & rotation
Coordinates have no meaning without specifying coordinate frame
Why do we need Coordinate Frames?
Rigid body transformations transform points from one frame to another
time t
time t+1
Right-handed Coordinate Frames
Direction of axes is important!
There is a common mnemonic:
right- handed
left- handed
Transformations and Frames
x
Transformations and Frames: Map Frame
– where are you with respect to the map – coordinates from origin
Map frame
Transformations and Frames: Sensor Frame
The – how does the world look from the sensor
Does this tell you anything about where obstacles are in the map?
Does this tell you anything about where we are in the map?
We must link frames together
Sensor frame
Transformations →
Transformations and Frames
The frame of reference in which the measurement is taken
Distance measurements returned by LIDAR
𝛥𝑧
Transformations and Frames
𝛥𝑧
X
Z
Y
The scan values from the LIDAR will not tell us how far the obstacles are. We must take care of the offsets
𝛥𝑥
Transformations and Frames
The frame of reference in which the measurement is taken
Distance measurements returned by LIDAR
𝛥𝑧
X
Z
Y
A world without frames and transformations
The actual motion of the car
Transformations and Frames
To convert measurements from one frame to another we need to perform transformations
X
Z
Y
Y
Y
Map frame
Car frame
laser frame
Between frames we need transformations that convert measurements from one frame to another
Transformations and Frames
X
Z
Y
Y
Y
Map frame
Car frame
laser frame
Y
Y
Y
Transform from map to car
Transform from car to laser
To convert measurements from one frame to another we need to perform transformations
Static Transformations Dynamic Transformations
Rigid Body Transforms: An aside
What’s with it being Rigid?
Play-Doh: Not a rigid body
The distance between any two given points of a rigid body remains constant in time regardless of external forces exerted on it.
Rigid Body Transforms
Baymax: Obviously, not a rigid body
Summary: why do we need transforms between frames?
Reference Frames on F1TENTH
x
Multiple Reference Frames on F1TENTH
We need to know where the robot is in the world.
We need to know the relationship between the measurement frame and the actuation frame.
32
map
laser
Why?
Multiple Reference Frames
Measurement Frame
Measurement in laser frame: can see some information about the environment, and some information on the positional relationship between the robot and the world.
Multiple Reference Frames
World Frame
Measurement in map frame: the range measurement we see fully makes sense. The observation matches up with the environment. We know where the robot is in the environment.
Multiple Reference Frames
Laser frame
Map frame
Frames we will use
map
base_link
laser
P.S. In ROS, RGB → XYZ
Frames we will use: Environment
map
base_link
laser
Frames we will use: Actuation
2. base_link
map
base_link
laser
Frames we will use: Measurement
3. laser
map
base_link
laser
Odometry
odom
map
base_link
laser
Poses & Transformations
x
An Example
An Example
Could be remedied by adding a frame in the center of the chassis and calculated the TTC from there.
An Example
How do we transform the measurements in the original frame into the new frame that we just added?
Rigid Body Transforms
XA
YA
ZA
Rigid Body Transforms
XB
YB
ZB
XA
YA
ZA
Rigid Body Transforms
XB
YB
ZB
XA
YA
ZA
Rotating a point in 2D
Rotating a point in 2D
Rotating a point in 2D
Rotating a point in 2D
Rigid Body Transforms
Special type of matrices called Rotation matrices
XA
YA
ZA
XB
YB
ZB
Rigid Body Transforms
XA
YA
ZA
XB
YB
ZB
Takes points in frame B and represents their orientation in frame A
Rigid Body Transforms: Rotation Matrices
XA
YA
ZA
XB
YB
ZB
Rigid Body Transforms: Rotation Matrices
XB
YB
ZB
Cosine component
(0,5,0)
Rigid Body Transforms: Rotation Matrices
XB
YB
ZB
Sine component
(0,5,0)
Rigid Body Transforms: Rotation Matrices
XB
YB
ZB
(0,5,0)
Rigid Body Transforms: Rotation Matrices
We have the Rotation Matrix, so now what?
We now have the point P as referenced in frame A
Known
Known
For example
= (-2.5,4.3,0)
XA
YA
ZA
(-2.5,4.3,0)
XA
YA
ZA
Important point to remember
The rotation matrix will take care of perspectives of orientation, what about displacement?
XA
YA
ZA
XB
YB
ZB
XA
YA
ZA
XB
YB
ZB
Origins of both the frames are at the same location
Rigid Body Transforms
XB
YB
ZB
XA
YA
ZA
Rigid Body Transforms
XB
YB
ZB
XA
YA
ZA
Rigid Body Transforms
XB
YB
ZB
XA
YA
ZA
Rigid Body Transforms
What we need is Point p with respect to Frame A, given its pose in Frame B
XB
YB
ZB
XA
YA
ZA
Rigid Body Transforms:
And we are back to the Future
XB
YB
ZB
XA
YA
ZA
XB
YB
ZB
XB
YB
ZB
Rigid Body Transforms:
And we are back to the Future
What we need is Point p with respect to Frame A, given its pose in Frame B
XA
YA
ZA
XB
YB
ZB
= Homogeneous transformations that transforms
measurements in Frame B to those in Frame A
Recap:
Rotation & Translation in a slightly different example
O2
p2
O1
p’
First we apply the rotation
Frame 2
Frame 1
Putting everything together (with translation)
O2
p2
O1
p’
p1
Then we apply the translation
Frame 2
Frame 1
Putting everything together
O2
p2
O1
What if we want a more compact representation?
Homogeneous Transformations
Summary: Poses & Transformations
x
Points & Positions
2D
3D
How to express orientation of a coordinate frame with respect to another?
e.g., What is the orientation of the robot frame in the world frame?
Poses & Transformations
Pose = position & rotation
Poses are used to:
Rigid-body Transformations
How to transform points from one coordinate frame to another?
Given point “c” in coordinate frame “r” what is the position of the point in
frame “w”?
Remark about notation
Positions Rotations
Poses
Composition of Transforms
x
Orientation & Rotations: 2D Case
wait! is angle positive or negative?
2D rotation matrix
x
y
How to express orientation of a coordinate frame with respect to another?
e.g., What is the orientation of the robot frame in the world frame?
Orientation & Rotations: 3D Case
3D case
x
y
z
x y z
3D rotation matrix
How to express orientation of a coordinate frame with respect to another?
e.g., What is the orientation of the robot frame in the world frame?
3D Rotation Matrix
3D Rotation Matrix
Elementary Rotations
0
cosφ
⎡
⎣
Rx (φ) = ⎢ 0
⎢ 0
⎤
⎥
⎢ 1 0
cosφ −sinφ ⎥
sinφ
⎥
⎦
cosθ 0 sinθ
0 1 0
−sinθ 0 cosθ
⎣
⎡
⎢
Ry (θ ) = ⎢
⎢
⎦
⎤
⎥
⎥
⎥
z
0
⎢
R (ψ) = sinψ
⎢
⎢
⎣
0 ⎤
⎦
⎡ cosψ −sinψ
⎥
cosψ 0
0
⎥
1 ⎥
Rotation around the x axis
Rotation around the y axis
Rotation around the z axis
Inverse of Rotations
Given
compute
Rotation Matrices
Euler Angles
Quaternions
Inverse
Composition of Rotations
Given
and
compute
Rotation Matrices
Euler Angles
Quaternions
Composition
(quaternion product)
Composition and Inverse of Transformations
Composition Inverse
Other representations of rotations
Euler Angles
Euler’s rotation theorem (1.0): Any rotation can be written as the product of no more than 3 elementary rotations (no two consecutive rotations along the same axis).
roll
pitch
yaw
•
We only need 3 numbers to represent a rotation!
•
•
why not x-y-z, y-x-z, x-x-z, …?
are generally called Euler angles
Where will you use this?
Labs 2, 3: Automatic Emergency Braking,
Reactive Methods for navigation & planning in local frame
Later labs: Map based methods, need transforms to perform planning in global frame.
Next: How do we do this in ROS?
X
Z
Y
Y
Y
Map frame
Car frame
laser frame
Y
Y
Y
Transform from map to car
Transform from car to laser
To convert measurements from one frame to another we need to perform transformations
Static Transformations Dynamic Transformations
Pose Representation and Coordinate Transformation
Key Takeaways
Questions?
x
Extra slides
Rotation Matrix
x1
y1
x
y
x2
y2
ϴ
Rotation Matrix - from the racecar’s perspective
x1
x2
y1
y2
ϴ
x
y
Rotation Matrix
x1
x2
y1
y2
P1, 2
O
Recall we represented the basis vectors of one frame as linear combinations of the other frame’s basis vector. We can do the same here.
Rotation Matrix
How do we relate the two?
x1
y1
p
O
x2
y2
p’
x2
y2
p’
Rotation Matrix
x1
y1
p
O
x2
y2
p’
Instead of using two frames, we can represent these two vectors in the same basis vector now.
Homogeneous Transformations
Pose & rigid body transformation
Rotation Matrix
x1
y1
p
O
x2
y2
p’
???
Example: Rotations in 3D
Rotation matrices in 3D around each axis.
See something similar?
Rigid Body Pose
Once chosen a frame, a rigid body is described in space by its position and orientation with respect to that reference frame.
100
map
base_link
laser
odom
Multiple Reference Frames
Laser frame
Map frame