10 #include <frc2/Timer.h>
14 #include <units/units.h>
28 using Unit_t = units::unit_t<Unit>;
29 using Rate = units::compound_unit<Unit, units::inverse<units::seconds>>;
30 using Rate_t = units::unit_t<Rate>;
40 : m_rateLimit{rateLimit}, m_prevVal{initialValue} {
52 m_prevVal += std::clamp(input - m_prevVal, -m_rateLimit * m_timer.
Get(),
53 m_rateLimit * m_timer.
Get());
Unit_t Calculate(Unit_t input)
Filters the input to limit its slew rate.
Definition: SlewRateLimiter.h:51
units::second_t Get() const
Get the current time from the timer.
void Start()
Start the timer running.
A wrapper for the frc::Timer class that returns unit-typed values.
Definition: Timer.h:40
A class that limits the rate of change of an input value.
Definition: SlewRateLimiter.h:27
SlewRateLimiter(Rate_t rateLimit, Unit_t initialValue=Unit_t{0})
Creates a new SlewRateLimiter with the given rate limit and initial value.
Definition: SlewRateLimiter.h:39
void Reset()
Reset the timer by setting the time to 0.
void Reset(Unit_t value)
Resets the slew rate limiter to the specified value; ignores the rate limit when doing so.
Definition: SlewRateLimiter.h:64
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16