Package org.chsrobotics.lib.math.filters
Class RateLimiter
- java.lang.Object
-
- org.chsrobotics.lib.math.filters.RateLimiter
-
- All Implemented Interfaces:
Filter
public class RateLimiter extends java.lang.Object implements Filter
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 Constructor Description RateLimiter(double rateLimit)Constructs a RateLimiter with the default robot loop cycle time.RateLimiter(double rateLimit, double dtSeconds)Constructs a RateLimiter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecalculate(double value)Adds the value to the window and calculates the current output of the filterdoublegetCurrentOutput()Returns the current output of the filter without updating with a new value.voidreset()Resets the history of the filter.
-
-
-
Constructor Detail
-
RateLimiter
public RateLimiter(double rateLimit, double dtSeconds)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.dtSeconds- Time, in seconds, expected between calls of this method.
-
RateLimiter
public RateLimiter(double rateLimit)
Constructs a RateLimiter with the default robot loop cycle time.- Parameters:
rateLimit- Maximum rate-of-change of the reference, in units per second.
-
-
Method Detail
-
calculate
public double calculate(double value)
Description copied from interface:FilterAdds the value to the window and calculates the current output of the filter
-
reset
public void reset()
Description copied from interface:FilterResets the history of the filter.
-
getCurrentOutput
public double getCurrentOutput()
Description copied from interface:FilterReturns 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()).
-
-