File-By-File
DifferentialOdometry

DifferentialOdometry

This class is an Odometry implementation specifically designed for differential drive robots. It leverages a DifferentialDriveOdometry instance, two encoders, and a gyroscope to accurately determine the robot's position.

Key Components

  • DifferentialDriveOdometry: The core odometry logic that calculates the robot's position.
  • EncoderConverter: Used to convert raw encoder ticks into meaningful distance values.
  • Right and Left Encoders: Provide raw tick counts for each side of the drivetrain.
  • Gyroscope: Provides the robot's heading angle.

Methods

DifferentialOdometry(DifferentialDriveOdometry odometry, EncoderConverter converter, Supplier<Integer> getRightTicks, Supplier<Integer> getLeftTicks, Supplier<Angle> getGyroAngle)

Constructs a new DifferentialOdometry instance.

  • odometry: An instance of DifferentialDriveOdometry responsible for the core position calculations. If unsure how to instantiate, you can typically provide the gyroscope's current angle and PointXYZ.ZERO as the initial position.
  • converter: An EncoderConverter used to transform encoder tick values into distance measurements. This requires knowledge of your encoder's counts per revolution and wheel circumference.
  • getRightTicks: A Supplier<Integer> that returns the raw tick count from the right encoder (unadjusted).
  • getLeftTicks: A Supplier<Integer> that returns the raw tick count from the left encoder (unadjusted).
  • getGyroAngle: A Supplier<Angle> that returns the current angle of the chassis from the gyroscope.

getRawPosition()

Overrides the abstract method from AbstractOdometry. This method retrieves the latest encoder tick counts and gyroscope angle, converts the ticks to distances, and then uses the internal DifferentialDriveOdometry instance to update and return the robot's current PointXYZ position.