Class SlewRateLimiter

java.lang.Object
edu.wpi.first.math.filter.SlewRateLimiter

public class SlewRateLimiter
extends Object
A class that limits the rate of change of an input value. Useful for implementing voltage, setpoint, and/or output ramps. A slew-rate limit is most appropriate when the quantity being controlled is a velocity or a voltage; when controlling a position, consider using a TrapezoidProfile instead.
  • Constructor Summary

    Constructors 
    Constructor Description
    SlewRateLimiter​(double rateLimit)
    Creates a new SlewRateLimiter with the given rate limit and an initial value of zero.
    SlewRateLimiter​(double rateLimit, double initialValue)
    Creates a new SlewRateLimiter with the given rate limit and initial value.
  • Method Summary

    Modifier and Type Method Description
    double calculate​(double input)
    Filters the input to limit its slew rate.
    void reset​(double value)
    Resets the slew rate limiter to the specified value; ignores the rate limit when doing so.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SlewRateLimiter

      public SlewRateLimiter​(double rateLimit, double initialValue)
      Creates a new SlewRateLimiter with the given rate limit and initial value.
      Parameters:
      rateLimit - The rate-of-change limit, in units per second.
      initialValue - The initial value of the input.
    • SlewRateLimiter

      public SlewRateLimiter​(double rateLimit)
      Creates a new SlewRateLimiter with the given rate limit and an initial value of zero.
      Parameters:
      rateLimit - The rate-of-change limit, in units per second.
  • Method Details

    • calculate

      public double calculate​(double input)
      Filters the input to limit its slew rate.
      Parameters:
      input - The input value whose slew rate is to be limited.
      Returns:
      The filtered value, which will not change faster than the slew rate.
    • reset

      public void reset​(double value)
      Resets the slew rate limiter to the specified value; ignores the rate limit when doing so.
      Parameters:
      value - The value to reset to.