]> git.taranathan.com Git - FRC2026.git/commitdiff
Merge branch 'main' into add-spindexer-motor
authoriefomit <timofei.stem@gmail.com>
Fri, 17 Apr 2026 22:57:48 +0000 (15:57 -0700)
committeriefomit <timofei.stem@gmail.com>
Fri, 17 Apr 2026 22:57:48 +0000 (15:57 -0700)
1  2 
src/main/java/frc/robot/subsystems/spindexer/Spindexer.java

index 62d7d399d89b30d23d9ae9c408c27e32bee21b6b,2901af04e6da0fe95bfcdf6ced480340477ca78b..9b2c40e81555f7bfcc165df9c0d8d9a9510a8a99
@@@ -1,15 -1,12 +1,13 @@@
  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;
@@@ -22,9 -18,9 +20,7 @@@ public class Spindexer extends Subsyste
  
      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;
          }