Skip to content

Commit

Permalink
shooter voltage control
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinH0 committed Oct 26, 2024
1 parent 4466148 commit 701f90d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,22 @@ private void configureButtonBindings() {
// .withTimeout(3)))));

controller
.povDown()
.povLeft()
.whileTrue(
Commands.startEnd(() -> shooter.setVoltage(-9), () -> shooter.setVoltage(0), pivot));

controller
.povUp()
.onTrue(
Commands.startEnd(() -> shooter.changeVoltage(1), () -> shooter.setVoltage(1))
);

controller
.povUp()
.onTrue(
Commands.startEnd(() -> shooter.changeVoltage(-1), () -> shooter.setVoltage(-1))
);

controller
.povRight()
.whileTrue(
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/frc/robot/subsystems/shooter/Shooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public void setVoltage(double voltage) {
io.setVoltage(voltage);
}

public void changeVoltage(double dv) {
setLeftRightVoltage(
inputs.leftVoltage >= 1 + dv ? inputs.leftVoltage + dv : 0,
inputs.rightVoltage >= 1 + dv ? inputs.rightVoltage + dv : 0
);
}

public void setLeftRightVoltage(double leftVoltage, double rightVoltage) {
io.setRightVoltage(rightVoltage);
io.setLeftVoltage(leftVoltage);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/subsystems/shooter/ShooterIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public interface ShooterIO {
public static class ShooterIOInputs {
public double leftMotorVelocity = 0.0;
public double rightMotorVelocity = 0.0;
public double leftVoltage = 0.0;
public double rightVoltage = 0.0;
}

public default void spinForwards() {}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/subsystems/shooter/ShooterIOReal.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ public double getRightvelocity() {
public void updateInputs(ShooterIOInputs inputs) {
inputs.leftMotorVelocity = getLeftvelocity();
inputs.rightMotorVelocity = getRightvelocity();
inputs.leftVoltage = leftShooterMotor.getBusVoltage();
inputs.leftVoltage = rightShooterMotor.getBusVoltage();
}
}

0 comments on commit 701f90d

Please sign in to comment.