SmartDashboard.putData("Spindexer Run Forward", new InstantCommand(() -> maxSpindexer()));
SmartDashboard.putData("Spindexer Run Reverse", new InstantCommand(() -> reverseSpindexer()));
SmartDashboard.putData("Spindexer Stop", new InstantCommand(() -> stopSpindexer()));
+
+ resetPID.setTolerance(0.05);
}
public enum SpindexerState {
Logger.processInputs("Spindexer", inputs);
if (resetPos == null) {
- resetPos = (motor.getPosition().getValueAsDouble() % gearRatio) % 1.0;
+ motor.setPosition(0.5 * gearRatio);
+ resetPos = (motor.getPosition().getValueAsDouble() / gearRatio) % 1.0;
resetPID.reset();
}
motor.set(0.0);
reversing = false;
} else if (state == SpindexerState.RESET && resetPos != null) {
- motor.set(resetPID.calculate((motor.getPosition().getValueAsDouble() % gearRatio) % 1.0, resetPos));
+ motor.set(resetPID.calculate((motor.getPosition().getValueAsDouble() / gearRatio) % 1.0, resetPos));
} else {
motor.set(power);
reversing = false;
}
private Double resetPos;
- private PIDController resetPID = new PIDController(0.5, 0.1, 0);
+ private PIDController resetPID = new PIDController(1.0, 0.0, 0);
private final double gearRatio = 27.0 / 1.0; //spindexer spins once for every 27 motor spins