Class DrivetrainState

java.lang.Object
frc.robot.localization.DrivetrainState

public class DrivetrainState extends Object
Maintains the drivetrain pose estimate using wheel odometry and vision observations.
  • Constructor Details

    • DrivetrainState

      public DrivetrainState(SwerveModulePosition[] wheelPositions, Rotation2d gyroYaw)
      Creates the drivetrain state estimator from the initial module positions and gyro yaw.
  • Method Details

    • resetPose

      public void resetPose(Pose2d pose)
      Resets the estimated pose to a known field pose.
    • resetInit

      public void resetInit()
      Allows the next accepted vision observation to initialize the pose again.
    • addOdometryObservation

      public void addOdometryObservation(SwerveModulePosition[] wheelPositions, Rotation2d gyroYaw, double timestamp)
      Updates odometry from a timestamped swerve measurement.
    • updateMeasuredSpeeds

      public void updateMeasuredSpeeds(ChassisSpeeds robotRelativeSpeeds)
      Updates the field-relative drivetrain speeds used when weighting vision observations.
    • addVisionObservation

      public void addVisionObservation(VisionObservation observation)
      Initializes or corrects the pose estimate with a processed vision observation.
    • getGlobalPoseEstimate

      public Pose2d getGlobalPoseEstimate()
      Returns the current estimated robot pose in field coordinates.
    • getFieldRelativeSpeeds

      public ChassisSpeeds getFieldRelativeSpeeds()
      Returns the latest measured chassis speeds in the field frame.