Logger.processInputs("Spindexer", inputs);
if (resetPos == null) {
- resetPos = motor.getPosition().getValueAsDouble();
+ resetPos = (motor.getPosition().getValueAsDouble() % gearRatio);
resetPID.reset();
}
motor.set(0.0);
reversing = false;
} else if (state == SpindexerState.RESET && resetPos != null) {
- motor.set(resetPID.calculate(motor.getPosition().getValueAsDouble(), resetPos));
+ motor.set(resetPID.calculate((motor.getPosition().getValueAsDouble() % gearRatio), resetPos));
} else {
motor.set(power);
reversing = false;
private Double resetPos;
private PIDController resetPID = new PIDController(0.5, 0.1, 0);
+ private final double gearRatio = 27.0 / 1.0; //spindexer spins once for every 27 motor spins
+
}