WPILibC++ 2024.3.2
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...
 
Unit_t Calculate (Unit_t input)
 Filters the input to limit its slew rate. More...
 
Unit_t LastValue () const
 Returns the value last calculated by the SlewRateLimiter. 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/2]

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/2]

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.

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.

◆ LastValue()

template<class Unit >
Unit_t frc::SlewRateLimiter< Unit >::LastValue ( ) const
inline

Returns the value last calculated by the SlewRateLimiter.

Returns
The last value.

◆ 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: