Package org.chsrobotics.lib.math.filters
Class ThresholdFilter
java.lang.Object
org.chsrobotics.lib.math.filters.Filter
org.chsrobotics.lib.math.filters.ThresholdFilter
A filter that completely attentuates any value (infinite impulse) below or above a defined
threshold.
-
Constructor Summary
ConstructorsConstructorDescriptionThresholdFilter
(double threshold, boolean invert) Constructs a ThresholdFilter. -
Method Summary
Modifier and TypeMethodDescriptiondouble
calculate
(double value, double dtSeconds) Adds the value to the window and calculates the current output of the filter, with a change in time since the last call of this.double
Returns the current output of the filter without updating with a new value.void
reset()
Resets the history of the filter.Methods inherited from class org.chsrobotics.lib.math.filters.Filter
add, calculate, scalarMultiply
-
Constructor Details
-
ThresholdFilter
public ThresholdFilter(double threshold, boolean invert) Constructs a ThresholdFilter. By default, filters out values above the threshold, but can be interved to filter out values below the threshold.- Parameters:
threshold
- The filter will attentuate values above this threshold.invert
- Whether to attentuate values *below* this threshold instead.
-
-
Method Details
-
calculate
public double calculate(double value, double dtSeconds) Description copied from class:Filter
Adds the value to the window and calculates the current output of the filter, with a change in time since the last call of this.Some filters do not use time in their calculations, and this method is identical to
calculate()
for them. -
reset
public void reset()Description copied from class:Filter
Resets the history of the filter. -
getCurrentOutput
public double getCurrentOutput()Description copied from class:Filter
Returns the current output of the filter without updating with a new value.- Specified by:
getCurrentOutput
in classFilter
- Returns:
- The current output of the filter (0 if no values have been given to
calculate()
).
-