MTBuilder AcademyLearn it. Test it. Build it.
Systems & robotsLesson 44 of 48
Practice70 minutes2 project connections

Perception from measurements

Turn raw sensor values into bounded observations by calibrating thresholds, features, and confidence against environmental variation.

After this lesson, you can
  • Design a simple perception pipeline, calculate a threshold from labeled data, and identify false-positive and false-negative failure modes.
Print / Save PDF
ReadPracticedBench demonstrated
Related study — optional context
01

Understand

The working idea

A sensor produces measurements; perception turns them into claims about the world. A camera provides pixels, not “a cup.” A reflectance sensor produces voltage, not “the line.” The pipeline may include calibration, filtering, feature extraction, classification, and temporal validation. Each stage should preserve enough evidence to explain why the final claim was made.

For a one-dimensional detector, a threshold can classify values above τ as object present. Performance is summarized with true positives, false positives, true negatives, and false negatives. Precision = TP/(TP + FP) asks how often positive reports are correct; recall = TP/(TP + FN) asks how many actual positives were found. Changing τ trades these errors. The best threshold depends on consequences: a robot approaching a stair edge should prefer missed-edge risk differently from a screen auto-brightness feature reacting to shadows.

Calibration data must represent expected variation in distance, lighting, surface, and unit-to-unit differences. Suppose labeled reflectance readings for dark tape are 120–180 counts and floor readings are 360–470; τ = 270 leaves a margin in that small data set. It does not prove separation under sunlight or dust. A useful build decision is to store raw value alongside the Boolean detection and require three consecutive detections, making borderline behavior diagnosable while adding known latency.

A common misconception is that filtering creates missing information. Averaging can reduce uncorrelated noise but blurs rapid changes; a saturated or poorly placed sensor remains uninformative. Another failure is evaluating on the same few cases used to choose the threshold, which overstates performance. Split calibration and challenge cases, label expected conditions independently, and record confusion counts. With cameras, avoid treating a demo under one background as general object recognition. Perception output is an uncertain observation with a frame and timestamp, not unquestionable world state.

02

Follow the reasoning

Worked example

A threshold detector is tested on 40 labeled cases: TP = 18, FP = 3, TN = 15, FN = 4. Compute precision, recall, and accuracy.

  1. 1

    Precision = 18/(18 + 3) = 18/21 = 0.857.

  2. 2

    Recall = 18/(18 + 4) = 18/22 = 0.818.

  3. 3

    Accuracy = (TP + TN)/40 = (18 + 15)/40 = 0.825.

Result

Precision is 85.7%, recall is 81.8%, and accuracy is 82.5% on this 40-case test set.

Sanity checkAll four counts sum to 40, and every metric lies between 0 and 1; none alone describes both types of error.

03

Try it yourself

Independent check

Lowering a threshold causes more samples to be labeled “obstacle.” What change is generally expected if all else stays fixed?
04

Move to the bench

Calibrate and challenge a simple reflectance or light-based classifier with raw evidence retained.

Gather
  • Microcontroller
  • low-voltage light or reflectance sensor
  • white paper and dark tape
  • desk lamp
  • ruler
  • serial logger

Experiment

  1. Collect at least 20 labeled raw readings for paper and 20 for tape at a fixed distance; keep the labels independent of the code’s output.
  2. Choose a threshold from the calibration readings and state which side means tape.
  3. Test new positions under two lighting conditions and record TP, FP, TN, and FN rather than only successful cases.
  4. Introduce a deliberate fault by reversing the comparison operator; identify the swapped pattern in the confusion counts, then restore it.
  5. Add a three-consecutive-sample rule and measure the detection latency at the configured sample period.

Observe

  • Expected: calibration classes may separate at fixed conditions, while changed light or distance can narrow or reverse the margin.
  • Record actual raw ranges, threshold, confusion counts, and decision latency; do not present expected separation as measured.
  • Expected fault signature: the reversed comparator makes most previously correct positives and negatives swap roles.
Transfer it

Outline a camera pipeline for detecting a colored marker, naming the raw image, color feature, threshold, temporal rule, and one background that should be a challenge test.

Limits and cautions
  • Use cool low-voltage sensors and ordinary room lighting; do not aim lasers or intense lamps at eyes or camera sensors.
05

Keep evidence

Bench note

Record what you expected, what you actually measured or observed, and one difference worth investigating. This is self-reported evidence, not a certification.

0 / 5,000A bench demonstration needs a concrete note of at least 20 characters.
Terms in this lessonBrowse the advanced glossary

Sources and further reading

  1. Modern Robotics
  2. CircuitPython BME280 examples