]> git.taranathan.com Git - FRC2026.git/commitdiff
spindexer
authormixxlto <maxtan0626@gmail.com>
Mon, 9 Feb 2026 23:44:44 +0000 (15:44 -0800)
committermixxlto <maxtan0626@gmail.com>
Mon, 9 Feb 2026 23:44:44 +0000 (15:44 -0800)
src/main/java/frc/robot/commands/gpm/AutoShootCommand.java
src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java
src/main/java/frc/robot/constants/IdConstants.java
src/main/java/frc/robot/subsystems/spindexer/Spindexer.java [new file with mode: 0644]
src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java [new file with mode: 0644]

index 45601be5ca28caeca4bcbcf2d503988fb135a1c3..db296538790070cd5029587ca947c9f9465afac1 100644 (file)
@@ -74,7 +74,7 @@ public class AutoShootCommand extends Command {
     public void updateSetpoints(Pose2d drivepose) {
 
         Translation2d target = FieldConstants.getHubTranslation().toTranslation2d();
-        Pose2d turretPosition = drivepose.transformBy(new Transform2d((TurretConstants.DISTANCE_FROM_ROBOT_CENTER), new Rotation2d()));
+        Pose2d turretPosition = drivepose.transformBy(new Transform2d((new Translation2d(TurretConstants.DISTANCE_FROM_ROBOT_CENTER.getX(),TurretConstants.DISTANCE_FROM_ROBOT_CENTER.getY())), new Rotation2d()));
         double turretToTargetDistance = target.getDistance(turretPosition.getTranslation());
         
         // If the robot is moving, adjust the target position based on velocity
index 07c06a4782f88c4c7feef31dd819d5f4da48ead8..6f92ef6e08b9ce9dcfb9a884bcbf6210df80537d 100644 (file)
@@ -43,7 +43,7 @@ public class TurretAutoShoot extends Command {
     public void updateTurretSetpoint(Pose2d drivepose) {
         
         Translation2d target = FieldConstants.getHubTranslation().toTranslation2d();
-        Pose2d turretPosition = drivepose.transformBy(new Transform2d((TurretConstants.DISTANCE_FROM_ROBOT_CENTER), new Rotation2d()));
+        Pose2d turretPosition = drivepose.transformBy(new Transform2d((new Translation2d(TurretConstants.DISTANCE_FROM_ROBOT_CENTER.getX(),TurretConstants.DISTANCE_FROM_ROBOT_CENTER.getY())), new Rotation2d()));
         double turretToTargetDistance = target.getDistance(turretPosition.getTranslation());
         
         // If the robot is moving, adjust the target position based on velocity
index 8d50b893239658d95909a31ccefd52e9d89acc93..19c58381ec43e9483bb8fdb3359d3c7ced4888c8 100644 (file)
@@ -24,7 +24,7 @@ public class IdConstants {
 
     // Shooter
     public static final int SHOOTER_LEFT_ID = 10;
-    public static final int SHOOTER_RIGHT_ID =4;
+    public static final int SHOOTER_RIGHT_ID = 4;
     public static final int FEEDER_ID = 21;
 
     // Climb
@@ -33,4 +33,7 @@ public class IdConstants {
 
     // Hood
     public static final int HOOD_ID = 11;
+
+    // Spindexer
+    public static final int SPINDEXER_ID = 12;
 }
diff --git a/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java b/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java
new file mode 100644 (file)
index 0000000..32f3fa8
--- /dev/null
@@ -0,0 +1,45 @@
+package frc.robot.subsystems.spindexer;
+
+import com.ctre.phoenix6.hardware.TalonFX;
+
+import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
+import edu.wpi.first.wpilibj2.command.InstantCommand;
+import edu.wpi.first.wpilibj2.command.SubsystemBase;
+import frc.robot.constants.IdConstants;
+import frc.robot.subsystems.spindexer.SpindexerIO;
+
+public class Spindexer extends SubsystemBase implements SpindexerIO{
+    TalonFX motor = new TalonFX(IdConstants.SPINDEXER_ID);
+
+    private double power = 0.0;
+    private double runPower = 0.0;
+
+    private SpindexerIOInputsAutoLogged inputs = new SpindexerIOInputsAutoLogged();
+
+    public Spindexer(){
+        //SmartDashboard.putData("Turn on Spindexer", new InstantCommand(()-> turnOnSpindexer()));
+    }
+
+    @Override
+    public void periodic() {
+        runPower = SmartDashboard.getNumber("Spindexer Power", runPower);
+        SmartDashboard.putNumber("Spindexer Power", runPower);
+
+        motor.set(power);
+    }
+
+    public void turnOnSpindexer(){
+        power = runPower;
+    }
+
+    public void stopSpindexer(){
+        power = 0.0;
+    }
+
+    @Override
+    public void updateInputs() {
+        inputs.spindexerVelocity = motor.getVelocity().getValueAsDouble();
+        inputs.spindexerCurrent = motor.getStatorCurrent().getValueAsDouble();
+    }
+
+}
diff --git a/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java
new file mode 100644 (file)
index 0000000..1cf6740
--- /dev/null
@@ -0,0 +1,13 @@
+package frc.robot.subsystems.spindexer;
+
+import org.littletonrobotics.junction.AutoLog;
+
+public interface SpindexerIO {
+    @AutoLog
+    public static class SpindexerIOInputs {
+        public double spindexerVelocity = 0.0;
+        public double spindexerCurrent = 0.0;
+    }
+
+    public void updateInputs();
+}