Skip to content

Commit

Permalink
Switch to command xbox controller
Browse files Browse the repository at this point in the history
Why wasn't a command controller used from the start? Why did they use a ps4 button definition? I have so many questions
  • Loading branch information
BlueZeeKing committed Dec 29, 2023
1 parent e072b88 commit 39caea3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import edu.wpi.first.math.trajectory.Trajectory;
import edu.wpi.first.math.trajectory.TrajectoryConfig;
import edu.wpi.first.math.trajectory.TrajectoryGenerator;
import edu.wpi.first.wpilibj.PS4Controller.Button;
import edu.wpi.first.wpilibj.XboxController;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.RunCommand;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SwerveControllerCommand;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import frc.constants.AutoConstants;
import frc.constants.ControllerConstants;
Expand All @@ -36,7 +36,8 @@ public class RobotContainer {
private final DriveSubsystem robotDrive = new DriveSubsystem();

// The driver's controller
XboxController driverController = new XboxController(ControllerConstants.DRIVER_CONTROLLER_PORT);
CommandXboxController driverController =
new CommandXboxController(ControllerConstants.DRIVER_CONTROLLER_PORT);

/** The container for the robot. Contains subsystems, OI devices, and commands. */
public RobotContainer() {
Expand All @@ -47,7 +48,7 @@ public RobotContainer() {
this.robotDrive.setDefaultCommand(
// The left stick controls translation of the robot.
// Turning is controlled by the X axis of the right stick.
new RunCommand(
Commands.run(
() ->
robotDrive.drive(
-MathUtil.applyDeadband(
Expand All @@ -68,8 +69,10 @@ public RobotContainer() {
* {@link JoystickButton}.
*/
private void configureButtonBindings() {
new JoystickButton(this.driverController, Button.kR1.value)
.whileTrue(new RunCommand(() -> this.robotDrive.setX(), this.robotDrive));
this.driverController.a().onTrue(Commands.runOnce(() -> this.robotDrive.zeroHeading()));
this.driverController
.rightBumper()
.whileTrue(Commands.run(() -> this.robotDrive.setX(), this.robotDrive));
}

public void log() {
Expand Down

0 comments on commit 39caea3

Please sign in to comment.