EasyStack Docs

Utils

#EasyStack Utilities

The dev.easyfamily.EasyStack.util package holds small helper classes for filtering sensor signals, detecting changes, measuring loop time, interpolating tables and common math.

Most of these classes keep state between calls. Create one instance per signal, create it before the OpMode loop, and call it once per loop cycle.

ClassGroupWhat it does
DebouncerSignalsAccepts a change in a boolean signal only after it stays stable for a set time.
EdgeDetectorSignalsReports rising edges, falling edges and changes of a boolean signal.
LowPassFilterFiltersSmooths a value with an exponential filter defined by a time constant in seconds.
MedianFilterFiltersReturns the median of the last N samples, which removes single-sample spikes.
MovingAverageFilterFiltersReturns the average of the last N samples.
SimpleKalmanFilterFiltersSmooths a noisy measurement with a gain that adapts to the estimate error.
SlewRateLimiterFiltersLimits how fast a value is allowed to change per second.
LoopTimerTimingMeasures the loop time, the loop frequency and a smoothed average.
InterpLUTLookupInterpolates between control points with a monotone cubic curve.
MathFunctionsMathStatic helpers: clamp, angle wrapping, epsilon comparison, deadband and input modulus.

Each class has its own section below, followed by a guide to choosing between the filters.

#Choosing a Filter

ProblemUse
A digital sensor flickers when it changes.Debouncer
You need to react once when a signal changes.EdgeDetector
An analog reading has occasional wrong spikes.MedianFilter
An analog reading has steady random noise.MovingAverageFilter or LowPassFilter
You want smoothing that does not depend on the loop rate.LowPassFilter
You want a filter that tunes how much it trusts the sensor.SimpleKalmanFilter
A command must not change faster than the mechanism can handle.SlewRateLimiter

Filters can be combined. For example, a MedianFilter first removes spikes, and a LowPassFilter then smooths what is left.

#Common Mistakes

ProblemCause and fix
The filter output jumps between two signals.One instance is shared by two signals. Create one instance per signal.
The output lags behind the real value.Every smoothing filter adds delay. Use a smaller window or time constant.
The smoothing changes when the loop gets slower.MedianFilter and MovingAverageFilter count samples, not time. Use LowPassFilter for time-based smoothing.
A filter starts with an old value after a mode change.Call reset(), or create a new instance.
Debouncer or EdgeDetector misses changes.calculate() or update() is not called every cycle. Call it once per loop.
InterpLUT throws an exception.createLUT() was not called after the last add() or clear(), or it was called with fewer than two points.
SlewRateLimiter does not move on the first call.The first calculate(input) call has no earlier call to measure the time from. The output starts moving on the second call.
LoopTimer shows 0.0.tick() has been called only once. The values start at the second call.

Last updated 2026-11-16

EasyStack - FTC Java library

This site records page views of visitors to understand how the documentation is used. Nothing is sold or shared with third parties.