Skip to content

Commit

Permalink
renamed shooter command
Browse files Browse the repository at this point in the history
  • Loading branch information
StewardHail3433 committed Jan 19, 2024
1 parent e69b6a2 commit aa87c28
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
9 changes: 4 additions & 5 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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) {}
}

0 comments on commit aa87c28

Please sign in to comment.