YAMS
Yet Another Mechanism System
Loading...
Searching...
No Matches
Public Member Functions | List of all members
yams::math::DerivativeTimeFilter Class Reference

#include <DerivativeTimeFilter.hpp>

Public Member Functions

 DerivativeTimeFilter (double initial, wpi::units::second_t debouncerPeriod)
 
 DerivativeTimeFilter (wpi::units::second_t debouncerPeriod)
 
double Derivative (double current, wpi::units::second_t dt)
 
double Derivative (double current)
 

Detailed Description

Computes the time-derivative of a scalar value, debounced to avoid updating too frequently.

The derivative is computed over the elapsed FPGA time between calls and is gated by a configurable debounce period so high-frequency callers still receive stable readings.

Constructor & Destructor Documentation

◆ DerivativeTimeFilter() [1/2]

yams::math::DerivativeTimeFilter::DerivativeTimeFilter ( double  initial,
wpi::units::second_t  debouncerPeriod 
)

Create a derivative filter with a known initial value.

The initial value is timestamped at the time of construction.

Parameters
initialInitial value to differentiate from.
debouncerPeriodMinimum period between derivative updates.

◆ DerivativeTimeFilter() [2/2]

yams::math::DerivativeTimeFilter::DerivativeTimeFilter ( wpi::units::second_t  debouncerPeriod)
explicit

Create a derivative filter with no initial value (starts from 0).

Parameters
debouncerPeriodMinimum period between derivative updates.

Member Function Documentation

◆ Derivative() [1/2]

double yams::math::DerivativeTimeFilter::Derivative ( double  current)

Get the derivative of the current value over the time elapsed since the last call.

If the debounce period has not elapsed, returns the cached result.

Parameters
currentCurrent value.
Returns
Derivative of current from the previous value over the elapsed FPGA time.

◆ Derivative() [2/2]

double yams::math::DerivativeTimeFilter::Derivative ( double  current,
wpi::units::second_t  dt 
)

Get the derivative of the current value over a specified delta time.

If the debounce period has not elapsed, returns the cached result.

Parameters
currentCurrent value.
dtDelta time to use as the denominator.
Returns
Derivative of current from the previous value divided by dt.

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