Skip to content

Commit

Permalink
Added Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
StewardHail3433 committed Jan 20, 2024
1 parent cbc3b25 commit 2825b65
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,34 @@
import edu.wpi.first.math.util.Units;

public class ShooterIOSparkMax implements ShooterIO {
// Gear ratio for the shooter mechanism
private static final double GEAR_RATIO = 5.0;

//define the 2 SparkMax Controllers. A leader, and a follower
private final CANSparkMax leader = new CANSparkMax(0, MotorType.kBrushless);
private final CANSparkMax follower = new CANSparkMax(1, MotorType.kBrushless);

//Gets the NEO encoder
private final RelativeEncoder encoder = leader.getEncoder();

public ShooterIOSparkMax() {
// leader motor is not inverted, and set follower motor to follow the leader
leader.setInverted(false);
follower.follow(leader, false);
}

@Override
public void updateInputs(ShooterIOInputs inputs) {
// Set velocityRadPerSec to the encoder velocity(rotationsPerMinute) divided by the gear ratio and converted into Radians Per Second
inputs.velocityRadPerSec =
Units.rotationsPerMinuteToRadiansPerSecond(encoder.getVelocity() / GEAR_RATIO);
// Get applied voltage from the leader motor
inputs.appliedVolts = leader.getAppliedOutput() * leader.getBusVoltage();
}

@Override
public void setVoltage(double volts) {
// Set the voltage output for the leader motor
leader.setVoltage(volts);
}
}

0 comments on commit 2825b65

Please sign in to comment.