TactivergeLite

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?

About 35 min · 2 goals · Checked by automated tests · Full interactive version

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.

Predict

A producer publishes data at 50 Hz; the consumer runs at 200 Hz and uses the latest value. What does the consumer see?

  1. Fresh data every cycle
  2. The same value reused for about four cycles in a row
  3. 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.

You can also open the interactive on the full site when you have a faster connection.

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

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

Practice 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?

cycles

m

Practice 4. Which addition to a message most helps a consumer detect stale data at runtime?

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?

Write your answer on paper or in your own notes. Lite never stores what you write.

← What I and D buy, and what they costThe latency budget →