From 38f0a10c92f6db00385cfbfff10fc07a54930c43 Mon Sep 17 00:00:00 2001 From: AikiKapila Date: Wed, 31 Jan 2024 17:46:49 -0800 Subject: [PATCH] Update SwerveDriveXboxControl.java --- .../SwerveDriveXboxControl.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/frc/robot/commands/SwerveRemoteOperation/SwerveDriveXboxControl.java b/src/main/java/frc/robot/commands/SwerveRemoteOperation/SwerveDriveXboxControl.java index 281f0a8..606dc0f 100644 --- a/src/main/java/frc/robot/commands/SwerveRemoteOperation/SwerveDriveXboxControl.java +++ b/src/main/java/frc/robot/commands/SwerveRemoteOperation/SwerveDriveXboxControl.java @@ -1,10 +1,13 @@ package frc.robot.commands.SwerveRemoteOperation; import edu.wpi.first.math.kinematics.ChassisSpeeds; +import edu.wpi.first.wpilibj2.command.button.CommandGenericHID; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; import frc.robot.Constants.RobotMovementConstants; import frc.robot.Constants.DriverConstants; import frc.robot.subsystems.SwerveDrivetrain; +import frc.robot.utils.OptionButton; +import frc.robot.utils.OptionButton.ActivationMode; // Here is the documentation for the xbox controller code: // https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/wpilibj2/command/button/CommandXboxController.html @@ -13,6 +16,8 @@ * This is the default command for the drivetrain, allowing for remote operation with xbox controller */ public class SwerveDriveXboxControl extends SwerveDriveBaseControl { + private final OptionButton preciseModeButton; + private final OptionButton boostModeButton; /** * Creates a new SwerveDriveXboxControl Command. * @@ -21,10 +26,10 @@ public class SwerveDriveXboxControl extends SwerveDriveBaseControl { */ public SwerveDriveXboxControl(SwerveDrivetrain drivetrain, CommandXboxController driverXboxController) { super(drivetrain, driverXboxController); - // Create and configure buttons // OptionButton exampleToggleButton = new OptionButton(controller::a, ActivationMode.TOGGLE); - + preciseModeButton = new OptionButton(driverXboxController, 8, ActivationMode.HOLD); + boostModeButton = new OptionButton(driverXboxController, 1, ActivationMode.HOLD); // Tell the command schedular we are using the drivetrain addRequirements(drivetrain); } @@ -51,7 +56,9 @@ public void execute() { double rightX = -applyJoystickDeadzone(xboxController.getRightX(), DriverConstants.XBOX_DEAD_ZONE); - int speedLevel = 1; + int speedLevel = 1 + - preciseModeButton.getStateAsInt() + + ; final ChassisSpeeds speeds = new ChassisSpeeds( leftX * DriverConstants.maxSpeedOptionsTranslation[speedLevel],