Software · Controls
Real sensors are noisy. A filter cleans up the reading, but every filter makes your code find out about real changes a little later. Turn filters on, change their settings, and measure what you gain and what you pay.
Make the filter once (a field), then call calculate() exactly once every loop. These filters assume they are called every 20 ms. Call it twice a loop, or skip loops, and the timing is wrong.
LinearFilter.singlePoleIIR(0.1, 0.02) MW-Lib uses on motor current. Raise the noise and watch the raw threshold flicker while the IIR stays steady.LinearFilter.singlePoleIIR(0.1, 0.02).singlePoleIIR(0.15, 0.02).new Debouncer(0.1, DebounceType.kRising): flywheel, hood and heading must all be on target for 0.1 s.new Debouncer(0.65, DebounceType.kFalling): it stays true for 0.65 s after the flywheel speed dip ends.new Debouncer(0.5) (Rising is the default), so one bad packet does not raise an alert.LinearFilter.movingAverage(...).DynamicSlewRateLimiter (a SlewRateLimiter whose limit can change), 40 m/s² by default.The Signal Filtering page also covers the Kalman filter, which mixes several sensors into one estimate. That is what WPILib's pose estimator does. Try it in the Pose Estimator Lab.