Package org.chsrobotics.lib.math.filters
Class DifferentiatingFilter
- java.lang.Object
-
- org.chsrobotics.lib.math.filters.DifferentiatingFilter
-
-
Constructor Summary
Constructors Constructor Description DifferentiatingFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecalculate(double value)Calculates the rate of change (derivative) of a value relative to the filter's previous input, using the default loop time of the robot.doublecalculate(double value, double dt)Calculates the rate of change (derivative) of a value relative to the filter's previous input, using a given change in time.doublegetCurrentOutput()Returns the current output of the filter without updating with a new value.voidreset()Resets the history of the filter.
-
-
-
Method Detail
-
calculate
public double calculate(double value, double dt)Calculates the rate of change (derivative) of a value relative to the filter's previous input, using a given change in time.The initial previous value is 0.
Returns 0 if
dtis equal to 0 (although negative values of dt won't be meaningful either).- Parameters:
value- The double value to input to the filter.dt- The elapsed time (in seconds) since the last call of eithercalculatemethod.- Returns:
- The rate of change, in units/second, between the current
valueand the previousvalue.
-
calculate
public double calculate(double value)
Calculates the rate of change (derivative) of a value relative to the filter's previous input, using the default loop time of the robot.The initial previous value is 0.
-
getCurrentOutput
public double getCurrentOutput()
Returns the current output of the filter without updating with a new value.- Specified by:
getCurrentOutputin interfaceFilter- Returns:
- The current output of the filter (0 if no values have been given to
calculate()).
-
-