Part 2 of the course, lessons 11 to 20: motion control to a goal pose, path following, planning for nonholonomic robots, then the professional work: odometry and calibration, Kalman filtering, dynamics and motor/battery sizing, software and ROS 2, safety and testing, a capstone project, and a final certification with a written exam, practical challenges and labs.
Before you start
This page is part 2. It uses the kinematics of part 1 everywhere: the pose (x, y, θ), the rolling and sliding constraints, the differential and car models, and the ICR. If these are not clear, do part 1 (lessons 1 to 10) first, or at least its exercises.
Part
Lessons
You will be able to…
Part 1 · A. Foundations (beginner)
1 – 4
do the maths of the course, describe the pose of a robot, and write the constraints of any wheel
Part 1 · B. Kinematics of every drive (intermediate)
5 – 10
compute the wheel speeds and the motion of differential, car, omni, Mecanum and swerve robots, and count their degrees of freedom
Part 2 · C. Control and planning (advanced)
11 – 13
drive a robot to a pose, make it follow a path, and plan feasible paths and speed profiles
Part 2 · D. Professional engineering
14 – 20
calibrate, filter, size, program, secure and test a real robot, design one from a specification, and pass the final certification
11
Motion control: driving a robot to a goal pose
18 min
You will learn
to compare open-loop and feedback control for a mobile robot, to write the polar-coordinate control law of a differential robot, and to choose gains that make it converge.
9.1 The goal of kinematic control
A kinematic controller makes the robot follow a trajectory described by position and/or velocity profiles as functions of time. It is not straightforward, because mobile robots are nonholonomic: you cannot just move to the right. Still, several good solutions exist. Most of them ignore the dynamics of the system and give the speeds that the wheels must have (lesson 5).
9.2 Open-loop control
Divide the path into segments of clearly defined shapes, straight lines and circle arcs, and pre-compute the speeds of each. The disadvantages:
it is not easy to pre-compute a feasible trajectory;
it must respect the limits of the robot velocities and accelerations;
it does not correct errors, or adapt if the environment changes;
the resulting trajectories are usually not smooth (the curvature jumps between a line and a circle).
9.3 Feedback control: the problem
With feedback, the controller uses the error e between the current pose and the goal: we look for a matrix K (2×3, its elements may depend on time and on the error), such that the commands
( v , ω )T = K · e = K · ( x , y , θ )T drive the error to zero: limt→∞e(t) = 0
Because the robot is nonholonomic, a constant matrix K cannot do it: the gains must depend on the error (kij = k(t, e)). A convenient way to get such gains is to change the coordinates.
9.4 Polar coordinates of the goal
Put the origin of a frame at the goal and describe the robot by three polar quantities, where Δx, Δy is the vector from the robot to the goal:
α: the angle between the robot heading and the direction of the goal (“am I pointing at it?”);
β: the angle between the line of sight and the goal orientation (“am I arriving the right way?”).
With the kinematics of the differential robot (ẋ = v cos θ, ẏ = v sin θ, θ̇ = ω), the system becomes, for α in (−90°, 90°]:
ρ̇ = −v cos αα̇ = ( v sin α ) / ρ − ωβ̇ = −( v sin α ) / ρ
For α outside this range the robot has the goal behind it: the same equations hold with the robot's “front” redefined as its back, and v changes sign: the robot drives backwards and arrives with its back to the goal direction (θ ≈ 180° instead of 0). Note also that the transformation is not defined at ρ = 0 (the goal itself), where the angles have no meaning.
The robot described from the goal: ρ is how far it is, α how much it must turn to face the goal, β the orientation it will have to correct at the goal. The controller drives the three to zero.
9.5 The control law
v = kρρω = kαα + kββ
It is a proportional law: go faster when far from the goal, turn toward the goal with kα, and turn to arrive in the right orientation with kβ. Closed loop, the system is:
ρ̇ = −kρρ cos αα̇ = kρ sin α − kαα − kβββ̇ = −kρ sin α
Stability: how to choose the gains
For small α, sin α ≈ α and cos α ≈ 1, and the system is linear. Its characteristic polynomial is ( λ + kρ ) ( λ² + λ ( kα − kρ ) − kρkβ ). All its roots have a negative real part, so the robot converges to ( ρ, α, β ) = ( 0, 0, 0 ), if:
kρ > 0 kβ < 0 kα − kρ > 0
A textbook choice is kρ = 3, kα = 8, kβ = −1.5. Note that ρ then shrinks faster than the angles converge, so the final heading is a little off when you stop at a distance tolerance: a smaller kρ (about 1 to 1.5) and a larger |kβ| give a more precise heading, but a slower approach. Another nice property: the speed v keeps a constant sign, so the robot never reverses during its approach: it parks in the most natural way.
Finally the commands v and ω are converted into wheel speeds with VR = v + ωL/2 and VL = v − ωL/2 (lesson 5), and the motors' own speed loops (lesson “Dynamics and control”) follow them. In practice, add saturations on v and on the wheel speeds, and stop when ρ is below a tolerance, since the law has no meaning at the goal itself.
The essentials
Open loop drives blind and accumulates errors; feedback measures the error and corrects it.
Polar coordinates of the goal: distance ρ, bearing α, and final heading error β.
v = kρ ρ, ω = kα α + kβ β is stable if kρ > 0, kβ < 0 and kα − kρ > 0.
Key terms
open-loop / feedback control
polar coordinates ρ, α, β
control gain
stability
singularity at ρ = 0
saturation
Exercises
Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.
Level 1 · Beginner1
The robot is at the origin and the goal is at (3, 4). What is ρ, the distance to the goal?
Solution
ρ = √(3² + 4²) = 5 m.
Level 1 · Beginner2
With k_ρ = 0.4 and ρ = 2.5 m, what is the commanded speed v = k_ρ ρ?
Solution
v = 0.4 × 2.5 = 1 m/s. As the robot approaches the goal, ρ decreases and so does v: the approach is smooth.
Level 2 · Intermediate3
The robot is at the origin with the heading θ = 30°; the goal is at (2, 2). What is α in degrees?
Hint
α = −θ + atan2(Δy, Δx).
Solution
atan2(2, 2) = 45°, so α = −30° + 45° = 15°: the goal is 15° to the left of the heading.
Level 2 · Intermediate4
The controller gives v = 0.4 m/s and ω = 0.8 rad/s. With L = 0.3 m, what is the right-wheel speed V_R?
Solution
V_R = v + ω L / 2 = 0.4 + 0.8 × 0.3 / 2 = 0.52 m/s (and V_L = 0.28 m/s).
Level 2 · Intermediate5
Which gains make the controller stable?
k_ρ = 3, k_α = 8, k_β = −1.5
k_ρ = 3, k_α = 2, k_β = −1.5
k_ρ = 3, k_α = 8, k_β = +1.5
Solution
Conditions: k_ρ > 0, k_β < 0 and k_α − k_ρ > 0. The second set has k_α − k_ρ = −1 < 0; the third has k_β > 0.
Level 3 · Professional6
With k_ρ = 1.5, k_α = 6, k_β = −2 the characteristic polynomial is (λ + k_ρ)(λ² + (k_α − k_ρ) λ − k_ρ k_β). What is the slowest (closest to zero) real pole?
Hint
Solve λ² + 4.5 λ + 3 = 0 and compare with −k_ρ = −1.5.
Solution
λ² + 4.5 λ + 3 = 0 gives λ = (−4.5 ± 2.872) / 2 = -0.814 and -3.686. The other pole is −1.5. The slowest is -0.814 1/s, so the time constant is about 1.23 s: the angles converge in roughly 4 time constants ≈ 4.9 s.
Check yourself
Why is open-loop control with lines and circles weak?
It cannot correct errors or adapt to changes, it is hard to precompute feasible trajectories, and the resulting path is not smooth.
With kρ = 2, kα = 5, kβ = −1, is the controller stable?
Yes: kρ > 0, kβ < 0 and kα − kρ = 3 > 0.
What do α and β mean?
α is the angle between the robot heading and the direction to the goal; β is the angle between the line of sight and the goal orientation.
Following a path: pure pursuit, Stanley and trajectory tracking
18 min
You will learn
to make a robot follow a path (not only reach a point), with the three standard controllers, and to choose their parameters with the speed and the delay of the robot.
12.1 From “go to a point” to “follow a path”
Lesson 11 drove the robot to one goal pose. A real robot has to follow a whole path: a list of points given by a planner, a line painted on the floor, or the lane of a road. The quality of the tracking is measured by two errors:
the cross-track errorey: the distance from the robot to the nearest point of the path;
the heading erroreθ: the angle between the robot heading and the tangent of the path.
12.2 Pure pursuit
The idea is the one of a driver looking ahead on the road. At each step: (1) find the point of the path nearest to the robot; (2) walk along the path until you are at the look-ahead distanceLd from the robot: this is the target; (3) steer along the circle that goes from the robot to the target while being tangent to the robot heading.
Express the target in the robot frame: ( xg , yg ), with x forward and y to the left, and Ld² = xg² + yg². The circle through the robot (tangent to its heading) and the target has the curvature:
Why 2 yg / Ld²? A circle tangent to the x axis at the origin has its centre at (0, R). The target is on it: xg² + ( yg − R )² = R², which gives xg² + yg² = 2 Ryg, so R = Ld² / (2 yg).
Worked example
A differential robot (L = 0.4 m) goes at v = 0.5 m/s. The target is at ( 1.0 , 0.3 ) m in its frame. Then Ld² = 1.09, κ = 0.6 / 1.09 = 0.55 1/m (R = 1.82 m) and ω = 0.5 × 0.55 = 0.275 rad/s; the wheels run at VR = 0.5 + 0.275 × 0.2 = 0.555 m/s and VL = 0.445 m/s.
A car (e = 2.5 m) with a target at ( 5 , 0.6 ): κ = 1.2 / 25.36 = 0.0473 1/m, so δ = arctan( 2.5 × 0.0473 ) = 6.7°.
Pure pursuit: take the point of the path at the look-ahead distance L_d (red), and steer along the circle that leaves the robot tangent to its heading and goes through that point (orange).
12.3 Choosing the look-ahead distance
Ld is the only real parameter, and it is a compromise:
too small: the robot reacts hard to every small error; with the delay of the motors and of the computer it oscillates around the path, and can even become unstable;
too large: the robot cuts the corners of the path and is slow to come back after a disturbance.
The right Ld grows with the speed: the faster the robot, the farther it must look. A usual rule is Ld = L0 + kv, with k between 0.5 and 2 seconds. Try it below: with no motor lag any small Ld works, but add a lag of 0.4 s and a high speed, and a small Ld makes the robot unstable.
12.4 Stanley: the controller of the front axle
For a car, the Stanford team (DARPA Grand Challenge, 2005) used a controller that measures the errors at the front axle and steers by the sum of two terms: the heading error, and a correction of the cross-track error that gets weaker when the speed grows:
δ = eθ + arctan( key / v ) (then limit δ to the steering range of the car)
Worked example
eθ = 0.1 rad, ey = 0.5 m, k = 1, v = 2 m/s: δ = 0.1 + arctan( 1 × 0.5 / 2 ) = 0.1 + 0.245 = 0.345 rad = 19.8°. At v = 8 m/s the same errors give 0.1 + arctan(0.0625) = 0.162 rad = 9.3°: the controller steers less when it goes fast, so it does not oscillate.
The Stanley controller looks at the front axle: e_θ is the angle between the car and the path, e_y the distance to the path. The wheel is turned by the heading error plus a correction of the distance that weakens with speed.
12.5 Tracking a trajectory (position and time)
If the path comes with a schedule (a trajectory: a reference pose ( xr , yr , θr ) and the speeds vr, ωr at every time), the robot must also be at the right place at the right time. Write the error in the robot frame: ( ex , ey , eθ ) = R(θ) ( pr − p ). The classical law of Kanayama (1990) for the unicycle is:
v = vr cos eθ + kxexω = ωr + vr ( kyey + kθ sin eθ ) kx, ky, kθ > 0
Each term has a clear role: the first parts are the feed-forward (the speeds the reference would need: vr, ωr) and the others are the feedback that corrects the errors. A good tracker always has both: feed-forward alone drifts, feedback alone is late.
Worked example
vr = 0.5 m/s, ωr = 0.2 rad/s. Error: ex = 0.10 m (the robot is behind), ey = 0.05 m, eθ = 0.1 rad. Gains kx = 1, ky = 5, kθ = 2. Then v = 0.5 cos 0.1 + 1 × 0.10 = 0.598 m/s (faster than the reference to catch up) and ω = 0.2 + 0.5 ( 5 × 0.05 + 2 sin 0.1 ) = 0.2 + 0.5 × 0.450 = 0.425 rad/s.
12.6 Practical limits every controller needs
Slow down in curves. The lateral acceleration is v² κ. If you allow at most alat, then v ≤ √( alat / | κ | ). With alat = 1 m/s² and a turn of radius 2 m (κ = 0.5): v ≤ 1.41 m/s.
Respect the wheel limit. In a turn the outer wheel goes faster: VR = v ( 1 + κL / 2 ). If a wheel can do 1.2 m/s, κ = 1 and L = 0.5 m, then v ≤ 1.2 / 1.25 = 0.96 m/s.
Compensate the delay. If the command arrives 0.2 s late, at 1 m/s the robot has moved 0.2 m. Estimate the pose forward in time by the delay before computing the errors, or increase Ld.
Measure. Report the RMS and the maximum of the cross-track error, never only “it looks good” (lesson 18).
The essentials
Pure pursuit steers on the circle through a look-ahead point: κ = 2 y_g / L_d².
A longer look-ahead is smoother but cuts corners; a shorter one is precise but oscillates; grow it with speed and delay.
Stanley corrects the heading and the cross-track error at the front axle; trajectory tracking also follows the time.
Key terms
path / trajectory tracking
cross-track error
look-ahead distance
pure pursuit
Stanley controller
feed-forward / feedback
curvature κ
Exercises
Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.
Level 1 · Beginner1
The look-ahead target is at (2, 0) in the robot frame. What is the curvature κ = 2 y_g / L_d²?
Solution
y_g = 0, so κ = 0: the target is straight ahead and the robot goes straight.
Level 1 · Beginner2
The target is at (1.0, 0.3) m in the robot frame. What is the curvature κ of the pure pursuit circle, in 1/m?
Hint
L_d² = x_g² + y_g² = 1 + 0.09.
Solution
κ = 2 × 0.3 / 1.09 = 0.55 1/m, a circle of radius 1.82 m.
Level 2 · Intermediate3
With that curvature and a speed v = 0.5 m/s, what angular speed ω does a differential robot command?
Solution
ω = v κ = 0.5 × 0.55 = 0.275 rad/s.
Level 2 · Intermediate4
A car (e = 2.5 m) has its target at (5, 0.6) m. What steering angle δ = arctan(e κ) does pure pursuit command, in degrees?
Stanley: e_θ = 0.1 rad, e_y = 0.5 m, k = 1, v = 2 m/s. What steering angle δ, in degrees?
Hint
δ = e_θ + arctan(k e_y / v), in radians, then convert.
Solution
δ = 0.1 + arctan(0.25) = 0.1 + 0.245 = 0.345 rad = 19.8°. At v = 8 m/s the same errors give 9.3°: Stanley steers less when it goes faster.
Level 3 · Professional6
A robot may have a lateral acceleration of at most 1 m/s². It must drive a turn of radius 2 m. What is the maximum speed, in m/s?
Hint
a_lat = v² κ.
Solution
κ = 1/2 = 0.5, so v ≤ √(a_lat / κ) = √(1 / 0.5) = 1.41 m/s.
Level 3 · Professional7
The wheels of a differential robot (L = 0.5 m) can go at most 1.2 m/s. It must follow a curve of curvature κ = 1 1/m. What is the maximum speed v of the robot centre?
Solution
The outer wheel goes at v (1 + κ L / 2) = v × 1.25 ≤ 1.2, so v ≤ 0.96 m/s.
Level 3 · Professional8
At 1 m/s a robot has a command delay of 0.2 s. What distance does it travel “blindly” during this delay, and what should you do about it?
0.2 m; nothing, it is negligible.
0.2 m; predict the pose forward by the delay and/or increase the look-ahead distance.
2 m; stop the robot.
Solution
distance = v × delay = 1 × 0.2 = 0.2 m. This is as big as the error you want to correct, so you must compensate it (pose prediction) or look farther ahead.
Check yourself
What happens if the look-ahead distance is too small, and if it is too large?
Too small: oscillations and possible instability (with delays). Too large: the robot cuts the corners and recovers slowly.
A target is at (2, 0) in the robot frame. What is the curvature?
κ = 2 y_g / L_d² = 0: the robot goes straight.
Why does Stanley steer less for the same error at high speed?
Because the correction term is arctan(k e_y / v): it decreases when v grows, which avoids oscillations.
13
Planning paths for nonholonomic robots: Dubins, parking and speed profiles
18 min
You will learn
to find the shortest feasible path of a car-like robot between two poses, to see why curvature and smoothness matter, and to compute the speed profile along a path.
13.1 A straight line is not always a path
A holonomic robot can follow any curve: the shortest path between two poses is a line, then a rotation. A nonholonomic robot cannot. A car has a minimum turning radius Rmin = e / tan δmax (lesson 6), so the curvature of every feasible path satisfies:
| κ | ≤ 1 / Rmin
The curvature of a plane curve ( x(s) , y(s) ) is κ = ( x′ y″ − y′ x″ ) / ( x′² + y′² )3/2. A planner for such robots must output paths whose curvature never exceeds this limit: a path that a robot cannot drive is useless. (A differential robot can turn on the spot, so for it Rmin = 0, but sharp corners still force it to stop and turn.)
13.2 Dubins paths
In 1957 Dubins proved a beautiful result: for a robot that only goes forward with a minimum turning radius R, the shortest path between two poses is always made of at most three pieces, each one a left arc (L), a right arc (R) or a straight line (S). Only six words are possible: LSL, RSR, LSR, RSL, RLR and LRL. The four with a straight line (“CSC” paths) are given by simple formulas. Place the start at the origin pointing along x, and put the goal at distance d = (distance between the poses) / R in the direction θ. With α = −θ and β = θgoal − θ (all angles mod 2π), the lengths, in units of R, of the first arc t, the line p and the last arc q are, for example:
LSL:p² = 2 + d² − 2 cos(α−β) + 2d ( sin α − sin β ) tmp = atan2( cos β − cos α , d + sin α − sin β ) t = −α + tmpq = β − tmp
The other three words have similar formulas (the widget below computes all four and picks the shortest). The total length is R ( t + p + q ). We checked these formulas numerically: following the three pieces ends exactly on the goal pose.
Worked example
Start (0, 0, 0°), goal ( 3 , 2 , 90° ), R = 1 m. The four straight-line words give lengths: LSL 3.81 m, LSR 9.82 m, RSL 10.06 m, RSR 16.00 m. The shortest is LSL: turn left, drive straight, then turn left again. The straight line distance is only 3.6 m, but the robot needs 3.81 m because it must also arrive with the right heading. If the goal is straight ahead at ( 4 , 0 , 0° ) the path degenerates to a line of 4 m.
13.3 Reversing: Reeds–Shepp and parking
A real car can also reverse. Reeds and Shepp (1990) solved the same problem when going backwards is allowed: the shortest path then has up to five pieces (arcs, lines, and cusps where the car stops and changes direction), in 46 possible words. You do not code this by hand: planners such as the Smac Hybrid-A* planner of Nav2 or OMPL provide Dubins and Reeds–Shepp paths as building blocks. What you must know is what the result means: parallel parking is a short Reeds–Shepp path, with two arcs in reverse, and its feasibility depends on the minimum turning radius and on the length of the free space.
13.4 Smooth paths and differential flatness
A Dubins path jumps from curvature 0 (a line) to 1/R (an arc) at once: a real car would have to turn its steering wheel instantly. To avoid this, planners use curves whose curvature changes smoothly: clothoids (curvature growing linearly with the distance, κ(s) = κ0 + cs), splines or Bézier curves.
A deep and very practical fact: the unicycle (and the differential robot) is differentially flat. Its pose and its commands can be computed from the path x(t), y(t) and its derivatives, without integrating anything:
Example: a circle of radius 2 m driven at 0.5 m/s has κ = 0.5 1/m, so the feed-forward command is ω = κv = 0.25 rad/s, constant.
13.5 The speed profile along the path
The path says where; the speed profile says when. The simplest profile accelerates at a up to vmax, cruises, then brakes at a (a trapezoid in the speed–time graph). For a distance s:
if s ≥ vmax² / a (the robot has the time to reach vmax): total time T = s / vmax + vmax / a;
otherwise the profile is a triangle: peak speed vpeak = √( as ), total time T = 2 √( s / a ).
Worked example
a = 0.5 m/s², vmax = 1 m/s. For s = 5 m: v²/a = 2 m ≤ 5 m, so T = 5 / 1 + 1 / 0.5 = 7 s. For s = 0.8 m: 0.8 < 2 m, triangle: vpeak = √( 0.5 × 0.8 ) = 0.63 m/s and T = 2 √( 0.8 / 0.5 ) = 2.53 s.
Along a curved path, take the minimum of all the limits at each point: v ≤ vmax, v ≤ √( alat / | κ | ), v ≤ Vwheel,max / ( 1 + | κ | L / 2 ), and the braking limit before an obstacle or a stop (lesson 18). Then smooth the accelerations. Professional profiles also limit the jerk (the change of acceleration, the “S-curve”), which protects the load and the gearboxes.
The essentials
A car-like robot needs paths whose curvature never exceeds 1 / R_min.
Dubins: the shortest forward path is one of six words of arcs and lines (LSL, RSR, LSR, RSL, LRL, RLR); Reeds–Shepp adds reversing.
The speed profile limits the speed in the curves (a_lat = v² κ) and smooths the accelerations (jerk).
Key terms
minimum turning radius
curvature
Dubins path (LSL, RSR…)
Reeds–Shepp path
clothoid
differential flatness
speed profile / jerk
Exercises
Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.
Level 1 · Beginner1
A car has a minimum turning radius of 4.27 m. What is the largest curvature of a path it can follow, in 1/m?
Solution
κ_max = 1 / R_min = 1 / 4.27 = 0.234 1/m.
Level 1 · Beginner2
What does a Dubins path assume about the robot?
It only goes forward and has a minimum turning radius.
It can reverse and spin on the spot.
It is omnidirectional.
Solution
Dubins (1957): forward-only, bounded curvature. With reversing allowed, the shortest paths are the Reeds–Shepp paths.
Level 2 · Intermediate3
A robot has a = 0.5 m/s² and v_max = 1 m/s. It must move 5 m, starting and ending at rest. What is the total time?
Hint
Does it have the time to reach v_max? (v_max² / a = 2 m)
Solution
v²/a = 2 m ≤ 5 m: trapezoid. T = s / v_max + v_max / a = 5 + 2 = 7 s.
Level 2 · Intermediate4
Same robot, but now the distance is only 0.8 m. What is the total time?
Solution
0.8 m < 2 m: the robot never reaches v_max (triangle profile). T = 2 √(s / a) = 2 √(0.8 / 0.5) = 2.53 s and the peak speed is √(a s) = 0.63 m/s.
Level 2 · Intermediate5
A differentially flat robot drives a circle of radius 2 m at 0.5 m/s. What constant angular speed ω is needed, in rad/s?
Solution
κ = 1/2 = 0.5 1/m and ω = κ v = 0.5 × 0.5 = 0.25 rad/s.
Level 3 · Professional6
Start (0, 0, 0°), goal (3, 2, 90°), R = 1 m. The shortest Dubins path is LSL. What is its length, in metres? (Use the widget above to find it, then understand why it is longer than the straight distance 3.6 m.)
Hint
Set the goal sliders to x = 3, y = 2, θ = 90°, R = 1.
Solution
Left arc, line, left arc: 3.81 m. The extra 0.2 m comes from the heading: the robot cannot turn on the spot, it must curve to arrive pointing up.
Level 3 · Professional7
What is the difference between a Dubins and a Reeds–Shepp path?
Reeds–Shepp paths allow reversing (with cusps), so they can be shorter.
Dubins paths are for flying robots only.
There is no difference.
Solution
Both assume a minimum turning radius, but Reeds–Shepp allows the car to go backwards, which is what a parallel-parking manoeuvre needs.
Check yourself
Why can a car not follow a path with a sharp corner?
A sharp corner needs an infinite curvature, but the curvature is limited by 1/R_min.
What does the Dubins theorem say?
For a robot that goes only forward with a minimum turning radius, the shortest path between two poses is made of at most three pieces: arcs (L, R) and a straight line (S).
What does it mean that a unicycle is differentially flat?
Its heading, speeds and commands can be computed directly from the path and its derivatives, without integration.
14
Odometry in practice: encoders, errors and calibration
22 min
You will learn
to turn encoder counts into distances, to understand the sources of odometry error, to calibrate the wheel radii and the track width with simple tests, and to know what a gyroscope adds.
14.1 From encoder counts to metres
A wheel encoder gives counts. A quadrature encoder with N lines per turn (“CPR”) gives 4 N counts per turn of the motor shaft, because the two channels A and B give four edges per line (and the order of the edges gives the direction). If the gearbox has the ratio G (motor turns per wheel turn), then:
counts per wheel turn = 4 NG distance per count = 2π r / ( 4 NG ) Δs = ( countsnow − countsbefore ) × distance per count
Worked example
N = 500 lines, G = 30, r = 0.05 m. Counts per wheel turn: 4 × 500 × 30 = 60 000. Distance per count: 2π × 0.05 / 60 000 = 5.2 µm. At 1 m/s the robot makes 191 000 counts per second: too fast to read with a normal software interrupt, so use the hardware encoder counter of the microcontroller. At 100 Hz sampling one step is about 1 910 counts, so the speed resolution (one count per step) is 0.0005 m/s: excellent.
Compare a cheap encoder of 20 counts per wheel turn: 15.7 mm per count and, at 100 Hz, a speed resolution of 1.57 m/s, which is useless. Then you must measure the time between counts, or use a longer window.
14.2 The odometry update, and its code
Each cycle, read the two distances ΔsR and ΔsL and update the pose with the midpoint rule of lesson 5: Δs = ( ΔsR + ΔsL ) / 2, Δθ = ( ΔsR − ΔsL ) / L, x += Δs cos( θ + Δθ/2 ), y += Δs sin( θ + Δθ/2 ), θ += Δθ. Here is a complete program, with a simulator of a robot whose real wheels are not the nominal ones. Run it (python3 odometry.py):
import math, random
class Odometry:
"""Differential-drive dead reckoning from the distance rolled by each wheel."""
def __init__(self, track, x=0.0, y=0.0, th=0.0):
self.L, self.x, self.y, self.th = track, x, y, th
def update(self, ds_right, ds_left):
ds = 0.5 * (ds_right + ds_left) # distance of the robot centre
dth = (ds_right - ds_left) / self.L # change of heading
self.x += ds * math.cos(self.th + 0.5 * dth) # midpoint rule
self.y += ds * math.sin(self.th + 0.5 * dth)
self.th += dth
return self.x, self.y, self.th
def drive_square(side, v, w, true_r_scale=(1.0, 1.0), true_track_scale=1.0, noise=0.0, dt=0.01, ccw=True, seed=1):
"""Open-loop square. The commands are computed with the NOMINAL robot (r = 0.05, L = 0.30),
the robot really moves with the TRUE parameters. Returns the real final pose."""
random.seed(seed)
r, L = 0.05, 0.30
rr, rl = r * true_r_scale[0], r * true_r_scale[1]; Lt = L * true_track_scale
x = y = th = 0.0
sgn = 1 if ccw else -1
def run(vv, ww, T):
nonlocal x, y, th
n = int(round(T / dt))
for _ in range(n):
wr = (vv + ww * L / 2) / r; wl = (vv - ww * L / 2) / r # commanded wheel speeds (rad/s)
dsr = rr * wr * dt * (1 + random.gauss(0, noise)); dsl = rl * wl * dt * (1 + random.gauss(0, noise))
ds = 0.5 * (dsr + dsl); dth = (dsr - dsl) / Lt
x += ds * math.cos(th + 0.5 * dth); y += ds * math.sin(th + 0.5 * dth); th += dth
for _ in range(4):
run(v, 0.0, side / v)
run(0.0, sgn * w, (math.pi / 2) / w)
return x, y, th
if __name__ == "__main__":
# 1. perfect robot: the 2 m square closes
x, y, th = drive_square(2.0, 0.4, 1.0)
print("perfect robot : end (%.3f, %.3f) m, heading %.2f deg" % (x, y, math.degrees(th)))
# 2. left wheel 1 % bigger than expected
x, y, th = drive_square(2.0, 0.4, 1.0, true_r_scale=(1.0, 1.01))
print("left wheel +1 %% : end (%.3f, %.3f) m -> error %.3f m" % (x, y, math.hypot(x, y)))
# 3. track 3 % wider than expected, ccw and cw
for ccw in (True, False):
x, y, th = drive_square(2.0, 0.4, 1.0, true_track_scale=1.03, ccw=ccw)
print("track +3 %% %s: end (%.3f, %.3f) m -> error %.3f m" % ("CCW" if ccw else "CW ", x, y, math.hypot(x, y)))
# 4. random slip 1 %: 20 runs
errs = []
for s in range(20):
x, y, th = drive_square(2.0, 0.4, 1.0, noise=0.01, seed=s)
errs.append(math.hypot(x, y))
m = sum(errs) / len(errs); sd = (sum((e - m) ** 2 for e in errs) / (len(errs) - 1)) ** 0.5
print("random slip 1 %% : mean error %.3f m, std %.3f m (20 runs)" % (m, sd))
The program drives a 2 m square open-loop (the commands come from the nominal model). Its output:
perfect robot : end (-0.003, 0.003) m, heading 359.82 deg
left wheel +1 % : end (-0.214, 0.275) m -> error 0.348 m
track +3 % CCW: end (-0.177, 0.203) m -> error 0.269 m
track +3 % CW : end (-0.177, -0.203) m -> error 0.269 m
random slip 1 % : mean error 0.015 m, std 0.012 m (20 runs)
Read this carefully, it is the whole lesson in five lines: a robot with a left wheel only 1 % too big ends 35 cm away from where it started after a 8 m trip; a track that is 3 % wrong gives 27 cm; and a random slip of 1 % per step gives only 1.5 cm. Systematic errors are far worse than random ones, and they can be removed.
detect with other sensors (gyroscope, lidar) and filter (lesson 15)
The two systematic errors have a different signature. Drive the square clockwise and counter-clockwise. In the program above, a track error moves the end point to the same side in both directions (x = −0.177 m in both), whereas a wheel-radius error moves it to opposite sides (x = −0.214 m counter-clockwise, +0.323 m clockwise). This is the idea of the UMBmark test of Borenstein and Feng (1996): drive a square in both directions, measure where you end, and the two clusters of end points tell the two errors apart.
14.4 Three simple calibration tests
Distance (wheel radius). Drive straight for a long, measured distance Dtrue (a tape on the floor, 5 to 10 m). Read the odometry distance Dodo. Then rnew = r × Dtrue / Dodo. Do it for the left and for the right wheel (or check that the robot ends on the line: if it curves, one wheel is relatively bigger).
Rotation (track width). Spin on the spot for 10 full turns (measure the real angle with a mark on the floor, or with a good gyroscope). If odometry says θodo and the truth is θtrue, then Lnew = L × θodo / θtrue. (Derivation: Δθ = (ΔsR − ΔsL) / L, so the angle is inversely proportional to L.) For skid-steer robots this gives the effective track χL of lesson 8.
Check with the square. Drive the square both ways with the new values and measure the end points. The clusters must be near the start and not on one side.
Worked example
Straight test: the tape says 8.00 m, the odometry says 8.12 m. Then rnew = 0.05 × 8.00 / 8.12 = 0.04926 m (−1.5 %). Spin test: 10 turns = 3 600°; the odometry says 3 600° but a gyroscope measured 3 540°. Then the odometry over-estimates the angle by 1.7 %, so Lnew = 0.30 × 3 600 / 3 540 = 0.3051 m.
14.5 What a gyroscope adds (and its trap)
A gyroscope measures the turning rate ω directly, without wheel slip. Integrated, it gives a heading that is much better than the one from the wheels, especially for skid-steer and Mecanum robots. The usual fusion is simple: heading from the gyroscope, distance from the wheels. The trap is the bias: a gyroscope that reads 0.5°/s when it is still gives, after one minute, an error of 30°. So: (1) estimate the bias by averaging the output while the robot is stopped (a few seconds at start-up); (2) re-estimate it every time the robot stops; (3) with a bias of only 0.01°/s the same minute gives 0.6°; (4) correct the remaining drift with an absolute sensor (lesson 15).
The rule of the professionals
Odometry is never “right”, it is only less wrong than nothing for a short time. Calibrate it, give it a gyroscope, and then correct it with something that does not drift. Lesson 15 shows how to combine them correctly.
The essentials
Distance per count = 2π r / (counts per turn × gear ratio); quadrature gives the direction and 4× the counts.
Systematic errors (radii, track) can be calibrated; non-systematic ones (slip, bumps) only filtered.
Calibrate with a straight line and square tests (UMBmark); a gyroscope fixes the heading but has a bias.
Key terms
encoder / quadrature
counts per turn
systematic / non-systematic error
calibration
UMBmark
gyroscope bias
Exercises
Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.
Level 1 · Beginner1
A quadrature encoder has 100 lines per turn and is on the motor shaft; the gearbox ratio is 10. How many counts per wheel turn?
Hint
4 N G.
Solution
4 × 100 × 10 = 4 000 counts per wheel turn.
Level 1 · Beginner2
With the same encoder and a wheel of radius 0.05 m, what distance does one count represent, in micrometres (µm)?
Solution
2π × 0.05 / 4 000 = 7.854 × 10⁻⁵ m = 78.5 µm.
Level 2 · Intermediate3
Straight test: the tape measures 10.00 m and the odometry says 10.15 m. The radius used is 0.05 m. What is the calibrated radius, in millimetres?
Hint
r_new = r × D_true / D_odo.
Solution
r_new = 50 × 10.00 / 10.15 = 49.26 mm. The odometry over-estimated the distance by 1.5 %, so the radius was too big by 1.5 %.
Level 2 · Intermediate4
Spin test, 10 turns: the odometry gives 3 600° but a gyroscope measured 3 480°. The track used is 0.400 m. What is the calibrated track, in metres?
Hint
L_new = L × θ_odo / θ_true.
Solution
L_new = 0.400 × 3 600 / 3 480 = 0.4138 m. The robot really turns less than the odometry thinks, so its real track is larger than the nominal one.
Level 2 · Intermediate5
In the square test, the end points of the clockwise and of the counter-clockwise runs are on the same side of the start. What is the main error?
A wheel-radius error (unequal wheels).
A track-width error.
Random slip.
Solution
A track error gives the same sign of the end-point offset in both directions; a wheel-radius error gives opposite signs. Random slip gives no offset of the centre.
Level 3 · Professional6
A gyroscope has an uncorrected bias of 0.3°/s. What heading error does it accumulate in 2 minutes, in degrees?
Solution
0.3 °/s × 120 s = 36°. That is why the bias must be estimated at rest, re-estimated at every stop, and why an absolute sensor is needed (lesson 15).
Level 3 · Professional7
A 16-bit unsigned counter read 65 500 at the previous cycle and reads 120 now (it wrapped around). How many counts happened between the cycles?
Hint
Compute (now − before) modulo 65 536.
Solution
(120 − 65 500) mod 65 536 = 156. Using the difference of unsigned counters modulo 2¹⁶ gives the right answer even when the counter wraps; a plain subtraction would give a huge negative jump in the odometry.
Check yourself
What is the distance per count of a 500-line quadrature encoder, ratio 30, wheel radius 0.05 m?
2π × 0.05 / (4 × 500 × 30) = 5.2 µm.
Which error is more dangerous for odometry: a 1 % systematic wheel-radius error, or a random slip of 1 % per step?
The systematic one: it always has the same sign and adds up (35 cm over the 8 m square), while random errors partly cancel (1.5 cm).
How do you tell a wheel-radius error from a track error with the square test?
Drive it both ways: a track error moves the end point to the same side in both directions, a wheel-radius error to opposite sides.
15
Knowing where you are: the Kalman filter and the EKF
24 min
You will learn
to combine a drifting odometry with an absolute measurement using an extended Kalman filter (EKF), to read a covariance matrix, and to write and test the filter.
15.1 The idea in one dimension
Two sources give an estimate of your position, each with its uncertainty (variance): the prediction from odometry, with the variance P, and a measurement (a GPS, a lidar match) with the variance R. The best combination is the average weighted by the confidence:
K = P / ( P + R ) x ← xpred + K ( z − xpred ) P ← ( 1 − K ) P
K is the Kalman gain, between 0 (trust the prediction) and 1 (trust the measurement). Example: P = 0.04 m² (σ = 20 cm) and R = 0.01 m² (σ = 10 cm): K = 0.04 / 0.05 = 0.8, the new variance is 0.2 × 0.04 = 0.008 m² (σ = 8.9 cm): the result is better than both sources.
15.2 The EKF for the pose of a robot
For the pose, the state is the vector μ = ( x , y , θ ) and the covariance matrixΣ (3 × 3) describes the uncertainty: the diagonal holds the variances, the other terms the correlations (they tell, for example, that a heading error produces a position error). Because the motion is nonlinear (cos θ, sin θ), we linearise it with its Jacobian G: this is the “extended” Kalman filter. Two steps repeat:
Prediction (every odometry step): μ ← ( x + v Δt cos θ , y + v Δt sin θ , θ + ω Δt ) Σ ← GΣGT + Q
G = 10−v Δt sin θ01v Δt cos θ001
Update (when a measurement z arrives, z = Hμ + noise of covariance R): K = ΣHT ( HΣHT + R )−1μ ← μ + K ( z − Hμ ) Σ ← ( I − KH ) Σ
For a sensor that measures the position (GPS, total station, a landmark with known place) H = ( 1 0 0 ; 0 1 0 ). For a compass or a gyroscope-corrected heading H = ( 0 0 1 ). The difference z − Hμ is the innovation: how much the measurement surprises the filter. If its size is large compared with its expected covariance (HΣHT + R), the measurement is probably an outlier and must be rejected: this is the Mahalanobis gated² = νTS−1ν < 9.21 (99 % for 2 degrees of freedom).
15.3 The code, and what it prints
import numpy as np
def predict(mu, S, v, w, dt, q):
x, y, th = mu
mu_new = np.array([x + v * dt * np.cos(th), y + v * dt * np.sin(th), th + w * dt])
G = np.array([[1, 0, -v * dt * np.sin(th)],
[0, 1, v * dt * np.cos(th)],
[0, 0, 1]])
return mu_new, G @ S @ G.T + np.diag(q)
def update(mu, S, z, H, R):
innov = z - H @ mu
Sinn = H @ S @ H.T + R
K = S @ H.T @ np.linalg.inv(Sinn)
mu_new = mu + K @ innov
S_new = (np.eye(3) - K @ H) @ S
return mu_new, S_new, innov, Sinn
if __name__ == "__main__":
# one step by hand
mu = np.array([0.0, 0.0, 0.0]); S = np.diag([0.01, 0.01, 0.005])
mu, S = predict(mu, S, v=1.0, w=0.2, dt=0.5, q=[0.002, 0.002, 0.001])
print("after prediction : mu =", np.round(mu, 3), " sigma_x =", round(float(np.sqrt(S[0, 0])), 4), " sigma_y =", round(float(np.sqrt(S[1, 1])), 4), " sigma_th =", round(float(np.sqrt(S[2, 2])), 4))
H = np.array([[1, 0, 0], [0, 1, 0]]); R = np.diag([0.0025, 0.0025]) # GPS-like, sigma = 5 cm
z = np.array([0.52, 0.03])
mu2, S2, innov, Sinn = update(mu, S, z, H, R)
print("innovation :", np.round(innov, 3))
print("after update : mu =", np.round(mu2, 3), " sigma_x =", round(float(np.sqrt(S2[0, 0])), 4), " sigma_th =", round(float(np.sqrt(S2[2, 2])), 4))
d2 = float(innov @ np.linalg.inv(Sinn) @ innov); print("Mahalanobis d^2 :", round(d2, 2), "(gate 9.21 for 99 %, 2 dof)")
# simulation: robot on a circle, noisy odometry, position fix every second
rng = np.random.default_rng(3)
dt, T = 0.1, 60.0
truth = np.array([0.0, 0.0, 0.0]); est = truth.copy(); dr = truth.copy(); P = np.diag([1e-4, 1e-4, 1e-4])
v, w = 0.5, 0.25
e_dr, e_ekf = [], []
for k in range(int(T / dt)):
# true motion
truth = np.array([truth[0] + v * dt * np.cos(truth[2]), truth[1] + v * dt * np.sin(truth[2]), truth[2] + w * dt])
# noisy measured speeds (this is what odometry sees): 3 % speed error + 0.02 rad/s gyro-like bias on w
vm = v * 1.03 + rng.normal(0, 0.02); wm = w + 0.02 + rng.normal(0, 0.01)
dr = np.array([dr[0] + vm * dt * np.cos(dr[2]), dr[1] + vm * dt * np.sin(dr[2]), dr[2] + wm * dt])
est, P = predict(est, P, vm, wm, dt, [1e-5, 1e-5, 1e-5])
if (k + 1) % 10 == 0: # a position fix every second
z = truth[:2] + rng.normal(0, 0.05, 2)
est, P, _, _ = update(est, P, z, H, R)
e_dr.append(np.hypot(*(dr[:2] - truth[:2]))); e_ekf.append(np.hypot(*(est[:2] - truth[:2])))
print("after %.0f s : odometry-only error %.2f m, EKF error %.3f m (RMS over the run: %.2f m vs %.3f m)" % (T, e_dr[-1], e_ekf[-1], np.sqrt(np.mean(np.square(e_dr))), np.sqrt(np.mean(np.square(e_ekf)))))
after prediction : mu = [0.5 0. 0.1] sigma_x = 0.1095 sigma_y = 0.1151 sigma_th = 0.0775
innovation : [0.02 0.03]
after update : mu = [0.517 0.025 0.105] sigma_x = 0.0455 sigma_th = 0.0749
Mahalanobis d^2 : 0.08 (gate 9.21 for 99 %, 2 dof)
after 60 s : odometry-only error 2.26 m, EKF error 0.083 m (RMS over the run: 1.33 m vs 0.117 m)
Read the output: (1) after the prediction the position uncertainty grows from 10 cm to 11 cm and the heading uncertainty from 0.071 rad to 0.078 rad: odometry makes the filter less sure. (2) A GPS-like fix (σ = 5 cm) gives an innovation of (0.02, 0.03) m, a gate value d² = 0.08 (far from 9.21): accepted. (3) After the update the position uncertainty falls to 4.6 cm: better than the prediction (11 cm) and than the GPS (5 cm). (4) Over a 60 s circle with a 3 % speed error and a gyroscope bias, odometry alone is wrong by 2.3 m at the end, while the EKF with a fix every second stays within 8 cm.
15.4 Tuning and checking a filter like a professional
Q (process noise) describes how wrong the odometry can be between two steps. Too small: the filter trusts odometry too much and reacts slowly to measurements. Too large: it trusts every noisy measurement. Start from the odometry errors measured in lesson 14.
R (measurement noise) comes from the data sheet of the sensor and from measurements at rest (the variance of the readings).
Consistency check: the normalised innovation squared d² must average the number of measurement dimensions (2 for a position fix). If it is always much larger, the filter is over-confident (raise Q or R); much smaller, it is too cautious.
Always normalise angles to (−π, π] after every update, and use angle differences, never plain subtraction.
Timestamps: a measurement is about the past. Use the pose of the filter at the time of the measurement, not the latest one, or you inject an error of v × delay.
In ROS 2 you rarely write the EKF yourself: the robot_localization package (ekf_node) and Nav2's AMCL (a particle filter on a map) do it. You still have to choose Q, R and the frames, so you must understand what they mean.
The essentials
A Kalman filter mixes a prediction and a measurement according to their uncertainties: K = P / (P + R) in 1D.
The EKF predicts with the motion model and its Jacobian G (P ← G P Gᵀ + Q), then corrects with each measurement.
Check a filter with the innovation and a Mahalanobis gate; tune Q and R from real measurements.
Key terms
Kalman gain
covariance matrix
EKF
Jacobian G
innovation
Mahalanobis gate
process / measurement noise
Exercises
Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.
Level 1 · Beginner1
In 1-D, the prediction has the variance P = 0.09 m² and the measurement R = 0.03 m². What is the Kalman gain K?
Solution
K = P / (P + R) = 0.09 / 0.12 = 0.75.
Level 1 · Beginner2
What is the variance after the update (in m²)?
Solution
P_new = (1 − K) P = 0.25 × 0.09 = 0.0225 m² (σ = 15 cm, better than both the prediction, 30 cm, and the measurement, 17 cm).
Level 2 · Intermediate3
The predicted position is 2.00 m, the measurement 2.40 m, and K = 0.75. What is the updated estimate, in metres?
Solution
x = 2.00 + 0.75 × (2.40 − 2.00) = 2.3 m: the estimate moves 75 % of the way to the measurement.
Level 2 · Intermediate4
The process noise Q is set too small. What happens?
The filter trusts odometry too much and reacts slowly to the measurements.
The filter trusts every noisy measurement.
Nothing: Q does not matter.
Solution
A small Q says that the odometry is very reliable, so the covariance stays small, the gain K small, and the corrections too weak: the estimate follows the drifting odometry.
Level 2 · Intermediate5
The innovation is 0.3 m and its expected variance is S = 0.04 m² (1-D). What is d² = ν² / S?
Solution
d² = 0.09 / 0.04 = 2.25. For one dimension the 99 % gate is 6.63, so the measurement is accepted.
Level 3 · Professional6
In the Jacobian G of the EKF, the term ∂x'/∂θ equals −v Δt sin θ. With v = 0.5 m/s, Δt = 0.1 s and θ = 90°, what is its value?
Solution
−0.5 × 0.1 × sin 90° = -0.05. It means that a heading error of 1 rad changes the predicted x by 0.05 m in this step: the heading error leaks into the position, which is why the covariance of x and θ become correlated.
Level 3 · Professional7
A lidar measurement takes 0.2 s to be processed. What is the correct way to use it in the filter?
Apply it as if it were taken now.
Compare it with the pose estimate at the time it was taken (its timestamp), not with the latest pose.
Ignore it.
Solution
Otherwise the innovation contains an error of about v × 0.2 s (0.2 m at 1 m/s) and the filter is pulled the wrong way. Use the stamped data and tf at that time.
Check yourself
In 1-D with P = 0.09 and R = 0.01, what is the Kalman gain K?
K = P / (P + R) = 0.09 / 0.10 = 0.9: the measurement is trusted much more than the prediction.
Why does the position uncertainty grow during the prediction step?
Because odometry adds errors at every step (the term Q) and a heading error spreads into position (the Jacobian G).
What should you do with a measurement whose Mahalanobis distance is d² = 30?
Reject it: it is far above the 99 % gate (9.21 for two dimensions), so it is probably an outlier.
16
Dynamics and sizing: forces, motors, traction, tipping and battery
26 min
You will learn
to compute the force, torque, speed and power that a mobile robot needs, to choose the motor and the gear ratio, to check traction and tipping, and to size the battery.
Up to now we ignored forces. A professional cannot: a robot with a perfect kinematic model that cannot climb its ramp, or whose battery lasts 40 minutes instead of 6 hours, is a failed robot. This lesson is the method, step by step.
16.1 The force the wheels must produce
Newton: the force at the ground is the sum of three terms (air drag is negligible below a few m/s):
F = ma + crrmg cos α + mg sin α
ma: accelerate the whole mass (robot + payload);
crrmg: rolling resistance, with the coefficient crr that depends on the wheel and the floor (very roughly 0.01 for hard wheels on a smooth floor, 0.02 to 0.05 for soft wheels, carpet or poor floors: measure it, lab 5);
mg sin α: climb a slope of angle α (a 5 % slope has tan α = 0.05, α = 2.86°).
16.2 From force to motor torque and speed
With n driven wheels of radius r, a gearbox of ratio G and efficiency ηg (about 0.8 to 0.9 for a planetary gearbox, much less for a worm gear):
m = 60 kg (robot + load), r = 0.10 m, two driven wheels, G = 20, ηg = 0.85, crr = 0.02, slope 5 %, v = 1.2 m/s, a = 0.5 m/s².
Forces: ma = 30 N; rolling = 0.02 × 60 × 9.81 = 11.8 N; slope = 60 × 9.81 × sin 2.86° = 29.4 N. Total F = 71.2 N.
Per wheel: τwheel = 71.2 × 0.10 / 2 = 3.56 N·m. Per motor: 3.56 / (20 × 0.85) = 0.209 N·m. Motor speed: 12 rad/s at the wheel × 20 = 240 rad/s = 2 292 rpm.
16.3 Choosing the motor: peak, continuous and RMS
A motor has two torque ratings: the peak torque (for a few seconds: the acceleration) and the continuous torque (what it can give for ever without overheating). The heating is proportional to the square of the torque, so what must stay under the continuous rating is the RMS torque over the work cycle:
τRMS = √( ( Σ τi² ti ) / Σ ti )
Worked example (same AMR)
Cycle of 40 s: accelerate 2 s (0.209 N·m), cruise 30 s (0.121 N·m), brake 2 s (0.033 N·m), stopped 6 s (0). τRMS = √( ( 2 × 0.209² + 30 × 0.121² + 2 × 0.033² ) / 40 ) = 0.115 N·m. With a margin of 1.5: choose a motor with a continuous torque ≥ 0.17 N·m and a peak torque ≥ 0.31 N·m, at 2 292 rpm or more. Do not forget that the robot must also hold on the slope when it stops: a brake or a torque of 0.12 N·m, which is why a failsafe brake is used.
Other checks of a professional: the supply voltage must allow the speed (back-EMF); the gear ratio trades torque for speed (a higher ratio needs a smaller motor but a higher motor speed, and a gearbox that is harder to back-drive); the current of the peak must be supplied by the drive and the battery; the encoder must be on the motor shaft for resolution (lesson 14).
16.4 Traction and tipping
The wheels can push with at most μ times the load they carry, where μ is the friction coefficient (about 0.6 for rubber on a dry floor, much lower when wet). With all the weight on the driven wheels the maximum acceleration is amax = μg = 5.9 m/s² and the steepest slope is tan α ≤ μ (31° for μ = 0.6). If only a fraction f of the weight is on the driven wheels (for example 80 % for a differential robot with castors), multiply the limit by f. For the AMR: 0.6 × 60 × 9.81 × 0.8 = 282 N available against 71 N needed: the traction is fine.
Tipping. Let h be the height of the centre of gravity, b its distance to the front or rear wheel line (about half the wheelbase) and T the track. The robot tips forward when braking harder than a = gb / h, sideways in a turn when the lateral acceleration v² / R exceeds gT / (2 h), and sideways on a slope steeper than arctan( T / (2 h) ). Example h = 0.4 m, b = 0.3 m, T = 0.5 m: 7.4 m/s², 6.1 m/s² and 32°. The robot should slip before it tips: these limits must be larger than μg = 5.9 m/s². With a tall robot (h = 0.9 m) the braking limit falls to 3.3 m/s²: it would tip before it slips, and you must limit the deceleration in software.
When the robot brakes, its inertia m a pushes the centre of gravity forward. It tips over the front wheel if the resultant of m g and m a passes in front of it, that is when a > g b / h.
16.5 Power, energy and battery
At cruise the robot has no acceleration: the mechanical power is Pm = ( crrmg cos α + mg sin α ) v. The electrical power adds the losses (gearbox, motor, drive: an overall efficiency η of about 0.6 to 0.8) and the consumption of the computer, sensors and brakes. The battery is not fully usable (about 80 % to protect its life):
Pel = Pm / η + Pelectronics runtime = 0.8 × Ebattery / Pel
Worked example (same AMR)
Cruise force on the slope: 11.8 + 29.4 = 41.2 N, so Pm = 41.2 × 1.2 = 49.4 W. With η = 0.7 and 30 W of electronics: Pel = 49.4 / 0.7 + 30 = 100.6 W. A 24 V, 20 Ah battery stores 480 Wh, of which 384 Wh are usable: runtime = 384 / 100.6 = 3.8 h (on a permanent 5 % slope; on the flat the robot would last much longer). The current is 100.6 / 24 = 4.2 A, that is 0.21 C: easy for the battery. For a 6 h mission at this power you need 6 × 100.6 / 0.8 = 755 Wh.
Pitfall: the “wish list” budget
Never size with the nominal case only. List the worst case (heaviest payload, steepest ramp, lowest battery voltage, worst floor, cold battery) and the typical case (for the runtime). Add a margin of 30 to 50 % on the torque, and measure the real power on the real robot (lab 5): a prediction within 25 % is a good result.
16.6 The control loops of a wheel
A real robot nests loops, each about 5 to 10 times faster than the one above: the current (torque) loop of the motor drive (kHz), the wheel speed loop (a PI controller with the encoder, 100 to 1 000 Hz), and above it the body loop of lessons 11 and 12 (20 to 100 Hz), which produces the wheel speed references. Add a feed-forward (the speed command times the motor constant) so that the PI only corrects the small errors, and limit the acceleration (a ramp) so that the wheels never ask for more than the traction allows.
The essentials
Wheel force F = m a + c_rr m g + m g sin(slope); torque at the motor = F r / (gear ratio × efficiency).
Size the motor on the peak torque and on the RMS torque of the cycle (below the continuous torque).
Check traction (F ≤ μ N), tipping (stopping deceleration) and the battery: energy = power × time with a margin.
Key terms
rolling resistance c_rr
gear ratio / efficiency
peak / continuous / RMS torque
traction limit μ
tip-over
runtime / C-rate
feed-forward
Exercises
Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.
Level 1 · Beginner1
A 50 kg robot climbs a 10 % slope at constant speed on a frictionless-rolling floor (c_rr = 0). What force is needed, in newtons?
Hint
F = m g sin α, with tan α = 0.1.
Solution
α = arctan 0.1 = 5.71°, F = 50 × 9.81 × sin 5.71° = 48.8 N.
Level 1 · Beginner2
Two driven wheels of radius 0.08 m share that force. What torque must each wheel give, in N·m?
Solution
τ_wheel = F r / n = 48.8 × 0.08 / 2 = 1.952 N·m.
Level 2 · Intermediate3
The gearbox has the ratio 15 and the efficiency 0.8. What torque must each motor give, in N·m?
Solution
τ_motor = 1.952 / (15 × 0.8) = 0.163 N·m.
Level 2 · Intermediate4
The robot must go at 1.5 m/s (wheel radius 0.08 m, ratio 15). What motor speed is needed, in rpm?
Solution
ω_wheel = 1.5 / 0.08 = 18.75 rad/s; ω_motor = 15 × 18.75 = 281 rad/s = 2686 rpm. The motor and its supply voltage must be able to reach this speed under load.
Level 2 · Intermediate5
A 480 Wh battery (80 % usable) powers a robot that uses 100 W on average. What is the runtime, in hours?
Solution
0.8 × 480 / 100 = 3.84 h.
Level 3 · Professional6
A work cycle of 30 s: 3 s at 0.40 N·m, 20 s at 0.15 N·m and 7 s at rest. What is the RMS torque, in N·m?
Solution
τ_RMS = √( (3 × 0.4² + 20 × 0.15²) / 30 ) = √( 0.93 / 30 ) = 0.176 N·m. This, with a margin, must be below the continuous torque of the motor; the peak 0.40 must be below its peak rating.
Level 3 · Professional7
A tall robot has h = 0.6 m and the half wheelbase b = 0.25 m. At what braking deceleration does it tip forward, in m/s²? (With μ = 0.6 the wheels can brake at 5.9 m/s².)
Solution
a_tip = g b / h = 9.81 × 0.25 / 0.6 = 4.09 m/s², lower than μ g = 5.9 m/s²: the robot would tip before it slips. The software must limit the braking deceleration below about 2.9 m/s² (a margin of 30 %), or the design must lower the centre of gravity.
Check yourself
A 100 kg robot climbs a 10 % slope at constant speed on a perfect floor (no rolling resistance). What force is needed?
F = m g sin α with tan α = 0.1, α = 5.71°: F = 100 × 9.81 × 0.0995 = 97.6 N.
Why is the RMS torque, and not the average torque, compared with the continuous rating?
Because the heating of the motor is proportional to the square of the torque (current²), so the peaks count more than their duration suggests.
Which should be larger: the tip-over acceleration limit, or μ g? Why?
The tip-over limit: the robot should slip (a harmless event) before it tips (a dangerous one).
17
Software: a clean kinematics module, ROS 2 and the pitfalls
22 min
You will learn
to write, test and integrate the kinematics of a robot as a professional software component, to know the ROS 2 conventions, and to avoid the bugs that appear in almost every first robot.
17.1 The architecture of a navigation stack
Layer
Role
Typical rate
In this course
Motor drive + wheel speed loop
make the wheels turn at the requested speed
0.1 – 1 kHz
lesson 16
Base controller
body speed (v, ω) ↔ wheel speeds; odometry
50 – 100 Hz
lessons 5, 14
Localisation (EKF, AMCL)
pose of the robot in the map
20 – 50 Hz
lesson 15
Path follower (controller)
from a path to (v, ω)
20 – 50 Hz
lessons 11, 12
Planner
path from the pose to the goal
1 – 10 Hz
lesson 13
17.2 A kinematics module you can trust
A good module is small, uses SI units everywhere, has no hidden state except the odometry, scales the wheel commands when a motor saturates (lesson 8), limits the acceleration, and comes with unit tests. Here is a complete one (diffdrive.py), with the controller of lesson 11 used on top of it:
import math
class DiffDrive:
"""Kinematics, limits and odometry of a differential-drive robot (SI units, radians)."""
def __init__(self, radius, track, max_wheel_speed, max_accel=None):
self.r, self.L, self.wmax, self.amax = radius, track, max_wheel_speed, max_accel
self.x = self.y = self.th = 0.0
self.cmd = (0.0, 0.0) # last wheel speeds sent (rad/s): right, left
def wheel_speeds(self, v, w, dt=None):
"""body (v, w) -> wheel angular speeds (right, left), scaled if a motor would saturate
and limited in acceleration if dt is given."""
wr = (v + w * self.L / 2) / self.r
wl = (v - w * self.L / 2) / self.r
s = max(1.0, abs(wr) / self.wmax, abs(wl) / self.wmax) # scale BOTH wheels by the same factor
wr, wl = wr / s, wl / s
if self.amax and dt: # ramp: limit the change per step
dmax = self.amax * dt / self.r
wr = min(max(wr, self.cmd[0] - dmax), self.cmd[0] + dmax)
wl = min(max(wl, self.cmd[1] - dmax), self.cmd[1] + dmax)
self.cmd = (wr, wl)
return wr, wl
def body_speeds(self, wr, wl):
return self.r * (wr + wl) / 2, self.r * (wr - wl) / self.L
def integrate(self, wr, wl, dt):
"""odometry from the measured wheel speeds (midpoint rule)."""
ds = self.r * (wr + wl) / 2 * dt
dth = self.r * (wr - wl) / self.L * dt
self.x += ds * math.cos(self.th + dth / 2)
self.y += ds * math.sin(self.th + dth / 2)
self.th += dth
return self.x, self.y, self.th
def go_to_goal(robot, kr=1.5, ka=6.0, kb=-2.0, tol=0.01, dt=0.02, t_max=60.0):
"""Lesson 11 controller (goal = origin, heading 0)."""
wrap = lambda a: (a + math.pi) % (2 * math.pi) - math.pi
t = 0.0
while t < t_max:
rho = math.hypot(robot.x, robot.y)
if rho < tol:
break
gamma = math.atan2(-robot.y, -robot.x)
alpha = wrap(gamma - robot.th); th = robot.th; sign = 1.0
if abs(alpha) > math.pi / 2: # goal behind: drive backwards
th += math.pi; alpha = wrap(gamma - th); sign = -1.0
beta = wrap(-th - alpha)
v = sign * kr * rho; w = ka * alpha + kb * beta
wr, wl = robot.wheel_speeds(v, w, dt)
robot.integrate(wr, wl, dt)
t += dt
return t
if __name__ == "__main__":
bot = DiffDrive(radius=0.05, track=0.30, max_wheel_speed=30.0)
# unit tests
wr, wl = bot.wheel_speeds(0.4, 0.0); assert abs(wr - wl) < 1e-9 and abs(wr - 8.0) < 1e-9
wr, wl = bot.wheel_speeds(0.0, 1.0); assert abs(wr + wl) < 1e-9 and abs(wr - 3.0) < 1e-9
v, w = bot.body_speeds(*bot.wheel_speeds(0.45, 0.33)); assert abs(v - 0.45) < 1e-9 and abs(w - 0.33) < 1e-9
wr, wl = bot.wheel_speeds(3.0, 0.0); assert abs(wr - 30.0) < 1e-9 # 60 rad/s asked, scaled to the limit
print("unit tests passed")
print("wheel speeds for v=0.45, w=0.33 :", tuple(round(x, 3) for x in DiffDrive(0.05, 0.30, 30).wheel_speeds(0.45, 0.33)))
print("saturation: v=1.2, w=2.0 ->", tuple(round(x, 3) for x in DiffDrive(0.05, 0.30, 20).wheel_speeds(1.2, 2.0)), "(limit 20 rad/s, ratio kept)")
bot = DiffDrive(radius=0.05, track=0.30, max_wheel_speed=30.0); bot.x, bot.y, bot.th = -2.0, -1.0, 0.0
t = go_to_goal(bot)
print("go to goal : arrived after %.1f s at (%.3f, %.3f), heading %.1f deg" % (t, bot.x, bot.y, math.degrees(math.atan2(math.sin(bot.th), math.cos(bot.th)))))
unit tests passed
wheel speeds for v=0.45, w=0.33 : (9.99, 8.01)
saturation: v=1.2, w=2.0 -> (20.0, 12.0) (limit 20 rad/s, ratio kept)
go to goal : arrived after 4.0 s at (-0.010, -0.000), heading 3.7 deg
Read the output: the four tests pass (straight line gives equal wheel speeds of 8 rad/s; a pure rotation gives opposite speeds; the round trip body → wheels → body is exact; a saturated command is scaled to the limit). The speeds for ( v, ω ) = (0.45, 0.33) are 9.99 and 8.01 rad/s, the numbers of lesson 5. For ( 1.2 , 2.0 ) with a 20 rad/s limit the wheel speeds are scaled from ( 30 , 18 ) to ( 20 , 12 ): the ratio is kept, so the robot still follows the same curve, only slower. Finally, the go-to-goal controller drives the simulated robot from ( −2 , −1 ) to within 1 cm of the goal in 4 s.
17.3 ROS 2 in ten minutes
Nodes are programs that exchange messages on named topics (publish / subscribe), call services (request / reply) and run long tasks with actions (goal, feedback, result). Nav2 uses actions: “navigate to this pose”.
The command: the topic cmd_vel, message geometry_msgs/Twist: linear.x is v (m/s, forward), angular.z is ω (rad/s, counter-clockwise). For a holonomic robot linear.y is the sideways speed. This single message is the interface between the whole navigation and your robot base.
The odometry: nav_msgs/Odometry on odom (pose and twist with covariances) and the transform odom → base_link in tf2.
Conventions (REP-103 and REP-105): SI units and radians; x forward, y left, z up; the frames map → odom → base_link: odom is smooth but drifts (wheel odometry), map is globally correct but may jump (localisation). The localisation publishes the map → odom correction, which is exactly the EKF update of lesson 15.
Existing building blocks: ros2_control with the diff_drive_controller (parameters wheel_separation, wheel_radius, velocity and acceleration limits, a cmd_vel timeout) does the kinematics of this lesson; robot_localization does the EKF; Nav2 provides planners (NavFn, Smac Hybrid-A* with Dubins or Reeds–Shepp motions) and controllers (DWB, MPPI, Regulated Pure Pursuit). Your work is to give them the right numbers: r, L, limits, covariances.
A minimal base node (a sketch to show the structure, not run in this course; self.drive is the module above and send_to_motors your hardware layer):
import rclpy
from rclpy.node import Node
from geometry_msgs.msg import Twist
class BaseNode(Node):
def __init__(self):
super().__init__('base_node')
self.drive = DiffDrive(radius=0.05, track=0.30, max_wheel_speed=30.0, max_accel=1.0)
self.v = self.w = 0.0
self.last_cmd = self.get_clock().now()
self.create_subscription(Twist, 'cmd_vel', self.on_cmd, 10)
self.create_timer(0.02, self.loop) # 50 Hz
def on_cmd(self, msg):
self.v, self.w = msg.linear.x, msg.angular.z
self.last_cmd = self.get_clock().now()
def loop(self):
if (self.get_clock().now() - self.last_cmd).nanoseconds > 0.5e9:
self.v = self.w = 0.0 # watchdog: stop if no command for 0.5 s
wr, wl = self.drive.wheel_speeds(self.v, self.w, dt=0.02)
send_to_motors(wr, wl)
17.4 The ten bugs of every first robot
Symptom
Usual cause
How to find it
Goes backwards when told forward
motor wired or encoder counted with the wrong sign
wheels in the air, command +v, check each sign
Turns the wrong way (left ↔ right)
the left and right motors are mirrored: one must be inverted; or ω has the wrong sign
command ω > 0 and check it turns counter-clockwise seen from above
Curves when going straight
unequal wheel radii or motor gains
calibration test 1 (lesson 14)
Rotates by 110° when told 90°
wrong track width L (or skid-steer slip)
calibration test 2
Angle jumps by 360°
no angle normalisation
wrap to (−π, π] and subtract angles with a function
Everything is 57 times too small or too big
degrees mixed with radians
name variables with their unit (theta_rad)
Odometry jumps when the wheel counter overflows
16-bit counter wraps around
use differences of unsigned counters, modulo 2^16
Robot keeps running after the network is lost
no command watchdog
stop after 0.5 s without cmd_vel (see the node above)
Jerky motion, wheels slip at start
no acceleration limit
ramp the wheel speeds (max_accel above)
Estimate lags behind the real robot
timestamps ignored; filter uses the latest data instead of the data time
log the stamps; use tf with the message time
Test before the robot moves
The pyramid of tests: (1) unit tests of the kinematics (as above, in a second, on every change); (2) a simulation (Gazebo, or your own as in lab 1) with the same cmd_vel interface; (3) the robot on blocks (wheels off the ground) to check signs and watchdogs; (4) low speed in a free area with an operator on the emergency stop; (5) the real site. Each level catches different bugs, at a lower cost than the next.
The essentials
Keep the kinematics in one small module with SI units and unit tests.
ROS 2: cmd_vel (Twist: linear.x = v, angular.z = ω) in, odom → base_link transform out, with tf2.
Add a watchdog that stops the robot when commands stop; most first bugs are units, signs and frames.
The data flow of a ROS 2 base: commands in, wheel speeds out, encoders back as odometry; a watchdog stops the motors when /cmd_vel goes silent.
Key terms
ROS 2 node / topic
cmd_vel (Twist)
odom → base_link
tf2
watchdog
unit test
Nav2
Exercises
Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.
Level 1 · Beginner1
In a geometry_msgs/Twist message, what does angular.z represent for a ground robot?
The forward speed in m/s.
The turning speed ω in rad/s, counter-clockwise positive.
The steering angle in degrees.
Solution
REP-103: SI units and radians, z up, so a positive rotation about z is counter-clockwise seen from above.
Level 1 · Beginner2
A command v = 0.5 m/s, ω = 0 for a robot with wheels of radius 0.05 m. What angular speed must each wheel have, in rad/s?
Solution
φ̇ = v / r = 0.5 / 0.05 = 10 rad/s for both wheels.
Level 2 · Intermediate3
The wheel commands are (24, 16) rad/s and the motor limit is 20 rad/s. After the correct scaling, what is the command of the second wheel?
Solution
s = 24 / 20 = 1.2, so the commands become (20, 13.33) rad/s. Clipping only the first wheel would give (20, 16) and change the curve of the robot.
Level 2 · Intermediate4
The robot turns right when told to turn left, but goes straight correctly. What is the most likely cause?
The sign of ω (or of the left/right wheel assignment) is inverted.
The wheel radius is wrong.
The battery is low.
Solution
Straight motion is symmetric, so it works. Only the turning direction reveals a swapped or inverted side: check on blocks that ω > 0 turns counter-clockwise seen from above.
Level 3 · Professional5
The robot moves at 1.2 m/s and the command watchdog times out after 0.5 s. What distance does it run on at most before the watchdog stops it (ignoring braking), in metres?
Solution
1.2 × 0.5 = 0.6 m, and then the braking distance is added. The timeout is a safety-relevant parameter: it must be short, but longer than the longest normal gap between commands.
Level 3 · Professional6
What does the transform map → odom represent?
The correction of the localisation: it re-aligns the drifting odometry frame with the global map.
The position of the wheels.
The speed of the robot.
Solution
odom → base_link is smooth but drifts; the localisation publishes map → odom so that map → base_link is globally correct, and the smooth short-term motion is kept for control.
Check yourself
What do linear.x and angular.z of a Twist message mean for a differential robot?
linear.x = forward speed v in m/s; angular.z = turning speed ω in rad/s, counter-clockwise.
Why scale all wheel commands by the same factor when a motor saturates?
To keep the ratio between the wheels, so the robot follows the same curve more slowly instead of a different one.
What is the role of the transform map → odom?
It is the correction published by the localisation: it moves the smooth but drifting odometry frame so that it matches the global map.
18
Safety, testing and metrics: how a professional proves a robot works
22 min
You will learn
to compute stopping distances and safe speeds, to know the safety functions and standards of mobile robots, and to plan and report tests with real numbers.
18.1 Stopping distance and safe speed
When an obstacle appears, the robot first travels during the reaction timetr (sensor, computer, communication, brake delay), then brakes with the deceleration a:
sstop = vtr + v² / ( 2 a ) for a free distance d: vsafe = −atr + √( ( atr )² + 2 ad )
Worked example
tr = 0.3 s and a = 1.0 m/s². At 0.5 m/s: 0.15 + 0.125 = 0.28 m. At 1.0 m/s: 0.30 + 0.50 = 0.80 m. At 1.5 m/s: 0.45 + 1.125 = 1.58 m. The distance grows with the square of the speed, so doubling the speed more than doubles it. If the free distance in front of the robot is 1.0 m, the maximum safe speed is −0.3 + √( 0.09 + 2 ) = 1.15 m/s. A professional adds a margin (sensor range tolerance, floor slip, the size of the robot): usually 0.2 to 0.5 m.
This is how speed-dependent protective fields of safety laser scanners work: the faster the robot, the longer the field in front of it, and the robot slows down when something enters a larger “warning” field before the “protective” one that triggers the stop.
18.2 Safety functions and standards
Emergency stop: a red button on a yellow background, hardware-wired (not only software), that removes the energy to the motors, reachable on every side.
Safe Torque Off (STO): a function of the motor drive that removes the torque safely, certified (IEC 61800-5-2). Fail-safe brakes (applied when the power is off) hold the robot on a slope.
Safety-rated sensors: a safety laser scanner with switchable protective fields, and mechanical bumpers with a contact switch as the last barrier.
Speed and force limits in the zones where people walk, and a watchdog on every command (lesson 17).
Visible and audible warnings (lights, beeper), and a tested procedure for recovery.
Relevant standards (the names to look for; always use the current edition and your own safety officer): ISO 3691-4 (driverless industrial trucks and their systems), ANSI/RIA R15.08 (industrial mobile robots, in North America), ISO 13849-1 (performance levels of safety-related control parts), ISO 12100 (risk assessment and reduction), IEC 62061 and IEC 61508 (functional safety), the EU Machinery Directive / Regulation for CE marking, and the ISO 18646 series (performance criteria and test methods of wheeled service robots). The method of the risk assessment is the same as for arms (see the “real world” course): hazard, severity, exposure, possibility to avoid it, then measures.
Software is not a safety function
A navigation program, however good, can crash or be wrong. Whatever protects a human (emergency stop, STO, protective field, brakes) must be a separate, certified chain that works even if the navigation software has failed. Never rely on cmd_vel = 0 to protect a person.
18.3 How to test: a plan, metrics and statistics
A test is not “I tried and it worked”. Write the plan before: the question, the setup, the number of repetitions, the metric, the pass criterion (a number), and what you do if it fails. Metrics to use for a wheeled robot:
Metric
How to measure
Typical pass criterion
Odometry error
square test both ways (lesson 14), end-point distance / path length
< 1 % of the path length after calibration
Path tracking
RMS and maximum cross-track error against a reference line (tape, laser tracker)
max < 0.10 m at the working speed
Goal accuracy
position and heading error at the goal, N ≥ 10 runs
mean + 2σ < 5 cm and 3°
Stopping distance
from the working speed, N ≥ 5 per speed, loaded and empty
measured ≤ computed with the margin (18.1)
Energy and runtime
power measured at the battery during the real mission
runtime ≥ requirement with a 20 % margin
Reliability
missions without intervention, mean time between failures
≥ 99 % of the missions
Statistics. One run proves nothing. With N runs report the mean, the standard deviation σ and the confidence interval of the mean (about t × σ / √N, with t = 2.26 for N = 10 and a 95 % level). Example: 10 docking runs with a mean error of 12 mm and σ = 5 mm give a mean of 12 ± 3.6 mm (95 %). But the requirement is often about every run, not the mean: so check mean + 2σ or the maximum, and run enough tests to see the rare failures (to be 95 % sure that the success rate is at least 99 % you need about 300 successes in a row).
The professional's checklist before the robot leaves the lab
Kinematics unit tests pass; signs and units verified on blocks.
Wheel radii and track calibrated; odometry error measured, both directions.
Motor, gearbox and battery margins computed for the worst case and checked by a measurement.
Speed limits from curvature, from the wheels, from the stopping distance.
Emergency stop, STO, brakes, protective fields and watchdog tested, and the results written.
Test plan with numeric pass criteria, executed, with logs saved.
The essentials
Stopping distance = v t_r + v² / (2a): the reaction travel plus the braking.
Safety functions (protective fields, emergency stop, STO) follow standards such as ISO 3691-4.
A professional test has a plan, metrics, enough trials, a confidence interval and a pass criterion.
The stopping distance grows with the square of the speed: the protective field of the scanner must be longer than it, with a margin.
Key terms
reaction time / stopping distance
protective field
STO (safe torque off)
ISO 3691-4
confidence interval
pass criterion
Exercises
Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.
Level 1 · Beginner1
v = 1.2 m/s, reaction time 0.25 s, deceleration 0.8 m/s². What is the stopping distance, in metres?
Solution
s = v t + v² / (2a) = 0.30 + 1.44 / 1.6 = 1.2 m.
Level 2 · Intermediate2
The free distance in front of the robot is 1.5 m (t = 0.25 s, a = 0.8 m/s²). What is the maximum safe speed, in m/s?
Docking test: N = 9 runs with σ = 4 mm. What is the half-width of the 95 % confidence interval of the mean (t = 2.306 for 8 degrees of freedom), in mm?
Solution
t σ / √N = 2.306 × 4 / 3 = 3.07 mm.
Level 2 · Intermediate4
Which is an acceptable emergency-stop design for a robot that works near people?
A button that sends a stop message to the navigation software.
A hard-wired, independent chain that removes the energy to the motors (STO / contactor) and applies fail-safe brakes.
A software timer.
Solution
Safety functions must work even if the software hangs: independent, hard-wired, certified. The software can be used for the normal, non-safety stop.
Level 3 · Professional5
About how many consecutive successful runs are needed to claim, with 95 % confidence, a success rate of at least 99 % (“rule of three”: failure rate ≤ 3 / N)?
Solution
3 / N ≤ 0.01 gives N ≥ 300. Ten successful runs only show a success rate above about 70 %: “it worked every time I tried” is a very weak statement.
Level 3 · Professional6
Which standard is specifically about the safety of driverless industrial trucks and their systems (AGV / AMR)?
ISO 3691-4
ISO 9283
ISO 8601
Solution
ISO 3691-4 (with ANSI/RIA R15.08 in North America). ISO 9283 is the performance of manipulating industrial robots, and ISO 8601 the date format.
Check yourself
Robot speed 2 m/s, reaction time 0.2 s, deceleration 1 m/s². What is the stopping distance?
s = 2 × 0.2 + 4 / 2 = 0.4 + 2.0 = 2.4 m.
Why must the emergency stop not depend only on the navigation software?
Because software can fail or hang exactly when you need to stop; the safety chain must be independent, hard-wired and certified.
Why report mean + 2σ and not only the mean?
Because a requirement usually applies to every run; the mean hides the larger errors.
19
Capstone project: design a hospital delivery robot from the specification
30 min
You will learn
to apply every lesson of the course in order, from a written specification to a justified design and a test plan, and to check each number as a professional would.
A design is a chain of decisions, each one justified by a number. Here is a complete worked design. Follow it with your calculator, then do the same for your own variant in the exercises.
19.1 The specification
Requirement
Value
Mission
carry 25 kg of medicine and meals along hospital corridors, 6 hours per charge
Environment
corridors 1.5 m wide, doors 0.9 m wide, ramps up to 5 %, smooth floor, people walking
Speed and acceleration
up to 1.0 m/s, acceleration 0.4 m/s²
Mass
robot 40 kg + payload 25 kg = 65 kg
Accuracy
stay within 0.10 m of the planned path; dock at a charger within ± 20 mm
Safety
must stop for a person; standard: ISO 3691-4 / R15.08
19.2 Step 1: choose the drive (lessons 5 to 10)
Option
Test against the specification
Verdict
Car (Ackermann)
Rmin = e / tan δmax ≈ 1 m or more: it cannot turn around in a 1.5 m corridor.
✗
Mecanum / omni
holonomic, but poor odometry, floor must be good, more wear; sideways is not required.
not needed
Differential (2 drive wheels + castors)
spins on the spot (Rmin = 0), 2 motors, accurate odometry, simple.
✓ chosen
19.3 Step 2: geometry (lessons 2 to 4)
Body 0.55 m wide × 0.70 m long: it passes a 0.9 m door with 0.175 m on each side. To turn around inside the corridor it must spin on the spot: the circle that contains the body has the radius √( 0.275² + 0.35² ) = 0.445 m, a diameter of 0.89 m, well below 1.5 m ✓. Track (distance between the drive wheels) L = 0.42 m, wheel radius r = 0.075 m (150 mm wheels, comfortable over floor thresholds of 10 mm).
19.4 Step 3: motors and gearbox (lesson 16)
m = 65 kg, crr = 0.025, slope 5 % (2.86°), a = 0.4 m/s²: forces 26.0 N (acceleration) + 15.9 N (rolling) + 31.8 N (slope) = 73.8 N. Two drive wheels, G = 25, ηg = 0.85: τwheel = 73.8 × 0.075 / 2 = 2.77 N·m, τmotor = 2.77 / (25 × 0.85) = 0.130 N·m. Speed: at 1.0 m/s the wheel turns at 13.3 rad/s, the motor at 333 rad/s = 3 183 rpm. But the turn needs more: at v = 1.0 m/s and ω = 1.5 rad/s the outer wheel goes at 1.0 + 1.5 × 0.21 = 1.315 m/s, that is 17.5 rad/s at the wheel and 4 180 rpm at the motor. Choose a motor with a continuous torque ≥ 1.5 × RMS (about 0.15 N·m), a peak ≥ 0.25 N·m and a speed ≥ 4 200 rpm at 24 V, with a fail-safe brake for the ramp.
Checks. Traction: 0.6 × 65 × 9.81 × 0.8 = 306 N available against 74 N ✓. Tipping with h = 0.5 m, T = 0.5 m: lateral limit gT / (2 h) = 4.9 m/s² ≫ the 0.8 m/s² we allow in turns ✓.
19.5 Step 4: battery (lesson 16)
Cruise force on the slope: 15.9 + 31.8 = 47.7 N, so Pm = 47.7 W at 1.0 m/s. With η = 0.7 and 25 W of electronics: Pel = 47.7 / 0.7 + 25 ≈ 93 W. For 6 h with 80 % usable capacity: 93 × 6 / 0.8 = 700 Wh. Add 20 % for ageing and cold: 840 Wh, so a 24 V, 35 Ah battery. (The average power is much lower on the flat, so this is a conservative design.)
19.6 Step 5: sensing and odometry (lessons 14, 15)
Encoder 500 lines on the motor shaft: 4 × 500 × 25 = 50 000 counts per wheel turn, so 9.4 µm per count, and 1.0 m/s means 106 000 counts/s: hardware counter. After calibration we expect an odometry error of about 1 % (10 cm over 10 m), which is exactly the tolerance of the specification (0.10 m), so odometry alone is not enough: add a gyroscope for the heading and a 2-D lidar with a map (AMCL or an EKF with scan matching) to bound the position error. The charger docking within ± 20 mm uses a reflective marker and a final visual-servo approach, not odometry.
19.7 Step 6: control and speed limits (lessons 11 to 13)
Path follower: pure pursuit with Ld = 0.4 + 0.5 v (0.9 m at 1 m/s), wheel speed loop at 200 Hz, body loop at 50 Hz.
Curvature limit: v ≤ √( 0.8 / | κ | ): a corner of radius 1 m allows 0.89 m/s.
Wheel limit: the motor reaches 4 200 rpm = 17.5 rad/s at the wheel; v + | ω | L / 2 ≤ 1.31 m/s.
Acceleration ramps of 0.4 m/s² (specification) and a command watchdog of 0.5 s.
19.8 Step 7: safety (lesson 18)
Reaction time 0.3 s (scanner + controller + brake), deceleration 0.8 m/s² (below the tip-over and slip limits, and gentle for the load). Stopping distance at 1.0 m/s: 1.0 × 0.3 + 1.0² / (2 × 0.8) = 0.93 m. With a margin of 0.3 m the protective field must be at least 1.25 m deep at full speed. If the scanner can only offer a 1.0 m field in that mode, the maximum safe speed is −0.24 + √( 0.0576 + 1.6 ) = 1.05 m/s before the margin, and about 0.8 m/s with it (0.24 + 0.40 = 0.64 m + 0.3 m = 0.94 m ≤ 1.0 m ✓). People walk in the corridor: use a warning field to slow down to 0.5 m/s, an emergency stop chain with STO and fail-safe brakes, bumpers, lights and a beeper.
19.9 Step 8: the test plan (lessons 14 and 18)
Test
Method
Pass criterion
Calibration
straight 10 m + 10-turn spin + 2 m square both ways (N = 5 each)
distance error < 1 %; square end points < 5 cm
Tracking
corridor loop, 20 laps, loaded and empty
max cross-track error < 0.10 m
Docking
30 approaches from random starts
mean + 2σ < 20 mm; 30/30 successes
Stopping
obstacle test at 0.5, 0.8, 1.0 m/s, loaded and empty (N = 5)
measured stop ≤ computed (18.1) in every run
Endurance
full mission with real payload on the real route
≥ 6 h × 1.2 and battery above 20 % at the end
The design review checklist
Every requirement of the specification has a number, a calculation and a test.
The worst case was computed (heaviest load, steepest ramp, lowest voltage), not only the typical one.
Each choice was compared with at least one alternative (here: Ackermann, omni, differential).
The units are SI everywhere, and the signs and the frames are written down.
The safety functions are independent from the software and tested.
The essentials
Start from a written specification with numbers, then take each decision in the order of the course.
Justify every choice (drive, motors, battery, sensors, speeds) with a calculation and a margin.
Finish with a test plan that proves each requirement.
The design order of the capstone: each decision comes from the specification and is justified by a calculation; the tests close the loop.
Key terms
specification
decision matrix
worst case / typical case
design margin
acceptance test
design review
Exercises
Try each exercise yourself first. Type your answer in the box (the checker accepts a small tolerance) or pick an option; use the hint only if you are stuck, and read the solution to compare your method.
Level 2 · Intermediate1
Your variant. A robot of 90 kg (with load), wheel radius 0.10 m, two driven wheels, gear ratio 30 (efficiency 0.85), c_rr = 0.03, slope 8 %, v = 1.2 m/s, a = 0.5 m/s², 40 W of electronics, a 5 h mission, reaction time 0.3 s and deceleration 0.8 m/s². What total force must the wheels produce when climbing and accelerating, in newtons?
Hint
F = m a + c_rr m g + m g sin α, tan α = 0.08.
Solution
α = arctan 0.08 = 4.57°. m a = 45 N; rolling = 26.5 N; slope = 70.4 N. Total 141.9 N.
Level 2 · Intermediate2
Same variant: what torque must each motor give, in N·m?
Solution
τ_motor = F r / (n G η) = 141.9 × 0.10 / (2 × 30 × 0.85) = 0.278 N·m.
Level 2 · Intermediate3
Same variant: what motor speed is needed at 1.2 m/s (straight), in rpm?
Solution
ω_wheel = 1.2 / 0.10 = 12 rad/s; ω_motor = 30 × 12 = 360 rad/s = 3438 rpm (more if the robot also turns: remember the outer wheel).
Level 3 · Professional4
Same variant: what battery energy do you need for the 5 h mission at the cruise speed on the slope (efficiency 0.7, 80 % usable), in Wh? (Without extra margin.)
Hint
Cruise force = rolling + slope; P_m = F v; P_el = P_m / 0.7 + 40; E = P_el × 5 / 0.8.
Solution
Cruise force 96.9 N → P_m = 116.3 W → P_el = 206.1 W → E = 206.1 × 5 / 0.8 = 1288 Wh. A 24 V pack of about 1 600 Wh (with a 20 % margin) is needed: the specification of such a robot is demanding on the battery.
Level 3 · Professional5
Same variant: how deep must the protective field be at 1.2 m/s with a margin of 0.3 m, in metres?
Solution
s = 1.2 × 0.3 + 1.2² / (2 × 0.8) = 0.36 + 0.90 = 1.26 m; plus 0.3 m margin: 1.56 m.
Level 2 · Intermediate6
The specification says the robot must turn around in a 1.2 m wide corridor. What is the first thing to check about a car-like design?
Its minimum turning radius, which is probably larger than the corridor allows.
The colour of the wheels.
The number of encoder lines.
Solution
R_min = e / tan δ_max; a 1.2 m corridor needs R_min below about 0.5 m, impossible for a car. A differential or a holonomic drive is the answer.
Level 3 · Professional7
What is the most common mistake in a first sizing?
Sizing with the typical case only, with no worst case (heaviest load, steepest ramp, lowest battery voltage) and no margin.
Using SI units.
Adding a brake.
Solution
The worst case and the margin are what make a design robust; the typical case gives the runtime.
Check yourself
Why is a car-like (Ackermann) robot a bad choice for 1.5 m wide corridors?
Its minimum turning radius is too large to turn around; a differential robot can spin on the spot.
Why does the outer wheel in a turn set the motor speed requirement, not the straight-line speed?
Because its speed is v + ω L / 2, higher than v: the motor must reach it at the maximum v and ω together.
The spec asks 0.10 m path tracking and odometry gives 1 % over 10 m. What do you add?
A gyroscope for the heading and a lidar localisation (AMCL / EKF with a map) so that the position error is bounded instead of growing.
20
Final exam and practical tests: prove it
90 min
You will learn
to show, with numbers and with real tests, that you master the whole course: a written exam (33 questions), five practical challenges in the browser, and seven labs with code and with a real robot.
Reading a course does not make a professional: building and measuring does. This last lesson therefore has three parts, and the course is complete only when you pass all three. Your results are saved in this browser.
Your result
Part A: the written exam
33 questions, one attempt each (the answer is recorded when you check it), no hints. Use a calculator and the formulas of the lessons. Pass mark: 70 %. Take your time: the solutions can be read after you have answered.
Written exam
Each question is checked once: your first answer counts. The solution appears below it to learn from your mistakes.
Level 1 · Beginner1
A motor turns at 200 rpm and drives a wheel of radius 0.06 m. What is the speed of the robot, in m/s?
The left wheel is really 2 % bigger than the odometry thinks (L = 0.5 m). After a "straight" run of 10 m, by how many degrees has the robot actually turned? (absolute value)
Solution
Left wheel 10.2 m, right wheel 10.0 m: Δθ = 0.2 / 0.5 = 0.4 rad = 22.9°. (Lessons 5 and 14)
Level 2 · Intermediate9
A tricycle: d = 1.2 m, steering angle 20°. What is the turning radius on the rear axle, in metres?
Solution
R = d / tan α = 1.2 / tan 20° = 3.3 m. (Lesson 6)
Level 2 · Intermediate10
A bicycle: r = 0.25 m, v = 2 m/s, δ = 40°. What is the angular speed of the rear wheel, in rad/s?
Solution
φ̇_F = v cos δ / r = 2 × 0.766 / 0.25 = 6.13 rad/s. (Lesson 6)
Level 3 · Professional11
A car: e = 3 m, track 1.6 m, virtual steering angle 20° (left turn). What is the steering angle of the inside front wheel, in degrees?
Solution
R = 3 / tan 20° = 8.24 m; tan δ_in = 3 / (8.24 − 0.8) = 0.403, δ_in = 22°. (Lesson 6)
Level 3 · Professional12
Three-wheel omni robot (l = 0.15 m, r = 0.04 m), wheel speeds (6, −3, 0) rad/s. What is ẏ, in m/s?
Straight test: tape 6.00 m, odometry 5.91 m, radius used 40 mm. What is the calibrated radius, in mm?
Solution
r_new = 40 × 6.00 / 5.91 = 40.61 mm: the odometry under-estimated the distance, so the radius was too small. (Lesson 14)
Level 2 · Intermediate26
1-D Kalman filter: prediction variance P = 0.02 m², measurement variance R = 0.08 m². What is the gain K?
Solution
K = P / (P + R) = 0.02 / 0.10 = 0.2: the filter trusts the prediction more than the measurement. (Lesson 15)
Level 3 · Professional27
An 80 kg robot accelerates at 0.3 m/s² on a flat floor with c_rr = 0.03. What force must the wheels produce, in newtons?
Solution
F = m a + c_rr m g = 24 + 0.03 × 80 × 9.81 = 47.5 N. (Lesson 16)
Level 2 · Intermediate28
A 600 Wh battery (80 % usable) feeds a robot using 90 W. What is the runtime, in hours?
Solution
0.8 × 600 / 90 = 5.33 h. (Lesson 16)
Level 2 · Intermediate29
What is the purpose of a command watchdog on the base controller?
To stop the robot if no velocity command arrives for a short time (network or software failure).
To make the robot faster.
To calibrate the wheels.
Solution
It is a basic safety-related behaviour of the software (but not a substitute for the hard-wired safety chain). (Lessons 17 and 18)
Level 2 · Intermediate30
v = 0.8 m/s, reaction time 0.4 s, deceleration 0.5 m/s². What is the stopping distance, in metres?
Solution
s = 0.8 × 0.4 + 0.64 / (2 × 0.5) = 0.32 + 0.64 = 0.96 m. (Lesson 18)
Level 3 · Professional31
A robot is 0.9 m tall at the centre of gravity with a half wheelbase of 0.25 m. It brakes at 4 m/s², and the wheels could brake at 5.9 m/s². What happens?
It slips first and stops safely.
It tips forward: g b / h = 2.7 m/s² is smaller than 4 m/s².
Nothing, the centre of gravity height does not matter.
Solution
a_tip = 9.81 × 0.25 / 0.9 = 2.73 m/s² < 4 m/s²: the robot tips before it slips; limit the braking in software or lower the centre of gravity. (Lesson 16)
Level 3 · Professional32
For a differential robot, where do systematic odometry errors come from, and how are they removed?
From wheel radii and track width that are not the nominal ones; by calibration (straight, spin and square tests).
From random slip; by averaging many runs.
From the encoder cable; by changing it.
Solution
(Lesson 14)
Level 3 · Professional33
Which is the best justification for choosing a differential robot over a car-like robot for 1.5 m corridors?
It spins on the spot (R_min = 0), so it can turn around in a narrow corridor.
It is holonomic.
It has more motors.
Solution
A differential robot is nonholonomic (δM = 2) but can rotate in place; a car has a minimum turning radius. (Lessons 5, 6, 19)
Part B: practical challenges in the browser
Each challenge is a widget of a lesson with a target to reach. When you reach it, the widget shows a green “Done!” and the result is saved here.
Differential drive: a circle of radius 1.0 m at v ≥ 0.3 m/s — go to lesson 5
Car: a circle of radius 6 m at v ≥ 3 m/s — go to lesson 6
Go-to-goal controller: arrive in under 4 s with a heading error below 2° — go to lesson 11
Pure pursuit: keep the error below 0.15 m with a 0.4 s lag at 1 m/s — go to lesson 12
Calibration: bring both square-test centres within 5 cm of the start — go to lesson 14
Part C: the labs
Seven labs: three on your computer (code provided and tested), four with a real robot (or the simulator if you have none). Do the labs, record your numbers, then tick them. At least 5 of the 7 are needed, among them labs 1 and 2. Hardware labs use any differential robot; with no robot, replace the real robot by the simulator of lab 1 with random errors of your choice, and write down the numbers in the same way.
Lab 1 (software): odometry and calibration in simulation
Goal: reproduce the odometry experiments of lesson 14 and calibrate a simulated robot. Tools: Python 3, the file odometry.py of lesson 14.
Run it and check that your five output lines match the ones of the lesson.
Choose secret errors: true_r_scale=(1.0, 1.008) and true_track_scale=1.02.
Run the square clockwise and counter-clockwise (ccw=False), with noise=0.005 and 20 seeds each. Compute the two centres of the end points.
Use the signature of lesson 14 to decide which error is which, then add correction factors to the commands until both centres are within 2 cm.
Pass: both centres of the 20 runs are within 2 cm of the start, and you can write the two correction factors you found (they should be close to 1.008 and 1.02).
Lab 2 (software): a tested kinematics module
Goal: extend the module diffdrive.py of lesson 17 like in a real project. Tools: Python 3.
Add three unit tests: (a) ( v, ω ) = ( 0.25, 0.5 ) gives the turning radius 0.5 m; (b) after saturation the ratio of the wheel speeds is unchanged; (c) with max_accel=1.0 the wheel speed never changes by more than the allowed step in one cycle.
Add a method stop_distance(v, t_reaction, a) using the formula of lesson 18, with a test for ( 1.0, 0.3, 1.0 ) → 0.8 m.
Add the Mecanum inverse kinematics of lesson 8 as a second class and test it with the worked example (0.5, 0.3, 0.2) → ( 2.6, 17.4, 14.6, 5.4 ).
Pass: all the tests pass (python3 diffdrive.py prints “unit tests passed”), and a deliberate bug (change a sign) makes at least one test fail.
Lab 3 (software): path tracking with a lag, measured
Goal: find by experiment the look-ahead distance that works at 1.0 m/s with a 0.4 s lag, and explain it. Tools: Python 3 and the file below.
import math
# Wavy reference path y = 0.8 sin(0.6 x), 5 cm between points
PATH = [(0.05 * i, 0.8 * math.sin(0.6 * 0.05 * i)) for i in range(0, 281)]
def pure_pursuit(ld, v, lag, start=(0.0, -0.4, 0.0), w_max=2.5, dt=0.02):
"""Differential robot with pure pursuit and a first-order lag on the turning rate.
Returns (max cross-track error, RMS error, finished). The first 3 s are ignored (start offset)."""
x, y, th = start
w_actual, idx, t = 0.0, 0, 0.0
sse, n, emax = 0.0, 0, 0.0
while t < 60.0:
# nearest path point (search only a small window ahead of the last one)
window = range(max(0, idx - 5), min(len(PATH), idx + 80))
idx = min(window, key=lambda i: math.hypot(PATH[i][0] - x, PATH[i][1] - y))
e = math.hypot(PATH[idx][0] - x, PATH[idx][1] - y)
if idx >= len(PATH) - 3:
return emax, math.sqrt(sse / max(n, 1)), True
# look-ahead target: first path point farther than ld from the robot
j = idx
while j < len(PATH) - 1 and math.hypot(PATH[j][0] - x, PATH[j][1] - y) < ld:
j += 1
gx, gy = PATH[j][0] - x, PATH[j][1] - y
xr = math.cos(th) * gx + math.sin(th) * gy # target in the robot frame
yr = -math.sin(th) * gx + math.cos(th) * gy
kappa = 2.0 * yr / (xr * xr + yr * yr) # pure pursuit curvature
w_cmd = max(-w_max, min(w_max, v * kappa))
w_actual += (w_cmd - w_actual) * dt / lag if lag > 0 else (w_cmd - w_actual)
x += v * math.cos(th) * dt; y += v * math.sin(th) * dt; th += w_actual * dt
t += dt
if t > 3.0:
emax = max(emax, e); sse += e * e; n += 1
if abs(y) > 20:
return emax, math.sqrt(sse / max(n, 1)), False
return emax, math.sqrt(sse / max(n, 1)), False
if __name__ == "__main__":
print("v = 1.0 m/s, motor lag 0.4 s")
print(" Ld [m] max error [m] RMS error [m]")
for ld in (0.3, 0.6, 1.0, 1.5, 2.5):
emax, rms, ok = pure_pursuit(ld, 1.0, 0.4)
print(" %.1f %.3f %.3f %s" % (ld, emax, rms, "" if ok else "(lost the path)"))
v = 1.0 m/s, motor lag 0.4 s
Ld [m] max error [m] RMS error [m]
0.3 0.808 0.505
0.6 0.149 0.045
1.0 0.121 0.028
1.5 0.097 0.039
2.5 0.549 0.187
Run it and read the table: too small an Ld loses the path, too large cuts the corners.
Repeat the table for the speeds 0.5 and 1.5 m/s and for the lags 0 and 0.2 s. Plot the best Ld against v.
Fit the rule Ld = L0 + kv and write the numbers you find.
Pass: your table agrees with the one printed here for v = 1.0 and lag 0.4, and your rule keeps the maximum error below 0.15 m for the six combinations.
Lab 4 (robot): calibrate the radius and the track
Goal: calibrate a real differential robot with the three tests of lesson 14. Materials: a robot with encoders, a tape measure, masking tape, a flat floor, a gyroscope or a mark on the floor.
Straight test: command 5 m, five times; measure the real distance and the lateral deviation. Compute the new radius of each wheel.
Spin test: 10 turns, five times; compute the new track.
Repeat both tests with the new values.
Pass: after calibration, the distance error is below 1 % and the 10-turn error below 1 % (36°), in the mean of five runs. Write your before and after numbers.
Lab 5 (robot): the square test and the power budget
Goal: run the square test of lesson 14 on your robot, and compare the measured power with the prediction of lesson 16. Materials: as lab 4, plus a way to measure the battery current and voltage (a power meter or the battery management system).
Mark a 2 m square. Drive it five times clockwise and five times counter-clockwise; mark each end point and measure it from the start. Compute the two centres.
Measure the battery power at standstill, and at three constant speeds on the flat floor. Fit P = P0 + kv and compare k with mgcrr / η from lesson 16.
Pass: both square centres are within 5 cm of the start, and the measured k is within 25 % of the prediction (or you explain the difference: floor, tyres, efficiency).
Lab 6 (robot): stopping distance
Goal: measure the stopping distance and compare it with the formula of lesson 18. Materials: a robot with a stop command, tape, a tape measure, a clear floor, a helper. Safety: low speeds, nobody in front of the robot, a person on the emergency stop.
Mark a line on the floor. Send the stop command when the robot front crosses it, at 0.3, 0.6 and 0.9 m/s (five runs each, empty and loaded).
Measure the stopping distance. Estimate the reaction time and the deceleration from your data (the distance is vt + v² / 2a).
Pass: the measured distances follow the formula within 15 %, and you give the protective field depth you would choose with a margin.
Lab 7 (robot or simulation): the capstone test report
Goal: write the test report of a design, like a professional. Materials: your design of the capstone variant (exercises of lesson 19) or your real robot.
Write the specification with numbers, the decisions with their calculations, and the test plan with pass criteria (as in lesson 19).
Run at least three of the tests (on the robot or in your simulator) with N ≥ 5 repetitions. Give the mean, the standard deviation and the worst case.
Conclude: for each requirement say “met”, “not met” or “not tested”, with the number.
Pass: a one-page report where every requirement has a number, a calculation and a verdict, with at least three measured tests.
What you can do now
Read a robot's specification and choose its wheels and drive with numbers, not with feeling (lessons 3 to 10, 19).
Write, test and calibrate its kinematics and odometry, and fuse them with other sensors (lessons 11 to 15, 17).
Make it follow a path, plan feasible paths, and respect its limits (lessons 12, 13).
Size its motors and battery, check traction and tipping, and prove it with measurements (lessons 16, 18).
The essentials
The written exam checks the theory and the calculations of the whole course.
The challenges check that you can tune and drive a robot, in the browser.
The labs prove it on code and on a real robot, with a short test report.
Key terms
written exam
challenge
lab
pass criterion
test report
Check yourself
Why is a test with N = 1 not enough to prove a requirement?
One run shows nothing about the variation: you need several runs to know the mean, the spread and the worst case.
Glossary
All the words of the course in one place.
Term
Meaning
Pose / posture
The position and orientation of the robot: (x, y, θ).
Rotation matrix R(θ)
Converts a vector from the global frame to the robot frame.
Rolling constraint
The wheel contact moves along its plane at r·φ̇ (pure rolling).
Sliding constraint
The wheel contact has no speed across its plane (no lateral slip).
Standard wheel (fixed / steered)
A wheel that rolls and does not slide; it constrains the robot.
Castor wheel
A wheel whose steering axis is offset from the contact point; it does not constrain the robot.
Swedish / Mecanum wheel
A wheel with free rollers on its rim: it also moves along the rollers.
Differential drive
Two driven wheels on one axle; v = (V_R + V_L) / 2, ω = (V_R − V_L) / L.
ICC / ICR
Instantaneous centre of curvature / rotation: the point around which the robot turns at one instant.
Ackermann steering
The inside front wheel turns more than the outside one, so all four wheel axes meet at the ICR.
Synchro drive
Three wheels driven and steered together by belts; the ICC is at infinity.
Degree of mobility δm
3 − rank of the sliding constraints: velocities available immediately.
Degree of steerability δs
Number of independent steering motions that change the constraints over time.
Degree of maneuverability δM
δm + δs: total degrees of freedom the robot can control.
DOF / DDOF
Poses the robot can reach / velocities it can produce independently at one instant.
Holonomic / nonholonomic
A holonomic robot has DDOF = DOF; a nonholonomic one has velocity constraints that cannot be integrated.
Path / trajectory
A curve in (x, y, θ) / the same curve with time.
Odometry
Computing the pose by integrating the wheel motions; it drifts.
Mecanum drive
Four Mecanum wheels in an X layout: holonomic; the wheel speeds satisfy FL + FR = RL + RR.
Swerve drive
Independently steered and driven modules; each module speed and angle come from u = (v_x − ω y, v_y + ω x).
Pure pursuit
Path following by steering along the circle to a look-ahead point: κ = 2 y_g / L_d².
Dubins / Reeds–Shepp path
Shortest path with a minimum turning radius, forward only / with reversing.
Calibration
Measuring and correcting the systematic parameters (wheel radii, track) of the odometry.
Kalman filter / EKF
Combines a prediction and a measurement according to their uncertainties; the EKF linearises a nonlinear motion model.
Rolling resistance c_rr
Ratio of the rolling force to the weight.
RMS torque
Root-mean-square torque over the work cycle: it must stay below the continuous torque of the motor.
Stopping distance
v·t_r + v² / (2a): reaction travel plus braking.
STO (Safe Torque Off)
A certified function of the motor drive that removes the torque safely.
cmd_vel / Twist
The ROS velocity command: linear.x = v (m/s), angular.z = ω (rad/s).
ISO 10218-1 and ISO 10218-2, Robotics — Safety requirements (industrial robots and robot applications).used for:safety functions
From zero to professional: you can model, size, control and test a wheeled robot!
Pass the final exam, the challenges and the labs of lesson 20 to complete the course. Then go further with the dynamics and control of arms, perception and AI, and the real world.