55package frc .robot .subsystems ;
66
77import com .ctre .phoenix6 .hardware .CANcoder ;
8+ import com .revrobotics .spark .SparkFlex ;
89import com .revrobotics .spark .SparkBase .PersistMode ;
910import com .revrobotics .spark .SparkBase .ResetMode ;
1011import com .revrobotics .spark .SparkLowLevel .MotorType ;
11- import com .revrobotics .spark .SparkMax ;
12+ import com .revrobotics .spark .config . SparkFlexConfig ;
1213import com .revrobotics .spark .config .SparkBaseConfig .IdleMode ;
13- import com .revrobotics .spark .config .SparkMaxConfig ;
1414
1515import edu .wpi .first .math .controller .PIDController ;
1616import edu .wpi .first .math .geometry .Rotation2d ;
2121import frc .robot .Robot ;
2222
2323public class SwerveModule {
24- private final SparkMax m_driveMotor ;
25- private final SparkMax m_turningMotor ;
24+ private final SparkFlex m_driveMotor ;
25+ private final SparkFlex m_turningMotor ;
2626
27- private final SparkMaxConfig m_driveMotorConfig = new SparkMaxConfig ();
28- private final SparkMaxConfig m_turningMotorConfig = new SparkMaxConfig ();
27+ private final SparkFlexConfig m_driveMotorConfig = new SparkFlexConfig ();
28+ private final SparkFlexConfig m_turningMotorConfig = new SparkFlexConfig ();
2929
3030 private final CANcoder m_turningEncoder ;
3131
@@ -50,8 +50,8 @@ public SwerveModule(
5050 int turningMotorPort ,
5151 int turningEncoderPort ,
5252 boolean driveMotorReversed ) {
53- m_driveMotor = new SparkMax (driveMotorPort , MotorType .kBrushless );
54- m_turningMotor = new SparkMax (turningMotorPort , MotorType .kBrushless );
53+ m_driveMotor = new SparkFlex (driveMotorPort , MotorType .kBrushless );
54+ m_turningMotor = new SparkFlex (turningMotorPort , MotorType .kBrushless );
5555 m_turningEncoder = new CANcoder (turningEncoderPort );
5656
5757 // converts default units to meters per second
@@ -97,7 +97,7 @@ public void setDesiredState(SwerveModuleState desiredState) {
9797 m_state .optimize (getEncoderAngle (m_turningEncoder ));
9898 driveOutput = m_state .speedMetersPerSecond / DriveConstants .kMaxSpeedMetersPerSecond ;
9999
100- turnOutput = m_turningPIDController .calculate (getEncoderAngle (m_turningEncoder ).getRadians (),
100+ turnOutput = - m_turningPIDController .calculate (getEncoderAngle (m_turningEncoder ).getRadians (),
101101 m_state .angle .getRadians ());
102102
103103 m_driveMotor .set (driveOutput );
0 commit comments