Class IMULinearMovingAverageFilter

java.lang.Object
swervelib.math.IMULinearMovingAverageFilter

public class IMULinearMovingAverageFilter extends Object
A linear filter that does not calculate() each time a value is added to the DoubleCircularBuffer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final double
    Gain on each reading.
    private final edu.wpi.first.util.DoubleCircularBuffer
    Circular buffer storing the current IMU readings
  • Constructor Summary

    Constructors
    Constructor
    Description
    IMULinearMovingAverageFilter(int bufferLength)
    Construct a linear moving average fitler
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addValue(double input)
    Add a value to the DoubleCircularBuffer
    double
    Calculate the average of the samples in the buffer

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • m_inputs

      private final edu.wpi.first.util.DoubleCircularBuffer m_inputs
      Circular buffer storing the current IMU readings
    • m_inputGain

      private final double m_inputGain
      Gain on each reading.
  • Constructor Details

    • IMULinearMovingAverageFilter

      public IMULinearMovingAverageFilter(int bufferLength)
      Construct a linear moving average fitler
      Parameters:
      bufferLength - The number of values to average across
  • Method Details

    • addValue

      public void addValue(double input)
      Add a value to the DoubleCircularBuffer
      Parameters:
      input - Value to add
    • calculate

      public double calculate()
      Calculate the average of the samples in the buffer
      Returns:
      The average of the values in the buffer