File-By-File
EncoderTracker

EncoderTracker

An EncoderTracker tracks the position of a tick-based encoder by storing the current and last tick values, as well as the elapsed time in milliseconds. This allows for the speed of the encoder to be calculated.

Methods

EncoderTracker(EncoderConverter converter, Supplier<Integer> getTicks, boolean isInverted)

Constructs a new EncoderTracker.

  • converter: An EncoderConverter that will convert ticks to rotations and distance.
  • getTicks: A Supplier<Integer> that returns the encoder's raw tick value.
  • isInverted: A boolean indicating whether the encoder is inverted. If true, all values will be multiplied by -1.

EncoderTracker(EncoderConverter converter, Supplier<Integer> getTicks)

Constructs a new EncoderTracker with isInverted set to false by default.

getSpeedConverter()

Returns the EncoderConverter instance used by this tracker.

getSpeedWithTime(double elapsedSeconds)

Calculates the speed of the encoder given the elapsedSeconds since the last call. It is strongly encouraged to use the getSpeed() method instead.

getSpeed()

Calculates and returns the speed of the encoder based on the elapsed time since the last update. This method handles the time tracking internally.