Skip to the lesson
FixTheRobot Explore Robotics / Perception / P1 Perception Foundations / P1-T4

Perception · Theory · P1

P1-T4 — Coordinate Frames and Sensor Geometry

A measurement is a position in the sensor’s own frame. To use it, you must say which frame, and how that frame sits on the robot.

  • Lesson 4 of 6
  • Module 1: Perception Foundations
  • Theory
  • About 10 minutes to read

A range of 2 m at 30° means nothing until you say 2 m from what, at 30° from which direction. Every sensor measures in its own frame, mounted at some pose on a robot that is itself somewhere in the world. Combining sensors, or handing a detection to a planner, requires moving points between frames with rigid transforms. This lesson sets out the frames, the maths of rotation and translation, the conventions that differ between cameras and robots, and the mistakes that cause the most trouble.

Learning objectives

After this lesson, you should be able to:

  • Name the common frames in a robot (sensor, base, world) and say what each is used for.
  • Express a point in another frame using a rotation and a translation, in 2D and with homogeneous coordinates.
  • Compose and invert transforms and keep the direction of each transform straight.
  • List the frame conventions that differ between cameras, robots and libraries, and the symptoms of mixing them up.

The idea: the same point, described from different places

If you stand in a room and point at a lamp, you can describe where it is in many ways. “Two metres in front of me and a little to my left” is a description in your frame. “By the north window, 3 m from the door” is a description in the room’s frame. The lamp has not moved; only the description changed. To translate between them you need to know where you are standing and which way you face.

A robot has several such frames:

  • Sensor frame: fixed to one sensor. A camera’s frame has its origin at the lens; a LiDAR’s at the optical centre of the scanner. All raw measurements are in these frames.
  • Base (robot) frame: fixed to the robot body, usually at the centre of the drive axle or the body, with x forward, y left and z up. Planners and controllers think in this frame.
  • World (map or odom) frame: fixed to the environment. The robot’s pose in this frame comes from localization, and it is how detections from different times are compared.
Robot frame and sensor frameA top view. The robot body is a rectangle with its base frame at the centre: x forward (right on the page), y left (up on the page). A LiDAR is mounted 0.30 m ahead of the base and rotated 20 degrees to the left, with its own x and y axes drawn. A point on a box lies ahead and slightly left; dashed lines show the vector from the sensor to the point and from the base to the point. robot base LiDAR point on a box measured in the sensor framewhat the planner needs: in the base frame t = 0.30 m ahead One point, two descriptions: the numbers differ, the point does not.
A LiDAR mounted 0.30 m ahead of the base and turned 20° sees a box in its own frame. The planner needs the same point in the base frame.

A transform is not a property of a point. It is a property of two frames: where one sits relative to the other. A point has different coordinates in each.

The word pose means a position and an orientation: in 2D, (x, y, θ); in 3D, a position plus a rotation. A sensor’s pose in the base frame is called its extrinsic calibration (Lesson P3-T2). A robot’s pose in the world is a localization result, not a perception result, which is why this track and the SLAM track use the same maths and different questions.

The mathematics: rotation, translation and composition

In 2D

A point pS = (xS, yS) in the sensor frame S is turned into a point in the base frame B using the pose of S in B, which has a position t = (tx, ty) and an angle θ:

rigid transform in 2D
xB=xS cos⁡ θ−yS sin⁡ θ+txx_{B}=x_{S}\,\cos \,\theta -y_{S}\,\sin \,\theta +t_{x}
yB=xS sin⁡ θ+yS cos⁡ θ+tyy_{B}=x_{S}\,\sin \,\theta +y_{S}\,\cos \,\theta +t_{y}
(xS, yS)
the point in the sensor frame, in metres.
θ
the rotation of the sensor frame relative to the base frame: how far the sensor’s x axis is turned counter-clockwise from the base’s x axis.
(tx, ty)
the position of the sensor origin in the base frame.
(xB, yB)
the same point, in the base frame.

The order matters: the point is rotated first (about the sensor origin) and then shifted. Doing it the other way round gives a different, wrong answer.

In 3D, with homogeneous coordinates

In three dimensions a rotation is a 3 × 3 matrix R (orthonormal, with determinant +1). Rotation and translation are combined in one 4 × 4 matrix acting on the point extended with a 1:

homogeneous transform
[pB1]=[Rt0⊤1][pS1]\begin{bmatrix}\mathbf p_B\\ 1\end{bmatrix} = \begin{bmatrix}\mathbf R & \mathbf t\\ \mathbf 0^{\top} & 1\end{bmatrix}\begin{bmatrix}\mathbf p_S\\ 1\end{bmatrix}
Homogeneous form: one matrix product applies the rotation and the translation.
Written out
pB=R pS+t\mathbf p_B = \mathbf R\,\mathbf p_S + \mathbf t

This is written TBS: the transform that takes coordinates in S to coordinates in B. The subscript order is a convention worth learning: read it as “B from S”, and it composes by matching neighbouring letters.

composition and inverse
TWS=TWB⋅TBST_{\text{WS}}=T_{\text{WB}}\cdot T_{\text{BS}}
sensor to base, then base to world
TSB=(TBS)−1=[R⊤−R⊤ t01]T_{\text{SB}}=(T_{\text{BS}})^{-1}=\begin{bmatrix}R^{\top} & -R^{\top}\,t \\ 0 & 1\end{bmatrix}
TBS
maps points from the sensor frame S into the base frame B. It is the sensor’s extrinsic calibration.
TWB
maps base coordinates into world coordinates. It is the robot’s pose, from localization.
Rᵀ
the transpose of R, which is also its inverse because R is orthonormal. Inverting a rigid transform never needs a general matrix inverse.

Inverting a transform swaps its direction: TSB maps base to sensor. Using the inverse where you meant the forward transform, or the other way round, is the most common sign error in robot code. A good check is to transform a point you can verify by eye.

Conventions that differ

Frame conventions that differ between robots and cameras
ConventionRobotics (ROS REP 103)Typical camera (optical)Danger
Forward axisx forwardz forward (along the optical axis)Forward distance mistaken for a sideways one
Left / righty leftx rightLeft and right swapped
Up / downz upy downObjects appear below the floor
AnglesCounter-clockwise positive about z (right-handed)Varies by libraryRotation direction reversed
UnitsMetres, radiansPixels, sometimes millimetresScale errors of 10, 100 or 1000

Both frames are right-handed, but they are rotated against each other. Going from the camera optical frame to the robot convention is a fixed rotation of −90° about one axis followed by −90° about another; most software hides it inside a named “optical frame”. It is also a place where a fix applied twice cancels itself, and a bug survives because two mistakes cancelled in one test.

A worked example: the LiDAR on the front of the robot

A LiDAR is mounted at t = (0.30, 0.00) m in the base frame and turned θ = 20° to the left. It measures a point at r = 2.00 m and bearing φ = 10° (in its own frame). Where is the point relative to the base?

  1. Sensor frame: xS = 2.00 cos 10° = 1.970 m, yS = 2.00 sin 10° = 0.347 m.
  2. Rotate: cos 20° = 0.9397 and sin 20° = 0.3420. x′ = 1.970 × 0.9397 − 0.347 × 0.3420 = 1.851 − 0.119 = 1.732 m. y′ = 1.970 × 0.3420 + 0.347 × 0.9397 = 0.674 + 0.326 = 1.000 m.
  3. Translate: xB = 1.732 + 0.30 = 2.032 m, yB = 1.000 + 0.00 = 1.000 m.

So the planner sees an obstacle 2.03 m ahead and 1.00 m to the left. As a check: the bearing in the sensor frame was 10° and the sensor is turned 20°, so the bearing from the sensor origin, in base axes, is 30°: 2.00 cos 30° = 1.732 and 2.00 sin 30° = 1.000, which matches the rotated values before the shift.

What happens if one thing is wrong

Effect of common frame mistakes on the worked example
MistakeResult for this pointError
Forgot the mounting offset(1.732, 1.000)0.30 m too near
Forgot the mounting rotation(2.270, 0.347)0.70 m off (mostly sideways)
Rotated by 20° the wrong way (clockwise)(2.270, −0.347)1.37 m off, on the wrong side of the robot
Translated first, then rotated(2.014, 1.103)0.10 m off here: small for this point, but the error depends on the offset and the angle, and grows with both

The point to take away is the size of these errors: a few degrees or tens of centimetres in a calibration are larger than the accuracy of the sensor itself (2 cm). A sensor that is accurate to centimetres can produce results wrong by a metre because of a frame error. Frame errors do not look like noise: they are consistent, repeatable and precisely wrong.

Engineering implications and limitations

Name frames in the data. Every measurement, detection and pose should carry its frame name and timestamp. A bare (x, y) is a bug waiting for the day someone assumes a different frame. Robot middleware such as ROS keeps a tree of transforms (TF) for this purpose and refuses to guess.

Calibrate once and store it in one place. The mounting pose of each sensor is measured (or estimated from data) and stored in a single file that every node reads. Copying the numbers into several nodes guarantees that one copy is eventually out of date after the sensor is moved.

Validate with a known object. Place a box at a measured position and check that every sensor reports it at the same place in the base frame. This catches wrong signs, wrong units and swapped axes in minutes. Compare overlapping sensors to each other too: a LiDAR cloud and a depth-camera cloud of the same wall should coincide.

Mind the time as well as the frame. A transform is a function of time on a moving robot. Transforming a measurement with the pose from a different moment gives an error of v·Δt; at 1.5 m/s a 100 ms mismatch is 15 cm. Lesson P8-T3 treats synchronisation.

Use the transform’s inverse carefully. A reliable habit is to write every transform as “target from source” and check that neighbouring letters cancel when composing: TWB TBS = TWS. If they do not match, something is wrong before any number is computed.

Common misconceptions

“Left-handed or right-handed does not matter if I am consistent.”

It matters at every boundary with a library or a sensor that uses the other convention. A mirrored axis produces a reflected world: obstacles on the wrong side.

“A rotation and a translation can be applied in any order.”

They do not commute. Rotating about the sensor origin and then shifting is not the same as shifting and then rotating about the base origin.

“A few degrees of mounting error do not matter.”

At 10 m, 2° is 35 cm of lateral error. Mounting angles are some of the largest error sources in a perception stack.

“The transform from A to B and from B to A are the same matrix.”

They are inverses of each other. Using the wrong one is a frequent error and gives a result that is wrong by exactly twice the transform’s effect.

Engineering takeaways

  1. Every measurement lives in a frame; a transform is a relation between two frames, not a property of a point.
  2. A 2D rigid transform rotates and then translates; in 3D the same is written pB = R pS + t, or a 4×4 homogeneous matrix.
  3. Transforms compose by matching letters (TWS = TWB · TBS) and invert by transposing the rotation.
  4. Cameras and robots use different axis conventions; mixing them mirrors or rotates the world.
  5. Frame mistakes are consistent and large compared with sensor noise: name frames in the data, store calibration once, and validate with a known object.

References and further reading

The numbers in the worked example were computed for this lesson.

  • Barfoot, T. D. (2017). State Estimation for Robotics. Cambridge University Press: rotations, poses and transformation matrices.
  • Hartley, R. and Zisserman, A. (2004). Multiple View Geometry in Computer Vision, 2nd ed. Cambridge University Press: homogeneous coordinates and camera frames.
  • ROS REP 103, Standard Units of Measure and Coordinate Conventions: the right-handed x-forward, y-left, z-up robot convention and optical frame conventions.

Knowledge check

Three conceptual questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

A camera frame has z forward, x right, y down. A robot frame has x forward, y left, z up. A point is 4 m ahead of the camera on its axis. What are its coordinates in each frame?

Explanation

In the camera frame it is (x, y, z) = (0, 0, 4): it lies along the optical axis, which is z. In the robot frame (if the frames share an origin and the camera looks straight ahead) it is (4, 0, 0): forward is x. Mixing the two would send the point 4 m sideways or up.

Question 2

Why is TWB · TBS = TWS a useful sanity check, and what does it say if you instead need the sensor pose in the base frame from TWS and TWB?

Explanation

Neighbouring letters (B and B) must cancel, leaving W from S, so the check catches transforms composed in the wrong order. To get TBS you invert TWB and apply it: TBS = (TWB)⁻¹ · TWS.

Question 3

A robot’s forward LiDAR is mounted 3° off its intended angle and nobody noticed. About how far off is a wall corner measured at 15 m, and does averaging more scans help?

Explanation

The lateral error is about 15 × tan 3° ≈ 0.79 m. Averaging more scans does not help: the error is a bias (the same in every scan), not noise. It is found by comparing against a known object, or an overlapping sensor, and corrected in the calibration.

What’s next

Next: the ways a measurement can be wrong or incomplete: noise, bias, occlusion and ambiguity.

Practice this lesson

Build a First Perception Pipeline

Assemble raw range data into a useful output (is the way clear, and how far?) and evaluate it.

Next lesson

P1-T5 — Noise, Uncertainty, Occlusion and Ambiguity

Classify the ways a measurement can be wrong or incomplete and the effect on downstream results.

Nothing below is required to finish this lesson.