[wpimath] Add lastValue() method to filters (#6351)

This commit is contained in:
N0tACyb0rg
2024-02-10 10:43:23 -08:00
committed by GitHub
parent e506e09a06
commit 3207795d0d
6 changed files with 48 additions and 0 deletions

View File

@@ -371,6 +371,13 @@ class LinearFilter {
return retVal;
}
/**
* Returns the last value calculated by the LinearFilter.
*
* @return The last value.
*/
T LastValue() const { return m_outputs.front(); }
private:
wpi::circular_buffer<T> m_inputs;
wpi::circular_buffer<T> m_outputs;

View File

@@ -61,6 +61,13 @@ class MedianFilter {
}
}
/**
* Returns the last value calculated by the MedianFilter.
*
* @return The last value.
*/
T LastValue() const { return m_valueBuffer.front(); }
/**
* Resets the filter, clearing the window of all elements.
*/

View File

@@ -75,6 +75,13 @@ class SlewRateLimiter {
return m_prevVal;
}
/**
* Returns the value last calculated by the SlewRateLimiter.
*
* @return The last value.
*/
Unit_t LastValue() const { return m_prevVal; }
/**
* Resets the slew rate limiter to the specified value; ignores the rate limit
* when doing so.