mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Remove redundant LinearFilter.finiteDifference() argument (#4335)
The number of samples is already determined by the length of the stencil list.
This commit is contained in:
@@ -147,17 +147,15 @@ public class LinearFilter {
|
||||
* stream-based online filtering (e.g., taking derivative of encoder samples in real-time).
|
||||
*
|
||||
* @param derivative The order of the derivative to compute.
|
||||
* @param samples The number of samples to use to compute the given derivative. This must be one
|
||||
* more than the order of derivative or higher.
|
||||
* @param stencil List of stencil points.
|
||||
* @param stencil List of stencil points. Its length is the number of samples to use to compute
|
||||
* the given derivative. This must be one more than the order of the derivative or higher.
|
||||
* @param period The period in seconds between samples taken by the user.
|
||||
* @return Linear filter.
|
||||
* @throws IllegalArgumentException if derivative < 1, samples <= 0, or derivative >=
|
||||
* samples.
|
||||
*/
|
||||
@SuppressWarnings("LocalVariableName")
|
||||
public static LinearFilter finiteDifference(
|
||||
int derivative, int samples, int[] stencil, double period) {
|
||||
public static LinearFilter finiteDifference(int derivative, int[] stencil, double period) {
|
||||
// See
|
||||
// https://en.wikipedia.org/wiki/Finite_difference_coefficient#Arbitrary_stencil_points
|
||||
//
|
||||
@@ -179,6 +177,8 @@ public class LinearFilter {
|
||||
"Order of derivative must be greater than or equal to one.");
|
||||
}
|
||||
|
||||
int samples = stencil.length;
|
||||
|
||||
if (samples <= 0) {
|
||||
throw new IllegalArgumentException("Number of samples must be greater than zero.");
|
||||
}
|
||||
@@ -236,7 +236,7 @@ public class LinearFilter {
|
||||
stencil[i] = -(samples - 1) + i;
|
||||
}
|
||||
|
||||
return finiteDifference(derivative, samples, stencil, period);
|
||||
return finiteDifference(derivative, stencil, period);
|
||||
}
|
||||
|
||||
/** Reset the filter state. */
|
||||
|
||||
Reference in New Issue
Block a user