Maths and motion, step by step

← Robot list · 3D robot arm →

A beginner course: how a robot arm knows where it is and how it moves, starting from zero. You only need to know what an angle and a multiplication are. Each lesson gives a mental picture, then a worked example, then a mini-quiz.

The big question

Take your arm. To grab a glass on the table you do not think: your brain computes by itself how much to turn the shoulder, the elbow and the wrist.

A robot knows nothing by itself. It only knows its motors: “motor 1, turn by 30 degrees; motor 2, turn by 60 degrees”. All the robotics of manipulator arms turns around three questions:

  • Question 1 (easy): I know the motor angles, where is the tool? This is the direct geometric model (forward kinematics, MGD).
  • Question 2 (harder): I want the tool at this place, which angles must I give the motors? This is the inverse geometric model (inverse kinematics, MGI).
  • Question 3 (the bonus): how do I go from one point to another smoothly, without jerks? These are the motion laws.
What the robot controlsWhat we care about
The motors: angles θ₁, θ₂, … (the joint space)The tool: position (x, y, z) (the operational space)
Question 1, direct model: motors → toolQuestion 2, inverse model: tool → motors

This course answers the three questions very progressively. We start in 2D (on a sheet of paper), then move to 3D.

1

The maths toolbox (without pain)

10 min
You will learn

the four maths tools used everywhere: sine and cosine, atan2, vectors and matrices.

We only need 4 tools. If you already know them, skip this lesson.

1.1 Cosine and sine: the “shadow” of a stick

The idea in one picture

Hold a stick of length L tilted by an angle θ from the ground. The sun is right above: the shadow on the ground measures L cos θ. If the sun were at the side, the shadow on the wall would measure L sin θ (the height of the end of the stick).

Remember

The end of a segment of length L, starting at the origin with an angle θ, is at the point:

x = L cos θ, y = L sin θ

Values to know: cos 0 = 1, sin 0 = 0; cos 90° = 0, sin 90° = 1; cos 30° ≈ 0.866, sin 30° = 0.5; cos 60° = 0.5, sin 60° ≈ 0.866; cos 45° = sin 45° ≈ 0.707.

1.2 Finding an angle: the atan2 function

The inverse problem: I know the point (x, y), what is the angle? We use θ = atan2(y, x) (“two-argument arctangent”, available on all calculators and in all languages).

Watch out

Do not simply use arctan(y/x): the point (1, 1) and the point (−1, −1) give the same ratio y/x = 1, but one is at 45° and the other at −135°! atan2 looks at the signs of x and y separately and always gives the right angle.

1.3 Vectors: an arrow with coordinates

A vector is an arrow, written as a column: 32 means “3 to the right, 2 up”. To chain two moves we add the vectors component by component: 32 + 1−1 = 41.

This is exactly what a robot arm does: the position of the tool is the sum of the arrows of each segment of the arm.

1.4 Matrices: a table that transforms a vector

A matrix is a table of numbers. Multiplying a matrix by a vector is doing “row times column”:

abcd xy = ax + bycx + dy example: 1234 56 = 1·5 + 2·63·5 + 4·6 = 1739

To multiply two matrices we do the same: the element (row i, column j) of the result = row i of the first “times” column j of the second.

Watch out

Order matters: in general A × B ≠ B × A. This is normal: “turn then move forward” does not lead to the same place as “move forward then turn”. Try with your body!

Key terms

  • sine / cosine
  • atan2
  • vector
  • matrix
Check yourself
  1. A 2 m segment makes an angle of 60° with the ground. Where is its end?

    x = 2 cos 60° = 1 m, y = 2 sin 60° ≈ 1.73 m.

  2. What is atan2(−1, 0)? (Hint: the point is straight down on the vertical axis.)

    −90°: the point (0, −1) is straight below the origin.

  3. Compute 0−110 20.

    0×2 + (−1)×01×2 + 0×0 = 02: a rotation of the vector (2, 0) by 90°.

2

What is a manipulator robot?

8 min
You will learn

the vocabulary of a robot arm, the two joint types and the two “worlds” used to describe it.

2.1 The human arm as a model

On a humanOn a robotTechnical name
the trunk (does not move)the base screwed to the floorbase (body 0)
the bones of the arm and forearmrigid metal piecesbodies or segments
shoulder, elbow, wristmotors linking the bodiesjoints (links)
the handgripper, welding torch, suction cup…end effector / tool
the tip of the fingersthe point that workstool centre point (TCP)

2.2 Only two kinds of joints

  • Pivot (revolute, “R”): it turns by an angle θ, like an elbow.
  • Slider (prismatic, “P”): it slides by a length r, like a drawer.

Each joint has a single adjustable value, called the joint variable and written q: an angle for a pivot, a length for a slider.

New word

Degree of freedom (DOF). It is the number of independent movements. A robot with 6 joints has 6 DOF. A free object in space needs 6 DOF to be placed anywhere and in any orientation: 3 for the position (move forward, sideways, up) and 3 for the orientation (like a plane: turn left/right, nose up/down, tilt the wings). That is why most industrial robots have 6 axes.

2.3 The robots you will meet

  • SCARA robot (4 DOF): two arms turning horizontally + a rod going up and down + a rotation of the tool. Very fast to pick and place parts on a table.
  • “Anthropomorphic” 6-axis robot (6R: six pivots): looks like a human arm (Kuka, ABB, Fanuc, Stäubli, Universal Robots). Can do everything: weld, paint, assemble.
  • Cartesian robot: three perpendicular sliders (like a 3D printer).
  • Redundant robot (7 DOF or more): it has more joints than needed, like your arm (you can move the elbow without moving the hand resting on the table).

All these robots are serial robots: the bodies are attached one after the other, like the links of a chain.

2.4 Two “worlds” to describe the robot

  • The joint space: the list of the motor values, (q1, q2, …). It is the language of the robot.
  • The operational space: the position (and orientation) of the tool, (x, y, z, …). It is the language of the human who programs the task.

The models MGD and MGI are the dictionaries that translate from one language to the other.

Key terms

  • base
  • end effector
  • DOF
  • joint space
  • operational space
  • redundant
Check yourself
  1. A slider joint: is its variable an angle or a length?

    A length (the slider slides).

  2. How many DOF do you need to place and orient an object freely in space?

    6: 3 for the position, 3 for the orientation.

  3. Why do we say that the human arm (shoulder 3 DOF + elbow 1 + wrist 3 = 7) is “redundant”?

    Because 7 DOF is more than the 6 needed: you can move the elbow without moving the hand.

See a SCARA, a 6-axis robot and a gantry in 3D →

3

First robot: one single joint

4 min
You will learn

to write your very first direct geometric model.

Let us start with the simplest possible robot: a single arm of length L, fixed at the origin by a pivot. The motor sets the angle θ.

From lesson 1, the end of the arm is at:

x = L cos θ, y = L sin θ

Congratulations: you have just written your first direct geometric model!

Worked example

L = 0.5 m and θ = 30°: x = 0.5 × 0.866 = 0.433 m, y = 0.5 × 0.5 = 0.25 m.

And the inverse model? I want the end of the arm to be at the point (x, y).

  • The angle is given by θ = atan2(y, x).
  • But careful: this is only possible if the point is exactly at the distance L from the origin (√(x² + y²) = L). Otherwise the arm is too short or too long: no solution.
Remember

First important lesson: the direct model always has an answer, the inverse model not necessarily.

Key terms

  • direct model (MGD)
  • inverse model (MGI)
Check yourself
  1. With L = 1 m and θ = 90°, where is the end of the arm?

    x = 1·cos 90° = 0 and y = 1·sin 90° = 1: straight up, at (0, 1).

Move the joints of a real arm →

4

The two-joint arm (the heart of the subject)

15 min
You will learn

the direct and inverse models of a 2-axis arm, elbow left and right, the workspace and singularities.

4.1 The direct model: adding the arrows

Two arms: the first, of length L1, turns by an angle θ1 relative to the ground; the second, of length L2, turns by an angle θ2 relative to the first arm (like your elbow bends relative to your arm, not relative to the floor).

  • The arrow of arm 1 makes an angle θ1 with the ground: L1 cos θ1L1 sin θ1.
  • The arrow of arm 2 makes an angle θ1 + θ2 with the ground (the angles add up!): L2 cos(θ1+θ2)L2 sin(θ1+θ2).
  • The position of the tool is the sum of the two arrows:

x = L1 cos θ1 + L2 cos(θ1+θ2)
y = L1 sin θ1 + L2 sin(θ1+θ2)

This is the MGD of the SCARA robot (seen from above). In the full course, we just add the height z = h + q3 and the orientation of the tool θE = θ1 + θ2 + θ4.

Worked example

L1 = 0.5 m, L2 = 0.3 m, θ1 = 30°, θ2 = 60° (so θ1 + θ2 = 90°).

x = 0.5 × 0.866 + 0.3 × cos 90° = 0.433 + 0 = 0.433 m
y = 0.5 × 0.5 + 0.3 × sin 90° = 0.25 + 0.3 = 0.55 m

The tool is at E = (0.433 ; 0.55). It is the figure above.

4.2 The inverse model: finding the angles

Now we know the point E = (x, y) and look for θ1, θ2. The trick is done in two steps.

Step 1: find the elbow θ2 thanks to the distance. The distance between the shoulder and the tool, D = √(x² + y²), only depends on the opening of the elbow (a straight elbow gives a large distance, a folded elbow a small one). The Al-Kashi formula (generalised Pythagoras) gives:

cos θ2 = x² + y² − L1² − L2²2 L1 L2 ⟹ θ2 = ± arccos(…)

Step 2: find the shoulder θ1. We take the direction of the tool, atan2(y, x), and we remove the small angle that arm 1 makes with this direction:

θ1 = atan2(y, x) − atan2(L2 sin θ2, L1 + L2 cos θ2)

Worked example

We aim at E = (0.433 ; 0.55) with L1 = 0.5 and L2 = 0.3 (we redo the path backwards).

  1. x² + y² = 0.1875 + 0.3025 = 0.49. cos θ2 = 0.49 − 0.25 − 0.092 × 0.5 × 0.3 = 0.150.3 = 0.5, so θ2 = ±60°.
  2. With θ2 = +60°: atan2(0.55 ; 0.433) ≈ 51.8° and atan2(0.3 × 0.866 ; 0.5 + 0.3 × 0.5) = atan2(0.26 ; 0.65) ≈ 21.8°. So θ1 ≈ 51.8 − 21.8 = 30°. We find the starting angles again!
  3. With θ2 = −60°: θ1 ≈ 51.8 + 21.8 = 73.6°. It is a second valid solution.

4.3 Two solutions? Elbow right, elbow left

To reach the same point, the arm can bend the elbow on one side or on the other. Each solution is called an aspect (or a posture). The ± sign in the arccos is used to choose the aspect.

Remember

The inverse model can have:

  • 0 solution: the point is too far or too close (the number inside the arccos is outside [−1, 1]);
  • several solutions: 2 for this arm (elbow right/left), up to 8 for a 6-axis robot;
  • infinitely many: for a redundant robot (7 axes), or in some particular positions.

4.4 Where can the robot go? The workspace

With the arm fully stretched, the tool is at L1 + L2 = 0.8 m from the shoulder: it is the farthest possible. With the arm completely folded, it is at |L1 − L2| = 0.2 m: the closest possible. If the motors can do a full turn, the reachable zone is a ring. In reality each motor has stops (for example θ1 between −105° and +105°), and the workspace takes the shape of a crescent or a kidney.

New word

Singularity. When the arm is completely stretched (θ2 = 0) or completely folded, it can no longer move in the direction of the arm, whatever the speed of its motors. It is a “trap” position called a singularity. It is also the border between the two aspects: to go from elbow right to elbow left, the arm must go through the stretched position.

Key terms

  • aspect (posture)
  • Al-Kashi formula
  • workspace
  • singularity
  • joint stops
Check yourself
  1. With L1 = 0.5, L2 = 0.3, θ1 = 0° and θ2 = 90°, where is the tool?

    x = 0.5 + 0.3 cos 90° = 0.5 m; y = 0 + 0.3 sin 90° = 0.3 m. The tool is at (0.5 ; 0.3).

  2. Is the point (1 ; 0) reachable by this robot? Why?

    No: it is 1 m from the shoulder, but the stretched arm only measures L1 + L2 = 0.8 m. (The arccos would give cos θ2 = (1 − 0.34)/0.3 = 2.2 > 1: impossible.)

  3. Arm stretched horizontally to the right (θ1 = θ2 = 0): can it still move to the right?

    No: it is a singularity. The arm is already at its maximum extension in this direction.

Watch the 2-axis kinematics of the SCARA →

5

Frames: looking at the world from each piece

12 min
You will learn

rotation matrices, the three angles of an orientation and the matrix that packs rotation + move.

For a 2-axis planar arm we could “draw” the calculation. For a 6-axis robot in space it is impossible: we need a systematic method. The idea: stick a small system of axes (a frame) on each piece of the robot.

The idea in one picture

Imagine that every piece of the robot carries a small personal GPS with its own directions “forward”, “left” and “up”. The frame of the base is called R0, the one of arm 1 is R1, etc. To know where the tool is in the base frame, we go from one piece to the next, like an object handed from hand to hand in a human chain.

5.1 A rotation, written with a matrix

If a frame R1 is turned by an angle θ relative to R0 (in 2D), a point of coordinates (x1, y1) in R1 has, in R0, the coordinates:

x0y0 = cos θ−sin θsin θcos θ x1y1

Worked example

θ = 90°, point (1 ; 0) in R1: R(90°) 10 = 0−110 10 = 01. The point that was “in front” of the turned frame is found “up” in the fixed frame. Logical!

In 3D it is the same with 3×3 matrices. For example a rotation around the vertical axis z:

Rz(θ) = cos θ−sin θ0sin θcos θ0001

The height z does not change, hence the 1. There are also Rx and Ry to turn around the two other axes.

5.2 Describing an orientation in 3D with 3 angles

To orient an object in space, we chain three rotations. The most intuitive is the vocabulary of planes and boats:

RotationAround the axisWhat it does
Rollx, the forward axisthe plane tilts its wings
Pitchy, the axis of the wingsthe plane lifts or lowers its nose
Yawz, the vertical axisthe plane turns left or right

These are the Cardan angles. The full course also presents the Euler angles, another way of chaining three rotations. In both cases: 3 angles, and the order of the rotations matters.

5.3 The “all-in-one” matrix: rotation + move

A frame is not only turned, it is also moved. We store both pieces of information in one single matrix, by adding a row and a column. In 2D it gives a 3×3 matrix:

T = cos θ−sin θasin θcos θb001 and the point is written with a 1 more: xy1

  • the top-left block is the rotation;
  • the right column (a, b) is the position of the origin of the moved frame;
  • the last row (0 0 1) only makes the calculation work.

This matrix is called a homogeneous transformation matrix. In 3D it is 4×4, but the idea is the same.

Worked example

A frame R1 is turned by 90° and its origin is at the point (2 ; 1) of R0. Where is the point (1 ; 0) of R1 in R0?

0−12101001 101 = 0+0+21+0+11 = 221

Answer: (2 ; 2). We turned then moved, in one single multiplication.

5.4 The big advantage: we chain by multiplying

If I know the move from the base to arm 1 (T0→1), then from arm 1 to arm 2 (T1→2), etc., the move from the base to the tool is simply the product:

T0→tool = T0→1 × T1→2 × T2→3 × …

In the full course we write T0→1 in the form 0T1 (the left superscript = the frame from which we look). It is exactly the same thing.

Key terms

  • frame
  • rotation matrix
  • roll / pitch / yaw
  • homogeneous matrix
Check yourself
  1. In a homogeneous matrix, where do you read the position of the frame origin?

    In the last column (in 2D: the first two numbers of the 3rd column).

  2. A frame is simply moved by (3 ; 0), without rotation. Write its 2D matrix.

    103010001 (no rotation = identity, move (3 ; 0)).

  3. A plane “lifts its nose”. Is it roll, pitch or yaw?

    Pitch (rotation around the axis of the wings).

See the frames of a real arm →

6

The Denavit–Hartenberg method, gently

8 min
You will learn

where exactly to put the frames, and why 4 numbers per joint are enough.

6.1 The problem

We know we must put a frame on each piece, but where exactly? If everyone does it their own way, nobody finds the same calculations. Denavit and Hartenberg (1955), then Khalil and Kleinfinger (the “modified” version, DHm, the one of your course) proposed a common rule of the game.

6.2 The rule of the game in 3 moves

  1. The z axis of each frame is put on the axis of the motor: the axis around which it turns (pivot), or the direction in which it slides (slider).
  2. The x axis links the axis of the current motor to the next one, by the shortest way (the “common perpendicular”).
  3. The y axis is deduced from the two others (right-handed frame, right-hand rule).

6.3 Only 4 numbers per joint

Thanks to this rule, to go from one frame to the next, 4 numbers are enough (instead of 6):

NameWhat it isMental picture
αthe angle between two successive motor axes“are the two motors parallel (0) or skew (±90°)?”
dthe distance between two successive motor axesthe length of an arm
θthe rotation angle around the new z axisthe angle of the pivot motor
rthe shift along the new z axisthe travel of the slider, or a height
  • α and d are fixed: they describe the shape of the robot (they are read on the data sheet).
  • For a pivot, θ moves (the motor); for a slider, r moves.

Everything is stored in a table (one row per joint). The table contains all the geometry of the robot; then a computer does the calculations.

6.4 Example: our 2-axis arm

The two motors have vertical axes (perpendicular to the sheet), so they are parallel: α = 0 everywhere.

RowαdθrExplanation
100θ10motor 1 is at the origin
20L1θ20motor 2 is at the end of arm 1
tool0L200the tool is at the end of arm 2

Each row gives a homogeneous matrix (“turn by θ, after moving forward by d”). By multiplying the three, we find exactly:

x = L1 cos θ1 + L2 cos(θ1+θ2), y = L1 sin θ1 + L2 sin(θ1+θ2)

The DH method gives the same result as our drawing, but it also works for a 6-axis robot, where the drawing becomes impossible.

Watch out

For a 6-axis robot, the DHm tables contain α = ±π/2 (skew motors). The sign depends on the direction chosen for the z axes: two students can find different tables, both correct. Always check by setting all the angles to zero and comparing with the real robot.

Key terms

  • DHm
  • common perpendicular
  • DH table
Check yourself
  1. Which two DH numbers describe the fixed shape of the robot?

    α (twist between axes) and d (distance between axes).

  2. For a slider joint, which number moves?

    r, the shift along the z axis (for a pivot it is θ).

Compare DH and DHM tables on the arm page →

7

Moving the robot smoothly: the motion laws

12 min
You will learn

how a robot goes from A to B without jerks, and how to compute the trapezoid.

7.1 Why it matters

Knowing the start and arrival points is not enough. If we asked the motor to go instantly from 0 to its maximum speed, an infinite force would be needed: the robot would vibrate, the part would fall from the gripper, the motor would wear out.

The idea in one picture

It is like driving a car between two red lights: you start (you accelerate), you cruise at constant speed, then you brake to stop exactly at the next light.

7.2 The velocity trapezoid law

The speed graph has the shape of a trapezoid. The two settings of the robot are:

  • the maximum speed Vmax (the motor cannot go faster);
  • the acceleration a (the force of the motor limits how fast it can start).

The secret: distance travelled = area under the speed curve.

Step by step: the robot must travel a distance X
  1. Time to reach the maximum speed: T1 = Vmax/a.
  2. Is there room for a cruise phase? Yes if X > Vmax²/a.
  3. If yes: cruise time T2 = X/Vmax − T1; braking time T3 = T1.
  4. If not: the robot has no time to reach Vmax; the trapezoid becomes a triangle (“bang-bang” law: we accelerate half of the way, we brake the other half). Then T1 = T3 = √(X/a).
Worked example

A trapeze: X = 1 m, Vmax = 0.5 m/s, a = 1 m/s².

  1. T1 = 0.5/1 = 0.5 s.
  2. Vmax²/a = 0.25 < 1: there is a cruise phase.
  3. T2 = 1/0.5 − 0.5 = 1.5 s; T3 = 0.5 s; total 2.5 s (it is the graph above).

Check by the areas: start ½ × 0.5 × 0.5 = 0.125 m; cruise 0.5 × 1.5 = 0.75 m; braking 0.125 m. Total: 1 m. ✓

Worked example

A triangle: X = 0.1 m, Vmax = 0.5 m/s, a = 0.5 m/s². Here Vmax²/a = 0.5 > 0.1: no cruise phase. T1 = T3 = √(0.1/0.5) ≈ 0.45 s, and the maximum speed actually reached is only √(0.1 × 0.5) ≈ 0.22 m/s.

7.3 Even smoother laws

The trapezoid has a flaw: the acceleration changes abruptly (from “I accelerate” to “I cruise”). To spare the motors we also use (graphs above, from left to right: bang-bang, trapezoid, acceleration trapezoid, sine squared):

  • the sine-squared law: the speed rises smoothly along an S curve;
  • the acceleration trapezoid: the acceleration itself rises and falls progressively;
  • the degree-5 polynomial: a ready-made, very smooth formula.

7.4 Several motors at the same time

A 6-axis robot moves its 6 motors together. So that they start and stop at the same time, we give the maximum speed to the motor which has the longest way to go, and the others go slower, in proportion (homothetic trapezoids).

Worked example

Axis 1: +50°, axis 2: +20°, axis 3: −30°; maximum speed 100°/s. Axis 1 (the longest): 100°/s. Axis 2: 100 × 20/50 = 40°/s. Axis 3: 100 × (−30)/50 = −60°/s.

7.5 “Joint” or “linear” movement?

  • Joint movement: we directly vary the motor angles. It is simple and fast, but the tool does not follow a straight line (it makes a curve).
  • Linear movement: we impose a straight line to the tool. The robot must recompute the inverse model at every instant. Essential to weld or glue along an edge.

Key terms

  • velocity trapezoid
  • bang-bang
  • homothetic trapezoids
  • joint / linear movement
Check yourself
  1. X = 1 m, Vmax = 1 m/s, a = 2 m/s²: compute T1, T2, T3.

    T1 = 1/2 = 0.5 s; Vmax²/a = 0.5 < 1, so there is a cruise phase; T2 = 1/1 − 0.5 = 0.5 s; T3 = 0.5 s. Total 1.5 s.

  2. In a speed/time graph, what does the area under the curve represent?

    The distance travelled.

  3. To follow a perfectly straight glue bead, which type of movement should you choose?

    A linear movement (a straight line imposed to the tool).

8

Recap: the map of the course

5 min
You will learn

to see all the notions at a glance and know where to read more.

NotionIn one sentenceIn the full course
Framea system of axes stuck on a pieceStep 1
Rotation matrixa table that turns coordinatesSteps 1–2
Roll, pitch, yaw3 angles to orient an objectStep 2 (Cardan, Euler)
Homogeneous matrixrotation + move in one matrixStep 3
Denavit–Hartenbergrule to place the frames, 4 numbers per axisStep 4
MGDmotor angles → tool positionStep 5
MGIwanted position → motor anglesStep 6
Aspectone of the ways of reaching the same pointSteps 6–7
Workspacezone that the tool can reachStep 7
Singularitytrap position where the robot loses a movementStep 8
Trapezoid lawstart, cruise, brakeStep 9
Remember

You now have all the basic ideas. The full course “Robot modelling” takes these notions in 3D with the real notations (0T1, σj, αj, dj, θj, rj) and real industrial robots (SCARA, Kuka, ABB, UR3). Read it keeping this course nearby: each time a formula looks complicated, look for its 2D equivalent here.

Key terms

  • MGD
  • MGI
  • aspect
Check yourself
  1. Which two models translate between the “language of the motors” and the “language of the tool”?

    The direct geometric model (MGD) and the inverse geometric model (MGI).

Continue with the full course →

Glossary

All the words of the lessons in one place.

TermMeaning
JointA motorised link between two pieces.
atan2A function giving the angle of a point (x, y) in the right quadrant.
BaseThe fixed foot of the robot (body 0).
DOFDegree of freedom: an independent movement.
End effectorThe tool at the end of the robot.
Joint spaceThe set of the values of the motors.
Operational spaceThe set of the positions of the tool.
SliderA joint that slides (variable r).
PivotA joint that turns (variable θ).
RedundantHaving more axes than needed.
SCARAA fast robot with horizontal arms.
TCPTool centre point.
Joint variableThe value set by a motor, written q.

You have the basic ideas!

Next: the full course, in 3D, with the real notations and real industrial robots.

Go to the full course → Back to the roadmap