Class SwerveDrive

All Implemented Interfaces:
Loggable

public class SwerveDrive extends Replayable
  • Constructor Details

  • Method Details

    • drive

      public void drive(edu.wpi.first.math.geometry.Translation2d translation, edu.wpi.first.math.geometry.Rotation2d rotationSpeed, boolean fieldRelative, boolean openLoop)
      Sets the speed and rotation of each module using a translation and rotation.
      Parameters:
      translation - Translation for the robot (in meters).
      rotationSpeed - Rotation speed of the robot.
      fieldRelative - Whether the translation is field relative or not
      openLoop - Whether to use open loop or closed loop
    • stop

      public void stop()
    • spin

      public void spin(edu.wpi.first.math.geometry.Rotation2d rotationPerSecond, boolean openLoop)
    • setModuleStates

      public void setModuleStates(edu.wpi.first.math.kinematics.SwerveModuleState frontRight, edu.wpi.first.math.kinematics.SwerveModuleState backRight, edu.wpi.first.math.kinematics.SwerveModuleState frontLeft, edu.wpi.first.math.kinematics.SwerveModuleState backLeft, boolean openLoop, boolean runOptimization)
    • getSwervePositions

      public edu.wpi.first.math.kinematics.SwerveModulePosition[] getSwervePositions()
    • updateOdometry

      public void updateOdometry()
      Updates the odometry of the robot using the positions of the encoders.
    • resetOdometry

      public void resetOdometry(edu.wpi.first.math.geometry.Pose2d pose)
    • getPose

      public edu.wpi.first.math.geometry.Pose2d getPose()
    • getSettings

      public SwerveSettings getSettings()
    • getModules

      public SwerveModule[] getModules()
    • getAngle

      public edu.wpi.first.math.geometry.Rotation2d getAngle()
      Returns the angle of the gyroscope on the robot.
      Returns:
      The angle of the gyroscope on the robot
    • isReady

      public boolean isReady()
    • getBaseName

      public String getBaseName()
      Specified by:
      getBaseName in interface Loggable
      Specified by:
      getBaseName in class Replayable
    • getPointing

      public double[] getPointing()
    • replayGyroscope

      public void replayGyroscope(double[] pointing)
    • isOpenLoop

      public boolean isOpenLoop()
    • replayOpenLoop

      public void replayOpenLoop(boolean openLoop)
    • getAngles

      public double[] getAngles()
    • replayAngles

      public void replayAngles(double[] angles)
    • getSpeeds

      public double[] getSpeeds()
    • replaySpeeds

      public void replaySpeeds(double[] speeds)
    • replayInit

      public void replayInit()
      Specified by:
      replayInit in class Replayable
    • exitReplay

      public void exitReplay()
      Specified by:
      exitReplay in class Replayable