Level 3 Intelligent Robotic Systems · Term 4: Integrated Robotics
Bringing computation, motion, perception and feedback together in one simulated robot, and evaluating it like an engineer: architecture and interfaces, guarded state machines, P/PI/PID with step-response metrics, integration testing, fair experiments with baselines and ablations, and a technical report.
In this file: 30 lessons across weeks 28–36, with 156 practice questions (questions only, no answers).
Design, model and evaluate simulated robotic systems that integrate computation, the mathematics of motion, perception and feedback, and compare them fairly against alternatives. Levels describe what you can do, not your age. About About 3–4 hours a week: 1.5 hours of lessons, 1–1.5 hours of coding or lab work and 30–60 minutes of analysis and writing..
Week 28: Robotic system architecture
This week you will
- Break a robot into subsystems and draw a block diagram with data and power paths.
- Label each interface with signal, unit, frame and rate.
- Explain why different software layers run at different rates.
Blocks, arrows and promises
A warehouse robot has eight boxes on its diagram and twenty arrows between them. Which do engineers argue about more: the boxes or the arrows?
Why it matters
Nobody can hold a whole robot in their head. A block diagram lets a team split the work, agree what each part promises the others, and spot the single wire or message everything depends on, before any metal is cut.
Goals
- Break a mobile robot into sensing, estimation, planning, control, actuation and power subsystems.
- Draw a block diagram that separates data paths from power paths.
- Describe each arrow as an interface: what signal, in what unit, how often.
Predict
Two teams each finish a subsystem that passes all its own tests. They plug them together for the first time. What usually breaks first?
- The hardware inside one of the boxes
- The connection between them: units, timing or assumptions
- Nothing: tested parts always work together
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Place each block of the warehouse robot in its layer and give it an update rate. Before you check, predict: which blocks run fastest, and why are they the ones closest to the motors?
What the interactive shows, in words
The architecture builder can be done as a table: wheel encoders, sensing, 1 kHz; camera, sensing, 10 Hz; state estimator, estimation, 100 Hz; object detector, estimation, 10 Hz; mission planner, planning, 1 Hz; wheel speed PID, control, 1 kHz; motor driver, actuation, not a loop; battery, power, not a loop.
Understand
Subsystems and layers
A mobile robot's software and hardware fall into layers: sensing (encoders, cameras, IMU), perception and estimation (turning raw readings into 'I am here, a box is there'), planning (choosing what to do next), control (making motors follow the plan) and actuation (drivers and motors). Power runs underneath everything.
Data paths and power paths
In a block diagram, data arrows carry information (a pose, a speed command) and power arrows carry energy (battery to motor driver). Draw them differently, for example solid and dashed. A fault on a power path can take out several data paths at once, which is why engineers look for single points of failure there.
Every arrow is a promise
Label each arrow with its interface: the signal's name, unit, coordinate frame and rate. 'Pose' is vague; 'pose of the robot in the map frame, metres and radians, 50 Hz' is a promise the receiving team can build on and test against.
Explain it another way: intuitive
Think of a restaurant kitchen. Waiters (sensors) bring orders, the head chef (planner) decides, cooks (controllers) do the work with their tools (actuators), and the gas supply (power) feeds the lot. Most chaos happens at the pass, where one station hands food to the next.
Explain it another way: technical
A system block diagram is a directed graph: nodes are subsystems, edges are signals. Each edge has a type (data or power) and an interface specification. The diagram is the basis for splitting work, writing interface tests and analysing failure propagation.
Explain it another way: applied
Robot teams often keep the block diagram in the repository next to the code and update it whenever an interface changes, so that new members learn the system from one picture.
Try these examples
Example 1
Write a full interface label for the arrow from the wheel encoders to the wheel speed controller.
The worked solution is in the online lesson.
Common mix-ups
If every subsystem passes its own tests, the robot will work.
✓ Subsystem tests check each box against its own assumptions; the interfaces between boxes need their own tests.A block diagram is a picture of the hardware layout.
✓ It shows function and signal flow, not physical position. Two blocks can run on the same chip.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Which layer does an object detector that turns camera pixels into 'box at 1.2 m' belong to?
- Sensing
- Perception and estimation
- Planning
- Actuation
2. Why draw power paths differently from data paths?
- To make the diagram colourful
- Because a power fault can disable many data paths at once, so it needs its own analysis
- Because power paths never fail
3. Which is the best label for an arrow from the localiser to the planner?
- position
- pose (x, y, heading) in the map frame, m and rad, 50 Hz
- data
- the robot's location, sent often
4. A robot's motor-current loop runs at 500 Hz and its path planner at 20 Hz. How many current-loop updates happen between two planner updates?
Answer: updates
5. In a robot where one 5 V regulator feeds the computer, the camera and the lidar, what is the regulator?
- A data path
- A single point of failure
- A redundant component
Apply it
Draw the block diagram of a robot vacuum cleaner with at least seven blocks. Mark data and power paths differently, label four arrows with full interface descriptions, and circle one single point of failure.
Reflect
Which arrow in your vacuum-cleaner diagram would you test first, and why that one?
Fast loops inside slow ones
A balancing robot corrects its motors a thousand times a second but decides where to go only once a second. Why not do everything at 1 kHz?
Why it matters
Computing time is a budget. Spend it where the physics is fast (currents, wheel speeds, balance) and save it where the world changes slowly (goals, routes). Getting this split wrong gives either a sluggish robot or an overloaded processor.
Goals
- Explain why low-level control loops run faster than planning loops.
- Choose an update rate from how quickly the controlled quantity can change.
- Calculate how many inner-loop updates happen per outer-loop decision.
Predict
A wheel's speed can change noticeably in 5 ms. Roughly how often should its speed controller run?
- Once a second
- About every 50 ms
- About every 1 ms or faster
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Open the Robotics Workbench and run a motion with the default controller. Find the controller's update period, then make it ten times slower and run again. Describe what changes in the tracking and why.
What the interactive shows, in words
In the Robotics Workbench, slowing the controller update period by ten times makes the tracked motion lag and overshoot the target path, because corrections arrive too late for the arm's dynamics.
Understand
Rates follow the physics
Each loop should run several times faster than the quantity it controls can change. Motor current changes in microseconds to milliseconds, so current loops run at 10–20 kHz. Wheel speed changes in milliseconds (1 kHz). A robot's position on a map changes over tenths of a second (10–100 Hz). Goals change over seconds (1 Hz or less).
Cascaded loops
Layers are usually cascaded: the planner sends a path, a position loop turns it into speed targets, and a speed loop turns those into motor commands. Each inner loop treats its setpoint as constant between outer updates, which only works if the inner loop is much faster.
The cost of running fast
Running everything at the highest rate wastes processor time and energy, and heavy jobs such as vision may simply not finish in 1 ms. Splitting rates lets each job get the time it needs, often on different processors: a microcontroller for fast loops, a larger computer for perception and planning.
Explain it another way: intuitive
Driving a car: your hands make tiny steering corrections all the time, your eyes check the lane every moment, and you decide which road to take only at junctions.
Explain it another way: technical
For a cascade to behave, each inner loop's closed-loop bandwidth should be roughly 5–10 times that of the loop around it. Sample rates are then chosen around 10–20 times each loop's bandwidth.
Explain it another way: mathematical
Updates per decision = inner rate ÷ outer rate. A 1 kHz speed loop under a 10 Hz planner runs 1000 ÷ 10 = 100 times per planning step. Its period is 1/1000 s = 1 ms.
Explain it another way: applied
Drone flight controllers typically run attitude loops at hundreds of hertz to a few kilohertz on a microcontroller, while a companion computer handles mapping and route planning far more slowly.
Try these examples
Example 1
A planner runs at 5 Hz and a position loop at 200 Hz. How many position updates per plan, and what is the position loop's period?
The worked solution is in the online lesson.
Common mix-ups
Faster is always better, so run every loop as fast as possible.
✓ Each loop needs a rate matched to its dynamics. Over-fast loops waste computing; heavy jobs may not even finish in time.The update rate is a software detail you can choose later.
✓ Rates decide processors, buses and stability, so they belong on the block diagram from the start.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. A robot's motor-current loop runs at 1000 Hz and its path planner at 5 Hz. How many current-loop updates happen between two planner updates?
Answer: updates
2. A current loop runs at 20 kHz. What is its period, in microseconds?
Answer: µs
3. Which job should run at the highest rate?
- Choosing the next delivery shelf
- Recognising objects in camera images
- Controlling motor current
4. Why must an inner speed loop be much faster than the position loop around it?
- So the position loop can treat the speed as following its command almost instantly
- Because speed is more important than position
- It doesn't matter which is faster
5. A team moves the wheel PID from the main computer (which also runs vision) onto a small microcontroller. What is the main benefit?
- Vision runs faster
- The control loop's timing no longer depends on how busy vision is
- The robot needs less power overall
Apply it
For a line-following robot, list four loops (motor current, wheel speed, line tracking, lap strategy). Give each a rate with a one-line justification based on how fast its quantity changes, and calculate the updates per decision between each pair.
Reflect
Where in your own day do you make fast corrections inside a slow plan?
One brain or many?
Should a robot run everything on one powerful computer, or spread the work across several small ones? Both answers ship in real products.
Why it matters
Architecture choices are expensive to undo. Picking where computation lives decides wiring, software structure and how the robot fails, so engineers make the choice deliberately and write down why.
Goals
- Compare centralised and distributed architectures on cost, latency, reliability and complexity.
- Use weighted criteria to choose an architecture and state what was traded away.
Predict
A robot spreads its control across five small processors linked by a bus. Compared with one big computer, what gets harder?
- Nothing: more processors are always better
- Keeping their data consistent and in sync over the bus
- Running fast control loops
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Treat the designs in the trade-offs lab as architecture options. Weight cost, reliability and latency first for a toy robot, then for a hospital delivery robot. Does the winner change? Which design is dominated (worse on everything)?
What the interactive shows, in words
In the trade-offs lab, changing the weights changes which design scores highest; one design is worse on every criterion than another and can never win.
Understand
Centralised
One computer runs perception, planning and control. Pros: one place for all data, simpler software, easy to debug. Cons: one busy processor must also meet fast loop deadlines, and if it crashes, everything stops.
Distributed
Small processors near each motor or sensor run fast local loops, and a main computer coordinates them over a bus. Pros: fast, predictable local loops and less wiring. Cons: more interfaces, bus delays and clock synchronisation to manage. A failure can be contained to one node, if the design plans for it.
Decide with criteria, not taste
List criteria (cost, latency, reliability, power, development time), weight them for this robot's users, score each option and check whether any option is dominated. Then record the decision and what you gave up, so the next engineer knows it was a choice, not an accident.
Explain it another way: intuitive
One brain is like a single manager doing everything: simple, until they get overloaded. Many brains is like a team with walkie-talkies: faster locally, but they must keep talking.
Explain it another way: technical
Distributed designs move latency-critical loops next to the hardware and turn many analogue wires into one digital bus, at the cost of interface specifications, message scheduling and fault handling across nodes.
Explain it another way: applied
Many industrial arms put a servo drive at every joint that closes the current and speed loops locally, while a central controller plans trajectories and sends setpoints.
Try these examples
Example 1
A school robot must cost under 60 pounds and be easy for beginners to debug. Centralised or distributed?
The worked solution is in the online lesson.
Common mix-ups
There is one correct robot architecture.
✓ The best architecture depends on the robot's users, budget and risks; record the criteria behind your choice.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Which is a typical advantage of a distributed architecture?
- Fewer interfaces to specify
- Fast loops run close to the hardware with predictable timing
- No need to synchronise clocks
2. Design A costs more, is slower and is less reliable than design B. What is A?
- A trade-off
- Dominated: there is no reason to choose it
- The safe choice
3. Weights: cost 3, latency 2, reliability 5. Option X scores cost 4, latency 2, reliability 3 (out of 5). What is X's weighted total?
Answer:
4. Why write down what an architecture decision traded away?
- Documentation is required by law
- So later engineers know the weakness was a deliberate choice and when to revisit it
- It isn't useful
5. For a hospital delivery robot, which criterion should usually get the most weight?
- Lowest cost
- Reliability and safe failure
- Fastest top speed
Apply it
Pick a robot (lawn mower, delivery drone or classroom rover). Score centralised and distributed designs on four weighted criteria, state the winner and write two sentences on what you traded away.
Reflect
Which criterion did you find hardest to weight, and who should really decide it?
Week 29: State machines
This week you will
- Design a finite state machine with guarded transitions for a robot task.
- Check it for unreachable states, traps and unhandled events.
- Test every transition and each guard boundary.
States, events and guards
A delivery robot gets an order with 25 % battery left. Should it go, or charge first? Who decides, and where is that rule written?
Why it matters
Behaviour written as nested if-statements becomes impossible to check. A state machine puts every behaviour in a table you can read, test and argue about, which is why lifts, traffic lights and robot task logic use them.
Goals
- Describe robot behaviour as states, events, transitions and guards.
- Trace a guarded state machine through a sequence of events by hand.
- Explain why the order of rules matters when guards overlap.
Predict
The robot is DRIVING and receives the event 'order'. There is no rule for 'order' in DRIVING. What should happen?
- It crashes
- Nothing: the event is ignored in this state
- It starts a second delivery
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Load the complete design. Set the battery to 25 % and send: order, charged, order, arrived, done. Write the state after each event before you press it. Then load each 'Bug' design and read what the checker says.
What the interactive shows, in words
The state-machine runner shows a table of rules: IDLE plus order goes to DRIVING if battery is at least 30 %, else CHARGING; DRIVING plus arrived goes to DELIVERING; DRIVING plus bump goes to FAULT; DELIVERING plus done goes to IDLE and costs 20 % battery; CHARGING plus charged goes to IDLE at 100 %; FAULT plus reset goes to IDLE. Sending events steps through the table.
Understand
The four ingredients
A state is a mode the robot can be in (IDLE, DRIVING). An event is something that happens (an order arrives, a bump sensor fires). A transition says: in this state, on this event, go to that state. A guard is a condition that must also be true, such as battery ≥ 30 %.
Guards split one event into cases
IDLE + order has two rules: battery ≥ 30 % → DRIVING, battery < 30 % → CHARGING. Together the guards cover every battery level exactly once. If they overlapped, two rules could fire and the result would depend on which is listed first; if they left a gap, some orders would vanish.
Ignored events
If no rule matches, the machine stays where it is. That is often right (a second order while driving), but it can hide a missing rule. Review each state and ask, for every event: should something happen here?
Explain it another way: intuitive
A board game: your piece is on one square (state), a dice roll (event) moves it, and some squares have conditions (guards): 'only if you have a key'.
Explain it another way: technical
A finite state machine is a set of states S, events E, an initial state and a transition function δ(s, e, context) → s′. Guards make δ depend on context; for determinism, guards on the same (s, e) must be mutually exclusive.
Explain it another way: applied
Lift controllers, vending machines and the task layer of many service robots are state machines, often drawn as diagrams and then generated or hand-coded as transition tables.
Try these examples
Example 1
Battery 45 %. Events: order, arrived, done, order. Where does the robot end?
The worked solution is in the online lesson.
Common mix-ups
Guards are just extra if-statements you can add anywhere.
✓ Guards on the same state and event must together cover every case exactly once, or behaviour becomes order-dependent or silently lost.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. A delivery robot starts in IDLE (state 0) with its battery at 55 %. Rules: IDLE(0) + order → DRIVING(1) if battery ≥ 30 %, else → CHARGING(3). DRIVING(1) + arrived → DELIVERING(2). DRIVING(1) + bump → FAULT(4). DELIVERING(2) + done → IDLE(0) and the battery drops by 20 %. CHARGING(3) + charged → IDLE(0) with the battery at 100 %. FAULT(4) + reset → IDLE(0). Any other event in any state is ignored. Events arrive in this order: arrived, reset, reset, done. Which state number is it in at the end?
Answer: state number
2. A delivery robot starts in IDLE (state 0) with its battery at 35 %. Rules: IDLE(0) + order → DRIVING(1) if battery ≥ 30 %, else → CHARGING(3). DRIVING(1) + arrived → DELIVERING(2). DRIVING(1) + bump → FAULT(4). DELIVERING(2) + done → IDLE(0) and the battery drops by 20 %. CHARGING(3) + charged → IDLE(0) with the battery at 100 %. FAULT(4) + reset → IDLE(0). Any other event in any state is ignored. Events arrive in this order: arrived, arrived, charged, reset, order, reset, order. Which state number is it in at the end?
Answer: state number
3. Which pair of guards on IDLE + order is complete and non-overlapping?
- battery > 30 and battery < 30
- battery ≥ 30 and battery < 30
- battery ≥ 30 and battery ≤ 30
4. Which of these is an event rather than a state?
- CHARGING
- bump sensor triggered
- FAULT
5. Two rules both match DRIVING + bump: one goes to FAULT, one stays in DRIVING. What is wrong?
- Nothing
- The machine is non-deterministic: the outcome depends on rule order
- The robot will be in two states at once
Apply it
Add a LOW_BATTERY_RETURN state to the delivery robot: while DRIVING, if a 'battery-warning' event arrives, it abandons the delivery and heads to the charger. Write the new rules as a table and trace one sequence through it.
Reflect
Where in the delivery robot would silently ignoring an event be dangerous?
No state left behind
A robot hits a wall, enters FAULT, and stays there forever, even after someone clears the path. The code has no bug. The design does.
Why it matters
Most state-machine failures are not typos: they are missing transitions. A state nobody can leave, or a state nobody can reach, passes every test you thought to write. Engineers check completeness systematically.
Goals
- Check a state machine for unreachable states, trap states and unhandled events.
- Add safe default and fault states with explicit ways out.
- Pass an automated safety audit for a timed state machine.
Predict
A junction's state machine goes from NS green straight to EW green. What is missing?
- Nothing: it is faster
- Amber and an all-red clearance between them
- A walk signal
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Build the junction's controller as a cycle of states and run the server's safety audit. Start from the starter design and fix one failure at a time, re-running the audit after each fix.
What the interactive shows, in words
In the traffic-system build, the starter state cycle fails the audit for missing amber, missing all-red clearance and no pedestrian walk phase; adding those states in order makes the audit pass.
Understand
Three completeness checks
Reachability: can every state be entered from the initial state? An unreachable state is dead code, or a sign a transition is missing. Escape: does every state have a way out? A trap state freezes the robot. Coverage: for every state, is every event either handled or deliberately ignored?
Fault and safe states
Real robots need a FAULT or SAFE_STOP state reachable from every state where something can go wrong, and an explicit, deliberate way out (a reset, after the cause is cleared). The way out is part of the design, not an afterthought.
Tables beat diagrams for checking
Diagrams are good for understanding; tables are good for checking. Write a grid with states as rows and events as columns. Every cell must say a target state or 'ignore', with a reason. An empty cell is a decision nobody made.
Explain it another way: intuitive
Like a building's floor plan: every room needs a door in and a door out, and every corridor sign must point somewhere real.
Explain it another way: technical
Reachability is a graph search from the initial state. A trap is a reachable state with no outgoing transition to another state. Coverage is the state × event table with no undefined cells.
Explain it another way: applied
Traffic-signal controllers are checked for conflicting greens and minimum clearance times before deployment; the Build's audit applies the same kind of rules to your design.
Try these examples
Example 1
States IDLE, DRIVING, DELIVERING, FAULT. Transitions: IDLE→DRIVING (order), DRIVING→DELIVERING (arrived), DELIVERING→IDLE (done), DRIVING→FAULT (bump). Which check fails?
The worked solution is in the online lesson.
Common mix-ups
If the code runs without errors, the state machine is complete.
✓ Missing transitions produce no errors at all; only systematic reachability, escape and coverage checks find them.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Which state in the worked example is a trap?
- IDLE
- DELIVERING
- FAULT
2. A state machine has 5 states and 6 events. How many cells must a complete coverage table fill in?
Answer:
3. A state CHARGING exists in the code but no rule leads into it. What should you conclude?
- It is harmless
- A transition into it is probably missing, or the state should be deleted
- The robot will enter it randomly
4. A delivery robot starts in IDLE (state 0) with its battery at 45 %. Rules: IDLE(0) + order → DRIVING(1) if battery ≥ 30 %, else → CHARGING(3). DRIVING(1) + arrived → DELIVERING(2). DRIVING(1) + bump → FAULT(4). DELIVERING(2) + done → IDLE(0) and the battery drops by 20 %. CHARGING(3) + charged → IDLE(0) with the battery at 100 %. FAULT(4) + reset → IDLE(0). Any other event in any state is ignored. Events arrive in this order: bump, reset, arrived, done, arrived, order. Which state number is it in at the end?
Answer: state number
5. What is the best way out of a FAULT state on a delivery robot?
- Leave automatically after 5 seconds
- A deliberate reset event, accepted only when the fault cause is cleared
- Power-cycle the robot
Apply it
Write the full state × event table for the delivery robot (5 states, 6 events). Fill every cell with a target or 'ignore: reason'. Find at least one cell where 'ignore' would be unsafe and fix it.
Reflect
Which empty cell in your table surprised you most?
Test every arrow
Your state machine has 9 transitions. How many tests prove it works? (Hint: not 1, and not 1,000.)
Why it matters
A state machine is unusually testable: each transition is one small, checkable fact. Writing one test per arrow, plus the guard boundaries, catches most mistakes before the robot ever moves.
Goals
- Write a transition table as data and a test for each transition.
- Test guard boundaries on both sides of the threshold.
- Measure transition coverage of a test suite.
Predict
A guard says battery ≥ 30. Which battery values are the most valuable to test?
- 0 and 100
- 29 and 30
- 50 only
Write down your guess and your reason. The reveal is in the online lesson.
Discover
In the Code Lab, write the delivery robot's rules as a list of (state, event, guard, next) tuples and a step() function. Then write one assert per rule plus asserts at battery 29 and 30. Break one rule on purpose: does a test catch it?
What the interactive shows, in words
In the Code Lab, the rules are written as a list of tuples and a step function applies the first matching rule; tests assert the next state for each rule and for battery values 29 and 30.
Understand
Rules as data
Store transitions in a table (a list of tuples or a dictionary) instead of scattered if-statements. Then one generic step() function runs them, and the table itself can be printed, checked and tested.
Transition coverage
Transition coverage = transitions exercised by tests ÷ total transitions. Aim for 100 %: one test per arrow that starts in the source state, sends the event and checks the target. Add tests for important ignored events too, such as 'order while DRIVING does nothing'.
Boundaries and sequences
Test each guard on both sides of its threshold (29 and 30 for ≥ 30). Then add a few sequence tests that run realistic event chains, such as a full delivery, because some bugs only appear after the battery has changed.
Explain it another way: intuitive
Checking a train timetable: for every station and every departure, does the train go where the board says?
Explain it another way: technical
Unit tests per transition give transition coverage; boundary-value analysis covers guards; scenario tests cover paths. Together they are a cheap, strong test strategy for discrete logic.
Explain it another way: applied
Safety-related controllers are often required to show that every transition was exercised by a test, and code coverage tools can report it automatically.
Try these examples
Example 1
A suite has tests for 6 of the 7 delivery-robot transitions. What is its transition coverage, and which test is most likely missing?
The worked solution is in the online lesson.
Common mix-ups
100 % transition coverage proves the machine is correct.
✓ It proves every arrow was exercised, not that the arrows are the right ones. Reviews and scenario tests still matter.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Tests exercise 12 of a machine's 16 transitions. What is the transition coverage, in percent?
Answer: %
2. A guard is speed < 0.5 m/s. Which two test values check its boundary best?
- 0 and 1
- 0.49 and 0.5
- 0.25 and 0.75
3. A delivery robot starts in IDLE (state 0) with its battery at 45 %. Rules: IDLE(0) + order → DRIVING(1) if battery ≥ 30 %, else → CHARGING(3). DRIVING(1) + arrived → DELIVERING(2). DRIVING(1) + bump → FAULT(4). DELIVERING(2) + done → IDLE(0) and the battery drops by 20 %. CHARGING(3) + charged → IDLE(0) with the battery at 100 %. FAULT(4) + reset → IDLE(0). Any other event in any state is ignored. Events arrive in this order: done, done, order, arrived, order, bump. Which state number is it in at the end?
Answer: state number
4. Why store transitions in a table rather than nested if-statements?
- It runs faster
- The rules become data that can be printed, checked for completeness and tested one by one
- Python requires it
5. All single-transition tests pass, but the robot fails after its second delivery. Which test would have caught it?
- Another single-transition test
- A sequence test of two full deliveries, checking battery and state
- A test of the initial state
Apply it
Write a test suite with 100 % transition coverage for the delivery robot, plus boundary tests at 29 % and 30 % and one two-delivery sequence test. Report the coverage figure and one bug the tests caught when you broke a rule.
Reflect
Which test would you be most embarrassed to have skipped if the robot failed in public?
Week 30: Feedback control
This week you will
- Derive and use the steady-state error of proportional control, e = r/(1 + K·Kp).
- Measure rise time, overshoot, settling time and steady-state error, and tune PID to a specification.
- Explain what integral and derivative action add and what they cost, including windup.
Why P control always falls short
Turn the proportional gain up from 1 to 9 and the error shrinks from half the setpoint to a tenth. Why does it never reach zero?
Why it matters
Proportional control is the first controller everyone tries, and it nearly works. Understanding exactly why it leaves an error, and by how much, tells you when it is good enough and when you need something more.
Goals
- Derive the steady-state error of proportional control for a plant with static gain K.
- Calculate the gain needed to meet an error specification.
- Explain why higher gain is not a free fix.
Predict
A unit-gain plant under P control with Kp = 1 is asked to reach 1.0. Where does it settle?
- 1.0
- 0.5
- 0.0
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Choose P control on the first-order plant with gain 1. Try Kp = 1, 3 and 9 and read the final value each time. Compare with 1/(1 + Kp). Then double the plant gain: what happens to the error?
What the interactive shows, in words
In the feedback lab with P control on a unit-gain plant, the output settles at 0.5 for Kp = 1, 0.75 for Kp = 3 and 0.9 for Kp = 9, matching 1 − 1/(1 + Kp).
Understand
The error is doing a job
A P controller's output is proportional to the error. To hold a motor at speed, the motor needs a steady push; the only way P can provide one is to keep some error. That leftover is the steady-state error, e = r/(1 + K·Kp).
Designing to a spec
If the error must be within 2 % of r, set r/(1 + K·Kp) ≤ 0.02·r, so K·Kp ≥ 49. For a unit plant, Kp ≥ 49. That is a large gain, which leads to the next problem.
Why not just crank Kp?
High gain amplifies sensor noise into the motor command, can push the actuator into saturation, and on plants with more dynamics (a springy joint, a delay) causes overshoot and oscillation or even instability. Integral action removes steady-state error without needing enormous gain.
Explain it another way: intuitive
Holding a heavy door half-open against a spring: you only push when it starts to close. So it always sags a little before you push back hard enough.
Explain it another way: technical
The closed-loop DC gain of P control on a type-0 plant is K·Kp/(1 + K·Kp) < 1. Adding an integrator makes the loop type 1, giving zero steady-state error to a step.
Explain it another way: mathematical
e = r/(1 + K·Kp). Kp needed for error fraction f: Kp = (1/f − 1)/K. For f = 0.1, K = 1: Kp = 9. For f = 0.01: Kp = 99.
Explain it another way: applied
A cruise controller using P only would sit slightly below the set speed on a hill, and further below on a steeper one. Real cruise controllers add integral action for this reason.
Derivation: Steady-state error of P control
Controller: u = Kp·e, where e = r − y (setpoint minus output).
Plant at steady state: once nothing is changing, the output is just its static gain times its input, y = K·u.
Combine: y = K·Kp·e. Substitute into e = r − y to get e = r − K·Kp·e.
Collect the e terms: e·(1 + K·Kp) = r.
So e = r / (1 + K·Kp). For a unit plant (K = 1) and unit setpoint, e = 1/(1 + Kp).
e is zero only if Kp is infinite. Any finite gain leaves an error, because the controller needs a non-zero error to produce the non-zero push that holds the output up.
Try these examples
Example 1
K = 2, Kp = 4, r = 10. Find the steady-state error and final output.
The worked solution is in the online lesson.
Example 2
A unit plant must settle within 5 % of its setpoint. What Kp is needed?
The worked solution is in the online lesson.
Common mix-ups
Steady-state error means the controller is badly tuned.
✓ With P only, some error is built in: e = r/(1 + K·Kp). Tuning trades its size against noise and overshoot.Doubling Kp halves the error.
✓ The error goes as 1/(1 + K·Kp), so doubling Kp from 1 to 2 takes it from 1/2 to 1/3, not 1/4.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. A plant with static gain K = 1 is under proportional control with Kp = 5. The setpoint steps to r = 5. What is the steady-state error e = r − y once it settles?
Answer:
2. A plant with static gain K = 0.5 is under proportional control with Kp = 1. The setpoint steps to r = 2. What is the steady-state error e = r − y once it settles?
Answer:
3. A plant with static gain K = 2 must settle within 5 % of a setpoint r = 2 using proportional control only. What is the smallest Kp that achieves this?
Answer:
4. Why can a P controller never remove the steady-state error completely?
- Because the sensor is noisy
- Because its output is zero when the error is zero, but holding the setpoint needs a non-zero push
- Because the plant is too slow
5. Which is NOT a usual cost of raising Kp a lot?
- Amplified sensor noise in the command
- Actuator saturation
- Larger steady-state error
Apply it
In the feedback lab, find the smallest Kp that keeps the P-only error within 10 % on the first-order plant. Check it against the formula, then add sensor noise and describe what the high gain does to the control effort.
Reflect
In your own words: what job is the leftover error doing?
Reading a step response
Two controllers both reach the target. One gets there in 0.3 s but overshoots by 40 %; the other takes 2 s and never overshoots. Which is better?
Why it matters
'It works' is not a specification. Rise time, overshoot, settling time and steady-state error turn 'good control' into numbers that a customer can ask for and a test can check.
Goals
- Measure rise time, overshoot, settling time and steady-state error from a step response.
- Tune a PID controller on a simulated joint to meet a written specification.
- Calculate metrics for a P-controlled first-order plant from its parameters.
Predict
On a springy joint, you raise Kp in a P controller. What happens to overshoot?
- It falls
- It rises
- It stays the same
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Start with P only and find out why it cannot meet the spec. Then switch to PID and meet all three specs, changing one gain at a time. Record every setting you try in a table with its four metrics.
What the interactive shows, in words
The PID joint lab plots the joint angle against time for 8 seconds. With P only, the joint overshoots by over 50 % and settles below the setpoint. With PID gains around Kp 4, Ki 4, Kd 1, overshoot is near 1 %, settling under 1 second and steady-state error near zero. A table lists rise time, overshoot, settling time and steady-state error with pass or fail against the spec.
Understand
Four numbers for one curve
Rise time: how long the output takes to go from 10 % to 90 % of its final value. Overshoot: how far the peak passes the final value, as a percentage. Settling time: when the output enters and stays within a band (often ±2 %) of the final value. Steady-state error: setpoint minus final value.
First-order plants under P
A first-order plant (time constant τ) under P control behaves like a faster first-order system with τcl = τ/(1 + K·Kp). It never overshoots. Its rise time is τcl·ln 9 ≈ 2.2·τcl and its 2 % settling time τcl·ln 50 ≈ 3.9·τcl. Its final value is K·Kp/(1 + K·Kp).
Second-order plants ring
A springy joint is second-order. Its overshoot depends on its damping ratio ζ: overshoot ≈ exp(−πζ/√(1 − ζ²)) × 100 %. ζ = 0.25 gives about 44 %; ζ = 0.7 about 5 %. P gain makes it faster but less damped; derivative action adds damping.
Explain it another way: intuitive
Parking a car: rise time is how quickly you get near the space, overshoot is how far you roll past it, settling is when you stop shuffling, and steady-state error is how far from the kerb you end up.
Explain it another way: technical
Metrics are read from the response to a unit step. Rise and settling describe speed, overshoot describes damping, steady-state error describes accuracy. Specifications usually bound all of them at once because improving one often worsens another.
Explain it another way: mathematical
First-order with P: τcl = τ/(1 + Kp) for K = 1. τ = 1 s, Kp = 4: τcl = 0.2 s, rise ≈ 0.44 s, settling ≈ 0.78 s, final value 0.8.
Explain it another way: applied
Joint servos in robot arms are commissioned against exactly these numbers: overshoot limits protect the gripper and the part, settling time sets the cycle time.
Try these examples
Example 1
A logged step to 90° peaks at 99° and settles at 90°. Find the overshoot.
The worked solution is in the online lesson.
Common mix-ups
The fastest response is the best response.
✓ Speed usually costs overshoot, effort or noise sensitivity; 'best' means meeting the whole specification.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. A joint is commanded to 90°. The log shows it peaks at 91.8° and finally settles at 90°. What is the percentage overshoot?
Answer: %
2. A first-order plant (gain K = 1, time constant τ = 0.5 s) is under proportional control with Kp = 9 and a unit step setpoint. The closed loop is first-order with time constant τ/(1 + Kp). What is its 10–90 % rise time, in seconds? (Use rise time = τcl·ln 9 and 2 % settling = τcl·ln 50.)
Answer: s
3. A joint behaves like a second-order system with damping ratio ζ = 0.3. Using overshoot = exp(−π·ζ / √(1 − ζ²)) × 100 %, what percentage overshoot should a step produce?
Answer: %
4. A pick-and-place arm must not hit the part it is placing. Which metric matters most for that?
- Rise time
- Overshoot
- Steady-state error
5. In the PID joint lab, the response meets the error spec but rings for too long. Which change most directly helps?
- Increase Kd
- Increase Ki
- Remove the controller
6. Why do specifications bound several metrics at once?
- To make the job harder
- Because improving one metric (e.g. rise time) often worsens another (e.g. overshoot)
- Because they are all the same thing
Apply it
Find two different PID tunings that both pass the joint specification. Report all four metrics for each in a table and argue which you would ship, considering what the lab does not model (noise, torque limits).
Reflect
Which metric would a user of this joint notice first, and which would only an engineer notice?
What I and D buy, and what they cost
Integral action wipes out the lift's levelling error. So why do engineers sometimes switch it off while the lift is moving?
Why it matters
Every term in PID fixes one problem and creates another. An engineer who knows both sides can tune deliberately instead of twiddling knobs and hoping.
Goals
- Explain how integral action removes steady-state error and why it can add overshoot.
- Explain how derivative action adds damping and why it amplifies noise.
- Recognise integrator windup when an actuator saturates.
Predict
A lift motor is at full power for 4 seconds while the cabin accelerates, with a PI controller running. What happens to the integral term during those seconds?
- It stays small
- It keeps growing, because the error is large and the motor can't do more
- It resets itself
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Take six passengers from floor 0 to floor 7. First try P only and measure how far short of the floor it stops. Add integral action and measure again. Then look for overshoot at arrival and decide whether anti-windup helps.
What the interactive shows, in words
In the elevator build, P control stops the cabin a few millimetres short of the floor under load; adding integral action removes the shortfall but can cause a small overshoot at arrival, which anti-windup reduces.
Understand
Integral: memory of past error
The integral term adds up error over time. As long as any error remains, it keeps growing and keeps pushing, so it can supply the steady push P needed error for. Result: zero steady-state error to a step or a constant load. Cost: stored push takes time to unwind, so it tends to add overshoot and slow oscillation.
Derivative: a brake on fast change
The derivative term reacts to how fast the output is changing and pushes against rapid movement, like a shock absorber. It adds damping, reducing overshoot and ringing. Cost: differentiating a noisy signal amplifies the noise, so real controllers filter the derivative and often take it from the measurement rather than the error.
Windup
When the actuator saturates (full power), the error stays large and an unprotected integral grows far beyond anything useful. On arrival it overshoots badly. Anti-windup (for example, stopping integration while saturated) prevents this. Always check integral control with realistic actuator limits.
Explain it another way: intuitive
P is how hard you pull now, I is a grudge that grows the longer you're off target, D is caution when things move fast.
Explain it another way: technical
u = Kp·e + Ki·∫e dt − Kd·dy/dt. The integrator raises the loop type and removes step error; the derivative adds phase lead (damping). Saturation breaks the linear model, which is why windup protection is part of any practical PI or PID.
Explain it another way: applied
Lift, drone and process controllers almost always include anti-windup and derivative filtering; plain textbook PID rarely survives contact with real actuators.
Try these examples
Example 1
A P-only lift stops 12 mm short at 450 kg. With PI it reaches the floor but overshoots by 6 mm before settling. Which term caused each behaviour?
The worked solution is in the online lesson.
Common mix-ups
PID is always better than P.
✓ Each extra term adds tuning effort and risks (overshoot, noise, windup). P is fine when its steady-state error is within spec.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Which term removes a constant steady-state error?
- Proportional
- Integral
- Derivative
2. Why is derivative action often filtered?
- It is too slow
- Differentiating noise produces large, jumpy commands
- It removes steady-state error too well
3. What is integrator windup?
- The integral growing while the actuator is saturated, causing overshoot later
- The motor spinning backwards
- The derivative term getting too large
4. A joint behaves like a second-order system with damping ratio ζ = 0.4. Using overshoot = exp(−π·ζ / √(1 − ζ²)) × 100 %, what percentage overshoot should a step produce?
Answer: %
5. A plant with static gain K = 1 is under proportional control with Kp = 9. The setpoint steps to r = 1. What is the steady-state error e = r − y once it settles?
Answer:
Apply it
In BUILD Elevator Level 3, record the levelling error and arrival overshoot for P, PI and PI with anti-windup over three runs each. Present a table and say which you would ship and why.
Reflect
Which of the three terms do you trust least, and why?
UART: one wire, ten bits, one byte
There is no clock wire between your laptop and a GPS module, yet not a single bit gets lost. How does the receiver know when each bit starts?
Why it matters
Almost every microcontroller has a UART, and almost every debugging session starts with one: printing sensor values, talking to a GPS or Bluetooth module, flashing firmware. When the text comes out as garbage, the fix is nearly always in the frame: the wrong baud rate, the wrong parity, or a missing ground wire. Knowing the ten bits of a frame turns that garbage into a diagnosis.
Goals
- Draw a UART frame: idle high, start bit, 8 data bits least significant first, optional parity, stop bit.
- Convert a baud rate into bit time, frame time and maximum bytes per second.
- Decode a captured frame into a byte and its ASCII character, and check its parity.
Predict
A UART sends at 9600 baud (9600 bits per second). About how many bytes of text per second can it carry?
- 1200 bytes/s (9600 ÷ 8)
- 960 bytes/s
- 9600 bytes/s
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Pick the letter A (65) and look at the waveform: find the start bit and read the data bits from left to right. Then flip one data bit with parity off, then with even parity on. Which setting notices the damage?
What the interactive shows, in words
The UART diagram draws one frame as a square wave. For the letter A (65 = 0x41) with even parity the line reads, in time order: start 0, data 1 0 0 0 0 0 1 0, parity 0, stop 1. Choosing a byte updates the bits; choosing a data bit to flip inverts it and the readout reports the wrongly decoded byte and whether the parity check fails (it fails for any single flip when parity is on; with no parity the error is not noticed).
Understand
Asynchronous means no shared clock
A UART line rests high (idle). To send a byte, the transmitter pulls it low for one bit time: the start bit. The receiver sees that falling edge, waits half a bit, then samples once per bit time. Both sides must agree on the baud rate in advance; each keeps its own clock, so they only have to stay in step for one short frame before the next start bit lines them up again.
The frame, bit by bit
After the start bit come 8 data bits, least significant bit first, then an optional parity bit, then a stop bit (high) that returns the line to idle. The common format 8N1 means 8 data bits, no parity, 1 stop bit: 10 bits on the wire per byte. 8E1 adds an even-parity bit (11 bits). The letter A is 0x41 = 01000001, so the data bits go out as 1 0 0 0 0 0 1 0.
Parity: a one-bit alarm
With even parity the transmitter picks the parity bit so the total number of 1s in data + parity is even. 0x41 has two 1s, so its even-parity bit is 0. If noise flips any single bit, the count becomes odd and the receiver flags the frame. Two flipped bits cancel out and slip through, so parity detects errors but cannot correct them; real protocols add checksums on top.
When the text turns to garbage
A baud-rate mismatch makes the receiver sample in the wrong places, so bytes decode as nonsense or framing errors (no high stop bit where one was expected). Other usual suspects: transmit wired to transmit instead of crossing TX→RX, no shared ground, or a 5 V device talking to a 3.3 V input. UART voltage levels are a separate choice from the frame format.
Explain it another way: intuitive
It is like a starter's pistol at a race. Everyone is quiet (idle high), the pistol fires (start bit), and then the receiver counts: one, two, three… reading one bit on each beat. It only has to count accurately for ten beats before the next pistol shot resets everything.
Explain it another way: technical
A UART is a shift register plus a baud-rate generator. The receiver oversamples (often 16× the baud rate), detects the falling start edge, and samples each bit near its centre. Clock error between the two ends must stay under roughly half a bit across the whole frame, which for 10 bits means a few per cent at most.
Explain it another way: mathematical
Bit time T = 1/baud. Frame time = n·T for an n-bit frame (n = 10 for 8N1, 11 for 8E1 or 8N2). Maximum throughput = baud/n bytes per second. At 115200 baud 8N1: T ≈ 8.68 µs, frame ≈ 86.8 µs, throughput = 11 520 bytes/s.
Explain it another way: applied
A robot logging 20-byte sensor packets 100 times a second needs 2000 bytes/s. At 9600 baud 8N1 (960 bytes/s) the log falls behind; at 115200 baud (11 520 bytes/s) it uses about 17% of the link, leaving room for debug messages.
Derivation: From baud rate to bytes per second
One bit lasts T = 1/baud seconds. At 9600 baud, T = 1/9600 s ≈ 104.2 µs.
One 8N1 frame is 1 start + 8 data + 1 stop = 10 bits, so it lasts 10·T ≈ 1.042 ms.
Back to back with no idle gaps, frames per second = 1/(10·T) = baud/10 = 960.
Each frame carries one data byte, so the maximum data rate is 960 bytes/s. In general: bytes/s = baud ÷ (bits per frame).
Try these examples
Example 1
A logic analyser shows, after the start bit, the data bits 0 0 1 0 1 1 0 0 (first to last). What byte is it?
The worked solution is in the online lesson.
Example 2
How long does one 8E1 frame take at 115200 baud?
The worked solution is in the online lesson.
Common mix-ups
Baud rate ÷ 8 gives bytes per second.
✓ Divide by the frame length: 10 bits for 8N1, so 9600 baud carries 960 bytes/s, not 1200.Bytes are sent most significant bit first, just as we write them.
✓ UART sends the least significant bit first; I²C and most SPI devices send the most significant bit first.Parity can fix a corrupted byte.
✓ Parity only detects an odd number of flipped bits. It cannot tell which bit flipped, and two flips go unnoticed.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. What level does a UART transmit line sit at when nothing is being sent?
- Low (0)
- High (1)
- It toggles at the baud rate
2. After the start bit, a UART frame carries the data bits 0 0 1 0 1 1 0 0 (first to last, least significant bit first). What byte value is that, in decimal?
Answer:
3. A UART uses even parity. What parity bit goes with the data byte 0x07 (00000111)?
- 0
- 1
- It depends on the baud rate
4. At 9600 baud with 8N1 framing and no gaps, what is the maximum data rate, in bytes per second?
Answer: bytes/s
5. Your microcontroller prints readable text in one terminal but random symbols in another. What is the most likely difference?
- The second terminal uses a different baud rate
- The second terminal has a faster computer
- The cable is too short
6. A UART runs at 115200 baud with 1 start bit, 8 data bits, an even parity bit, 1 stop bit per frame. How long does one frame take, in microseconds? (1 decimal place)
Answer: µs
7. A logic analyser captures one 8N1 UART frame. After the start bit, the 8 data bits arrive in this order (first to last): 1 0 0 0 1 0 1 0. UART sends the least significant bit first. What byte value was sent, in decimal?
Answer:
8. A sensor streams bytes back to back over a UART at 19200 baud, using 1 start bit, 8 data bits, an even parity bit, 1 stop bit. At most how many data bytes per second can it send? (nearest whole byte)
Answer: bytes/s
Apply it
Design the UART link for a weather station that sends a 32-byte packet every 0.1 s. Choose the slowest standard baud rate (9600, 19200, 38400, 57600, 115200) that uses under half the link with 8N1, and show the numbers. Then add even parity: does your choice still work?
Reflect
Why can a UART work with no clock wire at all, and what would go wrong if one end's clock drifted by 10%?
I²C: decoding a bus conversation
Twenty sensors share the same two wires, and none of them talk over each other. Who decides who speaks, and how does a sensor say “got it”?
Why it matters
Temperature sensors, IMUs, real-time clocks and small displays almost all speak I²C, because it needs only two wires for a whole bus of devices. When a sensor “isn't found”, the answer is in the capture: the address byte, and whether anyone pulled SDA low to acknowledge it. Reading a bus capture bit by bit is the core skill of embedded debugging.
Goals
- Explain why I²C uses open-drain lines with pull-up resistors.
- Build the address byte from a 7-bit address and the R/W bit, and read ACK and NACK.
- Decode a captured register-read transaction byte by byte and estimate how long it takes.
Predict
A datasheet says a sensor's I²C address is 0x48. A logic analyser shows the first byte after START is 0x90. What has gone wrong?
- The sensor is broken
- Nothing: 0x90 is 0x48 shifted left with the write bit (0) added
- The bus is running at the wrong speed
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Leave the address at 0x48 and step through the register read one byte at a time. Watch the 9th bit of each byte: who drives it, and why is the very last one different?
What the interactive shows, in words
The I²C diagram lists a register read from address 0x48, register 0x00, with sample data 0x1A and 0xC3: byte 1 address+W 0x90 ACK by target; byte 2 register 0x00 ACK by target; byte 3 address+R 0x91 ACK by target; byte 4 data 0x1A ACK by controller; byte 5 data 0xC3 NACK by controller, then STOP. Each step shows the 8 SDA bits most significant first and the 9th acknowledge bit. The readout totals 45 clocks: 450 µs at 100 kHz and 112.5 µs at 400 kHz.
Understand
Two wires, pulled up
I²C has SCL (clock, driven by the controller) and SDA (data). Devices never drive a line high: they can only pull it low or let go (open drain). Pull-up resistors bring released lines back high. So two devices can never fight, one pushing high and one low; at worst both pull low. It also means a 0 is a definite act, which is why the acknowledge is a 0.
Start, address, acknowledge
A transaction begins with START: SDA falls while SCL is high (data normally changes only while SCL is low). Then the controller sends the address byte: 7 address bits, MSB first, plus R/W (0 = write, 1 = read). On the 9th clock it releases SDA; the device with that address pulls it low: ACK. If nobody does, SDA stays high: NACK, meaning no such device (or it is busy).
Reading a register
Most sensors keep values in numbered registers. A register read is: START, address+W, register index (target ACKs both), repeated START, address+R, then the target sends data bytes. Now the controller acknowledges: ACK means “send another”, and a NACK on the last byte means “that's enough”, followed by STOP (SDA rises while SCL is high).
Counting the time
Every byte costs 9 clocks: 8 data bits and the acknowledge. Reading 2 data bytes from a register is 5 bytes on the bus, so 45 clocks: 450 µs at standard mode (100 kHz) or 112.5 µs at fast mode (400 kHz), before counting the START, repeated START and STOP. The addressing overhead is why I²C suits small, occasional reads rather than streaming video.
Explain it another way: intuitive
It is a classroom with one teacher. The teacher calls a name (the address); only that pupil answers “here” (ACK). The teacher then asks a question (the register) and listens to the answer, nodding after each word until saying “thank you, that's all” (NACK and STOP).
Explain it another way: technical
I²C is synchronous, half duplex and multi-drop, with addressing in band. Clock stretching lets a slow target hold SCL low; multi-controller arbitration works because a controller that tries to send 1 but sees 0 knows it has lost. Pull-up value trades rise time against current: bus capacitance and the resistor form an RC that limits speed.
Explain it another way: mathematical
Address byte = (address << 1) | R/W, so 0x68 write → 0xD0 = 208 and read → 0xD1. Transaction time ≈ 9·N/f for N bytes at clock frequency f: N = 5, f = 400 kHz → 45 / 400 000 s = 112.5 µs.
Explain it another way: applied
An IMU at 0x68 read 1000 times a second for 14 bytes needs (3 + 14) × 9 = 153 clocks per read: 382.5 µs at 400 kHz, so about 38% of the bus. At 100 kHz (1.53 ms per read) it would not fit at all.
Derivation: How long a register read takes
List the bytes: address+W, register index, address+R (after the repeated START), then n data bytes: 3 + n bytes.
Each byte is 8 data clocks plus 1 acknowledge clock: 9 clocks per byte, so 9(3 + n) clocks.
One clock lasts 1/f. At 100 kHz that is 10 µs; at 400 kHz, 2.5 µs.
Time ≈ 9(3 + n)/f. For n = 2: 45 clocks → 450 µs at 100 kHz, 112.5 µs at 400 kHz (START/STOP conditions add a little more).
Try these examples
Example 1
A capture shows the first byte after START as SDA bits 1 1 0 1 0 0 0 1 (MSB first), then SDA low on the 9th clock. Decode it.
The worked solution is in the online lesson.
Example 2
After sending address 0x3C+W, SDA stays high on the 9th clock. What does it mean and what would you check?
The worked solution is in the online lesson.
Common mix-ups
The address byte on the wire is the 7-bit address itself.
✓ It is the address shifted left with R/W in the lowest bit, so 0x48 appears as 0x90 (write) or 0x91 (read).I²C devices drive the data line high and low like any output.
✓ They only pull low or let go; pull-up resistors make the highs. That is what makes sharing the bus safe.A NACK always means an error.
✓ A NACK after the address usually means no device; a NACK on the last byte of a read is the normal way to finish.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. A controller starts an I²C read from the device with 7-bit address 0x4E. The first byte on SDA is the address followed by the R/W bit (1 = read, 0 = write). What is that byte's value, in decimal?
Answer:
2. During the acknowledge clock, what does the receiving device do to say ACK?
- Drives SDA high
- Pulls SDA low
- Stops the clock
3. What is the address byte, in decimal, for writing to an I²C device at 7-bit address 0x68?
Answer:
4. In a multi-byte read, the controller answers the final data byte with a NACK. Why?
- The data was corrupted
- To tell the target to stop sending before the STOP condition
- Because the target sends the acknowledge on reads
5. A register read of 2 data bytes is 5 bytes on the bus at 9 clocks each. How long does it take at 400 kHz, in microseconds, ignoring START and STOP?
Answer: µs
6. A controller reads 4 data bytes from a sensor register over I²C at 400 kHz: address byte (write), register index, repeated start, address byte (read), then the data. Count 9 clock cycles per byte (8 bits + ACK) and ignore the start, stop and repeated-start conditions. How long does the transaction take, in microseconds? (1 decimal place)
Answer: µs
Apply it
Your robot reads a temperature sensor (2 data bytes) and an IMU (14 data bytes) on the same 400 kHz bus, each 200 times a second. Using 9 clocks per byte and the register-read pattern, what fraction of the bus time is used? Would 100 kHz still work?
Reflect
Why does it matter that an I²C device can only pull a line low? Describe what could happen on a shared bus if devices could also drive it high.
SPI: swapping bytes at full speed
A tiny colour screen needs over a megabyte every second. Which bus can keep up, and why does reading from it mean sending something too?
Why it matters
Displays, SD cards, fast ADCs and radio chips use SPI because it is simple and fast: no addresses, no acknowledges, no start or stop bits, just one bit per clock in each direction. The price is pins. Picking the right bus for each part of a robot is a real design decision you will make on every board.
Goals
- Name the four SPI signals and explain the shift-register exchange on every clock.
- Calculate SPI transfer time and data rate from the clock frequency.
- Choose between UART, I²C and SPI for a given device, data rate and pin budget.
Predict
A controller wants to read one byte from an SPI sensor. What must it do on MOSI while the byte arrives on MISO?
- Nothing: MOSI stays idle
- Send a byte too, often a dummy 0x00
- Send the sensor's address
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Set the controller to 0x9F and the peripheral to 0x3C. Clock once at a time and watch both registers. After how many clocks have the two bytes completely swapped places?
What the interactive shows, in words
The SPI diagram shows two 8-bit registers. Starting with the controller holding 0x9F (10011111) and the peripheral holding 0x3C (00111100), each press of Clock once shifts both registers left by one: the controller's top bit goes into the peripheral's bottom bit over MOSI and the peripheral's top bit goes into the controller's bottom bit over MISO. After 8 clocks the controller holds 0x3C and the peripheral holds 0x9F: the bytes have swapped.
Understand
Four wires, one conversation at a time
SCLK is the clock from the controller. MOSI (controller out, peripheral in) and MISO (controller in, peripheral out) carry data. CS (chip select, active low) picks which peripheral is listening: each peripheral normally gets its own CS line, so four devices need four CS pins. There are no addresses: pulling a CS low is the address.
Two shift registers in a ring
Inside, the controller and the peripheral each hold an 8-bit shift register, joined in a ring by MOSI and MISO. On each clock, each side shifts its most significant bit out and takes the other side's bit in. After 8 clocks the bytes have swapped. That is why SPI is full duplex, and why reading always means writing something.
Modes: when to sample
Devices differ on the clock's idle level (CPOL) and on which edge data is sampled (CPHA), giving modes 0–3. Mode 0 (clock idles low, sample on the rising edge) is the most common. Controller and peripheral must use the same mode, or every bit is read half a clock off. The datasheet always states it; check it before blaming the wiring.
Choosing a bus
UART: 2 wires, point to point, no clock; 115200 baud 8N1 is about 11.5 kB/s. I²C: 2 wires shared by many addressed devices, acknowledged; 400 kHz gives at most about 44 kB/s before addressing overhead. SPI: 3 wires plus a CS per device, no addressing or acknowledge; 10 MHz moves 1.25 MB/s. Choose by data rate, number of devices and spare pins.
Explain it another way: intuitive
Picture two people passing notes along a looped conveyor belt. Each time the belt clicks forward, one letter leaves each person and one arrives. After eight clicks they have swapped whole words, even if one of them only wanted to listen.
Explain it another way: technical
SPI is synchronous and full duplex with no protocol layer: framing is defined by CS, word length by the device (8, 16 or more bits), and there is no acknowledge, so a missing device reads as all 1s or all 0s rather than an error. Speed is limited by trace length, the peripheral's maximum SCLK and MISO propagation delay.
Explain it another way: mathematical
One bit per clock: a burst of N bytes takes 8N/f. At f = 10 MHz, 3 bytes = 24 clocks = 2.4 µs, and the data rate is f/8 = 1.25 MB/s. Compare I²C at 400 kHz: at best f/9 ≈ 44 400 bytes/s.
Explain it another way: applied
A 240 × 240 display at 16 bits per pixel holds 115 200 bytes per frame. At an 8 MHz SPI clock (1 MB/s) one full frame takes about 0.115 s, so roughly 8 frames per second; drawing only the part of the screen that changed is how small gadgets feel smooth.
Derivation: SPI burst time and data rate
SPI moves one bit per clock edge pair and has no start, stop, parity or acknowledge bits.
So N bytes need exactly 8N clocks (with CS held low and no gaps).
One clock lasts 1/f, so the burst takes t = 8N/f. With f in MHz, t comes out in microseconds.
The maximum data rate is N/t = f/8 bytes per second: 8 MHz → 1 000 000 bytes/s.
Try these examples
Example 1
How long does it take to send 64 bytes to an SD card at 4 MHz?
The worked solution is in the online lesson.
Example 2
A board has 3 SPI peripherals and 1 I²C sensor. How many microcontroller pins do the buses use?
The worked solution is in the online lesson.
Common mix-ups
You can read from SPI without writing.
✓ Every clock shifts one bit each way; reading N bytes means sending N bytes (often dummies).SPI devices have addresses like I²C devices.
✓ SPI has none: the chip-select line picks the device, at the cost of one pin each.If the wiring is right, any SPI mode will work.
✓ Controller and peripheral must agree on CPOL and CPHA; the wrong mode shifts every bit by half a clock.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. In an 8-bit SPI transfer, how many clock cycles does it take for the controller's and peripheral's bytes to swap completely?
Answer:
2. Why does a controller send 0x00 on MOSI while reading a byte from an SPI sensor?
- To reset the sensor
- Because clocking 8 bits in always clocks 8 bits out
- To tell the sensor its address
3. What is the maximum SPI data rate at an 8 MHz clock, in bytes per second?
Answer: bytes/s
4. Which bus suits a colour display that needs about 1 MB/s, on a board with pins to spare?
- UART at 115200 baud
- I²C at 400 kHz
- SPI at 10 MHz
5. Four SPI peripherals share SCLK, MOSI and MISO, each with its own chip select. How many microcontroller pins does the SPI bus use?
Answer:
6. A microcontroller clocks 43 bytes out of an SPI port at 10 MHz with chip select held low throughout and no gaps between bytes. How long does the burst take, in microseconds? (2 decimal places)
Answer: µs
Apply it
Plan the buses for a rover with a GPS (UART, 9600 baud), an IMU and a barometer (I²C), and a 160 × 128 colour display at 16 bits per pixel. How long does one full display frame take over SPI at 8 MHz, and how many pins do all the buses use together?
Reflect
SPI is faster and simpler than I²C, so why does I²C still exist? Give two situations where you would choose it anyway.
Week 31: System integration
This week you will
- Specify the interface between two subsystems: data, units, frame, rate and timing.
- Add up a sense-to-act latency budget and compare it with a deadline.
- Plan an incremental integration and diagnose a fault caused by mismatched timing or units.
Interface contracts
A lidar says the wall is 0.4 away. The safety monitor reads 0.4 too, and slams the brakes. Both programs are correct. What went wrong?
Why it matters
Interface faults are the classic integration bug: nothing crashes, every unit test passes, and the robot still does the wrong thing. A written contract for each signal is the cheapest prevention there is.
Goals
- Specify an interface between two subsystems: signal, unit, frame, rate and timing.
- Diagnose a fault caused by mismatched units, rates or frames from its symptoms.
Predict
A producer publishes data at 50 Hz; the consumer runs at 200 Hz and uses the latest value. What does the consumer see?
- Fresh data every cycle
- The same value reused for about four cycles in a row
- An error message
Write down your guess and your reason. The reveal is in the online lesson.
Discover
For each link, compare what is sent with what is expected and read the symptom. Tick every mismatch before checking. Which symptom gave the clearest clue?
What the interactive shows, in words
The integration-bug finder lists four links. Lidar to emergency stop: sent in metres, expected in millimetres, a unit mismatch. Odometry to planner: odom frame used as map frame, a frame mismatch. IMU to balance loop: 50 Hz published, 200 Hz expected, a rate mismatch. Encoders to dashboard: no mismatch.
Understand
What a contract says
For every signal crossing between subsystems, write: name and meaning, unit, coordinate frame (robot, odom, map, camera), rate (how often), latency (how old it may be when used), range and what an invalid value looks like. Both teams sign up to the same text.
Three silent mismatches
Units: metres read as millimetres is a factor of 1000. Frames: a pose in the odometry frame used as if in the map frame drifts once the two frames separate. Rates: a slow producer starves a fast consumer, which then reuses stale data. None of these raises an error by itself.
Make the contract checkable
Put units in names (range_m), stamp every message with time and frame, and add integration tests that send a known value across the link and check what arrives. A runtime check that rejects data older than its latency limit turns a silent fault into a loud one.
Explain it another way: intuitive
Two people building a bridge from opposite banks must agree on where they will meet, in the same units, before they start.
Explain it another way: technical
Interface control documents (or message definitions with typed fields, units and frame ids) are the contract; middleware timestamps and frame identifiers let consumers verify freshness and frame at runtime.
Explain it another way: applied
Robot software frameworks commonly attach a timestamp and a frame id to each message for exactly these reasons. A famous spacecraft loss was traced to one team using imperial units where another expected metric.
Try these examples
Example 1
Write a contract for an IMU tilt signal used by a balance loop.
The worked solution is in the online lesson.
Common mix-ups
If two programs exchange numbers without errors, the interface is fine.
✓ Units, frames and timing are invisible to the computer unless you encode and check them.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. A planner's paths bend away from the map after each turn, though odometry looks fine on its own. Which mismatch is most likely?
- Unit
- Coordinate frame
- Rate
2. A tilt sensor publishes at 50 Hz and the balance loop runs at 200 Hz. On average, how many loop cycles use each tilt value?
Answer: cycles
3. A range of 0.4 m is read by code that expects millimetres. What distance does the code think the obstacle is at, in metres?
Answer: m
4. Which addition to a message most helps a consumer detect stale data at runtime?
- A longer variable name
- A timestamp of when it was measured
- A comment in the code
5. A robot's motor-current loop runs at 2000 Hz and its path planner at 10 Hz. How many current-loop updates happen between two planner updates?
Answer: updates
Apply it
Write interface contracts for three signals in your vacuum-cleaner block diagram from week 28. For each, describe the symptom you would expect if one field were wrong.
Reflect
Which field of a contract do you think teams forget most often?
The latency budget
At 1.5 m/s, a robot covers 9 cm in 60 ms. That is how far it travels after seeing an obstacle and before it even starts to brake.
Why it matters
A robot reacts to the world as it was, not as it is. Adding up every delay between sensing and acting tells you how stale that picture is, how fast the robot can safely move, and where to spend effort speeding things up.
Goals
- Add the latencies of a sense-to-act pipeline and compare the total with a deadline.
- Convert latency into distance travelled at a given speed.
- Decide which stage to optimise first.
Predict
A pipeline has five stages: 16, 30, 8, 2 and 10 ms. Which single change saves the most time?
- Halve the 2 ms bus message
- Halve the 30 ms vision stage
- Halve the 8 ms planner
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Start with the default stages and a 60 ms deadline. Raise the robot's speed and watch the reaction distance. Then set the deadline to 40 ms and get back within budget by changing as few stages as possible.
What the interactive shows, in words
The latency-budget lab shows five stages as a stacked bar against a dashed deadline line. Default stages add to 66 milliseconds, over a 60 millisecond deadline; at 1.5 metres per second that is about 10 centimetres travelled before reacting.
Understand
Latencies in series add
Sense-to-act latency is the sum of every stage: sensor exposure and readout, transfer, processing, planning, communication to the motor controller, and the actuator's own response. Slack = deadline − total. Negative slack means the robot cannot meet its reaction requirement.
Latency is distance
Distance travelled before reacting = speed × latency. At 1.5 m/s, 60 ms is 9 cm. A safety requirement such as 'stop within 30 cm of an obstacle' therefore limits speed, latency or both, and braking distance comes on top.
Jitter and margin
Real stages do not take the same time every cycle; some frames take much longer. Budget with worst-case or high-percentile timings and keep a margin, and timestamp data so a late result can be recognised rather than trusted.
Explain it another way: intuitive
A relay race: the team's time is the sum of every leg, and the slowest runner costs the most.
Explain it another way: technical
End-to-end latency is the sum of stage latencies along the critical path (plus waiting time when stages run at different rates). Design compares the worst case against the deadline derived from the safety case.
Explain it another way: mathematical
Total = Σ tᵢ. Slack = T_deadline − Σ tᵢ. Distance = v × Σ tᵢ. With 16 + 30 + 8 + 2 + 10 = 66 ms and a 60 ms deadline, slack = −6 ms.
Explain it another way: applied
Driver-assistance and mobile-robot teams budget camera-to-brake latency explicitly, because it directly sets the safe speed.
Try these examples
Example 1
Stages 12, 25, 5, 2, 6 ms; deadline 50 ms; speed 2 m/s. Find slack and reaction distance.
The worked solution is in the online lesson.
Common mix-ups
Making the fastest stage even faster is a good use of effort.
✓ Savings come from the largest stages; a 2 ms stage can save at most 2 ms.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. A robot must react to an obstacle within 60 ms. Camera exposure and readout take 16 ms, vision processing 10 ms, planning 8 ms, the message over the bus 4 ms and the motor driver 10 ms. How much slack is left, in ms? (Negative means over budget.)
Answer: ms
2. A robot must react to an obstacle within 100 ms. Camera exposure and readout take 8 ms, vision processing 40 ms, planning 2 ms, the message over the bus 1 ms and the motor driver 10 ms. How much slack is left, in ms? (Negative means over budget.)
Answer: ms
3. Total latency is 80 ms and the robot moves at 1.2 m/s. How far does it travel before it starts to react, in cm?
Answer: cm
4. You must cut 10 ms. Stages: camera 16, vision 30, plan 8, bus 2, motor 10. Where do you look first?
- Bus
- Vision
- Motor driver
5. Why budget with worst-case timings rather than averages?
- Averages are harder to compute
- A safety deadline must hold on the slow cycles too, not just typical ones
- Worst cases never happen
Apply it
For a robot that must stop within 25 cm of an obstacle with 15 cm of braking distance, find the maximum safe speed for your default latency budget. Then say which stage you would optimise to allow 50 % more speed.
Reflect
Where else in daily life does a delay turn directly into distance?
One connection at a time
Plug in five new subsystems at once and the rover drives in circles. Which of the five is to blame? You have no idea, and that is the problem.
Why it matters
Big-bang integration feels fast and is almost always slower. Adding one connection at a time, with a test that must pass before the next, turns 'something is wrong' into 'step 4 broke it'.
Goals
- Plan an incremental integration with a test at each step.
- Use stubs and recorded data to test a subsystem before its neighbours exist.
- Diagnose which integration step introduced a fault.
Predict
A rover's odometry, camera fix and Kalman filter are all new. What is the best order to integrate them?
- All three at once
- Odometry alone, then add camera fixes with fixed trust, then switch to the Kalman filter
- Kalman filter first, without any sensors
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Integrate in steps: run the route with no checkpoints, then with one checkpoint and fixed camera trust, then with three checkpoints, then switch to the Kalman filter. Record the final error after each step.
What the interactive shows, in words
In the rover build, final position error falls as checkpoints are added one at a time; the learner records the error after each integration step and investigates any step that makes it worse.
Understand
Integrate in increments
Order the connections so each step adds one subsystem or one link to a system that already works. Write the test for each step before you do it: what should improve, and by roughly how much? Do not move on until it passes.
Stubs and recordings
A stub stands in for a subsystem that is not ready: a fake planner that sends a fixed path, a fake sensor that replays recorded data. Stubs let each team test against the agreed interface early, and recorded data makes a test repeatable.
When a step fails
Undo the step, confirm the earlier state still passes, then re-add the new piece with more logging at its interface: units, timestamps, frames. Most failures at this point are contract mismatches, not bugs inside either subsystem.
Explain it another way: intuitive
Assembling flat-pack furniture and checking it is square after each panel, instead of finding at the end that the first panel was upside down.
Explain it another way: technical
Incremental integration with regression tests at each step localises faults to the most recent change. Hardware-in-the-loop and log replay let steps be tested without the full system.
Explain it another way: applied
Space and automotive projects plan integration as a sequence of milestones with test procedures, often building up from simulation, through hardware-in-the-loop, to full system tests.
Try these examples
Example 1
Rover final errors after each step: no checkpoints 6.1 m; one checkpoint 2.4 m; three checkpoints 0.9 m; Kalman filter 1.7 m. What do you conclude?
The worked solution is in the online lesson.
Common mix-ups
If a subsystem worked alone, any failure after integration is in the other subsystem.
✓ Most integration failures are in the connection: units, frames, timing or assumptions both sides made.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. In the worked example, which step should you investigate?
- Adding one checkpoint
- Adding three checkpoints
- Switching to the Kalman filter
2. What is a stub in integration testing?
- A broken subsystem
- A simple stand-in that obeys the interface so others can be tested early
- The last subsystem to be added
3. Why is integrating everything at once usually slower overall?
- The computer takes longer to compile
- When it fails, the fault could be in any connection, so diagnosis takes much longer
- It isn't slower
4. A robot must react to an obstacle within 80 ms. Camera exposure and readout take 12 ms, vision processing 25 ms, planning 10 ms, the message over the bus 4 ms and the motor driver 5 ms. How much slack is left, in ms? (Negative means over budget.)
Answer: ms
5. Why replay recorded sensor data when testing a new filter?
- Recordings are always more accurate
- The same input every time makes before-and-after comparisons fair and repeatable
- It saves battery
Apply it
Write an integration plan for your vacuum-cleaner robot with at least five steps. For each step, name the new connection, any stub used, and a test with a pass criterion.
Reflect
What would you log at an interface to make a failure easy to explain?
Week 32: Experimental design
This week you will
- Design a fair test with independent, dependent and controlled variables and a control condition.
- Choose a number of trials from the standard error, and use seeds and randomised order.
- Write a test plan before running.
Change one thing
You switch the lift to PI control and also lighten the cabin. Error halves. Was it the controller?
Why it matters
Robot results are easy to fool yourself with: a battery that charged overnight, a different floor, a new seed. A fair test isolates the one change you care about, so the result means what you say it means.
Goals
- Identify independent, dependent and controlled variables for a robotics experiment.
- Spot a confounding variable and redesign the test to remove it.
- Write a testable hypothesis with a measurable outcome.
Predict
In the hook, can you tell whether PI or the lighter cabin reduced the error?
- Yes, it was PI
- Yes, it was the load
- No: the two changes are confounded
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Pick a question, classify every variable, and choose trials and run order. Before checking, write one sentence: 'If I forgot to control ___, the result could be wrong because ___.'
What the interactive shows, in words
The experiment designer lists variables for two questions. For PI versus P in the lift: controller type is independent, levelling error is dependent, load, trip and seeds are controlled, door colour is irrelevant. For rover checkpoints: number of checkpoints is independent, final distance is dependent, route and camera trust are controlled.
Understand
Three kinds of variable
The independent variable is what you deliberately change (controller type). The dependent variable is what you measure (levelling error in mm). Controlled variables are everything else that could affect the result and is held fixed (load, trip, seeds). A control condition is the reference you compare against, often the current method.
Confounding
A confounder changes along with the independent variable and also affects the outcome. Changing controller and load together, or running all P trials in the morning and all PI trials after a firmware update, confounds the comparison. Fix it by holding the variable fixed or by varying it equally across conditions.
A testable hypothesis
'PI is better' is not testable. 'With a 450 kg load, PI reduces mean final levelling error compared with tuned P, over the same 10 seeds' names the change, the measure, the conditions and the comparison. It can clearly turn out false.
Explain it another way: intuitive
Testing whether a new trainer makes you faster: same track, same distance, same weather, and only the shoes change.
Explain it another way: technical
Experimental design manipulates the independent variable while controlling or randomising nuisance factors, so differences in the dependent variable can be attributed to the manipulation.
Explain it another way: applied
Robotics papers that compare controllers or planners usually fix the scenarios, seeds and hardware and change one component at a time.
Try these examples
Example 1
Question: does a median filter reduce false obstacle stops? Name the variables.
The worked solution is in the online lesson.
Common mix-ups
Changing several things at once is efficient.
✓ It saves runs but makes the result uninterpretable unless the design deliberately crosses the factors.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. In 'Does checkpoint spacing change the rover's final error?', what is the dependent variable?
- Checkpoint spacing
- Final position error
- The route
2. All baseline runs were done before lunch, all new-method runs after a battery swap. What is the problem?
- None
- Battery state is confounded with the method
- Too few runs
3. Which is a testable hypothesis?
- The new planner is smarter
- On the 5 test maps, the new planner's mean path length is shorter than the baseline's
- Planners are interesting
4. What is the control condition in a test of a new obstacle filter?
- The robot with no filter, or the current filter, under the same conditions
- A robot that does not move
- The best possible filter
5. Five trials of a robot's docking error gave 49, 44, 52, 51, 49 mm. What is the mean, in mm?
Answer: mm
Apply it
Write a one-paragraph test plan for comparing P and PI in the elevator build: hypothesis, independent, dependent and controlled variables, control condition, and number of trials.
Reflect
Which variable would you be most likely to forget to control in your own project?
How many runs is enough?
One run says the new filter halves the error. The next run says it makes things worse. How many runs before you believe either?
Why it matters
Noisy sensors and random disturbances mean any single run can mislead. Repeating trials estimates how much results wobble, and the standard error tells you how many runs you need before a difference stands out from the wobble.
Goals
- Report repeated trials as mean ± standard deviation with n.
- Use the standard error to choose a number of trials.
- Explain why seeds and randomised run order make trials fair and repeatable.
Predict
To halve the uncertainty (standard error) of a mean, how many more trials do you need?
- Twice as many
- Four times as many
- One more
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Run the fusion lab several times with the same settings but different noise. Note the final error each time, then compute the mean and SD of five runs by hand. Change the noise level and repeat: how does the SD change?
What the interactive shows, in words
In the fusion lab, repeating a run with different noise gives slightly different final errors; their standard deviation grows with the noise setting.
Understand
Mean ± SD, with n
Report repeated trials as mean ± standard deviation (n = …). The sample SD, √(Σ(x − x̄)²/(n − 1)), describes how much single runs vary. Always state n and whether the ± is SD or SE.
Standard error and sample size
The standard error SE = SD/√n describes how uncertain the mean is. To reach a target SE, you need n ≥ (SD/target)². Run a few pilot trials to estimate the SD, then choose n so the SE is small compared with the difference you care about.
Seeds and run order
In simulation, a seed fixes the random noise and disturbances, so a run can be repeated exactly and both methods can face identical conditions. On hardware, randomise the run order so drifts (battery, temperature, wear) spread across conditions instead of favouring one.
Explain it another way: intuitive
One coin toss tells you little about a coin; a hundred tell you a lot. Each extra toss helps a bit less than the last.
Explain it another way: technical
Sample means are themselves random; their spread shrinks as 1/√n. Seeded simulations remove nuisance variation between conditions (common random numbers), which makes comparisons much more sensitive.
Explain it another way: mathematical
Pilot SD = 4 cm, target SE = 1 cm: n ≥ (4/1)² = 16. Target 0.5 cm: n ≥ 64.
Explain it another way: applied
Simulation studies of controllers and planners typically run every method on the same list of seeds and report the mean and spread across them.
Try these examples
Example 1
Five docking errors: 12, 15, 11, 14, 13 mm. Report them.
The worked solution is in the online lesson.
Common mix-ups
More trials make the robot more consistent.
✓ More trials make your estimate of the mean more precise; the SD of single runs stays about the same.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Five trials of a robot's docking error gave 29, 35, 41, 41, 32 mm. What is the sample standard deviation (divide by n − 1), in mm?
Answer: mm
2. A metric has a sample standard deviation of 1.2 across n = 36 independent trials. What is the standard error of the mean?
Answer:
3. Pilot runs suggest a trial-to-trial standard deviation of 4 cm. How many trials do you need so the standard error of the mean is at most 1.5 cm? (Give the smallest whole number.)
Answer: trials
4. Why run both controllers on the same list of seeds?
- It is faster
- So both face identical noise and disturbances, and differences come from the controllers
- Seeds make the results better
5. Which number tells a user how much a single run of the robot will vary?
- Standard deviation
- Standard error
- Number of trials
Apply it
Run five pilot trials of any lab or Build metric, compute mean ± SD, and use it to choose n for an SE of one tenth of the mean. State whether that n is affordable.
Reflect
When would you accept fewer trials than the formula suggests?
Write the plan before the runs
After 40 runs you notice the new sorter wins on accuracy but loses on throughput. Which metric were you testing?
Why it matters
Deciding what counts as success after you see the data is the easiest way to fool yourself, and others. A short plan written first protects the result and makes the report half-written already.
Goals
- Write a test plan with question, hypothesis, metrics, conditions, trials and analysis before running.
- Explain how choosing metrics after seeing results biases a comparison.
Predict
You test 6 metrics and report only the one where your method won. What is the risk?
- None, it's still true
- Readers believe a general advantage that may be luck or cherry-picking
- The report is too short
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Read the Level 5 investigation task. Before touching any setting, write a one-page test plan: question, hypothesis, primary metric, conditions held fixed, number of runs, and how you will compare results.
What the interactive shows, in words
The sorting-machine Level 5 task asks for an investigation changing one setting across recorded runs; this lesson asks for a written test plan before any run.
Understand
What goes in a test plan
Question and hypothesis. Primary metric (one) and secondary metrics. Conditions: what changes, what is held fixed, seeds. Trials: how many per condition, and why. Analysis: what you will compute (mean ± SD, difference, effect size) and what result would count as support. Stopping rule: when you stop collecting.
Why first?
Choosing the metric, the seeds or the number of trials after peeking at results lets chance pick your conclusion. Writing them first, dated, makes the test honest. You can still explore afterwards; just label exploration as exploration.
Plans can change, openly
If you discover the plan was wrong (a metric is broken), change it, note the change and the reason in the report, and say which results came before and after.
Explain it another way: intuitive
Calling your shot in pool: naming the pocket before you hit makes the shot count.
Explain it another way: technical
Pre-specifying hypotheses, primary outcomes and analysis controls the false-positive rate that grows with every extra comparison or flexible decision.
Explain it another way: applied
Clinical trials register their primary outcome publicly before starting; engineering verification plans name pass criteria before testing for the same reason.
Try these examples
Example 1
Write a primary metric for 'does majority voting help the sorter survive a lying sensor?'
The worked solution is in the online lesson.
Common mix-ups
Planning in advance is only for big research projects.
✓ A half-page plan takes ten minutes and protects even a small Build investigation from self-deception.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Which belongs in a test plan written before the runs?
- The results table
- The primary metric and how it will be compared
- The discussion of why it worked
2. Why name one primary metric?
- Reports have limited space
- Testing many metrics and picking the best-looking one makes chance wins look real
- Secondary metrics are always useless
3. Halfway through, you realise your metric ignores jammed parts. What should you do?
- Quietly switch metrics
- Change it, record the change and the reason, and report both
- Keep the broken metric
4. Pilot runs suggest a trial-to-trial standard deviation of 4 cm. How many trials do you need so the standard error of the mean is at most 1.5 cm? (Give the smallest whole number.)
Answer: trials
5. A metric has a sample standard deviation of 4.5 across n = 16 independent trials. What is the standard error of the mean?
Answer:
Apply it
Write and date a test plan for this term's controller comparison project before running anything. Keep it unchanged; you will check your report against it in week 35.
Reflect
Which decision in your plan was hardest to make before seeing data?
Week 33: Baseline comparisons
This week you will
- Explain why a result needs a baseline and choose a strong, fair one.
- Give the baseline the same effort, information and conditions as the proposed method.
- Use an ablation to find which components matter.
Better than what?
'Our controller has an error of 0.86.' Is that good? You cannot know until someone tells you what the old one scored.
Why it matters
A number alone means nothing; a number next to a strong baseline means a lot. Baselines are how engineers find out whether the clever new method is worth its complexity.
Goals
- Explain why a result needs a baseline.
- Compare a new method with a baseline over repeated seeded trials.
- Calculate percentage improvement and an effect size.
Predict
The new PI method beats an untuned P baseline (Kp = 1) by about 85 %. What happens to the improvement against a properly tuned P baseline?
- It stays about 85 %
- It gets much smaller
- PI loses
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Run 10 trials against the untuned baseline, then the tuned one. Record improvement and d for each. Then untick 'same seeds' and draw new seeds several times: what happens to the comparison?
What the interactive shows, in words
The baseline lab runs 3 to 20 seeded trials of a speed loop. Against an untuned P controller the PI method's error is about 85 % lower; against a tuned P controller about 50 % lower. Results are shown as a dot plot and as mean plus or minus standard deviation, difference, percentage improvement and effect size.
Understand
Why baselines
A baseline is a reference method run under exactly the same conditions: the current method, the simplest reasonable method, or the standard one in the field. Without it, no one can tell whether 0.86 is excellent or terrible for this task.
Same conditions, many trials
Run baseline and method on the same seeds, scenarios and metric, with enough trials to see past the noise. Report both as mean ± SD with n, then the difference, the percentage improvement (baseline − method)/baseline × 100 for lower-is-better metrics, and an effect size d = difference / pooled SD.
Reading d
d says how big the difference is compared with run-to-run spread. Rough guide: 0.2 small, 0.5 medium, 0.8 or more large. A large d with a tiny practical gain may still not be worth the complexity, so report both.
Explain it another way: intuitive
Saying you ran 100 m in 13 s means more when you add that last month you ran 14 s on the same track.
Explain it another way: technical
Paired comparisons on common seeds remove shared variation, so the difference is estimated more precisely than two separately measured means.
Explain it another way: mathematical
Tuned P: 1.79 ± 0.13; PI: 0.86 ± 0.09 (n = 10). Difference 0.93; improvement 0.93/1.79 ≈ 52 %; pooled SD ≈ 0.11, so d ≈ 8: far beyond the noise in this simulation.
Explain it another way: applied
In robotics papers, a method compared only against weak or untuned baselines is a common reason reviewers reject a claim.
Try these examples
Example 1
Baseline 40 mm, method 30 mm, both SD 5 mm. Improvement and d?
The worked solution is in the online lesson.
Common mix-ups
Beating any baseline proves a method is good.
✓ It proves it beats that baseline. A weak or untuned baseline proves very little.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. A baseline path follower has a mean tracking error of 40 mm. The new method has 38 mm under the same conditions. What is the percentage improvement (lower error is better)?
Answer: %
2. Over 10 seeded trials each, the baseline controller's settling time averaged 20 s and the new controller's 14 s. Both conditions have a standard deviation of 2 s, so the pooled SD is 2 s. What is the difference in means (baseline − new), in seconds?
Answer: s
3. Why is 'error 0.86' on its own not a result?
- It has too few digits
- Without a baseline on the same task, nobody can judge whether it is good
- Errors should be percentages
4. In the baseline lab, unticking 'same seeds' makes the comparison…
- More precise
- Noisier, because each method also gets different luck
- Unchanged
5. A method has d = 1.5 but saves only 0.2 mm on a task with a 5 mm tolerance and doubles the code size. What should the report say?
- Huge win, ship it
- The difference is consistent but probably not worth the complexity for this task
- d is wrong
Apply it
Using the baseline lab, write a three-row results table (untuned P, tuned P, PI) with mean ± SD over 10 seeds, then one sentence on which comparison is the fair one and why.
Reflect
Have you ever been impressed by a comparison that, looking back, had a weak baseline?
Give the baseline a fair fight
You spent three evenings tuning your new controller and three minutes on the old one. Your comparison is really measuring something else. What?
Why it matters
An unfair baseline is the most common way honest people produce misleading results. Treating the baseline as a real competitor is what makes a win mean something.
Goals
- Give a baseline the same tuning effort, information and conditions as the proposed method.
- Choose a strong, relevant baseline for a task.
Predict
Your new method was tuned with a 50-point grid search; the baseline used default gains. What does a win show?
- The new method is better
- Possibly only that tuning helps
- Nothing at all
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Treat P as the baseline and PI as the new method on the first-order plant with noise and a load disturbance. Spend the same number of tries (say eight) tuning each against the same metric, then compare their best results.
What the interactive shows, in words
In the feedback lab, P and PI are each tuned with the same number of attempts on the same noisy, disturbed plant; their best results are then compared under identical settings.
Understand
Equal effort
Tune the baseline with the same method and budget as your own: the same number of trials, the same search range, the same metric. If you use an automatic tuner for one, use it for both. Report how each was tuned.
Equal information and conditions
Both methods get the same sensors, the same data, the same seeds and the same limits (actuator saturation, computing time). A method that secretly sees ground truth, or a larger budget, is not comparable.
A strong, relevant baseline
Choose what a competent engineer would actually use: the standard method in the field, or the current system. A 'straw man' baseline nobody would choose makes any method look good. Including a trivial baseline as well is fine, as a sanity check.
Explain it another way: intuitive
A race where one runner gets new spikes and three weeks of coaching tells you about coaching, not about the runner.
Explain it another way: technical
Unequal hyper-parameter tuning is a confound: tuning effort varies with the method. Matching tuning budgets removes it.
Explain it another way: applied
Benchmark studies increasingly publish tuning budgets and search spaces for every method, because unequal tuning has repeatedly been found to explain claimed improvements.
Try these examples
Example 1
Write one method sentence describing fair tuning for a P vs PI comparison.
The worked solution is in the online lesson.
Common mix-ups
A baseline is just there for comparison, so its settings don't matter much.
✓ The baseline's settings decide what your comparison means. Give it your best honest effort.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Which makes a baseline comparison unfair?
- Same seeds for both
- Tuning only the new method
- Reporting both methods' SD
2. The new planner uses a perfect map; the baseline uses the noisy lidar map. Fair?
- Yes
- No: they must get the same information
- Only if the new planner wins by a lot
3. Why tune on seeds 101–110 and compare on seeds 1–10?
- Lower seeds are harder
- So the final comparison isn't on the same runs the gains were fitted to
- No reason
4. A baseline path follower has a mean tracking error of 25 mm. The new method has 18.75 mm under the same conditions. What is the percentage improvement (lower error is better)?
Answer: %
5. Over 10 seeded trials each, the baseline controller's settling time averaged 40 s and the new controller's 36 s. Both conditions have a standard deviation of 2 s, so the pooled SD is 2 s. What is the effect size d = (difference in means) / pooled SD?
Answer:
Apply it
Repeat your P vs PI comparison with equal tuning budgets and separate tuning and test seeds. Report how much the improvement changed compared with your first, unequal attempt.
Reflect
What would you have to admit in your report if the fair baseline won?
Take it apart to see what matters
Your rover plan has checkpoints, a Kalman filter and a dust rule. It works brilliantly. Which of the three is doing the work?
Why it matters
Complex systems collect features. An ablation, switching off one component at a time, shows which ones actually help, which do nothing, and which only help in combination. It keeps designs simple and claims honest.
Goals
- Design an ablation study that removes one component at a time.
- Interpret ablation results to decide which components earn their place.
Predict
Removing the Kalman filter from a working rover plan barely changes the final error. What does that suggest?
- The Kalman filter is essential
- In this setting it adds little; checkpoints may be doing the work
- The test is broken
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Start from a plan that passes. Remove one component at a time (fewer checkpoints, fixed trust instead of Kalman, no re-imaging) with the route and sol fixed, and record the final error for each version. Restore each before removing the next.
What the interactive shows, in words
In the rover build's investigation level, the learner disables one plan component at a time with the route and sol fixed, records the final position error for each version, and compares them with the full plan.
Understand
What an ablation is
Start from the full system. Remove or disable one component at a time, keeping everything else identical, and measure the same metric. The drop in performance estimates that component's contribution in this setting.
Reading the table
A big drop: the component carries weight. No drop: it may be redundant here, a candidate for removal. A drop only when two components are removed together: they back each other up. Run each ablation over the same seeds with repeats, as for any comparison.
Ablation vs baseline
A baseline asks 'is my system better than the alternative?' An ablation asks 'why is it better?' Good reports have both: a strong baseline and an ablation table.
Explain it another way: intuitive
Taking one ingredient out of a recipe at a time to discover which one makes it taste good.
Explain it another way: technical
Ablations are one-factor-at-a-time experiments from the full configuration. Interactions show up when removing two components costs more (or less) than the sum of removing each.
Explain it another way: applied
Machine-learning and robotics papers often include an ablation table showing the full method and versions with each module removed.
Try these examples
Example 1
Full rover: 0.6 m. No re-imaging: 0.7 m. Fixed trust: 0.8 m. One checkpoint instead of three: 2.9 m. Interpret.
The worked solution is in the online lesson.
Common mix-ups
If removing a component doesn't hurt in one test, it is useless.
✓ It doesn't help in that condition. Test the conditions it was designed for before removing it.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. In the worked example, which component contributes most?
- Re-imaging
- Kalman filter
- Number of checkpoints
2. Why remove only one component at a time?
- It's quicker
- So any change in performance can be attributed to that component
- Removing two is not allowed
3. Full system error 1.2 mm; without the filter 1.8 mm. By what percentage does removing the filter increase the error?
Answer: %
4. Removing A alone or B alone barely changes the result, but removing both makes it much worse. What does that mean?
- Neither matters
- A and B back each other up: either is enough, but you need one
- The experiment failed
5. A baseline path follower has a mean tracking error of 50 mm. The new method has 40 mm under the same conditions. What is the percentage improvement (lower error is better)?
Answer: %
Apply it
Run a four-row ablation of your best rover plan (full, minus each of three components) on the same sol, with the final error for each. Write two sentences: which component earns its place, and which you would test further.
Reflect
Which part of a system you have built would you most like to ablate, and what do you expect?
Week 34: Quantitative evaluation
This week you will
- Choose metrics that match the real goal and avoid misleading proxies.
- Report mean ± SD with n, labelled error bars and an effect size.
- Report a comparison as a difference with its uncertainty, not just two averages.
Measure what you actually want
A lift controller cuts average trip time by 2 seconds. Passengers hate it. Which number did the engineers forget to measure?
Why it matters
Whatever you measure is what gets optimised. A metric that misses the real goal produces a system that scores well and works badly, so choosing metrics is a design decision, not paperwork.
Goals
- Choose metrics that match the real goal of a robotic system.
- Recognise a misleading proxy metric and what it hides.
- Combine a primary metric with constraints that must also hold.
Predict
A sorter is judged only on parts per minute. What will tuning for that metric alone tend to do?
- Improve accuracy too
- Run the belt faster until accuracy collapses
- Nothing
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Make one controller pass every check with empty, half-full and full cabins. Before you start, list the metrics the Build checks and say which real need each one stands for (safety, comfort, accuracy, time).
What the interactive shows, in words
The elevator Build's Level 4 checks one controller with empty, half-full and full cabins against levelling, comfort and safety limits all at once.
Understand
Start from the goal
Write the real goal in words ('passengers arrive quickly, comfortably and level with the floor'), then pick a metric for each part: trip time, peak jerk or acceleration, levelling error. A single number rarely captures a whole goal.
Proxies and their traps
A proxy is an easy-to-measure stand-in, like 'average speed' for 'trip time'. Proxies drift from the goal when optimised hard: average error can look fine while rare large errors cause crashes. Ask what a system could do to score well while failing the user.
Primary metric plus constraints
A practical pattern: one primary metric to compare methods, plus constraints that every method must satisfy (overshoot ≤ 10 %, accuracy ≥ 98 %, worst case within limits). Report worst cases or high percentiles, not only averages, wherever safety is involved.
Explain it another way: intuitive
Grading a cake only on height rewards a tall, raw cake. You need taste and 'cooked through' too.
Explain it another way: technical
Metrics should be valid (measure the intended property), reliable (repeatable), and sensitive to the differences that matter. Constrained optimisation formalises 'best primary metric among options that meet the constraints'.
Explain it another way: applied
The elevator Build checks levelling, comfort and safety at several loads at once, so a controller cannot win on one by sacrificing another.
Try these examples
Common mix-ups
One overall score is the clearest way to compare robots.
✓ A single score hides trade-offs. Use a primary metric with explicit constraints, and show the parts.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. In the hook, which metric was missing?
- Trip time
- Comfort (acceleration or jerk)
- Number of floors
2. Mean tracking error is low, but a robot occasionally swings 30 cm off its path near shelves. Which metric reveals this?
- Mean error
- Maximum (or 99th-percentile) error
- Number of runs
3. Which is best written as a constraint rather than the primary metric for a hospital robot?
- Deliveries per hour
- No contact with people
- Energy per delivery
4. A joint is commanded to 45°. The log shows it peaks at 57.6° and finally settles at 45°. What is the percentage overshoot?
Answer: %
5. A baseline path follower has a mean tracking error of 50 mm. The new method has 40 mm under the same conditions. What is the percentage improvement (lower error is better)?
Answer: %
Apply it
For your term project, write the goal in one sentence, then one primary metric and two constraints. For each, describe how a controller could game it if it stood alone.
Reflect
Think of a score in school or games that can be gamed. What would a better metric look like?
Error bars that tell the truth
Two bar charts show the same data. In one, method A looks five times better. In the other, you can barely tell them apart. Which one lies?
Why it matters
Most readers look at the chart, not the table. Honest charts show the spread, say what the bars mean and keep differences in proportion, so readers judge the evidence rather than the styling.
Goals
- Choose and label error bars (SD, SE or an interval) correctly.
- Spot a truncated axis and other ways a chart exaggerates a difference.
- Compute a difference of means and an effect size from summary statistics.
Predict
A chart's y-axis starts at 40, and the means are 52 and 49. How tall does A's bar look compared with B's?
- About 6 % taller
- About 33 % taller
- About the same
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Try each error bar type with 3, 8 and 30 trials. Then truncate the axis. Write down one chart setting that makes the difference look bigger and one that makes it look more honest.
What the interactive shows, in words
The error-bar explorer draws two bars with means near 52 and 49. Switching between standard deviation, standard error and two-standard-error bars changes their length; starting the axis at 40 makes the first bar look about a third taller although the means differ by about 6 %.
Understand
Which bar?
SD bars show the spread of single runs: what a user would experience. SE bars (SD/√n) show the uncertainty of each mean and shrink with more trials. ± 2 SE is a rough 95 % interval for larger n. All three are fine if labelled; unlabelled bars are useless.
Show the points
With fewer than about 20 trials per condition, plot every trial as a dot next to the bar. Readers can then see outliers, skew and overlap directly instead of trusting a summary.
Size of a difference
Report the difference in means, its uncertainty, and an effect size d = difference/pooled SD. With equal SDs s and a difference Δ, d = Δ/s. And start bar charts at zero: bar length is read as quantity, so a truncated axis misleads.
Explain it another way: intuitive
A photo taken from a low angle makes a person look tall. Truncated axes are the chart version.
Explain it another way: technical
Overlapping SE bars do not prove 'no difference', and non-overlapping SD bars are not required for one. Judge the difference against its own standard error, √(SE₁² + SE₂²).
Explain it another way: mathematical
Means 52 and 49, SD 6, n = 8: difference 3; SE of each mean 6/√8 ≈ 2.12; SE of difference ≈ 3.0; d = 3/6 = 0.5. A medium effect, but with n = 8 the difference is about one SE: not yet convincing.
Explain it another way: applied
Many journals now ask authors to show individual data points and state the error bar type in every caption.
Try these examples
Example 1
Baseline 30 ± 4 s, new 26 ± 4 s (mean ± SD, n = 16 each). Find the difference, d and the SE of the difference.
The worked solution is in the online lesson.
Common mix-ups
If error bars overlap, there is no difference.
✓ Overlap rules depend on which bars are drawn. Compare the difference with its own standard error.SE bars are more honest because they are smaller.
✓ They answer a different question. Choose the bar that matches your claim and label it.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Over 10 seeded trials each, the baseline controller's settling time averaged 30 s and the new controller's 28 s. Both conditions have a standard deviation of 5 s, so the pooled SD is 5 s. What is the effect size d = (difference in means) / pooled SD?
Answer:
2. Five trials of a robot's docking error gave 16, 8, 8, 16, 17 mm. What is the mean, in mm?
Answer: mm
3. A metric has a sample standard deviation of 2 across n = 16 independent trials. What is the standard error of the mean?
Answer:
4. A chart has error bars but no caption saying what they are. What can a reader conclude?
- They are SD
- They are SE
- Very little: SD and SE can differ by a factor of √n
5. Means are 80 and 76. The y-axis starts at 70. How many times taller does the first bar look than the second?
Answer: ×
Apply it
Make two charts of your baseline-lab results: one honest (zero-based axis, labelled SD bars, points shown) and one deliberately misleading. Write a caption for the honest one that a sceptic would accept.
Reflect
Which chart trick do you think you have fallen for before?
Report the difference, not two averages
'Baseline 1.79, new 0.86.' What's missing from that sentence that a sceptical reader would demand?
Why it matters
The question a reader really asks is 'how much better, and how sure are you?' Two bare averages answer neither. A difference with its uncertainty answers both.
Goals
- Compute the difference between two conditions with its standard error.
- Use paired seeded trials to compare methods per seed.
- Write a one-sentence comparison with metric, conditions, uncertainty and n.
Predict
Over 10 paired seeds, the new method wins on all 10. Over 10 different seeds per method, means differ by the same amount. Which is stronger evidence?
- The paired comparison
- The unpaired comparison
- They are identical
Write down your guess and your reason. The reveal is in the online lesson.
Discover
In the Code Lab, enter two lists of 10 per-seed results. Compute each mean and SD, the difference of means, its standard error √(SE₁² + SE₂²), the per-seed differences and their mean and SD. Compare the two uncertainties.
What the interactive shows, in words
In the Code Lab, two lists of per-seed results are summarised as means, standard deviations, the difference of means with its standard error, and the mean and standard deviation of the per-seed differences.
Understand
Difference ± uncertainty
For independent conditions: difference = x̄₁ − x̄₂, with SE = √(SE₁² + SE₂²). A difference of several SEs is unlikely to be luck; one of about one SE could easily be. Also give the percentage improvement relative to the baseline.
Paired trials
With shared seeds, compute the difference per seed, then its mean and SD. Because shared conditions cancel, these differences usually vary much less than either method alone, giving a tighter estimate. Also report how many seeds the new method won on.
The reporting sentence
Template: 'On [task and conditions], [method] reduced [metric] from [baseline mean ± SD] to [method mean ± SD] (n = …, same seeds), a difference of [Δ ± SE] ([%] improvement).' Everything a reader needs to check the claim is in one place.
Explain it another way: intuitive
Comparing two runners on the same day on the same track tells you more than comparing their times from different races.
Explain it another way: technical
The paired difference removes between-trial variance shared by both conditions (common random numbers). The paired t-test formalises this; at this level, the mean and SD of differences is enough.
Explain it another way: mathematical
Unpaired: SE₁ = 0.13/√10, SE₂ = 0.09/√10; SE of difference ≈ √(0.0017 + 0.0008) ≈ 0.05. Δ = 0.93 ≈ 18 SE: overwhelming in this simulation.
Explain it another way: applied
Simulation benchmarks increasingly report per-seed or per-scenario results so readers can see where a method wins and where it loses.
Try these examples
Example 1
Write the reporting sentence for the tuned-P vs PI lab results.
The worked solution is in the online lesson.
Common mix-ups
If the averages differ, the methods differ.
✓ Averages always differ a little by chance. Compare the difference with its uncertainty.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. A baseline path follower has a mean tracking error of 40 mm. The new method has 38 mm under the same conditions. What is the percentage improvement (lower error is better)?
Answer: %
2. Condition A has SE 0.3 and condition B has SE 0.4 (independent). What is the SE of the difference?
Answer:
3. Over 10 seeded trials each, the baseline controller's settling time averaged 24 s and the new controller's 19 s. Both conditions have a standard deviation of 5 s, so the pooled SD is 5 s. What is the effect size d = (difference in means) / pooled SD?
Answer:
4. Which sentence reports a comparison properly?
- The new method is 52 % better.
- On 10 shared seeds, IAE fell from 1.79 ± 0.13 to 0.86 ± 0.09 (mean ± SD), a 52 % reduction.
- The new method has an IAE of 0.86.
5. Why also report 'won on 9 of 10 seeds'?
- It sounds impressive
- It shows how consistent the advantage is across conditions, not just on average
- It replaces the mean
Apply it
Write the reporting sentence for your own P vs PI comparison, including per-seed wins. Swap with a partner and try to find anything missing from theirs.
Reflect
What would you need to see before you believed someone else's 'better'?
Week 35: Technical reporting
This week you will
- Structure a technical report and separate results from discussion.
- Scope every claim to the conditions tested, with its uncertainty.
- Record enough detail for someone else to reproduce the results, and state real limitations.
Where does each sentence go?
A reader has two minutes. They read the abstract, glance at one figure, and skip to the limitations. Can your report survive that?
Why it matters
Engineers read reports to make decisions quickly. A predictable structure lets them find the method to check, the results to trust and the limits to respect, without reading every word.
Goals
- Structure a technical report into abstract, introduction, method, results, discussion and limitations.
- Place sentences in the right section and explain why.
- Write an abstract that states question, method, result and limit.
Predict
Where does 'The integral term removes the offset caused by the constant load' belong?
- Results
- Discussion
- Method
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Sort every sentence into its section before checking. For any you get wrong, write the rule you broke in your own words.
What the interactive shows, in words
The report sorter lists eight sentences from an example report and six sections: abstract, introduction, method, results, discussion and limitations. Each sentence is placed in one section and checked.
Understand
The sections
Abstract: question, method, key result with numbers, main limit, in one paragraph. Introduction: why the problem matters and what exactly you asked. Method: enough detail to repeat it: setup, conditions, seeds, metrics, baseline tuning. Results: what happened, with uncertainty, tables and figures. Discussion: what it means and why. Limitations: where the conclusion may not hold.
Figures and tables
Each figure needs a caption that says what is plotted, what the error bars are and what n is, so it can be understood on its own. Tables of mean ± SD with n are often clearer than bar charts for a few conditions.
Write in the right order
Write the method and results first, while the details are fresh; then the discussion; then the introduction; the abstract last. Check the report against the test plan you wrote before the runs.
Explain it another way: intuitive
A recipe: what you'll make and why (intro), ingredients and steps (method), how it turned out (results), what you'd change (discussion and limits).
Explain it another way: technical
The IMRaD structure (introduction, method, results and discussion) is used across science and engineering because it separates claims from evidence and makes work auditable.
Explain it another way: applied
Engineering design reviews, test reports and research papers all use variants of this structure.
Try these examples
Example 1
Write a four-sentence abstract for a P vs PI lift study.
The worked solution is in the online lesson.
Common mix-ups
Results and discussion can be mixed so the report flows better.
✓ Keeping them apart lets readers check the evidence before your interpretation of it.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. 'Each controller ran on seeds 1–10 at 450 kg' belongs in…
- Introduction
- Method
- Discussion
2. Which sentence belongs in Results?
- PI is better because of its integral term.
- Mean error: P 8.1 ± 1.2 mm, PI 3.9 ± 0.8 mm (n = 10).
- Lifts must be accurate.
3. Which section is usually best written last?
- Method
- Results
- Abstract
4. Which is the best figure caption?
- Results.
- Figure 2: IAE per seed for tuned P (orange) and PI (blue); bars are means, n = 10 shared seeds.
- PI wins!
5. A baseline path follower has a mean tracking error of 50 mm. The new method has 40 mm under the same conditions. What is the percentage improvement (lower error is better)?
Answer: %
Apply it
Draft the skeleton of your term-project report: six headings, with two bullet points under each saying what will go there. Write the abstract last.
Reflect
Which section do you find hardest to write, and why?
Claims no wider than the evidence
'PI is the best controller for robots.' Your data: one simulated plant, two controllers, ten seeds. What can you actually say?
Why it matters
Overclaiming is rarely lying; it is enthusiasm leaking past the evidence. Readers who catch one overclaim stop trusting the rest, so careful wording protects your work.
Goals
- Judge whether a claim is supported, overclaimed or missing its uncertainty.
- Rewrite an overclaim so it matches the conditions tested.
Predict
Your PI won in simulation. Which claim can you make?
- PI will work better on the real robot
- In this simulation, PI had lower error than tuned P
- PI is always better than P
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Judge each claim against the results in the caption. For every overclaim, write a corrected version that you would be happy to defend.
What the interactive shows, in words
The claim checker lists six claims about a simulated comparison where tuned P had error 1.79 plus or minus 0.13 and PI 0.86 plus or minus 0.09 over 10 seeds. Each claim is judged supported, overclaim, or missing uncertainty, with an explanation.
Understand
Three checks for every claim
Is it within the conditions tested (plant, loads, seeds, simulation or hardware)? Does it carry its uncertainty and n? Does it compare against a named baseline? A claim failing any of these needs rewording or more evidence.
Hedging, done well
Good hedges are specific: 'in simulation', 'at 450 kg', 'for these 10 seeds', 'compared with tuned P'. Vague hedges ('might possibly suggest') add words but not information.
Interpretation is allowed
Discussion can offer explanations ('the integral term removes load-induced offset') and predictions ('we expect similar gains at other loads'), as long as they are labelled as explanation or expectation and point to how they could be tested.
Explain it another way: intuitive
If you've only tasted one apple from a tree, you can say that apple was sweet, not that the whole orchard is.
Explain it another way: technical
External validity (does it generalise?) is limited by the conditions sampled. Claims should be scoped to the population of conditions actually tested.
Explain it another way: applied
Product safety and performance claims are usually tied to stated test conditions for exactly this reason.
Try these examples
Common mix-ups
Careful wording makes a report sound weak.
✓ Scoped claims sound confident because they can be defended; overclaims collapse under one question.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. 'PI was 52 % better.' What is wrong?
- Nothing
- Missing the metric, baseline, uncertainty and n
- 52 % is too precise
2. Which is an overclaim from a simulation-only study?
- In simulation, PI had lower IAE than tuned P
- PI will reduce wear on the real motor
- PI won on all 10 shared seeds
3. Which hedge adds real information?
- This may possibly suggest an improvement
- At 450 kg load in simulation
- Results might vary
4. A baseline path follower has a mean tracking error of 25 mm. The new method has 18.75 mm under the same conditions. What is the percentage improvement (lower error is better)?
Answer: %
5. Over 10 seeded trials each, the baseline controller's settling time averaged 40 s and the new controller's 36 s. Both conditions have a standard deviation of 2 s, so the pooled SD is 2 s. What is the effect size d = (difference in means) / pooled SD?
Answer:
Apply it
Highlight every claim in your draft report. For each, mark the conditions, uncertainty and baseline. Rewrite any that miss one.
Reflect
Which overclaim in the checker was most tempting to accept, and why?
Could someone else get your numbers?
A classmate reruns your experiment from your report and gets a different answer. Whose fault is it, and how could the report have prevented it?
Why it matters
A result only one person can reproduce is fragile. Recording seeds, versions and settings costs minutes and lets anyone, including you in six months, check the work.
Goals
- Record the settings someone else needs to reproduce a simulated result.
- Write a limitations section that names real threats to the conclusion.
Predict
Which detail is most often missing when a simulated result can't be reproduced?
- The author's name
- The random seeds and exact parameter values
- The date
Write down your guess and your reason. The reveal is in the online lesson.
Discover
In the Code Lab, write a short script that runs a seeded experiment and prints a results table. Put every setting at the top as named constants. Run it twice and confirm identical output; then change the seed and see what changes.
What the interactive shows, in words
In the Code Lab, a seeded script with all settings as constants prints identical results on repeated runs and different results when the seed changes.
Understand
The reproducibility checklist
Record: simulator or lab and its version; every parameter (plant, gains, limits, noise); the seeds for tuning and for testing; the metric's exact definition; the number of trials; and the analysis steps. Keep settings in one place in the code and save raw per-trial results, not only summaries.
Honest limitations
Name the threats that could actually change the conclusion: simplified model (no friction or delay), one plant or load only, few trials, tuning budget, simulation versus hardware. For each, say what result might change and how it could be tested.
Limitations are not apologies
A good limitations section makes the conclusion stronger by showing you know where it ends. Avoid generic lines ('more research is needed') and avoid hiding the important limits in the middle of a paragraph.
Explain it another way: intuitive
Leaving a map of how you got somewhere, so someone else can follow the same path and check the view.
Explain it another way: technical
Deterministic seeded simulations make exact reproduction possible; recording environment versions guards against changes in libraries that alter numerics.
Explain it another way: applied
Research groups and companies increasingly publish code and configuration with results; some venues check that results can be rerun.
Try these examples
Example 1
Write two limitations for the baseline-trials lab comparison.
The worked solution is in the online lesson.
Common mix-ups
A limitations section admits the work is bad.
✓ It shows the reader exactly where the conclusion applies, which is what makes it usable.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Which record most helps someone reproduce a seeded simulation?
- A screenshot of the final plot
- The seeds, parameters and code version
- A description of how long it took
2. Which is the most useful limitation?
- More research is needed
- Only one load (450 kg) was tested; at full load the integral term may wind up more
- The author is a student
3. Why save per-trial results, not just means?
- To fill space
- So others can recompute the statistics, see outliers and make paired comparisons
- Means are less accurate
4. Five trials of a robot's docking error gave 22, 23, 26, 19, 22 mm. What is the sample standard deviation (divide by n − 1), in mm?
Answer: mm
5. A metric has a sample standard deviation of 4.5 across n = 16 independent trials. What is the standard error of the mean?
Answer:
Apply it
Ask a classmate to rerun one result from your report using only the report and your code. Note every question they had to ask you, and add the answers to the method section.
Reflect
What detail would you most likely forget to record?
Week 36: Integrated robotics showcase
This week you will
- Scope an integrated simulated system and its evaluation plan for the year capstone.
- Analyse failure modes and test a mitigation.
- Present the evaluation against alternatives and defend design choices and limitations under questioning.
Scope an integrated system you can evaluate
An arm that sees, reaches and grips sounds amazing. Can you test all of it fairly in the time you have? Scoping decides.
Why it matters
The year capstone asks for a whole system evaluated against alternatives. Projects fail most often from scope, not skill: a smaller system evaluated well beats a large one that never gets a fair test.
Goals
- Scope a capstone system that integrates perception, computation, movement and feedback.
- Draw its architecture with interfaces and choose a fair baseline and two alternatives.
- Write an evaluation plan with metrics fixed before testing.
Predict
Which capstone scope is most likely to produce a strong report?
- A full humanoid robot
- A mobile robot following a path with noisy sensors, comparing two controllers against a tuned baseline
- Testing every controller you can find
Write down your guess and your reason. The reveal is in the online lesson.
Discover
In the Robotics Workbench, sketch a candidate capstone system. Identify which part senses, which computes, which moves and where the feedback loop closes. Note which settings you would vary to compare alternatives.
What the interactive shows, in words
In the Robotics Workbench the learner identifies the sensing, computing, moving and feedback parts of a candidate system and the settings that would be varied to compare alternatives.
Understand
Capstone requirements, in practice
You need: an architecture diagram showing perception, computation, movement and feedback; a working simulation with tests; at least two alternatives compared on metrics chosen before testing; a fair baseline; results with uncertainty; failure modes and limitations; a report and a short presentation.
Scope to the evaluation
Pick a system where each alternative can be run many times under identical, seeded conditions. If one trial takes an hour, you cannot run enough of them. Prefer one integrated loop studied well over many features studied badly.
Write the plan now
Before building: architecture with interface contracts, the question, the primary metric and constraints, the baseline and how it will be tuned, the two alternatives, the number of trials and the seeds. Date it. You will compare your report against it.
Explain it another way: intuitive
Planning a trip: choose a destination you can actually reach in the time you have, and decide in advance how you'll know you got there.
Explain it another way: technical
Scoping trades system breadth against evaluation depth. Capstone assessment rewards evidence quality, so depth usually wins.
Explain it another way: applied
Engineering projects define verification plans alongside requirements so that what is built can be shown to work.
Try these examples
Example 1
Outline a scoped capstone using this term's labs.
The worked solution is in the online lesson.
Common mix-ups
A bigger system makes a better capstone.
✓ A focused system with fair, repeated evaluation and honest limits makes a better capstone.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Which part of a line-following rover closes the feedback loop?
- The battery
- The controller comparing measured position with the line and correcting steering
- The chassis
2. Your trials take 40 minutes each. What should you change?
- Run fewer trials
- Simplify the system or simulation so trials take seconds
- Skip the baseline
3. Pilot runs suggest a trial-to-trial standard deviation of 4 cm. How many trials do you need so the standard error of the mean is at most 1.5 cm? (Give the smallest whole number.)
Answer: trials
4. A robot must react to an obstacle within 80 ms. Camera exposure and readout take 12 ms, vision processing 25 ms, planning 10 ms, the message over the bus 4 ms and the motor driver 5 ms. How much slack is left, in ms? (Negative means over budget.)
Answer: ms
5. When should the capstone's primary metric be fixed?
- After seeing which alternative wins
- Before any comparison runs
- While writing the report
Apply it
Write a one-page capstone proposal: system, architecture sketch with three labelled interfaces, question, primary metric, constraints, baseline and tuning plan, two alternatives, trials and seeds. Date it.
Reflect
What would you cut from your first idea to make it testable?
How will it fail?
Glare makes one colour sensor lie on 30 % of parts. Your sorter's accuracy drops from 99 % to 70 %. Did you plan for that, or discover it?
Why it matters
Every integrated robot fails somehow. Engineers list the ways in advance, test the important ones on purpose, and design so that failures are detected and safe. The capstone asks for exactly this analysis.
Goals
- List failure modes of an integrated system, their effects and how to detect them.
- Test a mitigation and measure its effect.
Safety: All failure testing in this course happens in simulation or the browser Builds. Never induce faults in real powered machinery.
Predict
Majority voting across three colour sensors is added. One sensor lies. What happens?
- The lie wins
- The two honest sensors outvote it
- The sorter stops
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Make the sorter survive a lying sensor with a voting circuit. Before building it, write down which single failure it should survive and which double failure it will not.
What the interactive shows, in words
In the sorting-machine build's Level 4, a voting circuit of AND and OR gates combines three colour sensors so that one sensor reading wrongly on 30 % of parts is outvoted by the other two.
Understand
A failure-mode table
For each subsystem and interface, list: failure mode (sensor lies, message late, motor saturates), effect on the system, how it is detected, and mitigation. Rank by severity and likelihood; test the top few deliberately.
Detect, then make safe
A failure you cannot detect is the dangerous kind. Add checks: plausibility (is this reading possible?), freshness (timestamps), agreement between redundant sensors. On detection, move to a defined safe state, as in the FAULT state from week 29.
Measure mitigations
Treat a mitigation as a method to evaluate: compare with and without it, under the failure, over repeated trials, and also without the failure to check it doesn't cost too much in normal operation.
Explain it another way: intuitive
Packing for a hike: you think about what could go wrong (rain, a blister, getting lost) and bring something for the likely, serious ones.
Explain it another way: technical
Failure modes and effects analysis (FMEA) systematically links component failures to system effects, detection and mitigation; redundancy with voting masks single faults.
Explain it another way: applied
Aircraft and many industrial robots use redundant sensors and voting so that one failed sensor cannot cause an unsafe action.
Try these examples
Example 1
Fill one row of a failure table for a rover's camera fix.
The worked solution is in the online lesson.
Common mix-ups
If the robot passes its tests, it has no failure modes.
✓ Tests check the conditions you tried. A failure table finds conditions you haven't tried yet.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Which failure is most dangerous?
- One that stops the robot and raises an alarm
- One that gives wrong data with no sign anything is wrong
- One that slows the robot slightly
2. Three-sensor majority voting tolerates…
- Any single sensor failure
- Any two failures
- Any number of failures
3. Why also test a mitigation when nothing has failed?
- To check it doesn't harm normal performance
- It isn't necessary
- To make the report longer
4. A baseline path follower has a mean tracking error of 25 mm. The new method has 18.75 mm under the same conditions. What is the percentage improvement (lower error is better)?
Answer: %
5. A delivery robot starts in IDLE (state 0) with its battery at 70 %. Rules: IDLE(0) + order → DRIVING(1) if battery ≥ 30 %, else → CHARGING(3). DRIVING(1) + arrived → DELIVERING(2). DRIVING(1) + bump → FAULT(4). DELIVERING(2) + done → IDLE(0) and the battery drops by 20 %. CHARGING(3) + charged → IDLE(0) with the battery at 100 %. FAULT(4) + reset → IDLE(0). Any other event in any state is ignored. Events arrive in this order: order, done, arrived, arrived, arrived. Which state number is it in at the end?
Answer: state number
Apply it
Write a five-row failure table for your capstone system. Choose the most severe row, test a mitigation with and without the failure over repeated trials, and report the result.
Reflect
Which failure in your system would be hardest to detect, and how could you make it loud?
Present it, then defend it
A reviewer asks: 'Why should I believe your baseline was tuned fairly?' You have ten seconds. What do you say?
Why it matters
Engineering decisions are made in conversations, not just documents. Being able to show your evidence, admit limits and answer hard questions calmly is what makes others trust and use your work.
Goals
- Present an integrated system and its evaluation in a short, structured talk.
- Answer challenging questions with evidence from the method and results.
- Explain design trade-offs and limitations without overclaiming.
Predict
A reviewer asks a question you can't answer. What is the best response?
- Guess confidently
- Say you don't know, say what evidence would answer it, and offer to follow up
- Change the subject
Write down your guess and your reason. The reveal is in the online lesson.
Discover
Use the trade-offs lab to rehearse a defence: pick a design, then argue for it under two different weightings. Prepare one sentence for why a dominated design was rejected.
What the interactive shows, in words
In the trade-offs lab, different weightings of the criteria change which design scores highest, and some designs are dominated; the learner uses this to rehearse explaining and defending a choice.
Understand
A five-minute structure
One slide each: the problem and question; the architecture (with interfaces); the method (baseline, alternatives, metric fixed in advance, trials, seeds); the results (one honest chart with labelled error bars); limitations and what you'd do next. Leave time for questions.
Prepare for the hard questions
Rehearse answers to: How was the baseline tuned? Why this metric? How many trials, and why is that enough? What would change on real hardware? What is the biggest limitation? Each answer should point to something in your method or results.
Defending trade-offs
Explain what you optimised and what you gave up: 'PID settled faster but needs a filtered derivative and is noisier; for this task the faster settling mattered more.' Naming the cost shows you chose it deliberately.
Explain it another way: intuitive
Like explaining a decision to a friend who keeps asking 'but why?': every answer should rest on something you can show.
Explain it another way: technical
A design review tests whether the evidence supports the claims and whether the risks are understood. Answers grounded in method details carry weight; impressions don't.
Explain it another way: applied
Engineering teams hold design reviews before committing to build; presenters are expected to show evidence and known risks, not just successes.
Try these examples
Example 1
Answer: 'Why should I believe your baseline was tuned fairly?'
The worked solution is in the online lesson.
Common mix-ups
Admitting a limitation in a presentation makes the work look weak.
✓ Stating limitations clearly makes the rest of the claims more believable.
Practice questions
Questions only. Check your answers in the Lite lesson; they are graded on our server and nothing is saved.
1. Which answer to 'Is 10 trials enough?' is strongest?
- It felt like enough
- Pilot runs gave SD 0.13, so SE ≈ 0.04, small next to a 0.93 difference
- Everyone uses 10
2. Asked 'Would this work on a real motor?', the best answer is…
- Yes, definitely
- We tested only in simulation; friction and delay could reduce the advantage, and a hardware test with the same metric would check it
- That's not relevant
3. Which statement explains a trade-off well?
- PID is just better
- PID settled 40 % faster but its command was noisier; settling mattered more for this task
- We picked PID because it has more letters
4. Over 10 seeded trials each, the baseline controller's settling time averaged 24 s and the new controller's 18 s. Both conditions have a standard deviation of 8 s, so the pooled SD is 8 s. What is the effect size d = (difference in means) / pooled SD?
Answer:
5. A baseline path follower has a mean tracking error of 50 mm. The new method has 40 mm under the same conditions. What is the percentage improvement (lower error is better)?
Answer: %
Apply it
Give a five-minute presentation of your term project to a partner or group. They ask the five hard questions from this lesson; write down any you couldn't answer from your evidence, and fix the report.
Reflect
Which question are you most nervous about, and what evidence would make it easy?