From: mixxlto Date: Mon, 9 Feb 2026 23:44:44 +0000 (-0800) Subject: spindexer X-Git-Url: https://git.taranathan.com/?a=commitdiff_plain;h=789539a391ef6e85a95c7db8431e8f1d21f7e468;p=FRC2026.git spindexer --- diff --git a/src/main/java/frc/robot/commands/gpm/AutoShootCommand.java b/src/main/java/frc/robot/commands/gpm/AutoShootCommand.java index 45601be..db29653 100644 --- a/src/main/java/frc/robot/commands/gpm/AutoShootCommand.java +++ b/src/main/java/frc/robot/commands/gpm/AutoShootCommand.java @@ -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 diff --git a/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java b/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java index 07c06a4..6f92ef6 100644 --- a/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java +++ b/src/main/java/frc/robot/commands/gpm/TurretAutoShoot.java @@ -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 diff --git a/src/main/java/frc/robot/constants/IdConstants.java b/src/main/java/frc/robot/constants/IdConstants.java index 8d50b89..19c5838 100644 --- a/src/main/java/frc/robot/constants/IdConstants.java +++ b/src/main/java/frc/robot/constants/IdConstants.java @@ -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 index 0000000..32f3fa8 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java @@ -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 index 0000000..1cf6740 --- /dev/null +++ b/src/main/java/frc/robot/subsystems/spindexer/SpindexerIO.java @@ -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(); +}