Skip to content

Commit

Permalink
removed redundant code for joystick mode selection
Browse files Browse the repository at this point in the history
  • Loading branch information
catr1xLiu committed Dec 30, 2024
1 parent 4159330 commit fd5e1fd
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ public class RobotContainer {
// Controller
private final CommandXboxController driverXBox = new CommandXboxController(0);

public enum JoystickMode {
LEFT_HANDED,
RIGHT_HANDED
}
// Dashboard Selections
private final LoggedDashboardChooser<JoystickMode> driverModeChooser;
private final LoggedDashboardChooser<Auto> autoChooser;
private final SendableChooser<Supplier<Command>> testChooser;

Expand Down Expand Up @@ -181,10 +175,6 @@ public RobotContainer() {
SmartDashboard.putData("Select Test", testChooser = buildTestsChooser());
autoChooser = buildAutoChooser();

driverModeChooser = new LoggedDashboardChooser<>("Driver Mode", new SendableChooser<>());
driverModeChooser.addDefaultOption(JoystickMode.LEFT_HANDED.name(), JoystickMode.LEFT_HANDED);
driverModeChooser.addOption(JoystickMode.RIGHT_HANDED.name(), JoystickMode.RIGHT_HANDED);

/* you can tune the numbers on dashboard and copy-paste them to here */
this.exampleShooterOptimization = new MapleShooterOptimization(
"ExampleShooter",
Expand Down Expand Up @@ -243,16 +233,10 @@ private SendableChooser<Supplier<Command>> buildTestsChooser() {
}

private boolean isDSPresentedAsRed = FieldConstants.isSidePresentedAsRed();
private boolean isLeftHanded = true;
private Command autonomousCommand = Commands.none();
private Auto previouslySelectedAuto = null;
/** reconfigures button bindings if alliance station has changed re-create autos if not yet created */
public void checkForCommandChanges() {
final boolean isLeftHandedSelected = !JoystickMode.RIGHT_HANDED.equals(driverModeChooser.get());
if (FieldConstants.isSidePresentedAsRed() != isDSPresentedAsRed || isLeftHanded != isLeftHandedSelected)
configureButtonBindings();
isLeftHanded = isLeftHandedSelected;

final Auto selectedAuto = autoChooser.get();
if (FieldConstants.isSidePresentedAsRed() != isDSPresentedAsRed || selectedAuto != previouslySelectedAuto) {
try {
Expand Down Expand Up @@ -297,9 +281,7 @@ private void resetFieldAndOdometryForAuto(Pose2d robotStartingPoseAtBlueAlliance
*/
public void configureButtonBindings() {
/* joystick drive command */
final MapleJoystickDriveInput driveInput = JoystickMode.RIGHT_HANDED.equals(driverModeChooser.get())
? MapleJoystickDriveInput.rightHandedJoystick(driverXBox)
: MapleJoystickDriveInput.leftHandedJoystick(driverXBox);
final MapleJoystickDriveInput driveInput = MapleJoystickDriveInput.rightHandedJoystick(driverXBox);
final JoystickDrive joystickDrive =
new JoystickDrive(driveInput, () -> true, driverXBox.getHID()::getPOV, drive);
drive.setDefaultCommand(joystickDrive);
Expand Down

0 comments on commit fd5e1fd

Please sign in to comment.