[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

@@ -313,6 +313,15 @@ public class LinearFilter {
return retVal;
}
/**
* Returns the last value calculated by the LinearFilter.
*
* @return The last value.
*/
public double lastValue() {
return m_outputs.getFirst();
}
/**
* Factorial of n.
*

View File

@@ -72,6 +72,15 @@ public class MedianFilter {
}
}
/**
* Returns the last value calculated by the MedianFilter.
*
* @return The last value.
*/
public double lastValue() {
return m_valueBuffer.getFirst();
}
/** Resets the filter, clearing the window of all elements. */
public void reset() {
m_orderedValues.clear();

View File

@@ -64,6 +64,15 @@ public class SlewRateLimiter {
return m_prevVal;
}
/**
* Returns the value last calculated by the SlewRateLimiter.
*
* @return The last value.
*/
public double lastValue() {
return m_prevVal;
}
/**
* Resets the slew rate limiter to the specified value; ignores the rate limit when doing so.
*