diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 6ba448b5..f7572c7c 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -8,7 +8,7 @@ import edu.wpi.first.wpilibj2.command.Commands; import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.button.CommandXboxController; -import frc.robot.commands.ShooterBaseCommand; +import frc.robot.commands.ShooterEnable; import frc.robot.subsystems.shooter.ShooterIOSim; import frc.robot.subsystems.shooter.ShooterSubsystem; @@ -30,14 +30,13 @@ public RobotContainer() { shooter = new ShooterSubsystem(new ShooterIOSim()); } - shooter.setDefaultCommand(new InstantCommand(() -> shooter.disable(), shooter)); - configureBindings(); } private void configureBindings() { - controller.rightTrigger().onTrue(new ShooterBaseCommand(shooter, () -> true)); - controller.rightTrigger().onFalse(shooter.getDefaultCommand()); + shooter.setDefaultCommand(new InstantCommand(() -> shooter.disable(), shooter)); + + controller.rightTrigger().whileTrue(new ShooterEnable(shooter)); } public Command getAutonomousCommand() { diff --git a/src/main/java/frc/robot/commands/ShooterBaseCommand.java b/src/main/java/frc/robot/commands/ShooterEnable.java similarity index 53% rename from src/main/java/frc/robot/commands/ShooterBaseCommand.java rename to src/main/java/frc/robot/commands/ShooterEnable.java index bde8a5a3..2495b757 100644 --- a/src/main/java/frc/robot/commands/ShooterBaseCommand.java +++ b/src/main/java/frc/robot/commands/ShooterEnable.java @@ -7,17 +7,14 @@ import edu.wpi.first.wpilibj2.command.Command; import frc.robot.subsystems.shooter.ShooterSubsystem; import java.util.Map; -import java.util.function.BooleanSupplier; -public class ShooterBaseCommand extends Command { +public class ShooterEnable extends Command { ShooterSubsystem shooter; - BooleanSupplier enable; ShuffleboardTab tab; GenericEntry voltsEntry; - public ShooterBaseCommand(ShooterSubsystem shooter, BooleanSupplier enable) { + public ShooterEnable(ShooterSubsystem shooter) { this.shooter = shooter; - this.enable = enable; // create shooter tab on ShuffleBoard tab = Shuffleboard.getTab("Shooter"); @@ -35,29 +32,17 @@ public ShooterBaseCommand(ShooterSubsystem shooter, BooleanSupplier enable) { } @Override - public void initialize() { - // disable shooter when initialize - shooter.disable(); - } + public void initialize() {} @Override public void execute() { - // Turns on motors if right trigger is fully pressed. else the motors turn off. - if (enable.getAsBoolean() == true) { - // Checks the volt Entry for the volt and sets the voltage of motors - shooter.setVoltage(voltsEntry.getDouble(0.0)); - - // Enable motors, It has to be called regularly for voltage compensation to work properly - shooter.enable(); - } else { - // Disable the shooters - shooter.disable(); - } + // Checks the volt Entry for the volt and sets the voltage of motors + shooter.setVoltage(voltsEntry.getDouble(0.0)); + + // Enable motors, It has to be called regularly for voltage compensation to work properly + shooter.enable(); } @Override - // disable shooter when it ends. - public void end(boolean interrupted) { - shooter.disable(); - } + public void end(boolean interrupted) {} }