Package org.chsrobotics.lib.math.filters
Class RateLimiter
java.lang.Object
org.chsrobotics.lib.math.filters.Filter
org.chsrobotics.lib.math.filters.RateLimiter
Filter which constrains the maximum rate of change of a reference. Useful for ensuring that an
open-loop-controlled mechanism doesn't accelerate uncontrollably, or that measurements can't
change unreasonably fast.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoublecalculate(double value) Adds the value to the window and calculates the current output of the filter.doublecalculate(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.doubleReturns the current output of the filter without updating with a new value.voidreset()Resets the history of the filter.Methods inherited from class org.chsrobotics.lib.math.filters.Filter
add, scalarMultiply
-
Constructor Details
-
RateLimiter
public RateLimiter(double rateLimit) Constructs a RateLimiter.- Parameters:
rateLimit- Maximum rate-of-change of the reference, in units per second. If equal to zero, this will not apply any kind of rate limiting.
-
-
Method Details
-
calculate
public double calculate(double value) Description copied from class:FilterAdds the value to the window and calculates the current output of the filter. If dt would be a required parameter for the filter, uses 20 milliseconds (the robot loop period). -
calculate
public double calculate(double value, double dtSeconds) Description copied from class:FilterAdds 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:FilterResets the history of the filter. -
getCurrentOutput
public double getCurrentOutput()Description copied from class:FilterReturns the current output of the filter without updating with a new value.- Specified by:
getCurrentOutputin classFilter- Returns:
- The current output of the filter (0 if no values have been given to
calculate()).
-