Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
fix stop all cmd at the end of auto since I accidentally broke it on …
Browse files Browse the repository at this point in the history
…Friday while cleaning up, we have tested it before and I also personally tested it heavily using the simulator and it works fine (no runtime exceptions)
  • Loading branch information
Ernie3 committed Mar 30, 2024
1 parent 070bbc0 commit c43db27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Robot extends TimedRobot {
@Override
public void robotInit() {
DriverStation.silenceJoystickConnectionWarning(true);

// for debugging
CommandScheduler.getInstance().onCommandInitialize((command) -> {
var cmdName = command.getName();
Expand Down Expand Up @@ -87,7 +87,7 @@ public void disabledInit() {
public void disabledPeriodic() {
RobotContainer.intake.setSetpoint(RobotContainer.intake.getPosition());
RobotContainer.arm.setSetpoint(RobotContainer.arm.getPosition());

SwerveDrive.kMaxAngularSpeedRadiansPerSecond = 3 * Math.PI;
SwerveDrive.kMaxSpeedMetersPerSecond = 4.6;
}
Expand All @@ -98,9 +98,9 @@ public void disabledPeriodic() {
*/
@Override
public void autonomousInit() {
autonomousRoutine = robotContainer.getAutonomousCommand();
var selectedAutoRoutine = robotContainer.getAutonomousCommand();

if (autonomousRoutine != null) {
if (selectedAutoRoutine != null) {
// for the end of the auto routine
var stopAllCmd = new InstantCommand(() -> {
RobotContainer.swerveDrive.stop();
Expand All @@ -109,11 +109,9 @@ public void autonomousInit() {
RobotContainer.intake.stop();
}, RobotContainer.swerveDrive, RobotContainer.shooter, RobotContainer.intake);


// get the auto routine as a proxy command so we are free to compose a sequential command group
// using it, run the auto routine then stop all motors
new ProxyCommand(() ->autonomousRoutine).andThen(stopAllCmd);

// get the auto routine as a proxy command so we are free to compose a
// sequential command group using it, run the auto routine then stop all motors
autonomousRoutine = new ProxyCommand(() -> selectedAutoRoutine).andThen(stopAllCmd);
autonomousRoutine.schedule();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void execute() {
}

var fieldRelative = RobotContainer.driverController.getHID().getRightTriggerAxis() > 0.5;
var sign = fieldRelative || RobotContainer.arm.isAtState(ArmState.kAmp) ? 1 : -1;
var sign = fieldRelative || RobotContainer.arm.rotationSetpoint == ArmState.kAmp.rotations ? 1 : -1;
RobotContainer.swerveDrive.holdAngleWhileDriving(-xSpeed*sign, -ySpeed*sign, angleSetpoint, fieldRelative);
}

Expand Down

0 comments on commit c43db27

Please sign in to comment.