]> git.taranathan.com Git - FRC2026.git/commitdiff
2 motors
authoriefomit <timofei.stem@gmail.com>
Sat, 18 Apr 2026 03:28:31 +0000 (20:28 -0700)
committeriefomit <timofei.stem@gmail.com>
Sat, 18 Apr 2026 03:28:31 +0000 (20:28 -0700)
src/main/java/frc/robot/subsystems/spindexer/SpindexerConstants.java
src/main/java/frc/robot/subsystems/spindexer/SpindexerIOTalonFX.java

index 9bd84836c7bba660f1e034095872899042677f94..f08d5e9d7de84cf7c0e55b709bc6fff88e06e435 100644 (file)
@@ -6,7 +6,6 @@ public class SpindexerConstants {
     public static final double spindexerForwardVoltage = 1.00; // Volts (set low for testing)
     public static final double spindexerReverseVoltage = -1.00; // Volts
     public static final double GEAR_RATIO = 27.0; // unused & both motors have same gearing
-
     public static final double CURRENT_SPIKE_LIMIT = 150.0;
     public static final double CURRENT_TIME_LIMIT = 1.0; //s
     public static final double JAM_CURRENT_THRESHOLD = 75.0; // A
index 284a46d7832ce7c4485c21d8749b419455e45254..e2ecefc54464f67fa857926470be82340c25bafa 100644 (file)
@@ -1,15 +1,18 @@
 package frc.robot.subsystems.spindexer;
 
 import com.ctre.phoenix6.configs.CurrentLimitsConfigs;
+import com.ctre.phoenix6.configs.MotorOutputConfigs;
 import com.ctre.phoenix6.controls.ControlRequest;
 import com.ctre.phoenix6.hardware.TalonFX;
+import com.ctre.phoenix6.signals.InvertedValue;
 
 import frc.robot.constants.Constants;
 import frc.robot.constants.IdConstants;
 
 public class SpindexerIOTalonFX implements SpindexerIO {
 
-  private TalonFX motor = new TalonFX(IdConstants.SPINDEXER_ID, Constants.CANIVORE_SUB);
+  private TalonFX motorOne = new TalonFX(IdConstants.SPINDEXER_ONE_ID, Constants.CANIVORE_SUB);
+  private TalonFX motorTwo = new TalonFX(IdConstants.SPINDEXER_TWO_ID, Constants.CANIVORE_SUB);
 
   public SpindexerIOTalonFX() {
     // configure current limit
@@ -18,15 +21,21 @@ public class SpindexerIOTalonFX implements SpindexerIO {
     limitConfig.StatorCurrentLimitEnable = true;
     limitConfig.SupplyCurrentLowerLimit = SpindexerConstants.currentLimit;
     limitConfig.SupplyCurrentLowerTime = 1.5;
-    motor.getConfigurator().apply(limitConfig);
+    motorOne.getConfigurator().apply(limitConfig);
+    motorTwo.getConfigurator().apply(limitConfig);
 
+    // Invert motor two so they spin in opposite directions
+    MotorOutputConfigs motorConfig = new MotorOutputConfigs();
+    motorConfig.Inverted = InvertedValue.Clockwise_Positive;
+    motorTwo.getConfigurator().apply(motorConfig);
   }
 
   @Override
   public void updateInputs(SpindexerIOInputs inputs) {
-    inputs.spindexerVelocity = motor.getVelocity().getValueAsDouble(); // SpindexerConstants.gearRatio;
-    inputs.spindexerCurrent = motor.getStatorCurrent().getValueAsDouble();
-    inputs.spindexerPosition = motor.getPosition().getValueAsDouble();
+    inputs.spindexerOneVelocity = motorOne.getVelocity().getValueAsDouble();
+    inputs.spindexerOneCurrent = motorOne.getStatorCurrent().getValueAsDouble();
+    inputs.spindexerTwoVelocity = motorTwo.getVelocity().getValueAsDouble();
+    inputs.spindexerTwoCurrent = motorTwo.getStatorCurrent().getValueAsDouble();
   }
 
   @Override
@@ -36,17 +45,19 @@ public class SpindexerIOTalonFX implements SpindexerIO {
     limitConfig.StatorCurrentLimitEnable = true;
     limitConfig.SupplyCurrentLowerLimit = newCurrentLimit;
     limitConfig.SupplyCurrentLowerTime = 1.5;
-    motor.getConfigurator().apply(limitConfig);
+    motorOne.getConfigurator().apply(limitConfig);
+    motorTwo.getConfigurator().apply(limitConfig);
   }
 
   @Override
   public void setControl(ControlRequest request) {
-    motor.setControl(request);
+    motorOne.setControl(request);
+    motorTwo.setControl(request);
   }
 
   @Override
   public void setPositionRaw(double pos) {
-    motor.setPosition(pos);
+    motorOne.setPosition(pos);
+    motorTwo.setPosition(pos);
   }
-
 }