WPILibC++  2021.3.1
frc::SlewRateLimiter< Unit > Class Template Reference

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

#include <frc/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 rateLimit, Unit_t initialValue=Unit_t{0})
 Creates a new SlewRateLimiter with the given rate limit 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

Constructor & Destructor Documentation

◆ SlewRateLimiter()

template<class Unit >
frc::SlewRateLimiter< Unit >::SlewRateLimiter ( Rate_t  rateLimit,
Unit_t  initialValue = Unit_t{0} 
)
inlineexplicit

Creates a new SlewRateLimiter with the given rate limit 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: