Here is a quick re-write I did, using all the above comments. Encoder is set to 1x.
Wouldn't get to test till next Wednesday. But comments are welcome.
Code:
public static void shooterEncoderStart() {
shooterEncoder.start();
shooterEncoder.setDistancePerPulse(1.0 / 360.0);
}
public static void shooterEncoderReset() {
shooterEncoder.reset();
}
public static double getRate() {
double get1 = shooterEncoder.get();
double time = Timer.getFPGATimestamp();
double get2 = shooterEncoder.get();
time -= Timer.getFPGATimestamp();
double rateDegreePerSec = Math.abs(get2-get1)/Math.abs(time);
return rateDegreePerSec/6.0; //RPM
}