Package frc.robot.subsystems.drivetrain
Class DrivetrainControls
java.lang.Object
frc.robot.subsystems.drivetrain.DrivetrainControls
Class that handles controlling the
Drivetrain
with HID controllers.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondriveAngularVelocity
(CommandXboxController controller) A copy ofdriveGeneric(CommandXboxController)
that uses angular velocity control for turning.driveAngularVelocityCommand
(CommandXboxController controller, Drivetrain.TranslationOrientation orientation) driveInputStreamScaledCommand(SwerveInputStream, TranslationOrientation)
that usesdriveAngularVelocity(CommandXboxController)
.driveDirectAngle
(CommandXboxController controller) A copy ofdriveGeneric(CommandXboxController)
that uses heading control for turning.driveDirectAngleCommand
(CommandXboxController controller, Drivetrain.TranslationOrientation orientation) driveInputStreamScaledCommand(SwerveInputStream, TranslationOrientation)
that usesdriveDirectAngle(CommandXboxController)
.driveDirectAngleSim
(CommandXboxController controller) A copy ofdriveGeneric(CommandXboxController)
that pulls rotation from controller axis 2 for use in simulation.driveDirectAngleSimCommand
(CommandXboxController controller, Drivetrain.TranslationOrientation orientation) driveInputStreamScaledCommand(SwerveInputStream, TranslationOrientation)
that usesdriveDirectAngleSim(CommandXboxController)
.driveStaticHeading
(CommandXboxController controller, Supplier<Rotation2d> heading) A copy ofdriveGeneric(CommandXboxController)
that uses a preset heading.driveStaticHeadingCommand
(CommandXboxController controller, Drivetrain.TranslationOrientation orientation, Supplier<Rotation2d> heading) driveInputStreamScaledCommand(SwerveInputStream, TranslationOrientation)
that usesdriveStaticHeading(CommandXboxController, Supplier)
.driveStaticHeadingNearestPoseCommand
(CommandXboxController controller, Drivetrain.TranslationOrientation orientation, List<Pose2d> poses) driveStaticHeadingCommand(CommandXboxController, TranslationOrientation, Supplier)
that uses the heading of the nearest pose from a list of poses.void
Sets the controller speed multiplier back toConstants.DrivetrainConstants.TRANSLATION_SCALE_NORMAL
.void
setSpeedMultiplier
(double speedMultiplier) Sets the controller speed multiplier.setSpeedMultiplierCommand
(Supplier<Double> speedMultiplier) Sets the controller speed multiplier.
-
Constructor Details
-
DrivetrainControls
Creates a new DrivetrainControls.- Parameters:
drivetrain
- The Drivetrain to control.
-
-
Method Details
-
setSpeedMultiplier
public void setSpeedMultiplier(double speedMultiplier) Sets the controller speed multiplier.- Parameters:
speedMultiplier
- Multiplier to set (0, 1].
-
resetSpeedMultiplier
public void resetSpeedMultiplier()Sets the controller speed multiplier back toConstants.DrivetrainConstants.TRANSLATION_SCALE_NORMAL
. -
setSpeedMultiplierCommand
Sets the controller speed multiplier. Resets the multiplier when canceled.- Parameters:
speedMultiplier
- Multiplier to set (0, 1].- Returns:
- Command to run.
-
driveAngularVelocity
A copy ofdriveGeneric(CommandXboxController)
that uses angular velocity control for turning.- Parameters:
controller
- The controller to read from.- Returns:
- SwerveInputStream with data from the controller.
-
driveDirectAngle
A copy ofdriveGeneric(CommandXboxController)
that uses heading control for turning.- Parameters:
controller
- The controller to read from.- Returns:
- SwerveInputStream with data from the controller.
-
driveDirectAngleSim
A copy ofdriveGeneric(CommandXboxController)
that pulls rotation from controller axis 2 for use in simulation.- Parameters:
controller
- The controller to read from.- Returns:
- SwerveInputStream with data from the controller.
-
driveStaticHeading
public SwerveInputStream driveStaticHeading(CommandXboxController controller, Supplier<Rotation2d> heading) A copy ofdriveGeneric(CommandXboxController)
that uses a preset heading.- Parameters:
controller
- The controller to read from.heading
- The rotation to point the heading to.- Returns:
- SwerveInputStream with data from the controller.
-
driveAngularVelocityCommand
public Command driveAngularVelocityCommand(CommandXboxController controller, Drivetrain.TranslationOrientation orientation) driveInputStreamScaledCommand(SwerveInputStream, TranslationOrientation)
that usesdriveAngularVelocity(CommandXboxController)
. CallsDrivetrain.resetLastAngleScalar()
on end to prevent snapback.- Parameters:
controller
- Controller to use.orientation
- The translation's field of reference.- Returns:
- Command to run.
-
driveDirectAngleCommand
public Command driveDirectAngleCommand(CommandXboxController controller, Drivetrain.TranslationOrientation orientation) driveInputStreamScaledCommand(SwerveInputStream, TranslationOrientation)
that usesdriveDirectAngle(CommandXboxController)
.- Parameters:
controller
- Controller to use.orientation
- The translation's field of reference.- Returns:
- Command to run.
-
driveDirectAngleSimCommand
public Command driveDirectAngleSimCommand(CommandXboxController controller, Drivetrain.TranslationOrientation orientation) driveInputStreamScaledCommand(SwerveInputStream, TranslationOrientation)
that usesdriveDirectAngleSim(CommandXboxController)
.- Parameters:
controller
- Controller to use.orientation
- The translation's field of reference.- Returns:
- Command to run.
-
driveStaticHeadingCommand
public Command driveStaticHeadingCommand(CommandXboxController controller, Drivetrain.TranslationOrientation orientation, Supplier<Rotation2d> heading) driveInputStreamScaledCommand(SwerveInputStream, TranslationOrientation)
that usesdriveStaticHeading(CommandXboxController, Supplier)
.- Parameters:
controller
- Controller to use.orientation
- The translation's field of reference.heading
- The rotation to point the heading to.- Returns:
- Command to run.
-
driveStaticHeadingNearestPoseCommand
public Command driveStaticHeadingNearestPoseCommand(CommandXboxController controller, Drivetrain.TranslationOrientation orientation, List<Pose2d> poses) driveStaticHeadingCommand(CommandXboxController, TranslationOrientation, Supplier)
that uses the heading of the nearest pose from a list of poses.- Parameters:
controller
- Controller to use.orientation
- The translation's field of reference.poses
- The list of poses to choose the nearest pose from.- Returns:
- Command to run.
-