Lite / Intelligent Robotic Systems / Week 31
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 should I care?
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.
- 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
Guess first, then reveal
It reuses each value about four times. Nothing fails loudly; a control loop simply acts on stale information, which can make a balancing robot wobble.
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 (text version)
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.
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.
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.
Worked example 1
Write a contract for an IMU tilt signal used by a balance loop.
'tilt: pitch angle of the robot body, radians, robot frame, positive nose-up, published at ≥ 200 Hz, used within 5 ms of measurement, range ±π/2, NaN on sensor fault.'
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
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
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?
Write your answer on paper or in your own notes. Lite never stores what you write.