Class 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
      double calculate​(double value)
      Adds the value to the window and calculates the current output of the filter
      double getCurrentOutput()
      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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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: Filter
        Adds the value to the window and calculates the current output of the filter
        Specified by:
        calculate in interface Filter
        Parameters:
        value - The value to input to the filter.
        Returns:
        The current output of the filter.
      • reset

        public void reset()
        Description copied from interface: Filter
        Resets the history of the filter.
        Specified by:
        reset in interface Filter
      • getCurrentOutput

        public double getCurrentOutput()
        Description copied from interface: Filter
        Returns the current output of the filter without updating with a new value.
        Specified by:
        getCurrentOutput in interface Filter
        Returns:
        The current output of the filter (0 if no values have been given to calculate()).