Skip to content

Commit

Permalink
- Subsystems
Browse files Browse the repository at this point in the history
   - Shooter
      - No longer setGoal during initialization.
      - No longer filter runVoltage()/runVelocity() calls if value is same as previous.
  • Loading branch information
BrownGenius committed Mar 22, 2024
1 parent 47d1e45 commit 5a2764c
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/main/java/frc/robot/subsystems/shooter/ShooterSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public ShooterSubsystem(ShooterIO io) {
Units.rotationsPerMinuteToRadiansPerSecond(ShooterConstants.maxVelocityInRPMs),
Units.rotationsPerMinuteToRadiansPerSecond(
ShooterConstants.maxAccelerationInRPMsSquared))));
setGoal(0);

this.io = io;
useSoftwarePidVelocityControl = !io.supportsHardwarePid();
Expand Down Expand Up @@ -103,25 +102,21 @@ public double getMeasurement() {
@Override
// Sets the voltage to volts. the volts value is -12 to 12
public void runVoltage(double volts) {
if (targetVoltage != volts) {
targetVoltage = volts;
targetVelocityRadPerSec = 0;
this.targetVelocityRPM = ShooterConstants.maxVelocityInRPMs * (volts / 12.0);
disable(); // disable PID control
io.setVoltage(targetVoltage);
}
targetVoltage = volts;
targetVelocityRadPerSec = 0;
this.targetVelocityRPM = ShooterConstants.maxVelocityInRPMs * (volts / 12.0);
disable(); // disable PID control
io.setVoltage(targetVoltage);
}

@Override
public void runVelocity(double velocityRPM) {
velocityRPM = MathUtil.clamp(velocityRPM, 0, ShooterConstants.maxVelocityInRPMs);
if (this.targetVelocityRPM != velocityRPM) {
targetVoltage = -1;
this.targetVelocityRPM = velocityRPM;
targetVelocityRadPerSec = Units.rotationsPerMinuteToRadiansPerSecond(velocityRPM);
setGoal(targetVelocityRadPerSec);
enable();
}
targetVoltage = -1;
this.targetVelocityRPM = velocityRPM;
targetVelocityRadPerSec = Units.rotationsPerMinuteToRadiansPerSecond(velocityRPM);
setGoal(targetVelocityRadPerSec);
enable();
}

@Override
Expand Down

0 comments on commit 5a2764c

Please sign in to comment.