Skip to content

Commit

Permalink
fixed button bindings and added arm requirement for run once.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob1272001 committed Feb 12, 2025
1 parent 11e567d commit 0ea9662
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ public class RobotContainer {

private final Telemetry logger = new Telemetry(MaxSpeed);

private final CommandXboxController joystick = new CommandXboxController(0);

public final CommandSwerveDrivetrain drivetrain = TunerConstants.createDrivetrain();


Expand Down Expand Up @@ -115,26 +113,26 @@ private void configureBindings() {{
drivetrain.setDefaultCommand(
// Drivetrain will execute this command periodically
drivetrain.applyRequest(() ->
drive.withVelocityX(-joystick.getLeftY() * MaxSpeed) // Drive forward with negative Y (forward)
.withVelocityY(-joystick.getLeftX() * MaxSpeed) // Drive left with negative X (left)
.withRotationalRate(-joystick.getRightX() * MaxAngularRate) // Drive counterclockwise with negative X (left)
drive.withVelocityX(-Constants.OIConstants.driverController.getLeftY() * MaxSpeed) // Drive forward with negative Y (forward)
.withVelocityY(-Constants.OIConstants.driverController.getLeftX() * MaxSpeed) // Drive left with negative X (left)
.withRotationalRate(-Constants.OIConstants.driverController.getRightX() * MaxAngularRate) // Drive counterclockwise with negative X (left)
)
);

joystick.a().whileTrue(drivetrain.applyRequest(() -> brake));
joystick.b().whileTrue(drivetrain.applyRequest(() ->
point.withModuleDirection(new Rotation2d(-joystick.getLeftY(), -joystick.getLeftX()))
Constants.OIConstants.driverController.a().whileTrue(drivetrain.applyRequest(() -> brake));
Constants.OIConstants.driverController.b().whileTrue(drivetrain.applyRequest(() ->
point.withModuleDirection(new Rotation2d(-Constants.OIConstants.driverController.getLeftY(), -Constants.OIConstants.driverController.getLeftX()))
));

// Run SysId routines when holding back/start and X/Y.
// Note that each routine should be run exactly once in a single log.
joystick.back().and(joystick.y()).whileTrue(drivetrain.sysIdDynamic(Direction.kForward));
joystick.back().and(joystick.x()).whileTrue(drivetrain.sysIdDynamic(Direction.kReverse));
joystick.start().and(joystick.y()).whileTrue(drivetrain.sysIdQuasistatic(Direction.kForward));
joystick.start().and(joystick.x()).whileTrue(drivetrain.sysIdQuasistatic(Direction.kReverse));
Constants.OIConstants.driverController.back().and(Constants.OIConstants.driverController.y()).whileTrue(drivetrain.sysIdDynamic(Direction.kForward));
Constants.OIConstants.driverController.back().and(Constants.OIConstants.driverController.x()).whileTrue(drivetrain.sysIdDynamic(Direction.kReverse));
Constants.OIConstants.driverController.start().and(Constants.OIConstants.driverController.y()).whileTrue(drivetrain.sysIdQuasistatic(Direction.kForward));
Constants.OIConstants.driverController.start().and(Constants.OIConstants.driverController.x()).whileTrue(drivetrain.sysIdQuasistatic(Direction.kReverse));

// reset the field-centric heading on left bumper press
joystick.leftBumper().onTrue(drivetrain.runOnce(() -> drivetrain.seedFieldCentric()));
Constants.OIConstants.driverController.leftBumper().onTrue(drivetrain.runOnce(() -> drivetrain.seedFieldCentric()));

drivetrain.registerTelemetry(logger::telemeterize);
// drive.setDefaultCommand(
Expand Down Expand Up @@ -191,7 +189,7 @@ private void configureBindings() {{
Constants.OIConstants.operatorController.povRight().onTrue(
Commands.sequence(
Commands.parallel(
Commands.runOnce(() -> Arm.getInstance().setGoal(1.02)),
Commands.runOnce(() -> Arm.getInstance().setGoal(1.02), Arm.getInstance()),
Elevator.getInstance().setGoal(0.57)
)
)
Expand All @@ -200,7 +198,7 @@ private void configureBindings() {{
Constants.OIConstants.operatorController.povLeft().onTrue(
Commands.sequence(
Elevator.getInstance().setGoal(ElevatorConstants.minDistance),
Commands.runOnce(() -> Arm.getInstance().setGoal(-1.8)),
Commands.runOnce(() -> Arm.getInstance().setGoal(-1.8), Arm.getInstance()),
Commands.waitSeconds(1.5)
)
);
Expand Down

0 comments on commit 0ea9662

Please sign in to comment.