From: iefomit Date: Tue, 7 Apr 2026 01:48:10 +0000 (-0700) Subject: enable foc on all motors X-Git-Url: https://git.taranathan.com/?a=commitdiff_plain;h=642d94bb73d85878c2ad0b9ca1b4c208d0cbbd31;p=FRC2026.git enable foc on all motors --- diff --git a/src/main/java/frc/robot/subsystems/Intake/Intake.java b/src/main/java/frc/robot/subsystems/Intake/Intake.java index b0eea66..d373bb9 100644 --- a/src/main/java/frc/robot/subsystems/Intake/Intake.java +++ b/src/main/java/frc/robot/subsystems/Intake/Intake.java @@ -255,8 +255,8 @@ public class Intake extends SubsystemBase implements IntakeIO{ */ public void setPosition(double setpoint) { double motorRotations = -inchesToRotations(setpoint); - rightMotor.setControl(voltageRequest.withPosition(motorRotations)); - leftMotor.setControl(voltageRequest.withPosition(motorRotations)); + rightMotor.setControl(voltageRequest.withPosition(motorRotations).withEnableFOC(true)); + leftMotor.setControl(voltageRequest.withPosition(motorRotations).withEnableFOC(true)); setpointInches = setpoint; } diff --git a/src/main/java/frc/robot/subsystems/hood/Hood.java b/src/main/java/frc/robot/subsystems/hood/Hood.java index 102d949..e0b8bdd 100644 --- a/src/main/java/frc/robot/subsystems/hood/Hood.java +++ b/src/main/java/frc/robot/subsystems/hood/Hood.java @@ -150,7 +150,8 @@ public class Hood extends SubsystemBase implements HoodIO { // Set control with feedforward motor.setControl(mmVoltageRequest .withPosition(motorGoalRotations) - .withFeedForward(velocityCompensation)); + .withFeedForward(velocityCompensation) + .withEnableFOC(true)); } if (!Constants.DISABLE_LOGGING) { diff --git a/src/main/java/frc/robot/subsystems/shooter/Shooter.java b/src/main/java/frc/robot/subsystems/shooter/Shooter.java index fcec299..af8cfac 100644 --- a/src/main/java/frc/robot/subsystems/shooter/Shooter.java +++ b/src/main/java/frc/robot/subsystems/shooter/Shooter.java @@ -93,8 +93,8 @@ public class Shooter extends SubsystemBase implements ShooterIO { } // Sets the motor control to target velocity - shooterMotorLeft.setControl(voltageRequest.withVelocity(targetVelocityRPS)); - shooterMotorRight.setControl(voltageRequest.withVelocity(targetVelocityRPS)); + shooterMotorLeft.setControl(voltageRequest.withVelocity(targetVelocityRPS).withEnableFOC(true)); + shooterMotorRight.setControl(voltageRequest.withVelocity(targetVelocityRPS).withEnableFOC(true)); if (!Constants.DISABLE_LOGGING) { Logger.recordOutput("Shooter/realVelocity", shooterMotorLeft.getVelocity().getValueAsDouble() * ShooterConstants.SHOOTER_LAUNCH_DIAMETER); diff --git a/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java b/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java index 4cba8ed..36724a7 100644 --- a/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java +++ b/src/main/java/frc/robot/subsystems/spindexer/Spindexer.java @@ -1,6 +1,7 @@ package frc.robot.subsystems.spindexer; import com.ctre.phoenix6.configs.CurrentLimitsConfigs; +import com.ctre.phoenix6.controls.DutyCycleOut; import com.ctre.phoenix6.hardware.TalonFX; import org.littletonrobotics.junction.Logger; @@ -62,18 +63,18 @@ public class Spindexer extends SubsystemBase implements SpindexerIO { } if (state == SpindexerState.MAX) { - motor.set(SpindexerConstants.spindexerMaxPower); + motor.setControl(new DutyCycleOut(SpindexerConstants.spindexerMaxPower).withEnableFOC(true)); reversing = false; } else if (state == SpindexerState.REVERSE) { - motor.set(SpindexerConstants.spindexerReversePower); + motor.setControl(new DutyCycleOut(SpindexerConstants.spindexerReversePower).withEnableFOC(true)); reversing = true; } else if (state == SpindexerState.STOPPED) { - motor.set(0.0); + motor.setControl(new DutyCycleOut(0.0).withEnableFOC(true)); reversing = false; } else if (state == SpindexerState.RESET && resetPos != null) { - motor.set(resetPID.calculate((motor.getPosition().getValueAsDouble() / gearRatio) % 1.0, resetPos)); + motor.setControl(new DutyCycleOut(resetPID.calculate((motor.getPosition().getValueAsDouble() / gearRatio) % 1.0, resetPos)).withEnableFOC(true)); } else { - motor.set(power); + motor.setControl(new DutyCycleOut(power).withEnableFOC(true)); reversing = false; } diff --git a/src/main/java/frc/robot/subsystems/turret/Turret.java b/src/main/java/frc/robot/subsystems/turret/Turret.java index 626a8ed..3c7d47a 100644 --- a/src/main/java/frc/robot/subsystems/turret/Turret.java +++ b/src/main/java/frc/robot/subsystems/turret/Turret.java @@ -216,7 +216,8 @@ public class Turret extends SubsystemBase implements TurretIO{ // Sets motor control with feedforward motor.setControl(mmVoltageRequest .withPosition(motorGoalRotations) - .withFeedForward(robotTurnCompensation)); + .withFeedForward(robotTurnCompensation) + .withEnableFOC(true)); } if (!Constants.DISABLE_LOGGING) {