# Week 3 — Sensing, noise, and state machines

DIS OpenLab · Foundations of Autonomous Systems · v0.1.0-prepilot · 2026-10-15
Track: deterministic sensor traces; optional Webots after native validation
License proposal: CC BY 4.0 for original text, pending rights review

## Learning objectives

Learners will distinguish raw response, normalized signal, and calibrated distance; identify noise and saturation; design a finite-state machine; use two thresholds to prevent rapid switching; and document false positives, false negatives, and sensor blind spots.

## Safety and truth boundary

An obstacle sensor is not a safety-rated people detector. A software stop does not make a mobile robot safe near stairs, roads, people, or unguarded edges. This lesson uses recorded or simulated signals. Any later physical trial requires an adult, barrier, low speed, manual isolation, and a site risk assessment.

## Session A — inspect the signal

The starter controller defines `obstacle_level` on 0..1, where 0 is clear and 1 is the strongest/nearest adapter response. It is deliberately not called metres.

Create or use a 30-sample trace containing:

- clear values around 0.05;
- three noisy values around the entry threshold 0.35;
- a sustained obstacle at 0.70;
- a clearing interval below the exit threshold 0.20;
- one impossible or missing value.

Plot on paper or with a spreadsheet. Mark `obstacle_enter`, `obstacle_exit`, and every mode transition.

## Session B — finite-state behavior

Draw states and transitions for:

```text
STOPPED -- valid + enabled --> FORWARD
FORWARD -- obstacle >= enter --> TURNING
TURNING -- hold time elapsed AND obstacle <= exit --> FORWARD
ANY -- disabled, invalid, or stale --> STOPPED
```

Run the unit tests and locate the test that proves the turn holds before exit. Add a new local test trace that touches exactly 0.35 and 0.20. Record the observed inclusivity of each comparison.

## Student lab sheet

| Sample | Signal 0..1 | Valid? | Previous state | Next state | Reason |
|---:|---:|---|---|---|---|
| 1 | | | | | |
| 2 | | | | | |
| … | | | | | |

State diagram reference: ______  Entry threshold: ______  Exit threshold: ______  Hold time: ______ s

Failure-case analysis:

| Case | Consequence | Detection/mitigation | Remaining limitation |
|---|---|---|---|
| Reflective surface | | | |
| Dark/absorbing surface | | | |
| Sensor disconnected/stale | | | |

## Required evidence

- labeled trace with thresholds and transitions;
- state diagram including invalid/stale/disabled stop paths;
- test output and exact code/config version;
- three failure cases with mitigations;
- statement that normalized signal is not metric distance.

## Instructor notes

Learners often respond to noise by adding an arbitrary delay. Ask what failure the delay addresses and what response time it sacrifices. Hysteresis gives different enter and exit thresholds; a hold time guarantees a minimum maneuver period. Neither proves collision avoidance.

Do not provide a “correct” threshold for unknown physical sensors. The threshold must be calibrated against the exact sensor, supply voltage, target surface, angle, ambient conditions, and speed.

## Offline/low-bandwidth activity

Print a sensor trace. Assign learners to act as the state machine, announcing transitions only when conditions are met. A second learner audits timestamp freshness. This activity produces valid reasoning evidence without Webots or hardware.

## Accessibility

Never rely on line color alone: label thresholds by name and use different dash patterns. Provide the trace as a numeric table. Learners may describe a state diagram as an ordered transition list.

## Exit ticket

Give one example where the rover should stop even though `obstacle_level` is low, and explain which independent condition causes that response.
