diff --git a/src/main/java/frc/robot/shooter/FlywheelMotorIOTalonFX.java b/src/main/java/frc/robot/shooter/FlywheelMotorIOTalonFX.java new file mode 100644 index 0000000..dde5595 --- /dev/null +++ b/src/main/java/frc/robot/shooter/FlywheelMotorIOTalonFX.java @@ -0,0 +1,40 @@ +package frc.robot.shooter; + +import com.ctre.phoenix6.hardware.TalonFX; +import com.ctre.phoenix6.signals.NeutralModeValue; + +public class FlywheelMotorIOTalonFX implements FlywheelMotorIO { + + private final TalonFX talonFX; + + public FlywheelMotorIOTalonFX() { + int canId = 39; + + talonFX = new TalonFX(canId); + } + + + @Override + public void configure() { + talonFX.setInverted(false); + + talonFX.setNeutralMode(NeutralModeValue.Coast); + } + + @Override + public void update(FlywheelMotorIOValues values) { + values.angularVelocityRotationsPerSecond = talonFX.getVelocity().getValue(); // TODO convert? + values.currentAmps = talonFX.getStatorCurrent().getValue(); + } + + @Override + public void setVoltage(double volts) { + talonFX.setVoltage(volts); + } + + @Override + public void stop() { + setVoltage(0); + } + +} diff --git a/src/main/java/frc/robot/shooter/ShooterFactory.java b/src/main/java/frc/robot/shooter/ShooterFactory.java index 2ff2c4d..75083a7 100644 --- a/src/main/java/frc/robot/shooter/ShooterFactory.java +++ b/src/main/java/frc/robot/shooter/ShooterFactory.java @@ -38,7 +38,7 @@ public static SerializerMotorIO createSerializerMotor() { */ public static FlywheelMotorIO createFlywheelMotor() { if (Robot.isReal() && RobotConstants.REAL_SUBSYSTEMS.contains(Subsystem.SHOOTER)) - return new FlywheelMotorIOSparkMax(); // TODO + return new FlywheelMotorIOTalonFX(); return new FlywheelMotorIOSim(); }