@@ -45,6 +45,9 @@ public class SwerveModule implements Sendable {
4545 public enum ModuleType {FL , FR , BL , BR };
4646
4747 private SwerveConfig config ;
48+ private SparkMaxConfig turnConfig = new SparkMaxConfig ();
49+ private SparkMaxConfig driveConfig = new SparkMaxConfig ();
50+
4851 private ModuleType type ;
4952 private SparkMax drive , turn ;
5053 private CANcoder turnEncoder ;
@@ -74,12 +77,14 @@ public SwerveModule(SwerveConfig config, ModuleType type, SparkMax drive, SparkM
7477 this .drive = drive ;
7578
7679 double positionConstant = config .wheelDiameterMeters * Math .PI / config .driveGearing ;
77- drive .setInverted (config .driveInversion [arrIndex ]);
80+ driveConfig .inverted (config .driveInversion [arrIndex ]);
81+ turnConfig .inverted (config .turnInversion [arrIndex ]);
82+
7883 // drive.getEncoder().setPositionConversionFactor(positionConstant); //no such thing
7984 // drive.getEncoder().setVelocityConversionFactor(positionConstant / 60); //no such thing
8085 final double drivePositionFactor = positionConstant ;
8186 final double turnPositionFactor = positionConstant / 60 ;
82- turn . setInverted ( config . turnInversion [ arrIndex ]);
87+
8388 maxControllableAccerlationRps2 = 0 ;
8489 final double normalForceNewtons = 83.2 /* lbf */ * 4.4482 /* N/lbf */ / 4 /* numModules */ ;
8590 double wheelTorqueLimitNewtonMeters = normalForceNewtons * config .mu * config .wheelDiameterMeters / 2 ;
@@ -168,6 +173,10 @@ public SwerveModule(SwerveConfig config, ModuleType type, SparkMax drive, SparkM
168173
169174 SendableRegistry .addLW (this , "SwerveModule" , type .toString ());
170175
176+ //do stuff here
177+ drive .configure (driveConfig , ResetMode .kNoResetSafeParameters , PersistMode .kPersistParameters );
178+ turn .configure (turnConfig , ResetMode .kNoResetSafeParameters , PersistMode .kPersistParameters );
179+
171180 }
172181
173182 public ModuleType getType () {
0 commit comments