The maths of robotics, one tool per lesson

← Robot list · The basics

Every maths tool a robot needs, each in its own short lesson, from zero: angles and trigonometry, vectors, matrices, rotations, frames and transformations, then the Denavit–Hartenberg method explained twice: the standard DH alone, the modified DH (DHM) alone, and the two side by side, and finally derivatives (towards the Jacobian), probability (towards the Kalman filter) and the 3D orientations (Euler angles, axis-angle, quaternions). Each lesson has worked examples, exercises and a quiz.

The path of this course

Each lesson uses the one before. Trigonometry finds the end of one arm. Vectors add the arms. Matrices transform vectors. Rotation matrices turn them. Homogeneous matrices turn and move at once, and can be chained from the base to the tool. DH and DHM are two rules to write this chain as a small table. Derivatives turn positions into speeds, and probability handles the noise of the sensors.

You only need the four operations and a calculator. If a lesson is already known to you, do its quiz and move on.

1

Angles and trigonometry

10 min
You will learn

to measure an angle in degrees and radians, to use sine and cosine to find a point, and atan2 to find an angle.

1.1 Degrees and radians

A robot joint turns by an angle. We know degrees: a full turn is 360°. Computers and formulas use radians: a full turn is 2π ≈ 6.28 rad. So:

radians = degrees × π / 180    degrees = radians × 180 / π

Degrees0°30°45°90°180°360°
Radians0π/6 ≈ 0.52π/4 ≈ 0.79π/2 ≈ 1.57π ≈ 3.142π ≈ 6.28
Why radians?

With radians, the length of an arc is simply radius × angle. A wheel of radius 0.1 m that turns by 2 rad rolls 0.1 × 2 = 0.2 m. No factor to remember.

1.2 Sine and cosine: where is the end of the arm?

Take an arm of length L, fixed at the origin, tilted by an angle θ from the x axis. Its end is at:

x = L cos θ    y = L sin θ

The cosine gives the part of the arm along x, the sine the part along y. Values to know by heart:

θ0°30°45°60°90°180°
cos θ10.8660.7070.50−1
sin θ00.50.7070.86610
Worked example

An arm of 0.8 m at 30°: x = 0.8 × 0.866 = 0.693 m, y = 0.8 × 0.5 = 0.4 m. Check with Pythagoras: √(0.693² + 0.4²) = 0.8 m, the length of the arm.

1.3 Two formulas you will meet everywhere

  • Pythagoras: cos² θ + sin² θ = 1. The distance from the origin to the point (x, y) is √(x² + y²).
  • Sum of angles: cos(a + b) = cos a cos b − sin a sin b, and sin(a + b) = sin a cos b + cos a sin b. This is why a 2-axis arm has terms in cos(θ1 + θ2).

1.4 The other way: from a point to an angle (atan2)

You know the point (x, y) and want the angle. Use θ = atan2(y, x), found in every programming language. Note the order: y first.

Never use arctan(y / x) alone

The points (1, 1) and (−1, −1) have the same ratio y/x = 1, so arctan gives 45° for both. But the second one is at −135°. atan2 looks at the signs of x and y and gives the right angle over the full turn, even when x = 0.

Key terms

  • radian
  • sine / cosine
  • Pythagoras
  • atan2
The essentials
  • Radians = degrees × π / 180. A full turn is 2π.
  • The end of an arm of length L at angle θ is at x = L cos θ, y = L sin θ.
  • To find an angle from a point, use atan2(y, x), never arctan(y/x) alone.
Cosine starts at 1 and sine at 0; both repeat every 360°.

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

Convert 60° to radians.

Solution

Rule used radians = degrees × π / 180 lesson 1 — 1.1 Degrees and radians

  1. Write the rule with 60°: 60 × π / 180.
  2. Simplify: 60 / 180 = 1/3, so the angle is π/3.
  3. Compute: 3.1416 / 3 = 1.047.

Answer π/3 ≈ 1.047 rad

Level 2 · Intermediate2

An arm of 1.2 m is at 45°. x of its end (m)?

Solution

Rule used end of an arm of length L at the angle θ: x = L cos θ, y = L sin θ lesson 1 — 1.2 Sine and cosine

  1. L = 1.2 m and θ = 45°.
  2. cos 45° = 0.707 (table of 1.2).
  3. x = 1.2 × 0.707 = 0.849 m. (y is the same, because sin 45° = cos 45°.)

Answer x ≈ 0.849 m

Level 3 · Professional3

The tool is at x = −1, y = 1. Angle atan2(y, x) in degrees?

Hint

The point is up and to the left.

Solution

Rule used the angle of a point (x, y) is atan2(y, x), which looks at the signs of x and y lesson 1 — 1.3 Two formulas you will meet everywhere

  1. Place the point: x = −1 (left), y = 1 (up): upper-left quadrant, between 90° and 180°.
  2. The point makes 45° with the negative x axis (|y| = |x|).
  3. So the angle is 180° − 45° = 135°.
  4. Trap: arctan(y / x) = arctan(−1) = −45° points the other way: it does not know the signs.

Answer 135°

Check yourself
  1. How many radians is 90°?

    π/2 ≈ 1.57 rad.

  2. An arm of 2 m is at 60°. Where is its end?

    x = 2 × 0.5 = 1 m, y = 2 × 0.866 = 1.73 m.

  3. Why use atan2(y, x) and not arctan(y/x)?

    atan2 uses the signs of x and y, so it gives the right angle in all four quadrants, and it works when x = 0.

2

Vectors

11 min
You will learn

what a vector is, how to add vectors, measure their length, and use the dot and cross products.

2.1 An arrow with numbers

A vector is an arrow: it has a direction and a length. We write it as a column of numbers, its components: 31 means “3 to the right, 1 up”. In space there is a third number for the height: xyz.

In robotics vectors describe positions (where the tool is), speeds (how it moves), forces (how it pushes) and axes (around what a joint turns).

2.2 Adding vectors: one arrow after the other

To chain two moves, add the components one by one: 31 + 12 = 43.

This is a robot arm

Look at the picture again: the blue arrow is link 1, the orange arrow is link 2, and the dashed arrow goes from the base to the tool. The position of the tool is the sum of the arrows of the links. All of forward kinematics is in this sentence.

2.3 Length, scaling, unit vector

  • Length (norm): ‖v‖ = √(x² + y² + z²). For (4, 3): √(16 + 9) = 5.
  • Multiply by a number: every component is multiplied. 2 × (4, 3) = (8, 6): same direction, twice as long.
  • Unit vector: a vector of length 1, used to give a direction only. Divide a vector by its length: (4, 3) / 5 = (0.8, 0.6).

2.4 The dot product: how much two arrows agree

a · b = axbx + ayby + azbz = ‖a‖ ‖b‖ cos φ

The result is a number. φ is the angle between the two arrows. Three cases to remember:

The arrows are…Dot productExample
in the same directionpositive, maximum(1, 0) · (2, 0) = 2
perpendicularzero(1, 0) · (0, 3) = 0
oppositenegative(1, 0) · (−2, 0) = −2

Use: the dot product with a unit vector gives the part of a vector along that direction (the speed of a robot along its forward axis, the force along a joint axis).

2.5 The cross product: a vector perpendicular to two others

In 3D, a × b is a new vector, perpendicular to both a and b. Its direction is given by the right hand: index along a, middle finger along b, the thumb shows a × b.

x × y = z    y × z = x    z × x = y

a and b lie in the floor plane; a × b stands up, perpendicular to both. Its length is the area of the orange parallelogram.
  • It builds the third axis of a frame from the two others (lessons 5 and 6).
  • It gives the speed of a point that turns: v = ω × r, and the torque of a force: τ = r × F.

Key terms

  • vector
  • component
  • norm
  • unit vector
  • dot product
  • cross product
The essentials
  • A vector is an arrow written as a column of numbers. Add vectors component by component.
  • Length: √(x² + y² + z²). A unit vector has length 1.
  • Dot product = 0 means perpendicular. The cross product gives a perpendicular vector.

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

Length of the vector (3, 4)?

Solution

Rule used length of a vector: √(x² + y²) lesson 2 — 2.3 Length, scaling, unit vector

  1. Square the components: 3² = 9, 4² = 16.
  2. Add them: 9 + 16 = 25.
  3. Take the root: √25 = 5.

Answer 5

Level 2 · Intermediate2

Link 1 is the arrow (0.4, 0.3) m and link 2 is (0.1, 0.5) m. y of the tool (m)?

Solution

Rule used to chain two moves, add the vectors component by component (the tool = the sum of the arrows of the links) lesson 2 — 2.2 Adding vectors

  1. Add the x: 0.4 + 0.1 = 0.5.
  2. Add the y: 0.3 + 0.5 = 0.8.
x (m)y (m)
link 10.40.3
link 20.10.5
tool = sum0.50.8

Answer y = 0.8 m

Level 3 · Professional3

A robot moves with the velocity (0.3, 0.4) m/s. Its forward direction is the unit vector (0.6, 0.8). Speed along the forward direction (m/s)?

Hint

Dot product with the unit vector.

Solution

Rule used the part of a vector v along a unit vector u is the dot product u · v = uₓvₓ + uᵧvᵧ lesson 2 — 2.4 The dot product

  1. Check that u = (0.6, 0.8) is a unit vector: √(0.36 + 0.64) = 1. ✓
  2. Multiply component by component: 0.3 × 0.6 = 0.18 and 0.4 × 0.8 = 0.32.
  3. Add: 0.18 + 0.32 = 0.5 m/s.
  4. Check: the full speed is √(0.3² + 0.4²) = 0.5 m/s too: the robot moves exactly forward.

Answer 0.5 m/s

Check yourself
  1. What is (2, 5) + (1, −3)?

    (3, 2): add the components one by one.

  2. Two vectors have a dot product of 0. What does it mean?

    They are perpendicular (or one of them is zero).

  3. What is the direction of x × y?

    The z axis: the cross product is perpendicular to both vectors (right-hand rule).

3

Matrices

12 min
You will learn

to multiply a matrix by a vector and by another matrix, and what the identity, the transpose, the inverse and the determinant are.

3.1 A table that transforms a vector

A matrix is a table of numbers. Its job: take a vector and give back another vector (turned, stretched, moved). The rule is “row times column”: multiply the numbers of a row by the numbers of the column, one by one, and add.

abcd xy = ax + bycx + dy

Worked example

1234 56 = 1×5 + 2×63×5 + 4×6 = 1739

What the columns mean

The first column of a matrix is where the vector 10 (the x axis) goes; the second column is where 01 (the y axis) goes. To build a matrix that does what you want, ask: “where do the axes go?” and write the answers as columns. Lesson 4 uses this to build the rotation matrix.

3.2 Matrix times matrix: two transformations in a row

The product A B is the matrix that does B first, then A. Same rule: the element in row i, column j of the result is row i of A “times” column j of B.

1234 0110 = 1×0 + 2×11×1 + 2×03×0 + 4×13×1 + 4×0 = 2143

The order matters

In general A B ≠ B A. With the same two matrices in the other order: 0110 1234 = 3412. It is normal: “turn then move forward” does not lead to the same place as “move forward then turn”.

The same two moves in a different order do not lead to the same place: this is why A B ≠ B A for matrices.

3.3 Four words to know

WordWhat it isFor a 2×2 matrixUse in robotics
Identity IThe matrix that changes nothing: I v = v.1001“No rotation, no move”.
Transpose ATRows become columns.abcdT = acbdThe inverse of a rotation; forces from torques (JT).
Determinant det AOne number: how much the matrix scales areas.ad − bcdet = 0: the matrix flattens space. For a Jacobian it is a singularity.
Inverse A−1The matrix that undoes A: A−1 A = I. It exists only if det A ≠ 0.1⁄ad−bc d−b−caGo back from the tool to the joints.
Worked example: determinant and inverse

A = 2111: det A = 2×1 − 1×1 = 1, so A−1 = 1−1−12. Check: A−1 A = 1×2 − 1×11×1 − 1×1−1×2 + 2×1−1×1 + 2×1 = 1001.

You will almost never invert a big matrix by hand: a computer does it. What you must know is what the inverse means and when it does not exist.

Key terms

  • matrix
  • identity
  • transpose
  • determinant
  • inverse
The essentials
  • Matrix × vector: row times column. The columns of a matrix say where the axes go.
  • A B does B first, then A. In general A B ≠ B A.
  • det = 0 means no inverse. For a 2×2 matrix: det = ad − bc.
The columns of a matrix are where the axes go: A sends the unit square (grey) to the orange parallelogram. Its area is det A = 2.

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

Multiply the matrix with rows (2, 0) and (1, 3) by the vector (4, 1). First component of the result?

Solution

Rule used matrix × vector: each component = one row of the matrix “times” the column (multiply term by term, then add) lesson 3 — 3.1 A table that transforms a vector

  1. First row (2, 0) times the column (4, 1): 2 × 4 + 0 × 1 = 8.
  2. Second row (1, 3): 1 × 4 + 3 × 1 = 7.
  3. Result: (8, 7).

Answer 8

Level 2 · Intermediate2

Determinant of the matrix with rows (3, 2) and (1, 4)?

Solution

Rule used determinant of a 2×2 matrix with rows (a, b) and (c, d): det = ad − bc lesson 3 — 3.3 Four words to know

  1. Read a = 3, b = 2, c = 1, d = 4.
  2. ad = 3 × 4 = 12 and bc = 2 × 1 = 2.
  3. det = 12 − 2 = 10.

Answer 10

Level 3 · Professional3

The matrix with rows (2, 4) and (1, 2): can it be inverted?

  1. No: its determinant is 0
  2. Yes
  3. Only if we transpose it first

Solution

Rule used a matrix can be inverted only if its determinant is not 0 lesson 3 — 3.3 Four words to know

  1. det = ad − bc = 2 × 2 − 4 × 1 = 4 − 4 = 0.
  2. The columns (2, 1) and (4, 2) point in the same direction (the second is twice the first): the matrix flattens the plane onto a line.
  3. A flattened plane cannot be unfolded: no inverse. For a robot Jacobian, this is a singularity.

Answer No: its determinant is 0

Check yourself
  1. What do the columns of a matrix tell you?

    Where the axes go: column 1 is the image of (1, 0), column 2 the image of (0, 1).

  2. In the product A B applied to a vector, which matrix acts first?

    B, the one closest to the vector. Then A.

  3. A matrix has a determinant of 0. Can you invert it?

    No. It flattens space onto a line or a point, and this cannot be undone.

4

Rotation matrices

12 min
You will learn

to build the matrix that turns a vector by an angle, its properties, and the three rotations of 3D space.

4.1 Build it from its columns

We want the matrix that turns every vector by an angle θ (counter-clockwise). Use the idea of lesson 3: where do the axes go?

  • The x axis 10 turns to cos θsin θ (lesson 1). This is the first column.
  • The y axis 01 turns to −sin θcos θ. This is the second column.
The rotation matrix in the plane

R(θ) = cos θ−sin θsin θcos θ

Worked example

Turn the vector 21 by 30° (cos = 0.866, sin = 0.5): 0.866−0.50.50.866 21 = 0.866×2 − 0.5×10.5×2 + 0.866×1 = 1.2321.866. The length did not change: √(2² + 1²) = √(1.232² + 1.866²) = 2.236.

4.2 Four properties to remember

PropertyWhyWhat it gives you
The columns have length 1 and are perpendicular.They are the axes of a frame.A quick check of any rotation matrix.
det R = 1cos² θ + sin² θ = 1: a rotation does not change sizes.A rotation can always be undone.
R−1 = RT = R(−θ)To undo a rotation, turn back by the same angle.The inverse costs nothing: swap rows and columns.
R(a) R(b) = R(a + b)Turning by b then by a is turning by a + b.In a planar arm the angles add: θ1 + θ2.

4.3 Rotations in space

In 3D a rotation turns around an axis. The positive direction is given by the right hand: thumb along the axis, the fingers show the positive rotation. The three basic rotations keep one axis fixed (its row and column are 0, 0, 1):

Rz(θ) = c−s0sc0001 Ry(θ) = c0s010−s0c Rx(θ) = 1000c−s0sc

with c = cos θ and s = sin θ. Rz is the plane rotation of 4.1 with a third axis that does not move: it is the rotation of a revolute joint around its own z axis, the one you will meet in every DH table.

Each basic rotation keeps one axis fixed (thick) and turns the two others by θ (dashed: before, solid: after). The orange arrow shows the positive direction (right hand, thumb along the axis).
In 3D the order of rotations matters

Take the x axis (1, 0, 0). Turn it by 90° around x (nothing happens), then by 90° around z: it becomes (0, 1, 0). In the other order, 90° around z gives (0, 1, 0), then 90° around x gives (0, 0, 1). Two different results. In the plane the order did not matter; in space it does. Try it with a book in your hands.

Key terms

  • rotation matrix
  • right-hand rule
  • orthogonal matrix
The essentials
  • R(θ) has the columns (cos θ, sin θ) and (−sin θ, cos θ): where the axes go.
  • A rotation keeps lengths; its inverse is its transpose.
  • In the plane the angles add; in 3D the order of rotations matters.

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

Turn the vector (1, 0) by 90°. y of the result?

Solution

Rule used the columns of R(θ) are where the axes go: (cos θ, sin θ) and (−sin θ, cos θ) lesson 4 — 4.1 Build it from its columns

  1. (1, 0) is the x axis, so its image is the first column of R(90°).
  2. (cos 90°, sin 90°) = (0, 1).

Answer y = 1

Level 2 · Intermediate2

Turn the vector (2, 0) by 60°. x of the result?

Solution

Rule used x′ = cos θ · x − sin θ · y, y′ = sin θ · x + cos θ · y (R(θ) times the vector) lesson 4 — 4.1 Build it from its columns

  1. cos 60° = 0.5 and sin 60° = 0.866.
  2. x′ = 0.5 × 2 − 0.866 × 0 = 1.
  3. (y′ = 0.866 × 2 + 0.5 × 0 = 1.73; check: √(1² + 1.73²) = 2, the length is kept.)

Answer x = 1

Level 3 · Professional3

A planar arm turns by 30° at joint 1 and by −50° at joint 2. Orientation of the tool (degrees)?

Solution

Rule used in the plane, two rotations add: R(a) R(b) = R(a + b) lesson 4 — 4.2 Four properties to remember

  1. The tool is turned by joint 1, then by joint 2: R(30°) R(−50°).
  2. Add the angles: 30° + (−50°) = −20°.

Answer −20°

Check yourself
  1. What is the first column of R(θ)?

    (cos θ, sin θ): where the x axis goes.

  2. How do you invert a rotation matrix?

    Take its transpose: R⁻¹ = Rᵀ.

  3. Does the order of two rotations matter?

    Not in the plane (the angles add). In 3D yes, when the axes differ.

5

Frames and transformations

14 min
You will learn

to go from one frame to another with a rotation and a translation, and to pack both in one homogeneous matrix that you can chain.

5.1 The same point, seen from two frames

A frame is an origin and axes: a place from which you measure. A robot has many: one on the floor, one on each link, one on the tool, one on the camera. The same point has different coordinates in each frame.

  • How to name a frame. A frame is an origin O and two perpendicular axes x and y (z in 3D). The small letter under each name says which frame it belongs to: OA, xA, yA are the axes of frame A; OB, xB, yB those of frame B. Red is always x, green is always y.
  • How to read the coordinates. Each axis is graduated in units (here 1 square = 1). For frame A, start at OA: P is 2 graduations along xA (to the right) and 3 along yA (up), so P = (2, 3) in A.
  • The same point for B. Frame B is turned by 90°: its xB axis points up and its yB axis points to the left. Start at OB: go 2 graduations along xB (up), then 1 along yB (to the left): you reach P. So P = (2, 1) in B.

Frame B sits at t = (3, 1) in frame A, and is turned by 90°. The point P is at (2, 1) for B. Where is it for A? Two steps: turn the coordinates with the rotation of B, then add the position of B.

Change of frame

pA = R pB + t

R = the orientation of B seen from A (its columns are the axes of B, written in A). t = the origin of B, written in A.

Worked example

R(90°) = 0−110. pA = 0−110 21 + 31 = −12 + 31 = 23. Check on the picture: from B, go 2 along xB (up) and 1 along yB (left).

5.2 One matrix for both: the homogeneous matrix

“Multiply, then add” is not practical to chain ten frames. The trick: add a 1 under every point, and put R and t in one bigger matrix. One product now does the rotation and the translation:

pA1 = Rt01 pB1    ATB = Rt01

In the plane it is a 3×3 matrix; in space a 4×4 matrix (R is 3×3, t has 3 numbers, the last row is always 0 0 0 1). With our example: 0−13101001 211 = 0×2 − 1×1 + 3×11×2 + 0×1 + 1×11 = 231.

The 4 × 4 homogeneous matrix in three blocks: the rotation R (where the axes of the new frame point), the translation t (where its origin is), and the fixed last row.
How to read a homogeneous matrix
  • The last column is the position of the frame: where it is.
  • The other columns are its axes: how it is turned.
  • A point ends with 1 (the translation applies); a direction ends with 0 (it is only turned).

5.3 Chaining frames: this is forward kinematics

0T2 = 0T1 1T2

To go from frame 2 to frame 0, go through frame 1: multiply the matrices. Reading trick: the indices that touch “cancel” (the 1 below and the 1 above). For a robot with n joints: 0Tn = 0T1 1T2 … n−1Tn, and the last column of the result is the position of the tool.

The 2-axis arm of the worked example with its three frames. ⁰T₁ takes frame 0 to frame 1, ¹T₂ takes frame 1 to frame 2; their product ⁰T₂ goes straight from the base to the tool.
Worked example: a 2-axis arm

L1 = 0.5 m, L2 = 0.4 m, θ1 = 30°, θ2 = 45°. Each matrix says “turn by θ, then move forward by L along the new x”: its last column is (L cos θ, L sin θ).

0T1 = 0.866−0.50.4330.50.8660.25001 1T2 = 0.707−0.7070.2830.7070.7070.283001 0T2 = 0.259−0.9660.5370.9660.2590.636001

The tool is at x = 0.537 m, y = 0.636 m. The same as the sum of arrows of lesson 2: 0.5 cos 30° + 0.4 cos 75° = 0.537 and 0.5 sin 30° + 0.4 sin 75° = 0.636. And the top-left block is a rotation of 75° = 30° + 45°: the orientation of the tool.

5.4 Going back: the inverse

(ATB)−1 = BTA = RT−RT t01

No heavy computation: transpose the rotation, and turn the translation back. It answers the opposite question: “where is A, seen from B?”

Key terms

  • frame
  • translation
  • homogeneous matrix
  • homogeneous coordinates
  • chain of transformations
The essentials
  • Change of frame: p_A = R p_B + t (turn, then add the position of the frame).
  • A homogeneous matrix holds R and t; its last column is the position.
  • Chain the frames by multiplying: ⁰T₂ = ⁰T₁ ¹T₂.

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

Frame B is at (2, 1) in A, not turned. A point is at (0.5, 0.3) in B. x of the point in A?

Solution

Rule used change of frame: p_A = R p_B + t; with no rotation, R = I lesson 5 — 5.1 The same point, seen from two frames

  1. No rotation: R p_B = p_B = (0.5, 0.3).
  2. Add t = (2, 1): (0.5 + 2, 0.3 + 1) = (2.5, 1.3).

Answer x = 2.5

Level 2 · Intermediate2

Frame B is at (1, 2) in A and turned by 90°. A point is at (3, 0) in B. y of the point in A?

Hint

Turn (3, 0) by 90° first.

Solution

Rule used change of frame: p_A = R p_B + t (turn first, then add the position of B) lesson 5 — 5.1 The same point, seen from two frames

  1. R(90°) has the columns (0, 1) and (−1, 0).
  2. R(90°)(3, 0) = 3 × (0, 1) = (0, 3).
  3. Add t = (1, 2): (0 + 1, 3 + 2) = (1, 5).

Answer y = 5

Level 3 · Professional3

A 2-axis arm: L1 = 1 m, L2 = 1 m, θ1 = 90°, θ2 = −90°. x of the tool (m)?

Solution

Rule used chaining frames: the tool is the sum of the links, each one at the sum of the angles before it (⁰T₂ = ⁰T₁ ¹T₂) lesson 5 — 5.3 Chaining frames

linkanglexy
1θ₁ = 90°1 × cos 90° = 01 × sin 90° = 1
2θ₁ + θ₂ = 0°1 × cos 0° = 11 × sin 0° = 0
tool11

Answer x = 1 m

Check yourself
  1. In a homogeneous matrix, where do you read the position of the frame?

    In the last column (above the final 1).

  2. Why do we add a 1 under the coordinates of a point?

    So that one matrix product does both the rotation and the translation, and transformations can be chained by multiplying.

  3. How do you get the transformation from frame 3 to frame 0?

    Multiply in order: ⁰T₃ = ⁰T₁ ¹T₂ ²T₃.

6

The Denavit–Hartenberg method (standard DH)

25 min
You will learn

to draw the axes z and x of every frame step by step, to know exactly between which two axes each parameter is measured, and to fill the DH table of any robot alone.

6.1 The problem: too much freedom

Lesson 5 showed that a robot is a chain of frames, one per link, and that we multiply their matrices. If everybody places the frames freely, each frame needs 6 numbers and nobody gets the same equations. Denavit and Hartenberg (1955) gave rules to place the frames; with them, going from one frame to the next needs only 4 numbers, and a whole robot becomes a small table: one row per joint.

6.2 Numbering: links, joints, frames

  • Links (the rigid parts): 0 = the fixed base, 1, 2, … n = the last link, which carries the tool.
  • Joints: joint i connects link i−1 to link i. Its axis is the axis of rotation (revolute joint, R) or the direction of sliding (prismatic joint, P).
  • Frames: frame i (origin Oi, axes xi, yi, zi) is fixed to link i. Frame 0 is fixed to the base and never moves.

6.3 The method: how to draw the axes

Draw the robot in a simple pose (often its zero pose), then place the axes in this order: all the z first, then all the x, then the origins. The y axes are never drawn.

Standard DH: drawing the frames, step by step
  1. Step 1, the z axes. Put zi−1 on the axis of joint i: z0 on joint 1, z1 on joint 2, …, zn−1 on joint n. Choose its direction (either way is correct): the positive rotation of the joint is then given by the right-hand rule around it.
  2. Step 2, the x axes. For i = 1 to n, look at the two axes zi−1 and zi, and put xi on their common perpendicular (the shortest segment that joins them, perpendicular to both), pointing from zi−1 towards zi.
  3. Step 3, the origins. Oi is the point where xi meets zi.
  4. Step 4, frame 0 (base). O0 anywhere on z0 (often on the floor), x0 perpendicular to z0, in a direction you choose — usually the direction of x1 in the drawn pose, so that θ1 = 0 there.
  5. Step 5, frame n (tool). There is no joint n+1: put On on the tool point, zn parallel to zn−1 (or along the direction in which the tool points), and xn from zn−1 towards the tool.
The common perpendicular: four cases
Skew axes (not parallel, not crossing): there is one common perpendicular. xi is on it.
Axes that cross (very common: a vertical axis and a horizontal one): the distance is 0, so ai = 0. xi goes through the crossing point, perpendicular to both axes (two possible directions: choose one; it sets the sign of αi).
Parallel axes (shoulder and elbow): there are infinitely many common perpendiculars. Choose the one that goes through Oi−1, so that di = 0.
Same axis (two joints on one line): xi is any line perpendicular to it; choose the simplest one.
Prismatic joint: only the direction of its axis is fixed; you can move the line parallel to itself to a convenient place (usually through the origin before or after).

Demonstration: the 3-axis arm, step by step

Here is the method applied to a real arm. Use the buttons to go from one step to the next: at each step the new axes appear with a yellow halo.

Draw the axis of each joint first (dashed). z₀ goes on the axis of joint 1 (vertical), z₁ on the axis of joint 2 and z₂ on the axis of joint 3 (both towards you): zᵢ₋₁ is on joint i.
z₀ and z₁ cross at the shoulder: x₁ goes through that point, perpendicular to both (to the right). z₁ and z₂ are parallel: x₂ is the common perpendicular (yellow) that goes from z₁ to z₂, along the upper arm.
O₁ is where x₁ meets z₁: the shoulder. O₂ is where x₂ meets z₂: the elbow.
O₀ on z₀, on the floor. x₀ to the right, in the direction of x₁, so that θ₁ = 0 in this pose.
O₃ on the tool, z₃ parallel to z₂, x₃ from z₂ towards the tool. The drawing is finished: now read the table (θ, d on each old z; a, α on each new x).

6.4 The four parameters: between which two axes

Once the axes are drawn, each row i of the table is read on two axes only: on the old axis zi−1 you measure between two x (that gives θ and d), and on the new axis xi you measure between two z (that gives a and α).

ParameterFrom……toMeasuredName
θixi−1xiaround zi−1joint angle (the variable of an R joint)
dixi−1xialong zi−1offset (the variable of a P joint)
aizi−1zialong xilink length (always fixed)
αizi−1ziaround xitwist (always fixed)
Standard DH, row i: θ and d are measured on zᵢ₋₁ (between xᵢ₋₁ and xᵢ), a and α on xᵢ (between zᵢ₋₁ and zᵢ). Dashed: an axis moved parallel to itself, to show the angle.
Signs: the right-hand rule
  • An angle “from A to B around C”: put the thumb of the right hand along C; if the fingers turn from A towards B, the angle is positive, otherwise negative.
  • A distance “from A to B along C”: positive if you go from A to B in the direction of C. ai is always ≥ 0, because xi points from zi−1 to zi.
  • The variable: for a revolute joint θi = qi + a fixed offset (the angle you read in the drawn pose); for a prismatic joint di = qi + a fixed offset.

6.5 Filling the table, row by row

  1. Write one row per joint, i = 1 to n, with the columns θi, di, ai, αi.
  2. For row i, look at zi−1: the angle from xi−1 to xi around it is θi; the distance from xi−1 to xi along it is di.
  3. Then look at xi: the distance from zi−1 to zi along it is ai; the angle from zi−1 to zi around it is αi.
  4. Replace the angle or distance that changes when the joint moves by its variable q (+ offset). Everything else is a number you can measure on the robot.

6.6 Worked example: the 3-axis arm, cell by cell

The arm of the “Build your first robot” workshop: joint 1 turns around the vertical; joints 2 (shoulder) and 3 (elbow) turn around a horizontal axis. Shoulder height 0.40 m, upper arm 0.45 m, forearm 0.38 m. It is drawn at its zero pose: both links horizontal.

The 3-axis arm at its zero pose with all the frames of standard DH and the numbers of its table: each zᵢ₋₁ on joint i, each xᵢ from zᵢ₋₁ to zᵢ, frame 3 on the tool.

The axes. z0 on joint 1: vertical, upwards. z1 on joint 2 and z2 on joint 3: horizontal, towards you. x1: z0 and z1 cross at the shoulder, so x1 goes through the shoulder, perpendicular to both — horizontal, to the right. x2: z1 and z2 are parallel, so take the perpendicular through O1: along the upper arm, to the elbow. x3: along the forearm, to the tool. x0: to the right, like x1.

CellValueWhy (between which axes)
θ1q1from x0 to x1 around z0: 0 in the drawing, so only the joint variable
d10.40from x0 (floor) to x1 (shoulder) along z0
a10from z0 to z1 along x1: the two axes cross
α190°from z0 (up) to z1 (towards you) around x1 (right): right thumb to the right, the fingers turn from up to towards you → +90°
θ2q2from x1 to x2 around z1: both to the right in the drawing → 0 + variable
d20from x1 to x2 along z1: both go through the shoulder
a20.45from z1 (shoulder) to z2 (elbow) along x2
α20from z1 to z2 around x2: parallel, same direction
θ3q3from x2 to x3 around z2: 0 in the drawing + variable
d30from x2 to x3 along z2: both go through the elbow
a30.38from z2 (elbow) to z3 (tool) along x3
α30from z2 to z3 around x3: parallel

The finished table:

iθidiaiαi
1q10.40090°
2q200.450
3q300.380

6.7 The matrix of one row

The four parameters are four simple moves, applied in the order of the columns: turn by θ around z, slide by d along z, slide by a along x, turn by α around x.

i−1Ti = Rot(z, θi) · Trans(z, di) · Trans(x, ai) · Rot(x, αi) = cθ−sθ cαsθ sαa cθsθcθ cα−cθ sαa sθ0sαcαd0001

One row of a standard DH table is four simple moves, in this order. Dashed grey: the frame before the move; in colour: after. After the fourth move you are on frame i.
Check with numbers

q1 = 25°, q2 = 70°, q3 = −80°. Multiplying the three matrices gives the tool at (0.479, 0.223, 0.757) m. By hand: r = 0.45 cos 70° + 0.38 cos(−10°) = 0.528; x = r cos 25° = 0.479; y = r sin 25° = 0.223; z = 0.40 + 0.45 sin 70° + 0.38 sin(−10°) = 0.757. The table and the drawing agree.

To remember

θ and d live on zi−1 (between xi−1 and xi); a and α live on xi (between zi−1 and zi). Write these two sentences next to your drawing, and every cell of the table becomes a measurement.

Key terms

  • DH convention
  • common perpendicular
  • joint angle θ
  • offset d
  • link length a
  • twist α
  • right-hand rule
  • DH table
The essentials
  • Standard DH: frame i is at the far end of link i; z_i is the axis of joint i+1.
  • One row = θ, d (along z), then a, α (along x).
  • Revolute joint: θ moves. Prismatic joint: d moves. a and α are the shape of the link.

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

How many numbers describe one joint in a DH table?

Solution

Rule used with the DH placement rules, one frame to the next needs only 4 numbers lesson 6 — 6.1 The problem: too much freedom

  1. A free frame needs 6 numbers (3 for the position, 3 for the orientation).
  2. The rules (z on the joint axis, x on the common perpendicular) remove 2 of them.
  3. What is left: θ, d, a, α.

Answer 4

Level 2 · Intermediate2

2-axis arm, standard DH: a₁ = 0.6, a₂ = 0.3, θ₁ = 0°, θ₂ = 90°. y of the tool (m)?

Solution

Rule used for a planar arm, the DH table gives x = a₁ cos θ₁ + a₂ cos(θ₁ + θ₂), y = a₁ sin θ₁ + a₂ sin(θ₁ + θ₂) lesson 6 — 6.7 The matrix of one row

  1. Link 1 at 0°: (0.6, 0).
  2. Link 2 at 0° + 90° = 90°: (0.3 cos 90°, 0.3 sin 90°) = (0, 0.3).
  3. Tool: (0.6, 0.3).
iθᵢdᵢaᵢαᵢ
10°00.60
290°00.30

Answer y = 0.3 m

Level 3 · Professional3

3-axis arm of the lesson (d₁ = 0.40, a₂ = 0.45, a₃ = 0.38) with θ₁ = 0°, θ₂ = 90°, θ₃ = −90°. z of the tool (m)?

Hint

z = d₁ + a₂ sin θ₂ + a₃ sin(θ₂ + θ₃).

Solution

Rule used the 3-axis arm: z = d₁ + a₂ sin θ₂ + a₃ sin(θ₂ + θ₃) (the shoulder height, then each link at its angle) lesson 6 — 6.6 Worked example: the 3-axis arm

  1. Shoulder: d₁ = 0.40 m.
  2. Upper arm at θ₂ = 90° (vertical): 0.45 × sin 90° = 0.45.
  3. Forearm at θ₂ + θ₃ = 0° (horizontal): 0.38 × sin 0° = 0.
  4. z = 0.40 + 0.45 + 0 = 0.85 m.
iθᵢdᵢaᵢαᵢ
10°0.40090°
290°00.450
3−90°00.380

Answer z = 0.85 m

Check yourself
  1. In standard DH, on which axis is z of frame i−1?

    On the axis of joint i.

  2. Between which two axes is θᵢ measured, and around which axis?

    From xᵢ₋₁ to xᵢ, around zᵢ₋₁.

  3. Between which two axes is aᵢ measured, and along which axis?

    From zᵢ₋₁ to zᵢ, along xᵢ.

  4. Two consecutive joint axes cross. What are aᵢ and the direction of xᵢ?

    aᵢ = 0, and xᵢ is perpendicular to both axes, through the crossing point.

See a DH table on a live 3D arm →

7

The modified DH method (DHM)

22 min
You will learn

the same method for the modified convention: where each axis goes, between which two axes each parameter is measured, and the DHM table of the same arm cell by cell.

7.1 One idea changes: the frame sits on its own joint

In standard DH, frame i−1 is on joint i: the numbers are shifted. The modified convention (Khalil and Kleinfinger, 1986; also J. Craig) puts frame j on joint j, the joint that moves link j: the same number everywhere. It is the convention of most French courses.

7.2 The method: how to draw the axes

Modified DH: drawing the frames, step by step
  1. Step 1, the z axes. Put zj on the axis of joint j: z1 on joint 1, z2 on joint 2, …, zn on joint n. Choose its direction.
  2. Step 2, the x axes. For j = 1 to n−1, put xj on the common perpendicular to zj and zj+1, pointing from zj towards zj+1. The four cases of lesson 6 (skew, crossing, parallel, same axis) apply the same way.
  3. Step 3, the origins. Oj is the point where xj meets zj — so the origin of frame j is on its own joint.
  4. Step 4, frame 0 (base). Usually z0 on the same line as z1, and x0 in the direction of x1 when q1 = 0: row 1 is then as simple as possible.
  5. Step 5, the last joint and the tool. There is no zn+1: choose xn (usually towards the tool). The tool gets its own frame E, linked to frame n by one more fixed row (no variable).

Demonstration: the 3-axis arm, step by step

The same arm with the modified method. Compare with lesson 6: the z axes are numbered differently, and a frame E is added on the tool.

Draw the axis of each joint first (dashed). Each z takes the number of its own joint: z₁ on joint 1 (vertical), z₂ on joint 2 and z₃ on joint 3 (towards you).
z₁ and z₂ cross at the shoulder: x₁ goes through that point, perpendicular to both (to the right). z₂ and z₃ are parallel: x₂ is the common perpendicular (yellow) from z₂ to z₃, along the upper arm.
O₁ = where x₁ meets z₁, O₂ = where x₂ meets z₂: both are at the shoulder, so frames 1 and 2 have the same origin.
z₀ on the same line as z₁, O₀ on the floor, x₀ to the right like x₁.
There is no z₄: x₃ points towards the tool and O₃ is at the elbow. The tool frame E sits on the gripper: it gives the fixed row of the table.

7.3 The four parameters: between which two axes

Row j goes from frame j−1 to frame j. It is read on two axes only: on the old axis xj−1 you measure between two z (α and a), then on the new axis zj you measure between two x (θ and d). The letters below are those of the robot pages of this site (J. Craig); the column “Khalil” gives the letters of the French courses.

ParameterKhalilFrom……toMeasuredName
αj−1αjzj−1zjaround xj−1twist (fixed)
aj−1djzj−1zjalong xj−1distance between the two joint axes (fixed)
θjθjxj−1xjaround zjjoint angle (variable of an R joint)
djrjxj−1xjalong zjoffset (variable of a P joint)
Modified DH, row j: α and a are measured on xⱼ₋₁ (between zⱼ₋₁ and zⱼ), θ and d on zⱼ (between xⱼ₋₁ and xⱼ). Dashed: an axis moved parallel to itself, to show the angle.

The signs follow the same right-hand rule as in lesson 6. The variable of joint j is θj (R) or dj (P), always in row j: the row of joint j contains its own variable.

7.4 Filling the table, row by row

  1. One row per joint, j = 1 to n, plus one fixed row for the tool. Columns: αj−1, aj−1, θj, dj.
  2. For row j, look at xj−1: the angle from zj−1 to zj around it is αj−1; the distance from zj−1 to zj along it is aj−1.
  3. Then look at zj: the angle from xj−1 to xj around it is θj; the distance from xj−1 to xj along it is dj.
  4. Put the variable q (+ offset) in the cell that changes when joint j moves.

7.5 Worked example: the same 3-axis arm, cell by cell

The same arm with all the frames of modified DH and the numbers of its table: each zⱼ on joint j itself, each xⱼ from zⱼ to zⱼ₊₁, frames 1 and 2 at the shoulder, frame E on the tool.

The axes. z1 on joint 1: vertical. z2 on joint 2 and z3 on joint 3: horizontal, towards you. x1: z1 and z2 cross at the shoulder → through the shoulder, perpendicular to both, to the right; so O1 is at the shoulder (on z1, 0.40 m up). x2: z2 and z3 are parallel → along the upper arm, from the shoulder to the elbow; O2 is also at the shoulder. x3: towards the tool (no z4). Frame 0: on the floor, z0 on the line of z1, x0 to the right.

CellValueWhy (between which axes)
α00from z0 to z1 around x0: same line, same direction
a00from z0 to z1 along x0: same line
θ1q1from x0 to x1 around z1: 0 in the drawing + variable
d10.40from x0 (floor) to x1 (shoulder) along z1
α190°from z1 (up) to z2 (towards you) around x1 (right) → +90°
a10from z1 to z2 along x1: they cross
θ2q2from x1 to x2 around z2: both to the right in the drawing → 0 + variable
d20from x1 to x2 along z2: both at the shoulder
α20from z2 to z3 around x2: parallel
a20.45from z2 (shoulder) to z3 (elbow) along x2
θ3q3from x2 to x3 around z3: 0 in the drawing + variable
d30from x2 to x3 along z3: both at the elbow
tool: a₃0.38from z3 (elbow) to zE (tool) along x3; the other three cells of the tool row are 0

The finished table:

jαj−1aj−1θjdj
100q10.40
290°0q20
300.45q30
E (tool)00.3800

7.6 The matrix of one row

j−1Tj = Rot(x, αj−1) · Trans(x, aj−1) · Rot(z, θj) · Trans(z, dj) = cθ−sθ0asθ cαcθ cα−sα−d sαsθ sαcθ sαcαd cα0001

One row of a modified DH table: the same four moves, but the moves along and around x come first. Dashed grey: before the move; in colour: after. After the fourth move you are on frame j.

With 25°, 70° and −80° the product of the four matrices gives (0.479, 0.223, 0.757) m: the same tool position as with the standard table of lesson 6. Compare the two tables: the numbers 0.40, 90°, 0.45, 0.38 are all there, but 90° and the lengths have moved one row down.

To remember

α and a live on xj−1 (between zj−1 and zj); θ and d live on zj (between xj−1 and xj). In Khalil's letters: αj, dj on xj−1; θj, rj on zj.

Key terms

  • modified DH (DHM)
  • Khalil–Kleinfinger
  • common perpendicular
  • fixed row
  • twist α
  • offset d (Khalil: r)
The essentials
  • Modified DH: frame j is on the axis of joint j, at the start of link j.
  • One row = α, a (along x, shape of the previous link), then θ, d (along z, motion of joint j).
  • A fixed last row often brings the frame to the tool.

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

In the DHM table of the 2-axis arm, in which row is the length L₁?

Solution

Rule used in DHM, row j holds aj−1: the distance from zj−1 to zj, that is the link before joint j lesson 7 — 7.3 The four parameters

  1. L₁ goes from joint 1 to joint 2: it is a₁.
  2. a₁ is in the row j = 2 (aj−1 with j − 1 = 1).
jαj−1aj−1θⱼdⱼ
100θ₁0
20L₁θ₂0
E (tool)0L₂00

Answer row 2

Level 2 · Intermediate2

DHM, parallel axes (α = 0): a = 0.5, θ = 90°, d = 0. Where is the origin of the new frame, seen from the old one? Give x.

Solution

Rule used a DHM row moves along x by a first, then turns around z by θ: ʲ⁻¹Tⱼ = Rot(x, α) Trans(x, a) Rot(z, θ) Trans(z, d) lesson 7 — 7.6 The matrix of one row

  1. α = 0: nothing turns around x.
  2. Trans(x, 0.5): the origin goes to (0.5, 0).
  3. Rot(z, 90°): only the axes of the new frame turn; the origin stays at (0.5, 0).
  4. d = 0: no slide along z.

Answer x = 0.5

Level 3 · Professional3

A book gives a row (α_j, d_j, θ_j, r_j) = (0, 0.45, θ, 0). In the notation of this lesson, what is a_{j−1}?

Solution

Rule used Khalil letters (αⱼ, dⱼ, θⱼ, rⱼ) and Craig letters (αj−1, aj−1, θⱼ, dⱼ) name the same four numbers lesson 7 — 7.3 The four parameters (column “Khalil”)

KhalilCraigvalue
αⱼαj−10
dⱼaj−10.45
θⱼθⱼθ
rⱼdⱼ0

Answer aj−1 = 0.45

Level 3 · Professional4

Hard exercise 1, SCARA robot (R R P R). Joint 1: vertical axis, its shoulder 0.35 m above the floor. Joint 2: vertical axis, 0.40 m from joint 1. Joint 3: vertical slide (prismatic), 0.30 m from joint 2, variable q₃ (positive upwards). Joint 4: rotation of the wrist, on the same vertical line as joint 3. The tool tip is 0.10 m below the last frame. All z axes point up; frame 0 is on the floor under joint 1. (a) Draw z₁…z₄ and x₁…x₄ and write the DHM table (αj−1, aj−1, θj, dj) with the tool row. (b) For q₁ = 30°, q₂ = 60°, q₃ = −0.15 m, q₄ = 45°, give y of the tool (m).

The robot of exercise 1 at q = 0 (side view). Joints 1, 2 and 4 turn around vertical axes; joint 3 slides up and down.

Hint

All z are parallel: every α is 0, and each x goes from one vertical axis to the next one (common perpendicular = horizontal). z₃ and z₄ are the same line: a₃ = 0. The prismatic variable goes in the d column.

Solution

Rule used DHM method: z on each joint axis, x on the common perpendicular from zⱼ to zj+1; parallel axes give α = 0; a prismatic variable goes in the d column lesson 7 — 7.2 The method and 7.4 Filling the table

  1. Axes: z₁…z₄ vertical, up (all parallel), so every α is 0.
  2. x₁ goes from z₁ to z₂ along link 1; x₂ from z₂ to z₃ along link 2; z₃ and z₄ are the same line, so x₃ and x₄ are chosen in the direction of x₂.
  3. Read each cell between its two axes (table below).
  4. (b) All axes are vertical: seen from above it is a 2-link arm. y = 0.40 sin 30° + 0.30 sin(30° + 60°) = 0.20 + 0.30 = 0.50 m. (q₄ only turns the tool; q₃ and the tool row only change z.)
jαj−1aj−1θⱼdⱼwhy
100q₁0.35d₁: x₀ (floor) → x₁ (shoulder) along z₁
200.40q₂0a₁: z₁ → z₂ along x₁
300.300q₃a₂: z₂ → z₃ along x₂; the slide moves x₃ along z₃
400q₄0z₃ = z₄, so a₃ = 0
E (tool)000−0.10the tip is 0.10 m below, along z₄

Answer y = 0.50 m

Level 3 · Professional5

Hard exercise 2, arm with offsets. Joint 1: vertical axis. Joint 2 (shoulder): horizontal axis, pointing towards you, 0.50 m above the floor, but 0.15 m in front of axis 1 (the two axes do not cross). Joint 3 (elbow): parallel to joint 2, 0.60 m further along the upper arm, and shifted 0.10 m towards you along its own axis. The tool is 0.50 m beyond the elbow. Zero pose: upper arm and forearm horizontal, pointing to the right (+x₀). (a) Write the DHM table, explaining between which axes each non-zero value is measured. (b) For q₁ = 90°, q₂ = q₃ = 0, give x of the tool in frame 0 (m).

The robot of exercise 2 at q = 0 (“towards you” is drawn down and to the left). Axis 1 is vertical; axes 2 and 3 are horizontal and point towards you.

Hint

z₁ and z₂ do not cross: their common perpendicular is horizontal, 0.15 m long, at the height of the shoulder — that is x₁, so O₁ is 0.50 m up on z₁. Between z₂ and z₃ (parallel), x₂ along the upper arm; the 0.10 m shift is then measured along z₃, between x₂ and x₃.

Solution

Rule used axes that do not cross: x is their common perpendicular and a is its length; a shift along a joint axis is a d; α by the right-hand rule lesson 6 — 6.3 The common perpendicular: four cases, and 6.4 Signs

  1. z₁ vertical (up); z₂ and z₃ horizontal, towards you.
  2. z₁ and z₂ do not cross: their common perpendicular is horizontal, 0.15 m long, at the shoulder height. It is x₁ (to the right), so O₁ is 0.50 m up on z₁.
  3. α₁: from z₁ (up) to z₂ (towards you) around x₁ (right). Right thumb to the right, the fingers turn from up towards you: +90°.
  4. z₂ and z₃ are parallel: x₂ along the upper arm (0.60 m). The elbow is 0.10 m further towards you along z₃: that is d₃ = +0.10 (z₃ points towards you).
  5. (b) At q = 0 the tool is at (0.15 + 0.60 + 0.50, −0.10, 0.50) = (1.25, −0.10, 0.50). q₁ = 90° turns it around the vertical: x = cos 90° × 1.25 − sin 90° × (−0.10) = 0 + 0.10.
jαj−1aj−1θⱼdⱼwhy
100q₁0.50d₁: x₀ (floor) → x₁ (shoulder height) along z₁
290°0.15q₂0α₁, a₁: z₁ → z₂ around / along x₁
300.60q₃0.10a₂: z₂ → z₃ along x₂; d₃: x₂ → x₃ along z₃
E (tool)00.5000z₃ → tool along x₃

Answer x = 0.10 m (forgetting d₃ would give 0)

Check yourself
  1. In modified DH, on which axis is z of frame j?

    On the axis of joint j itself.

  2. Between which two axes is αⱼ₋₁ measured, and around which axis?

    From zⱼ₋₁ to zⱼ, around xⱼ₋₁.

  3. Between which two axes is dⱼ (Khalil: rⱼ) measured, and along which axis?

    From xⱼ₋₁ to xⱼ, along zⱼ.

  4. Why does a DHM table often have one more row than the number of joints?

    The last frame sits on the last joint, not on the tool: a fixed row brings it to the tool.

The full DHM lesson, with a SCARA and 6-axis robots →

8

DH and DHM side by side

10 min
You will learn

to tell the two conventions apart at a glance, to avoid mixing them, and to check any table.

8.1 The differences in one table

Standard DHModified DH (DHM)
Where is frame i?at the far end of link iat the start of link i
zi is the axis of…joint i+1joint i
Order of the movesθ, d (along z), then a, α (along x)α, a (along x), then θ, d (along z)
Indices in row iθi, di, ai, αiαi−1, ai−1, θi, di
Rows for n jointsn: the last frame is on the tooln, plus often one fixed row for the tool
Found inSpong; Siciliano; many manufacturer data sheetsCraig; Khalil and Dombre; dynamics and robots with branches
Same robot, same result

The two conventions describe the same robot. The frames in the middle of the chain are placed differently, so the intermediate matrices differ, but the final matrix from the base to the tool is the same. Lessons 6 and 7 showed it twice: (0.537, 0.636) and (0.479, 0.223, 0.757).

8.2 The same arm, both tables

The 3-axis arm of lessons 6 and 7:

StandardθdaαModifiedαaθd
1θ10.40090°100θ10.40
2θ200.450290°0θ20
3θ300.380300.45θ30
tool00.3800

Read it like this: in the standard table the 90° is in row 1 (the twist of link 1); in the modified table it is in row 2 (the twist before joint 2). The lengths 0.45 and 0.38 also move one row down.

8.3 The mistake that costs hours: mixing them

A standard table in a modified matrix gives another robot

Take the standard table of the 2-axis arm (a = 0.5 and 0.4, 30° and 45°) and feed it to the modified matrix by mistake. Each row now means “move forward, then turn” instead of “turn, then move forward”. The tool lands at (0.5 + 0.4 cos 30°, 0.4 sin 30°) = (0.846, 0.200) instead of (0.537, 0.636). No error message: just a robot that goes to the wrong place.

8.4 How to recognise the convention of a table

  • The columns start with θ, d and end with a, α → standard. They start with α, a → modified.
  • The indices ai−1, αi−1 appear → modified.
  • The letters are α, d, θ, r → modified, in the Khalil–Kleinfinger notation.
  • In a software library, look for an option such as “standard” / “modified” (often written mdh).

8.5 Checklist: is my table right?

  1. Zero pose: set every variable to 0, compute the tool position, and compare with the drawing of the robot in that pose.
  2. One joint at a time: turn joint 1 by 90° only. Does the tool go where you expect? Then joint 2, and so on.
  3. Parallel axes have α = 0; perpendicular axes have α = ±90°. Count them on the robot.
  4. Lengths: every non-zero a or d must be a real distance you can measure on the robot.
Which one should you use?

The one of your course, your book or your software, and only that one inside a project. Two people can also write two different correct tables in the same convention (the direction of an axis is a free choice): what counts is that the final matrix is right. On the robot pages of this site you can switch between the DH and DHM tables of the same robot and watch the frames move.

Key terms

  • standard DH
  • modified DH
  • zero pose
  • convention
The essentials
  • Standard: frame at the far end of the link, row θ, d, a, α. Modified: frame on its own joint, row α, a, θ, d.
  • Both give the same tool position, if each table is used with its own matrix.
  • Always check a table with the zero pose.
Where frame i sits: on its own joint in the modified convention, at the far end of the link in the standard one.

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

A table has the columns θ, d, a, α. Which convention?

  1. Standard DH
  2. Modified DH

Solution

Rule used the order of the columns tells the convention: standard DH starts with the moves along z (θ, d), modified DH with the moves along x (α, a) lesson 8 — 8.4 How to recognise the convention of a table

  1. The columns start with θ, d: moves along z first.

Answer Standard DH

Level 2 · Intermediate2

The 3-axis arm has 3 joints. How many rows in its DHM table of the lesson, with the tool?

Solution

Rule used DHM: one row per joint, plus one fixed row that brings the last frame to the tool lesson 7 — 7.4 Filling the table, row by row

  1. 3 joints: 3 rows.
  2. The last frame is on joint 3, not on the tool: + 1 fixed row (E).

Answer 4

Level 3 · Professional3

Zero pose of the 3-axis arm (all θ = 0, standard table of the lesson). x of the tool (m)?

Solution

Rule used always check a table at the zero pose: the links are where the drawing puts them lesson 8 — 8.5 Checklist: is my table right?

  1. All θ = 0: the upper arm and the forearm are horizontal, along x.
  2. x = a₂ + a₃ = 0.45 + 0.38 = 0.83 m (at the height z = d₁ = 0.40 m).

Answer x = 0.83 m

Check yourself
  1. The columns of a table are α, a, θ, d. Which convention?

    Modified DH: the moves along x (α, a) come first.

  2. Do the two conventions give the same position of the tool?

    Yes, if each table is used with its own matrix. Only the intermediate frames differ.

  3. What is the first check of a new DH table?

    The zero pose: set all the variables to 0 and compare the computed tool position with the robot.

Switch between DH and DHM on the 3D arm →

9

Derivatives and partial derivatives: from positions to speeds

15 min
You will learn

what a derivative is, the few rules you need, how a computer estimates it, and how partial derivatives build the Jacobian of a robot.

9.1 A derivative is a rate of change

When the position x of something changes with the time t, its derivative dx/dt says how fast it changes: it is the speed. On the graph of x(t), it is the slope of the curve at that moment. In robotics we write it with a dot: ẋ = dx/dt, θ̇ = dθ/dt.

The derivative of the derivative is the acceleration: ẍ = d²x/dt². Position → speed → acceleration: each one is the rate of change of the one before.

9.2 The five rules you need

FunctionDerivativeExample
a constant c0a length does not change
tnn tn−1(2t²)′ = 4t
sin tcos t
cos t−sin tnote the minus sign
chain rule: f(θ(t))f ′(θ) · θ̇(sin θ)′ = cos θ · θ̇

A sum is derived term by term, and a constant factor stays: (3 t² + 5)′ = 6 t.

Worked example: the speed of the end of an arm

The end of an arm of length L is at x = L cos θ, y = L sin θ (lesson 1). The motor turns, so θ depends on time. Chain rule:

ẋ = −L sin θ · θ̇    ẏ = L cos θ · θ̇

With L = 0.5 m, θ = 30° and θ̇ = 2 rad/s: ẋ = −0.5 × 0.5 × 2 = −0.5 m/s, ẏ = 0.5 × 0.866 × 2 = 0.866 m/s. The speed is L θ̇ = 1 m/s, perpendicular to the arm, as expected for a point that turns.

9.3 How a computer derives: the finite difference

A robot does not have the formula of its motion: it has measurements at regular times. It estimates the derivative with the change divided by the time step:

θ̇ ≈ ( θ(t + Δt) − θ(t) ) / Δt

Example: the encoder reads 1.00 rad, then 1.02 rad 10 ms later: θ̇ ≈ 0.02 / 0.01 = 2 rad/s.

The robot only has samples (dots). Between two samples, the change Δθ divided by the time step Δt is the slope of the red line: an estimate of the speed.
Deriving amplifies noise

If the encoder has a noise of 0.001 rad, dividing by Δt = 0.001 s gives a speed noise of about 1 rad/s. This is why the D term of a PID is always filtered (control course), and why speeds are often estimated with a filter rather than a raw difference.

9.4 Partial derivatives: one variable at a time

The tool of a 2-axis arm depends on two angles: x = L1 cos θ1 + L2 cos(θ1 + θ2). The partial derivative ∂x/∂θ1 is the derivative with respect to θ1, the other angle being frozen. It answers: “if only motor 1 turns a little, how much does x change?”

∂x/∂θ1 = −L1 sin θ1 − L2 sin(θ1 + θ2)    ∂x/∂θ2 = −L2 sin(θ1 + θ2)

∂y/∂θ1 = L1 cos θ1 + L2 cos(θ1 + θ2)    ∂y/∂θ2 = L2 cos(θ1 + θ2)

Look at ∂x/∂θ2: the first term L1 cos θ1 disappeared, because it does not contain θ2. Motor 2 only moves the second link.

Each column of the Jacobian is the speed of the tool when only one motor turns (1 rad/s): around the base for column 1, around the elbow for column 2. The arm of the worked example: L₁ = 0.5 m, L₂ = 0.4 m, θ₁ = 30°, θ₂ = 45°.

9.5 The Jacobian: the table of all partial derivatives

Put the four partial derivatives in a matrix: one row per coordinate of the tool, one column per joint. This is the Jacobian J. When all the joints move together, the speeds add (chain rule with several variables):

ẋẏ = ∂x/∂θ1∂x/∂θ2∂y/∂θ1∂y/∂θ2 θ̇1θ̇2    Ẋ = J θ̇

Worked example

L1 = 0.5 m, L2 = 0.4 m, θ1 = 30°, θ2 = 45° (the arm of lesson 5). Then J = −0.636−0.3860.5370.104. If θ̇1 = 0.5 rad/s and θ̇2 = 1 rad/s: ẋ = −0.636 × 0.5 − 0.386 × 1 = −0.705 m/s, ẏ = 0.537 × 0.5 + 0.104 × 1 = 0.372 m/s.

Two uses you will meet again
  • Small errors: ΔX ≈ J Δθ. An error of 0.1° (0.00175 rad) on motor 1 moves the tool by about 0.636 × 0.00175 = 1.1 mm in x and 0.9 mm in y.
  • Singularities: here det J = L1 L2 sin θ2 = 0.141. It becomes 0 when θ2 = 0 (arm stretched): the tool can no longer move in some direction. The course “Singularities and the Jacobian” starts exactly here.

Key terms

  • derivative
  • slope
  • chain rule
  • finite difference
  • partial derivative
  • Jacobian
The essentials
  • A derivative is a rate of change: position → speed → acceleration.
  • Chain rule: (sin θ)′ = cos θ · θ̇. A computer estimates a derivative with (new − old) / Δt.
  • Partial derivatives (one variable at a time) form the Jacobian: Ẋ = J θ̇.

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

x(t) = 3t². Speed at t = 2 s (m/s)?

Solution

Rule used derivative of tⁿ: n tⁿ⁻¹ (so the derivative of 3t² is 6t) lesson 9 — 9.2 The five useful rules

  1. ẋ = 3 × 2 t = 6t.
  2. At t = 2 s: 6 × 2 = 12 m/s.

Answer 12 m/s

Level 2 · Intermediate2

An encoder reads 0.50 rad, then 0.53 rad 5 ms later. Estimated speed (rad/s)?

Solution

Rule used finite difference: speed ≈ (new value − old value) / Δt lesson 9 — 9.3 The finite difference

  1. Change: 0.53 − 0.50 = 0.03 rad.
  2. Time step in seconds: 5 ms = 0.005 s.
  3. 0.03 / 0.005 = 6 rad/s.

Answer 6 rad/s

Level 3 · Professional3

2-axis arm, L1 = 0.5 m, L2 = 0.4 m, θ1 = 0°, θ2 = 90°. ∂y/∂θ1 = L1 cos θ1 + L2 cos(θ1 + θ2). Value (m/rad)?

Solution

Rule used a partial derivative: derive with respect to one angle, the other one frozen lesson 9 — 9.4 Partial derivatives

  1. θ₁ = 0° and θ₁ + θ₂ = 90°.
  2. 0.5 × cos 0° = 0.5 × 1 = 0.5.
  3. 0.4 × cos 90° = 0.4 × 0 = 0.
  4. Sum: 0.5 m/rad. Meaning: turning joint 1 by 0.01 rad lifts the tool by 0.005 m = 5 mm.

Answer 0.5 m/rad

Check yourself
  1. What is the derivative of the position with respect to time?

    The speed. The derivative of the speed is the acceleration.

  2. What does the partial derivative ∂x/∂θ₂ mean for a 2-axis arm?

    How much x changes when only joint 2 turns a little, joint 1 being frozen.

  3. How is the Jacobian built?

    It is the table of the partial derivatives of the tool coordinates: one row per coordinate, one column per joint.

Continue with the Jacobian and singularities →

10

Probability: living with noisy sensors

14 min
You will learn

the mean, the variance and the standard deviation, the normal law and its 68–95–99.7 rule, and how to combine measurements: the idea behind the Kalman filter.

10.1 Every measurement is a little wrong

Measure the same wall five times with a laser: 2.02 m, 1.98 m, 2.05 m, 1.97 m, 1.98 m. None is “the” distance. A robot must decide with numbers like these. Probability gives the tools to say what is most likely and how sure we are.

10.2 Mean, variance, standard deviation

QuantityFormulaMeaningOur 5 measurements
Mean μ(x1 + … + xN) / Nthe best guess10.00 / 5 = 2.00 m
Variance σ²mean of (x − μ)²the spread, in m²(0.0004 + 0.0004 + 0.0025 + 0.0009 + 0.0004) / 5 = 0.00092 m²
Standard deviation σ√(σ²)the spread, in metres: the typical error√0.00092 ≈ 0.03 m (3 cm)

(Statistics books often divide by N − 1 instead of N for a small sample: here it gives 0.034 m. The idea is the same.)

10.3 The normal law (the bell curve)

The noise of most sensors follows the normal (Gaussian) law: values near the mean are frequent, far values are rare. It is described by only two numbers, μ and σ. The rule to remember:

IntervalShare of the measurements
μ ± σ68 %
μ ± 2σ95 %
μ ± 3σ99.7 %
Worked example

A lidar has σ = 2 cm and reads 1.50 m. With 95 % confidence the true distance is in 1.50 ± 0.04 m, between 1.46 m and 1.54 m. A safety stop that must never miss an obstacle uses ±3σ: 1.44 m.

10.4 Three rules to handle errors

  1. Averaging reduces the noise: the mean of N independent measurements has a standard deviation σ / √N. Four measurements divide the error by 2; one hundred divide it by 10.
  2. Independent errors add in variance, not in standard deviation: σtotal = √(σ1² + σ2²). A camera error of 3 mm and a robot error of 4 mm give 5 mm, not 7 mm.
  3. Independent events multiply: if a grasp succeeds 9 times out of 10, three grasps in a row succeed 0.9 × 0.9 × 0.9 = 73 % of the time.

10.5 Combining two sensors: Kalman in one line

Two sensors measure the same position: the GPS says 10 m (σ = 3 m), the wheels say 12 m (σ = 4 m). The best combination gives each one a weight 1/σ²: the more precise sensor counts more.

x = (x1/σ1² + x2/σ2²) / (1/σ1² + 1/σ2²)    1/σ² = 1/σ1² + 1/σ2²

Here: weights 1/9 = 0.111 and 1/16 = 0.0625, so x = (10 × 0.111 + 12 × 0.0625) / 0.174 = 10.72 m, and 1/σ² = 0.174, so σ = 2.4 m: better than each sensor alone. The Kalman filter repeats this fusion at every step, between the prediction of the motion and the new measurement.

Two uncertain measurements of the same position (blue, violet) give a fused estimate (orange) that is narrower than both and closer to the more precise sensor.
What to remember

A measurement without its σ is half a measurement. Robots carry, with every estimate, its uncertainty: this is what lets them combine sensors, decide when to trust them, and stop safely.

Key terms

  • mean
  • variance
  • standard deviation
  • normal (Gaussian) law
  • independent
  • sensor fusion
The essentials
  • Mean = best guess; standard deviation σ = typical error.
  • Normal law: 68 % within ±σ, 95 % within ±2σ, 99.7 % within ±3σ.
  • Averaging N measurements divides σ by √N; two sensors are combined with weights 1/σ².

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

Measurements: 4, 6, 5, 5 cm. Mean (cm)?

Solution

Rule used mean = sum of the values / number of values lesson 10 — 10.2 Mean, variance, standard deviation

  1. Sum: 4 + 6 + 5 + 5 = 20.
  2. 4 values: 20 / 4 = 5.

Answer 5 cm

Level 2 · Intermediate2

A sensor has σ = 6 mm. You average 9 measurements. New σ (mm)?

Solution

Rule used averaging N independent measurements divides σ by √N lesson 10 — 10.4 Three rules to handle errors

  1. N = 9, so √N = 3.
  2. 6 / 3 = 2 mm.

Answer 2 mm

Level 3 · Professional3

Two sensors measure the same distance with the same σ = 2 cm. Standard deviation of their fusion (cm)?

Hint

1/σ² = 1/σ1² + 1/σ2².

Solution

Rule used fusion of two sensors: 1/σ² = 1/σ₁² + 1/σ₂² lesson 10 — 10.5 Combining two sensors

  1. 1/σ₁² = 1/2² = 1/4, and the same for sensor 2.
  2. 1/σ² = 1/4 + 1/4 = 1/2, so σ² = 2.
  3. σ = √2 ≈ 1.41 cm: the same as averaging two measurements (2 / √2).

Answer σ ≈ 1.41 cm

Check yourself
  1. What share of the measurements falls within μ ± 2σ for a normal law?

    About 95 %.

  2. How does averaging 4 independent measurements change the error?

    It divides the standard deviation by √4 = 2.

  3. Two sensors are combined. Which one gets the larger weight?

    The more precise one (the smaller σ): the weight is 1/σ².

See the Kalman filter at work in the perception course →

11

Orientations in 3D: Euler angles, axis-angle and quaternions

16 min
You will learn

the four ways to describe how an object is turned in space, why robots and ROS 2 use quaternions, and how to read and write one.

11.1 Four ways to say “how it is turned”

A position needs 3 numbers. An orientation in space also has 3 degrees of freedom, but there are several ways to write it, each with its strengths:

RepresentationNumbersStrengthWeakness
Rotation matrix (lesson 4)9direct to compute with: chain by multiplying9 numbers for 3 degrees of freedom; small errors make it slowly stop being a rotation
Euler / roll-pitch-yaw angles3easy for a human to readgimbal lock; 12 different conventions; bad for interpolation
Axis-angle3 (or 4)easy to picture: one axis, one anglecomposing two rotations is not simple
Quaternion4no gimbal lock, compact, smooth interpolation, cheap to fixnot intuitive: you read it through formulas

11.2 Roll, pitch, yaw — and their trap

For a drone, a car or a gripper we often say: yaw ψ (turn around the vertical z), pitch θ (nose up or down, around y), roll φ (tilt the wings, around x). In the usual convention:

R = Rz(ψ) Ry(θ) Rx(φ)

Roll–pitch–yaw: three turns, each around an axis of the frame obtained so far (grey dashed: before; in colour: after). When the pitch reaches 90°, the roll axis lies on the yaw axis: two angles describe the same motion.
Gimbal lock

When the pitch reaches ±90° (nose straight up), the yaw axis and the roll axis line up: two of the three angles do the same thing, and one degree of freedom is lost in the description (not in the object). Near this pose, a small motion of the object can make the angles jump. The course “Singularities and the Jacobian” (lesson 6) shows it in 3D.

11.3 Axis-angle: one axis, one angle

A theorem of Euler says: any orientation can be reached by one single rotation, by an angle θ, around one well-chosen axis u (a unit vector). Hold a book, turn it any way you like: there is always one axis that would have done it in one move.

Packed as one vector θ u it is called the rotation vector: its direction is the axis, its length the angle. The angle can be read directly on a rotation matrix:

cos θ = ( trace R − 1 ) / 2    (trace = R11 + R22 + R33)

Check: Rz(90°) = 0−10100001 has a trace of 0 + 0 + 1 = 1, so cos θ = 0 and θ = 90°.

11.4 The quaternion: axis-angle in a smart form

A unit quaternion is four numbers built from the axis and the angle, using half the angle:

The quaternion of a rotation by θ around u

q = ( w, x, y, z ) = ( cos θ/2, ux sin θ/2, uy sin θ/2, uz sin θ/2 )

Its length is always 1: w² + x² + y² + z² = 1.

RotationQuaternion (w, x, y, z)
none(1, 0, 0, 0)
90° around z(0.707, 0, 0, 0.707)
120° around x(0.5, 0.866, 0, 0)
180° around y(0, 0, 1, 0)

Three rules are enough to use them:

  • Chain two rotations: multiply the quaternions, q = q1 q2 (as for matrices, the order matters). The product of (w1, v1) and (w2, v2) is (w1w2 − v1·v2, w1v2 + w2v1 + v1 × v2), with the dot and cross products of lesson 2.
  • Undo a rotation: change the sign of x, y, z (the conjugate q* = (w, −x, −y, −z)).
  • Turn a vector v: write it as (0, v) and compute q (0, v) q*. In practice a library does it, or converts q to a rotation matrix.
Worked example: 45° then 45° around z

q45 = (cos 22.5°, 0, 0, sin 22.5°) = (0.924, 0, 0, 0.383). Product with itself: w = 0.924² − 0.383² = 0.707, z = 2 × 0.924 × 0.383 = 0.707. We get (0.707, 0, 0, 0.707): the quaternion of 90° around z, as expected.

q and −q are the same orientation

Turning by θ around u or by 360° − θ around −u ends in the same place, and the formula gives q and −q. Do not be surprised if a program prints (−0.707, 0, 0, −0.707) for 90° around z.

11.5 Quaternions in a robot program

A mobile robot on a flat floor only turns around z by its heading ψ (yaw). Then the quaternion is simple, and the heading comes back with atan2:

q = ( cos ψ/2, 0, 0, sin ψ/2 )    ψ = 2 atan2(z, w)

For a general orientation: ψ = atan2( 2(wz + xy), 1 − 2(y² + z²) ).

The order of the four numbers differs between libraries
  • ROS 2 messages (geometry_msgs/Quaternion), tf2 and SciPy write (x, y, z, w): w last.
  • Eigen (C++), many books and this lesson write (w, x, y, z): w first.
  • A heading of 90° is (0, 0, 0.707, 0.707) in a ROS message. Mixing the two orders gives a robot that faces the wrong way, with no error message.

11.6 Why robots prefer quaternions

  1. No gimbal lock: every orientation has a smooth description.
  2. Compact and cheap: 4 numbers instead of 9; after many products, dividing by the length is enough to correct the rounding errors.
  3. Smooth interpolation: the slerp goes from one orientation to another at constant speed, along the shortest path. Halfway between 0° and 90° around z it gives exactly 45°. This is how a robot tool turns smoothly during a linear move, and how an IMU filter tracks the attitude of a drone.
In practice

Store and compute orientations as quaternions, show them to humans as roll, pitch, yaw, and convert to a rotation matrix when you need to turn many points. Let a library do the conversions, and check its order (w first or last).

Key terms

  • roll / pitch / yaw
  • gimbal lock
  • axis-angle
  • rotation vector
  • quaternion
  • conjugate
  • slerp
The essentials
  • An orientation has 3 degrees of freedom: rotation matrix (9 numbers), roll-pitch-yaw (3, with gimbal lock), axis-angle, quaternion (4).
  • Quaternion of θ around u: (cos θ/2, u sin θ/2). Chain by multiplying, undo with the conjugate.
  • ROS 2 writes (x, y, z, w): w last. Heading of a mobile robot: ψ = 2 atan2(z, w).

Worked exercises

Do each exercise on paper first, then type your answer (a small error is accepted) or pick an option. Open the hint if you are stuck, then read the solution: every step is explained.

Level 1 · Beginner1

Quaternion of a rotation of 120° around x: value of w?

Solution

Rule used quaternion of a rotation of θ around a unit axis u: q = (cos θ/2, u sin θ/2) lesson 11 — 11.4 The quaternion

  1. Half the angle: 120° / 2 = 60°.
  2. w = cos 60° = 0.5 (and x = sin 60° = 0.866, y = z = 0).

Answer w = 0.5

Level 2 · Intermediate2

A ROS message gives the orientation of a mobile robot (x, y, z, w) = (0, 0, 0.383, 0.924). Heading ψ in degrees?

Solution

Rule used in ROS 2 the quaternion is written (x, y, z, w), w last; for a turn around z only, the heading is ψ = 2 atan2(z, w) lesson 11 — 11.5 Quaternions in a robot program

  1. x = y = 0: the robot only turns around z.
  2. atan2(0.383, 0.924) = 22.5°.
  3. ψ = 2 × 22.5° = 45°.

Answer 45°

Level 3 · Professional3

A rotation matrix has a trace of 2. Angle of the rotation (degrees)?

Hint

cos θ = (trace − 1) / 2.

Solution

Rule used the trace of a rotation matrix is 1 + 2 cos θ, whatever the axis lesson 11 — 11.3 Axis-angle

  1. 1 + 2 cos θ = 2, so cos θ = (2 − 1) / 2 = 0.5.
  2. θ = arccos 0.5 = 60°.

Answer 60°

Check yourself
  1. How many numbers does a quaternion have, and how many degrees of freedom does an orientation have?

    4 numbers for 3 degrees of freedom: the length of the quaternion is fixed to 1.

  2. Why is the angle divided by 2 in a quaternion?

    Because a vector is turned by q v q*: q appears twice, so each one carries half of the rotation.

  3. A ROS message gives the orientation (0, 0, 0.707, 0.707). Which number is w?

    The last one: ROS writes (x, y, z, w). This is a rotation of 90° around z.

Use quaternions with tf2 in the ROS 2 course →

Glossary

All the words of the course in one place.

TermMeaning
RadianUnit of angle: a full turn is 2π radians.
atan2(y, x)The angle of the point (x, y), right in all four quadrants.
VectorAn arrow: a direction and a length, written as a column of numbers.
Dot productA number that says how much two vectors point the same way; zero if perpendicular.
Cross productA vector perpendicular to two others (right-hand rule).
MatrixA table of numbers that transforms a vector.
DeterminantOne number of a square matrix; zero means it cannot be inverted.
Rotation matrixA matrix that turns vectors; its columns are the axes of the turned frame; its inverse is its transpose.
FrameAn origin and axes from which positions are measured.
Homogeneous matrixA 4×4 matrix that holds a rotation and a translation.
Common perpendicularThe shortest segment between two joint axes; it carries the x axis of a DH frame.
Standard DHFrame i at the far end of link i; row: θ, d, a, α.
Modified DH (DHM)Frame j on the axis of joint j; row: α, a, θ, d.
DerivativeThe rate of change of a quantity: the derivative of a position is a speed.
Partial derivativeThe derivative with respect to one variable, the others being frozen.
Jacobian JThe table of the partial derivatives of the tool coordinates; it turns joint speeds into tool speeds.
Standard deviation σThe typical error of a measurement.
Normal lawThe bell curve: 68 % of the values within ±σ, 95 % within ±2σ.
QuaternionFour numbers (w, x, y, z) of length 1 that describe an orientation without gimbal lock.
Axis-angleAn orientation written as one rotation by an angle θ around one axis u.
Twist αThe angle between two consecutive joint axes.

Sources and references

This course was written from these books, papers, standards and documentation. They are also the best way to go further.

Videos to go further

References

  1. G. Strang, Introduction to Linear Algebra, 5th ed., Wellesley-Cambridge Press, 2016. used for: vectors, matrices, determinants
  2. K. M. Lynch, F. C. Park, Modern Robotics, online book and videos, modernrobotics.northwestern.edu (3.2.2 Angular velocities). used for: frames and angular velocities, with videos
  3. J. J. Craig, Introduction to Robotics: Mechanics and Control, 4th ed., Pearson, 2017. used for: rotations, frames, homogeneous matrices, DH (Craig’s modified convention)
  4. J. Denavit, R. S. Hartenberg, “A kinematic notation for lower-pair mechanisms based on matrices”, ASME Journal of Applied Mechanics, 22, 1955. used for: the original DH convention
  5. W. Khalil, J.-F. Kleinfinger, “A new geometric notation for open and closed-loop robots”, IEEE International Conference on Robotics and Automation, 1986. used for: the modified convention and Khalil’s letters
  6. W. Khalil, E. Dombre, Modeling, Identification and Control of Robots, Hermes Penton Science, 2002 (French edition: Modélisation, identification et commande des robots, Hermès, 1999). used for: DHM as taught in French courses
  7. K. M. Lynch, F. C. Park, Modern Robotics: Mechanics, Planning, and Control, Cambridge University Press, 2017 (free at modernrobotics.org). used for: rotations, quaternions, Jacobian
  8. S. Thrun, W. Burgard, D. Fox, Probabilistic Robotics, MIT Press, 2005. used for: probability and sensor fusion

You have the whole toolbox!

Now use it: the next course builds a 2-axis arm step by step, with its direct and inverse models and its motion laws.

Go to “Maths and motion” → Home page