Module 3 · Signal Processing
Every sensor is a little bit wrong. A distance sensor spikes, a vision pose jitters from frame to frame, an IMU heading drifts. Feed raw readings into a controller and the noise goes straight into your motors, especially through a derivative term. This module is about cleaning up the signal before you control with it, and it has two halves.
Part 1: filtering one sensor
A filter takes one noisy stream and smooths it, at the cost of a little lag. True/false signals need a different tool: wait for the input to stay changed before treating it as real.
- Signals & Noise: what sensor noise looks like, which sensors actually need filtering, and how to measure noise before filtering anything.
- Debouncer: make a limit switch or beam break prove a boolean transition before it can advance your state machine.
- Low-pass filtering: the exponential moving average, the one-line filter you will reach for most.
- Moving average: the windowed alternative, and when its latency is worth its smoothness.
- Savitzky-Golay: fit a small polynomial to the window instead of a flat line, so smoothing stops flattening the peaks, and read velocity off the same fit.
Filtering can only fight jitter. If a sensor's readings are slowly walking away from the truth, no amount of smoothing brings them back. For that you need a second sensor.
Part 2: combining two sensors
These combine two imperfect sensors that fail in opposite ways:
- Complementary filter: a fast motor encoder that drifts, corrected by a slower absolute encoder that doesn't, blended with one constant.
- Kalman filter: the same idea, except the blend is worked out every loop from how uncertain each source is.
A controller can only be as good as the signal it gets, and even clean controller code will oscillate on a noisy distance sensor. But you don't need this whole module before using the controllers. Come back for the right tool when a sensor is what's holding a controller back.
Start with Signals & Noise, use the filtering lessons as sensors need them, then move on to the complementary and Kalman filters.