File-By-File
GyroOdometry

GyroOdometry

This class is a PathfinderPlugin that provides gyroscope-based odometry. It is designed to work with a Voyager instance to refine the robot's position tracking, particularly by compensating for drift when the robot's combined velocity falls below a certain threshold.

Methods

GyroOdometry(Supplier<Double> getGyroVelocity, double minCombinedVelocity)

Constructs a new GyroOdometry plugin.

  • getGyroVelocity: A Supplier<Double> that provides the current angular velocity from the gyroscope.
  • minCombinedVelocity: The minimum combined velocity threshold. If the robot's combined velocity (as reported by getGyroVelocity) falls below this value, the odometry will be offset to its last known position, effectively reducing drift when stationary or moving very slowly.

getName()

Returns the name of the plugin, which is "GyroOdometry".

preTick(Voyager voyager)

This method is called before each tick of the Voyager instance. It stores the robot's current position (voyager.getPosition()) in lastPosition.

postTick(Voyager voyager)

This method is called after each tick of the Voyager instance. If the getGyroVelocity is less than minCombinedVelocity, it offsets the Voyager's odometry so that the robot's position is reset to lastPosition. This helps to prevent position drift when the robot is not actively moving or turning significantly.