Upgrading to 2024.7.0

This commit is contained in:
thenetworkgrinch
2024-11-06 00:10:07 +00:00
parent b8e06f205e
commit 9fe6551d88
14 changed files with 211 additions and 182 deletions

View File

@@ -3,10 +3,10 @@ package swervelib.math;
import edu.wpi.first.util.DoubleCircularBuffer;
/**
* A linear filter that does not calculate() each time a value is added to
* the DoubleCircularBuffer.
* A linear filter that does not calculate() each time a value is added to the DoubleCircularBuffer.
*/
public class IMULinearMovingAverageFilter {
public class IMULinearMovingAverageFilter
{
/**
* Circular buffer storing the current IMU readings
@@ -16,39 +16,42 @@ public class IMULinearMovingAverageFilter {
* Gain on each reading.
*/
private final double m_inputGain;
/**
* Construct a linear moving average fitler
* @param bufferLength The number of values to average across
*/
/**
* Construct a linear moving average fitler
*
* @param bufferLength The number of values to average across
*/
public IMULinearMovingAverageFilter(int bufferLength)
{
m_inputs = new DoubleCircularBuffer(bufferLength);
m_inputGain = 1.0 / bufferLength;
}
/**
* Add a value to the DoubleCircularBuffer
* @param input Value to add
*/
/**
* Add a value to the DoubleCircularBuffer
*
* @param input Value to add
*/
public void addValue(double input)
{
m_inputs.addFirst(input);
}
/**
* Calculate the average of the samples in the buffer
* @return The average of the values in the buffer
*/
/**
* Calculate the average of the samples in the buffer
*
* @return The average of the values in the buffer
*/
public double calculate()
{
double returnVal = 0.0;
for(int i = 0; i < m_inputs.size(); i++)
{
returnVal += m_inputs.get(i) * m_inputGain;
}
return returnVal;
for (int i = 0; i < m_inputs.size(); i++)
{
returnVal += m_inputs.get(i) * m_inputGain;
}
return returnVal;
}
}