WPILibC++ 2023.4.3-108-ge5452e3
frc::SlewRateLimiter< Unit > Class Template Reference

A class that limits the rate of change of an input value. More...

#include <frc/filter/SlewRateLimiter.h>

Public Types

using Unit_t = units::unit_t< Unit >
 
using Rate = units::compound_unit< Unit, units::inverse< units::seconds > >
 
using Rate_t = units::unit_t< Rate >
 

Public Member Functions

 SlewRateLimiter (Rate_t positiveRateLimit, Rate_t negativeRateLimit, Unit_t initialValue=Unit_t{0})
 Creates a new SlewRateLimiter with the given positive and negative rate limits and initial value. More...
 
 SlewRateLimiter (Rate_t rateLimit)
 Creates a new SlewRateLimiter with the given positive rate limit and negative rate limit of -rateLimit. More...
 
 SlewRateLimiter (Rate_t rateLimit, Unit_t initialValue)
 Creates a new SlewRateLimiter with the given positive rate limit and negative rate limit of -rateLimit and initial value. More...
 
Unit_t Calculate (Unit_t input)
 Filters the input to limit its slew rate. More...
 
void Reset (Unit_t value)
 Resets the slew rate limiter to the specified value; ignores the rate limit when doing so. More...
 

Detailed Description

template<class Unit>
class frc::SlewRateLimiter< Unit >

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.

See also
TrapezoidProfile

Member Typedef Documentation

◆ Rate

template<class Unit >
using frc::SlewRateLimiter< Unit >::Rate = units::compound_unit<Unit, units::inverse<units::seconds> >

◆ Rate_t

template<class Unit >
using frc::SlewRateLimiter< Unit >::Rate_t = units::unit_t<Rate>

◆ Unit_t

template<class Unit >
using frc::SlewRateLimiter< Unit >::Unit_t = units::unit_t<Unit>

Constructor & Destructor Documentation

◆ SlewRateLimiter() [1/3]

template<class Unit >
frc::SlewRateLimiter< Unit >::SlewRateLimiter ( Rate_t  positiveRateLimit,
Rate_t  negativeRateLimit,
Unit_t  initialValue = Unit_t{0} 
)
inline

Creates a new SlewRateLimiter with the given positive and negative rate limits and initial value.

Parameters
positiveRateLimitThe rate-of-change limit in the positive direction, in units per second. This is expected to be positive.
negativeRateLimitThe rate-of-change limit in the negative direction, in units per second. This is expected to be negative.
initialValueThe initial value of the input.

◆ SlewRateLimiter() [2/3]

template<class Unit >
frc::SlewRateLimiter< Unit >::SlewRateLimiter ( Rate_t  rateLimit)
inlineexplicit

Creates a new SlewRateLimiter with the given positive rate limit and negative rate limit of -rateLimit.

Parameters
rateLimitThe rate-of-change limit.

◆ SlewRateLimiter() [3/3]

template<class Unit >
frc::SlewRateLimiter< Unit >::SlewRateLimiter ( Rate_t  rateLimit,
Unit_t  initialValue 
)
inline

Creates a new SlewRateLimiter with the given positive rate limit and negative rate limit of -rateLimit and initial value.

Parameters
rateLimitThe rate-of-change limit.
initialValueThe initial value of the input.

Member Function Documentation

◆ Calculate()

template<class Unit >
Unit_t frc::SlewRateLimiter< Unit >::Calculate ( Unit_t  input)
inline

Filters the input to limit its slew rate.

Parameters
inputThe input value whose slew rate is to be limited.
Returns
The filtered value, which will not change faster than the slew rate.

◆ Reset()

template<class Unit >
void frc::SlewRateLimiter< Unit >::Reset ( Unit_t  value)
inline

Resets the slew rate limiter to the specified value; ignores the rate limit when doing so.

Parameters
valueThe value to reset to.

The documentation for this class was generated from the following file: