File-By-File
EncoderConverter

EncoderConverter

This class is responsible for converting raw encoder tick values into more meaningful units like rotations and distance. It requires the encoder's counts per revolution (CPR) and the circumference of the wheel attached to the encoder to perform accurate conversions.

Methods

EncoderConverter(double encoderCountsPerRevolution, double wheelCircumference)

Constructs a new EncoderConverter.

  • encoderCountsPerRevolution: The number of encoder ticks for one full revolution of the encoder.
  • wheelCircumference: The circumference of the wheel (in the desired unit of distance) that is being measured by the encoder.

getEncoderCpr()

Returns the configured encoder counts per revolution.

getWheelCircumference()

Returns the configured wheel circumference.

rotationsFromTicks(double ticks)

Converts a given number of encoder ticks into the equivalent number of rotations.

distanceFromRotations(double rotations)

Converts a given number of rotations into the equivalent distance traveled, based on the wheel circumference.

distanceFromTicks(double ticks)

Converts a given number of encoder ticks directly into the equivalent distance traveled. This method combines the rotationsFromTicks and distanceFromRotations calculations.