Package frc.robot.swerve
Class SwerveStates
java.lang.Object
frc.robot.swerve.SwerveStates
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static edu.wpi.first.wpilibj2.command.CommandaimDrive(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.CommandalignDrive(DoubleSupplier xGoalMeters, DoubleSupplier yGoalMeters, DoubleSupplier headingRadians) Align the robot to the given x, y, and heading goals.protected static edu.wpi.first.wpilibj2.command.Commandprotected static edu.wpi.first.wpilibj2.command.CommandfpvAimDrive(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.CommandfpvDrive()Drive the robot with its front bumper as the forward direction.static double[]protected static edu.wpi.first.wpilibj2.command.CommandheadingLock(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.Commandprotected static edu.wpi.first.wpilibj2.command.CommandlockToClosest45deg(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.protected static edu.wpi.first.wpilibj2.command.Commandprotected static edu.wpi.first.wpilibj2.command.CommandlockToClosestFieldAngle(DoubleSupplier velocityX, DoubleSupplier velocityY) protected static edu.wpi.first.wpilibj2.command.Commandprotected static edu.wpi.first.wpilibj2.command.Commandlog(edu.wpi.first.wpilibj2.command.Command cmd) protected static edu.wpi.first.wpilibj2.command.CommandpilotAimDrive(DoubleSupplier targetDegrees) Drive the robot with the front bumper trying to match a target angle.protected static edu.wpi.first.wpilibj2.command.CommandDrive the robot using left stick and control orientation using the right stick.protected static edu.wpi.first.wpilibj2.command.Commandprotected static edu.wpi.first.wpilibj2.command.Commandprotected static edu.wpi.first.wpilibj2.command.Commandprotected static edu.wpi.first.wpilibj2.command.Commandprotected static edu.wpi.first.wpilibj2.command.Commandprotected static edu.wpi.first.wpilibj2.command.Commandprotected static edu.wpi.first.wpilibj2.command.Commandstatic Triggerstatic Triggerprotected static voidprotected static edu.wpi.first.wpilibj2.command.CommandsetTargetHeading(DoubleSupplier targetHeading) protected static voidprotected static edu.wpi.first.wpilibj2.command.CommandDrive the robot with the front bumper trying to match the robot's motion.protected static edu.wpi.first.wpilibj2.command.CommandDrive the robot with the robot's orientation snapping to the closest cardinal direction.protected static edu.wpi.first.wpilibj2.command.CommandtweakOut()Tweak the robot's orientation by a small angle back and forth.static edu.wpi.first.wpilibj2.command.CommandMeasures the robot's wheel radius by spinning in a circle.protected static edu.wpi.first.wpilibj2.command.CommandxBrake()Turn the swerve wheels to an X to prevent the robot from moving.
-
Constructor Details
-
SwerveStates
public SwerveStates()
-
-
Method Details
-
robotInNeutralZone
-
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
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 secondvelocityY- The leftward velocity in meters per secondtargetRadians- 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 secondvelocityY- The leftward velocity in meters per secondtargetRadians- 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 secondvelocityY- 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 secondvelocityY- 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)
-