Skip to the content
FixTheRobot Explore Robotics / Manipulator Basics / Theory / 03

Manipulator Basics · Theory · Module 03 of 14

03 — Coordinate Frames and Rotations

Every pose in robotics is a frame relative to another frame. Learn the 4×4 homogeneous transform, how to chain and invert transforms, and the main ways to write an orientation: matrices, Euler angles, axis-angle and quaternions.

  • Beginner
  • About 7 minutes to read
  • 1 linked lab

A robot is a stack of coordinate frames: world, base, one per link, tool. Almost every computation in manipulation is a product of transforms between them, so this module is the arithmetic of the rest of the course.

Learning objectives

After this module you should be able to:

  • Name the frames of a robot cell (world, base, joint, link, end-effector) and say what each one is for.
  • Build a homogeneous transform from a rotation matrix and a translation vector, then compose and invert transforms.
  • Convert a point between frames correctly, including the order of multiplication.
  • Move between rotation matrices, ZYX Euler angles, axis-angle and unit quaternions, and know each one's pitfalls.
  • State the defining properties of SO(3) and SE(3).

Conceptual explanation

A frame is an origin plus three perpendicular unit axes. In a robot cell we use several:

  • the world frame W, fixed in the room, in which the cell layout (tables, parts, other robots) is measured;
  • the base frame B, fixed to the robot's mounting flange; the controller expresses everything relative to it;
  • the joint and link frames 1 … n, one rigidly attached to each link, placed by a convention such as Denavit–Hartenberg (Module 05);
  • the end-effector frame E, or tool centre point (TCP) frame, at the working point of the tool, for example between the fingertips.
Frames in a robot cellWorld frame W, robot base frame B, joint frames along the arm, and the end-effector frame E at the tool.W worldB base12E toolT: W → BT: B → E (q)
The frames of a cell. ᵂT_B is fixed (where the robot stands). ᴮT_E(q) changes with the joints; computing it is forward kinematics.

The pose of frame B relative to frame A is a rotation ARB{}^{A}R_{B} (the axes of B written in A) plus a translation ApB{}^{A}p_{B} (the origin of B written in A). Packing both into one 4×4 matrix lets a single multiplication rotate and translate a point. That makes chaining frames a matrix product.

Reading a transform

Read ATB{}^{A}T_{B} as "B seen from A". Its columns are B's x, y and z axes and B's origin, all in A coordinates. The subscripts chain like fractions, ATB BTC=ATC{}^{A}T_{B}\,{}^{B}T_{C} = {}^{A}T_{C}, and the inverse swaps them: (ATB)−1=BTA({}^{A}T_{B})^{-1} = {}^{B}T_{A}.

Orientation representations

  • Rotation matrix (9 numbers, 3 DOF): unambiguous, composes by multiplication; the standard internal form.
  • Euler angles (3 numbers): intuitive (yaw, pitch, roll), but there are 12 axis orders, and they have a singularity (gimbal lock: at ZYX pitch ±90° yaw and roll merge).
  • Axis-angle (unit axis ω^\hat\omega and angle θ\theta): any rotation is one turn about one axis (Euler's theorem). The rotation vector θω^\theta\hat\omega is a natural orientation error.
  • Unit quaternion (4 numbers, q=[w,x,y,z]q = [w, x, y, z]): no singularity, cheap to compose and renormalise, and interpolates smoothly (slerp). qq and −q-q are the same rotation.

Mathematical formulation

A rotation matrix belongs to the special orthogonal group:

SO(3)
SO(3)={R∈R3×3:RTR=I,  det⁡R=+1}SO(3) = \{ R \in \mathbb{R}^{3\times 3} : R^{T}R = I,\; \det R = +1 \}

The elementary rotations about the coordinate axes:

Elementary rotations
Rz(θ)=[cθ−sθ0sθcθ0001],  Ry(θ)=[cθ0sθ010−sθ0cθ],  Rx(θ)=[1000cθ−sθ0sθcθ]R_z(\theta) = \begin{bmatrix} c_\theta & -s_\theta & 0 \\ s_\theta & c_\theta & 0 \\ 0 & 0 & 1 \end{bmatrix},\; R_y(\theta) = \begin{bmatrix} c_\theta & 0 & s_\theta \\ 0 & 1 & 0 \\ -s_\theta & 0 & c_\theta \end{bmatrix},\; R_x(\theta) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & c_\theta & -s_\theta \\ 0 & s_\theta & c_\theta \end{bmatrix}

A homogeneous transform is an element of the special Euclidean group SE(3):

Homogeneous transform
ATB=[ARBApB01×31],Ap~=ATB  Bp~,p~=[p1]{}^{A}T_{B} = \begin{bmatrix} {}^{A}R_{B} & {}^{A}p_{B} \\ 0_{1\times3} & 1 \end{bmatrix}, \qquad {}^{A}\tilde p = {}^{A}T_{B}\; {}^{B}\tilde p, \quad \tilde p = \begin{bmatrix} p \\ 1 \end{bmatrix}
  1. ATC=ATB BTC=[ARBBRCARB BpC+ApB01]{}^{A}T_{C} = {}^{A}T_{B}\,{}^{B}T_{C} = \begin{bmatrix} {}^{A}R_{B}{}^{B}R_{C} & {}^{A}R_{B}\,{}^{B}p_{C} + {}^{A}p_{B} \\ 0 & 1 \end{bmatrix}

    Composition: rotate C's offset into A, then add B's origin.

  2. (ATB)−1=BTA=[RT−RTp01]({}^{A}T_{B})^{-1} = {}^{B}T_{A} = \begin{bmatrix} R^{T} & -R^{T}p \\ 0 & 1 \end{bmatrix}

    Inversion is cheap: transpose the rotation and rotate the negated translation. Never use a general 4×4 inverse.

ZYX Euler angles (yaw ψ\psi, pitch θ\theta, roll ϕ\phi), axis-angle (Rodrigues) and the quaternion:

Euler, axis-angle and quaternion
R=Rz(ψ)Ry(θ)Rx(ϕ),R=I+sin⁡θ [ω^]×+(1−cos⁡θ)[ω^]×2,q=[cos⁡θ2,  ω^sin⁡θ2]R = R_z(\psi)R_y(\theta)R_x(\phi), \qquad R = I + \sin\theta\,[\hat\omega]_\times + (1-\cos\theta)[\hat\omega]_\times^{2}, \qquad q = \left[\cos\tfrac{\theta}{2},\; \hat\omega \sin\tfrac{\theta}{2}\right]

Inverse map for ZYX: θ=−arcsin⁡r31\theta = -\arcsin r_{31}, ψ=atan2⁡(r21,r11)\psi = \operatorname{atan2}(r_{21}, r_{11}) and ϕ=atan2⁡(r32,r33)\phi = \operatorname{atan2}(r_{32}, r_{33}). These are undefined when cos⁡θ=0\cos\theta = 0: that is gimbal lock.

Diagrams

The frame figure in the conceptual section shows the chain of transforms in a cell. The interactive figure below draws a frame rotated by ZYX Euler angles and prints its rotation matrix.

Worked examples

Example 1: where is a point on the tool, in the world?

The robot stands at (1.0,0.5,0)(1.0, 0.5, 0) m in the world, turned 90° about z: WTB=Trans⁡(1,0.5,0) Rz(90°){}^{W}T_{B} = \operatorname{Trans}(1, 0.5, 0)\,R_z(90°). Its tool frame is at BTE=Trans⁡(0.4,0,0.3) Ry(90°){}^{B}T_{E} = \operatorname{Trans}(0.4, 0, 0.3)\,R_y(90°). A point 0.1 m along the tool's z axis, Ep=(0,0,0.1){}^{E}p = (0, 0, 0.1), is where in the world?

WTE=WTB BTE=[0.000−1.0000.0001.0000.0000.0001.0000.900−1.0000.0000.0000.3000.0000.0000.0001.000]{}^{W}T_{E} = {}^{W}T_{B}\,{}^{B}T_{E} = \begin{bmatrix}0.000 & -1.000 & 0.000 & 1.000 \\ 0.000 & 0.000 & 1.000 & 0.900 \\ -1.000 & 0.000 & 0.000 & 0.300 \\ 0.000 & 0.000 & 0.000 & 1.000\end{bmatrix}
Wp=WTE Ep~=(1.000, 1.000, 0.300) m{}^{W}p = {}^{W}T_{E}\,{}^{E}\tilde p = (1.000,\ 1.000,\ 0.300)\ \text{m}

Check by reasoning: the tool's z axis is the base x axis (after Ry(90°)R_y(90°)), which is the world y axis (after Rz(90°)R_z(90°)). So the point is 0.1 m further along world y from the tool origin, which sits at (1.0,0.9,0.3)(1.0, 0.9, 0.3). That gives (1.0,1.0,0.3)(1.0, 1.0, 0.3), as computed.

Example 2: inverting the transform

To express a world point in the tool frame (for example a part seen by a camera), use ETW=(WTE)−1{}^{E}T_{W} = ({}^{W}T_{E})^{-1}:

ETW=[RT−RTp01]=[0.0000.000−1.0000.300−1.0000.0000.0001.0000.0001.0000.000−0.9000.0000.0000.0001.000]{}^{E}T_{W} = \begin{bmatrix} R^{T} & -R^{T}p \\ 0 & 1 \end{bmatrix} = \begin{bmatrix}0.000 & 0.000 & -1.000 & 0.300 \\ -1.000 & 0.000 & 0.000 & 1.000 \\ 0.000 & 1.000 & 0.000 & -0.900 \\ 0.000 & 0.000 & 0.000 & 1.000\end{bmatrix}

Multiplying the two gives the identity to machine precision. Try it in Lab 02.

Example 3: one orientation, four representations

Yaw 30°, pitch 20°, roll 10° (ZYX) gives

R=[0.8138−0.44100.37850.46980.88260.0180−0.34200.16320.9254]R = \begin{bmatrix}0.8138 & -0.4410 & 0.3785 \\ 0.4698 & 0.8826 & 0.0180 \\ -0.3420 & 0.1632 & 0.9254\end{bmatrix}

The same rotation as axis-angle is a turn of θ=35.82°\theta = 35.82° about ω^=(0.124,0.616,0.778)\hat\omega = (0.124, 0.616, 0.778). As a unit quaternion it is q=[0.9515,0.0381,0.1893,0.2393]q = [0.9515, 0.0381, 0.1893, 0.2393], which satisfies w=cos⁡(θ/2)w = \cos(\theta/2). All three were computed by the engine and convert back to the same matrix.

Interactive experiment

Interactive rotation (needs JavaScript): R = Rz(ψ)Ry(θ)Rx(φ), with det R and the orthogonality error shown.

A frame rotated by ZYX Euler angles. Push the pitch to ±90°: yaw and roll then turn the frame about the same axis (gimbal lock).

Real-world applications

  • Cell layout: the robot's base frame is measured in the world frame so that CAD positions of fixtures can be sent to the robot.
  • Tool changes: changing grippers only changes 6TE{}^{6}T_{E}; every program written for the TCP still works.
  • Vision: a camera reports a part in its own frame; BTpart=BTcam camTpart{}^{B}T_{\text{part}} = {}^{B}T_{\text{cam}}\,{}^{\text{cam}}T_{\text{part}} gives the grasp target.
  • ROS 2 TF2 keeps exactly this tree of transforms and composes them on request.

Common mistakes

Multiplying in the wrong order

ATB BTC is not BTC ATB. Matrix products of rotations do not commute; check the sub- and superscripts chain like fractions.

Inverting a transform by negating it

The inverse of Trans(p)R is RTTrans(−p), whose translation is −RTp, not −p.

Mixing Euler conventions

"Roll-pitch-yaw" in one library may be XYZ about moving axes and in another ZYX about fixed axes. Always state the order and whether the axes are fixed or moving.

Interpolating Euler angles

Linearly interpolating Euler angles gives a curved, uneven motion and breaks near gimbal lock. Interpolate quaternions with slerp, or rotation vectors.

Forgetting that q and −q are the same rotation

Comparing quaternions element-wise can report a 360° error for identical orientations. Compare |q₁·q₂| with 1 instead.

Key takeaways

  1. A frame pose is a rotation in SO(3) plus a translation; together they form a 4×4 transform in SE(3).
  2. Chain transforms by multiplying in the order the subscripts cancel; invert with Rᵀ and −Rᵀp.
  3. The columns of ARB are B's axes written in A.
  4. Euler angles are readable but have singularities; quaternions and axis-angle do not, and are better for computation and interpolation.

Knowledge check

Write an answer to each question, then reveal the explanation. Your answers stay in your browser.

Question 1

If ATB has rotation R and translation p, what is the translation part of BTA?

Explanation

−Rᵀp: the origin of A seen from B. Negating p alone is wrong unless R = I.

Question 2

A transform has rotation R = Rz(90°) and translation (1, 0, 0). Where does it send the point (1, 0, 0)?

Explanation

R(1, 0, 0) = (0, 1, 0); adding the translation gives (1, 1, 0).

Question 3

Why does ZYX Euler angle extraction fail at pitch = 90°?

Explanation

With cos θ = 0, the formulas for ψ and φ use atan2(0, 0): yaw and roll rotate about the same axis, so only their sum (or difference) is defined. This is gimbal lock, a singularity of the representation, not of the rotation.

Question 4

What are the axis and angle of the quaternion [0, 0, 0, 1]?

Explanation

w = cos(θ/2) = 0, so θ = 180°, and the axis is (0, 0, 1): a half turn about z.

Question 5

Give two properties every rotation matrix must satisfy, and what each guarantees.

Explanation

RᵀR = I (the columns are orthonormal, so lengths and angles are preserved) and det R = +1 (a proper rotation, not a reflection).

Practise it in the labs

Then test yourself in practice exercises and challenge mode.

References and further reading

  • K. M. Lynch and F. C. Park, Modern Robotics, Cambridge, 2017, chapter 3 (rigid-body motions).
  • J. Diebel, "Representing attitude: Euler angles, unit quaternions, and rotation vectors", Stanford University technical report, 2006.
  • P. Corke, Robotics, Vision and Control, 3rd ed., Springer, 2023, chapter 2.