Class SwerveStates

java.lang.Object
frc.robot.swerve.SwerveStates

public class SwerveStates extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static edu.wpi.first.wpilibj2.command.Command
    aimDrive(DoubleSupplier velocityX, DoubleSupplier velocityY, DoubleSupplier targetRadians)
    Applies a field-centric drive request with the specified velocities (m/s) and a target heading.
    static edu.wpi.first.wpilibj2.command.Command
    alignDrive(DoubleSupplier xGoalMeters, DoubleSupplier yGoalMeters, DoubleSupplier headingRadians)
    Align the robot to the given x, y, and heading goals.
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
    fpvAimDrive(DoubleSupplier velocityX, DoubleSupplier velocityY, DoubleSupplier targetRadians)
    Reset the turn controller and then run the field-centric drive command with a angle supplier.
    protected static edu.wpi.first.wpilibj2.command.Command
    Drive the robot with its front bumper as the forward direction.
    static double[]
     
    protected static edu.wpi.first.wpilibj2.command.Command
    headingLock(DoubleSupplier velocityX, DoubleSupplier velocityY)
    Reset the turn controller, set the target heading to the current heading(end that command immediately), and then run the drive command with the Rotation controller.
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
    Reset the turn controller, set the target heading to the closest 45 degree angle, and then run the drive command with the Rotation controller.
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
    log(edu.wpi.first.wpilibj2.command.Command cmd)
     
    protected static edu.wpi.first.wpilibj2.command.Command
    Drive the robot with the front bumper trying to match a target angle.
    protected static edu.wpi.first.wpilibj2.command.Command
    Drive the robot using left stick and control orientation using the right stick.
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static edu.wpi.first.wpilibj2.command.Command
     
    static Trigger
     
    static Trigger
     
    protected static void
     
    protected static edu.wpi.first.wpilibj2.command.Command
     
    protected static void
     
    protected static edu.wpi.first.wpilibj2.command.Command
    Drive the robot with the front bumper trying to match the robot's motion.
    protected static edu.wpi.first.wpilibj2.command.Command
    Drive the robot with the robot's orientation snapping to the closest cardinal direction.
    protected static edu.wpi.first.wpilibj2.command.Command
    Tweak the robot's orientation by a small angle back and forth.
    static edu.wpi.first.wpilibj2.command.Command
    Measures the robot's wheel radius by spinning in a circle.
    protected static edu.wpi.first.wpilibj2.command.Command
    Turn the swerve wheels to an X to prevent the robot from moving.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SwerveStates

      public SwerveStates()
  • Method Details

    • robotInNeutralZone

      public static Trigger robotInNeutralZone()
    • robotInEnemyZone

      public static Trigger robotInEnemyZone()
    • setupDefaultCommand

      protected static void setupDefaultCommand()
    • setStates

      protected static void setStates()
    • pilotDrive

      protected static edu.wpi.first.wpilibj2.command.Command pilotDrive()
      Drive the robot using left stick and control orientation using the right stick.
    • fpvDrive

      protected static edu.wpi.first.wpilibj2.command.Command fpvDrive()
      Drive the robot with its front bumper as the forward direction.
    • alignDrive

      public static edu.wpi.first.wpilibj2.command.Command alignDrive(DoubleSupplier xGoalMeters, DoubleSupplier yGoalMeters, DoubleSupplier headingRadians)
      Align the robot to the given x, y, and heading goals.
    • snapSteerDrive

      protected static edu.wpi.first.wpilibj2.command.Command snapSteerDrive()
      Drive the robot with the robot's orientation snapping to the closest cardinal direction.
    • snakeDrive

      protected static edu.wpi.first.wpilibj2.command.Command snakeDrive()
      Drive the robot with the front bumper trying to match the robot's motion.
    • tweakOut

      protected static edu.wpi.first.wpilibj2.command.Command tweakOut()
      Tweak the robot's orientation by a small angle back and forth.
      Returns:
      A command that repeatedly tweaks the robot's orientation.
    • xBrake

      protected static edu.wpi.first.wpilibj2.command.Command xBrake()
      Turn the swerve wheels to an X to prevent the robot from moving.
    • pilotAimDrive

      protected static edu.wpi.first.wpilibj2.command.Command pilotAimDrive(DoubleSupplier targetDegrees)
      Drive the robot with the front bumper trying to match a target angle. The target angle can be specified in degrees.
      Parameters:
      targetDegrees - The target angle in degrees
      Returns:
      A command that drives the robot to match the target angle while allowing translation control with the left stick
    • headingLockDrive

      protected static edu.wpi.first.wpilibj2.command.Command headingLockDrive()
    • lockToClosest45degDrive

      protected static edu.wpi.first.wpilibj2.command.Command lockToClosest45degDrive()
    • lockToClosestFieldAngleDrive

      protected static edu.wpi.first.wpilibj2.command.Command lockToClosestFieldAngleDrive()
    • resetXController

      protected static edu.wpi.first.wpilibj2.command.Command resetXController()
    • resetYController

      protected static edu.wpi.first.wpilibj2.command.Command resetYController()
    • resetTurnController

      protected static edu.wpi.first.wpilibj2.command.Command resetTurnController()
    • setTargetHeading

      protected static edu.wpi.first.wpilibj2.command.Command setTargetHeading(DoubleSupplier targetHeading)
    • fpvAimDrive

      protected static edu.wpi.first.wpilibj2.command.Command fpvAimDrive(DoubleSupplier velocityX, DoubleSupplier velocityY, DoubleSupplier targetRadians)
      Reset the turn controller and then run the field-centric drive command with a angle supplier. This can be used for aiming at a goal or heading locking, etc.
      Parameters:
      velocityX - The forward velocity in meters per second
      velocityY - The leftward velocity in meters per second
      targetRadians - The target heading in radians that the robot should align to while driving
      Returns:
      A command that resets the turn controller and then applies a field-centric drive request with the specified velocities and target heading.
    • aimDrive

      protected static edu.wpi.first.wpilibj2.command.Command aimDrive(DoubleSupplier velocityX, DoubleSupplier velocityY, DoubleSupplier targetRadians)
      Applies a field-centric drive request with the specified velocities (m/s) and a target heading. The robot will attempt to maintain the target heading while driving.
      Parameters:
      velocityX - The forward velocity in meters per second
      velocityY - The leftward velocity in meters per second
      targetRadians - The target heading in radians that the robot should align to while driving
      Returns:
      A command that applies a field-centric drive request with the specified velocities and target heading.
    • headingLock

      protected static edu.wpi.first.wpilibj2.command.Command headingLock(DoubleSupplier velocityX, DoubleSupplier velocityY)
      Reset the turn controller, set the target heading to the current heading(end that command immediately), and then run the drive command with the Rotation controller. The rotation controller will only engage if you are driving x or y.
      Parameters:
      velocityX - The forward velocity in meters per second
      velocityY - The leftward velocity in meters per second
      Returns:
      A command that returns an aimDrive command that locks the robot's heading to its current heading while allowing translation control.
    • lockToClosest45deg

      protected static edu.wpi.first.wpilibj2.command.Command lockToClosest45deg(DoubleSupplier velocityX, DoubleSupplier velocityY)
      Reset the turn controller, set the target heading to the closest 45 degree angle, and then run the drive command with the Rotation controller. The rotation controller will only engage if you are driving x or y.
      Parameters:
      velocityX - The forward velocity in meters per second
      velocityY - The leftward velocity in meters per second
      Returns:
      A command that returns an aimDrive command that locks the robot's heading to the closest 45 degree angle while allowing translation control.
    • lockToClosestFieldAngle

      protected static edu.wpi.first.wpilibj2.command.Command lockToClosestFieldAngle(DoubleSupplier velocityX, DoubleSupplier velocityY)
    • getWheelRadiusCharacterizationPositions

      public static double[] getWheelRadiusCharacterizationPositions()
    • wheelRadiusCharacterization

      public static edu.wpi.first.wpilibj2.command.Command wheelRadiusCharacterization()
      Measures the robot's wheel radius by spinning in a circle. (Method from AdvantageKit).

      This command will ramp up the robot's rotation rate to a specified maximum while recording the change in gyro angle and wheel positions. When the command is cancelled, it will calculate and print the effective wheel radius based on the recorded data.
    • reorientForward

      protected static edu.wpi.first.wpilibj2.command.Command reorientForward()
    • reorientLeft

      protected static edu.wpi.first.wpilibj2.command.Command reorientLeft()
    • reorientBack

      protected static edu.wpi.first.wpilibj2.command.Command reorientBack()
    • reorientRight

      protected static edu.wpi.first.wpilibj2.command.Command reorientRight()
    • cardinalReorient

      protected static edu.wpi.first.wpilibj2.command.Command cardinalReorient()
    • log

      protected static edu.wpi.first.wpilibj2.command.Command log(edu.wpi.first.wpilibj2.command.Command cmd)