← Back

This preview is the content that will print. Choose “Save as PDF” in your browser’s print dialog to make a PDF.

Metatransformer report

Perception from measurements

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

Text report: images and diagrams are omitted, and links to project files are inactive. Keep the exported project alongside this PDF for wiring diagrams, models, and linked files.

Learning outcomes

  • Design a simple perception pipeline, calculate a threshold from labeled data, and identify false-positive and false-negative failure modes.

Prerequisites

  • probability-uncertainty

Concepts

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.

Worked example

Problem

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

Steps

  1. Precision = 18/(18 + 3) = 18/21 = 0.857.
  2. Recall = 18/(18 + 4) = 18/22 = 0.818.
  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 check

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

Check your understanding

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

A. Both false positives and false negatives must become zero B. Recall tends to rise while false positives may also rise C. Precision must rise because there are more positive labels D. The sensor’s physical resolution doubles

Your answer: ______________________________

Reasoning:



Answer key

ANSWER KEY — check only after attempting the question.

B. Recall tends to rise while false positives may also rise

A lower threshold admits more true cases but also more negative cases, typically reducing misses while increasing false alarms. Precision can move either way and often falls. Classification policy does not change physical sensor resolution, and no threshold guarantees zero errors when classes overlap.

Hands-on lab

Goal

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

Equipment

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

Procedure

  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.

What to 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 challenge

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.

Cautions

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

Evidence record

Learner: ____________________ Date: ____________________

Evidence artifact or file: ____________________________________________

ItemRecord
Prediction or expected result
Actual observation or measurement
Conditions and tools used
Difference from expectation
Next decision or follow-up

Notes:




Sources and references

  1. Modern Robotics (opens in a new tab)
  2. CircuitPython BME280 examples (opens in a new tab)