20
20
import frc .robot .Configs ;
21
21
22
22
public class MAXSwerveModule {
23
- private final SparkMax m_drivingSparkMax ;
24
- private final SparkMax m_turningSparkMax ;
23
+ private final SparkMax m_drivingSpark ;
24
+ private final SparkMax m_turningSpark ;
25
25
26
26
private final RelativeEncoder m_drivingEncoder ;
27
27
private final AbsoluteEncoder m_turningEncoder ;
28
28
29
- private final SparkClosedLoopController m_drivingPIDController ;
30
- private final SparkClosedLoopController m_turningPIDController ;
29
+ private final SparkClosedLoopController m_drivingClosedLoopController ;
30
+ private final SparkClosedLoopController m_turningClosedLoopController ;
31
31
32
32
private double m_chassisAngularOffset = 0 ;
33
33
private SwerveModuleState m_desiredState = new SwerveModuleState (0.0 , new Rotation2d ());
@@ -39,21 +39,21 @@ public class MAXSwerveModule {
39
39
* Encoder.
40
40
*/
41
41
public MAXSwerveModule (int drivingCANId , int turningCANId , double chassisAngularOffset ) {
42
- m_drivingSparkMax = new SparkMax (drivingCANId , MotorType .kBrushless );
43
- m_turningSparkMax = new SparkMax (turningCANId , MotorType .kBrushless );
42
+ m_drivingSpark = new SparkMax (drivingCANId , MotorType .kBrushless );
43
+ m_turningSpark = new SparkMax (turningCANId , MotorType .kBrushless );
44
44
45
- m_drivingEncoder = m_drivingSparkMax .getEncoder ();
46
- m_turningEncoder = m_turningSparkMax .getAbsoluteEncoder ();
45
+ m_drivingEncoder = m_drivingSpark .getEncoder ();
46
+ m_turningEncoder = m_turningSpark .getAbsoluteEncoder ();
47
47
48
- m_drivingPIDController = m_drivingSparkMax .getClosedLoopController ();
49
- m_turningPIDController = m_turningSparkMax .getClosedLoopController ();
48
+ m_drivingClosedLoopController = m_drivingSpark .getClosedLoopController ();
49
+ m_turningClosedLoopController = m_turningSpark .getClosedLoopController ();
50
50
51
51
// Apply the respective configurations to the SPARKS. Reset parameters before
52
52
// applying the configuration to bring the SPARK to a known good state. Persist
53
53
// the settings to the SPARK to avoid losing them on a power cycle.
54
- m_drivingSparkMax .configure (Configs .MAXSwerveModule .drivingConfig , ResetMode .kResetSafeParameters ,
54
+ m_drivingSpark .configure (Configs .MAXSwerveModule .drivingConfig , ResetMode .kResetSafeParameters ,
55
55
PersistMode .kPersistParameters );
56
- m_turningSparkMax .configure (Configs .MAXSwerveModule .turningConfig , ResetMode .kResetSafeParameters ,
56
+ m_turningSpark .configure (Configs .MAXSwerveModule .turningConfig , ResetMode .kResetSafeParameters ,
57
57
PersistMode .kPersistParameters );
58
58
59
59
m_chassisAngularOffset = chassisAngularOffset ;
@@ -100,9 +100,9 @@ public void setDesiredState(SwerveModuleState desiredState) {
100
100
// Optimize the reference state to avoid spinning further than 90 degrees.
101
101
correctedDesiredState .optimize (new Rotation2d (m_turningEncoder .getPosition ()));
102
102
103
- // Command driving and turning SPARKS MAX towards their respective setpoints.
104
- m_drivingPIDController .setReference (correctedDesiredState .speedMetersPerSecond , ControlType .kVelocity );
105
- m_turningPIDController .setReference (correctedDesiredState .angle .getRadians (), ControlType .kPosition );
103
+ // Command driving and turning SPARKS towards their respective setpoints.
104
+ m_drivingClosedLoopController .setReference (correctedDesiredState .speedMetersPerSecond , ControlType .kVelocity );
105
+ m_turningClosedLoopController .setReference (correctedDesiredState .angle .getRadians (), ControlType .kPosition );
106
106
107
107
m_desiredState = desiredState ;
108
108
}
0 commit comments