Skip to content

Commit

Permalink
added brake and field oriented toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
PGgit08 committed Nov 16, 2024
1 parent 4e48fe2 commit 4527221
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/frc/robot/subsystems/CommandSwerveDrivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class CommandSwerveDrivetrain extends SwerveDrivetrain implements Subsyst
private final RobotCentric _robotCentricRequest = new RobotCentric();
private final FieldCentric _fieldCentricRequest = new FieldCentric();

private final SwerveDriveBrake _brakeRequest = new SwerveDriveBrake();

// auton request
private final ApplyRobotSpeeds _robotSpeedsRequest = new ApplyRobotSpeeds();

Expand Down Expand Up @@ -88,7 +90,14 @@ public CommandSwerveDrivetrain(
* Toggles the field oriented boolean.
*/
public Command toggleFieldOriented() {
return runOnce(() -> _isFieldOriented = !_isFieldOriented);
return brake().withTimeout(2).alongWith(runOnce(() -> _isFieldOriented = !_isFieldOriented));
}

/**
* Brakes the swerve drive (module form an "X" formation).
*/
public Command brake() {
return run(() -> setControl(_brakeRequest));
}

/**
Expand Down

0 comments on commit 4527221

Please sign in to comment.