package frc.robot.subsystems.spindexer;
import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
- import com.ctre.phoenix6.controls.DutyCycleOut;
+import com.ctre.phoenix6.configs.MotorOutputConfigs;
import com.ctre.phoenix6.controls.VoltageOut;
import com.ctre.phoenix6.hardware.TalonFX;
+import com.ctre.phoenix6.signals.InvertedValue;
import org.littletonrobotics.junction.Logger;
--import edu.wpi.first.math.controller.PIDController;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
private double power = 0.0;
public int ballCount = 0;
-- private boolean wasSpindexerSlow = false;
private SpindexerState state = SpindexerState.STOPPED;
-- private boolean reversing = false;
private SpindexerIOInputsAutoLogged inputs = new SpindexerIOInputsAutoLogged();
public boolean noIndexing = false;
updateInputs();
Logger.processInputs("Spindexer", inputs);
- if (resetPos == null) {
- motor.setPosition(0.1 * gearRatio);
- resetPos = (motor.getPosition().getValueAsDouble() / gearRatio) % 1.0;
- resetPID.reset();
- }
-
if (state == SpindexerState.MAX) {
- motor.setControl(new VoltageOut(12 * SpindexerConstants.spindexerMaxPower).withEnableFOC(true));
- reversing = false;
+ setMotorVoltages(SpindexerConstants.spindexerForwardVoltage);
- reversing = false;
} else if (state == SpindexerState.REVERSE) {
- motor.setControl(new VoltageOut(12 * SpindexerConstants.spindexerReversePower).withEnableFOC(true));
- reversing = true;
+ setMotorVoltages(SpindexerConstants.spindexerReverseVoltage);
- reversing = true;
} else if (state == SpindexerState.STOPPED) {
- motor.setControl(new VoltageOut(12 * 0.0).withEnableFOC(true));
- reversing = false;
- } else if (state == SpindexerState.RESET && resetPos != null) {
- motor.setControl(new VoltageOut(12 * resetPID.calculate((motor.getPosition().getValueAsDouble() / gearRatio) % 1.0, resetPos)).withEnableFOC(true));
+ setMotorVoltages(0.0);
- reversing = false;
} else {
- motor.setControl(new VoltageOut(12 * power).withEnableFOC(true));
- reversing = false;
+ setMotorVoltages(power);
- reversing = false;
}