Distance sensor
Show all numbers
How each number is measured is under Go deeper.
Software · Controls
See how filters clean up noisy sensor readings, and how much delay each one adds.
How each number is measured is under Go deeper.
Make each filter once, as a field. Then call calculate() exactly once every loop. These filters assume a 20 ms loop: call one twice a loop, or skip loops, and its timing is wrong.
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 WPILib class is Debouncer. Read more on the Signal Filtering page.
The Signal Filtering page also covers the Kalman filter. It mixes several sensors into one best guess, which is what WPILib's pose estimator does with odometry, the gyro and vision. Try it in the Pose Estimator Lab.