Skip to content

Commit 26c3893

Browse files
authored
Merge pull request #122 from DeepBlueRobotics/FixSwerveCurrentAndTorque
2 parents f30d84c + 9059304 commit 26c3893

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

src/main/java/org/carlmontrobotics/lib199/swerve/SwerveModule.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,19 @@ public SwerveModule(SwerveConfig config, ModuleType type, SparkBase drive, Spark
9797
final double normalForceNewtons = 83.2 /* lbf */ * 4.4482 /* N/lbf */ / 4 /* numModules */;
9898
double wheelTorqueLimitNewtonMeters = normalForceNewtons * config.mu * config.wheelDiameterMeters / 2;
9999
double motorTorqueLimitNewtonMeters = wheelTorqueLimitNewtonMeters / config.driveGearing;
100-
final double neoStallTorqueNewtonMeters = 3.36;
101-
final double neoFreeCurrentAmps = 1.3;
102-
final double neoStallCurrentAmps = 166;
103-
double currentLimitAmps = neoFreeCurrentAmps + 2*motorTorqueLimitNewtonMeters / neoStallTorqueNewtonMeters * (neoStallCurrentAmps-neoFreeCurrentAmps);
104-
// SmartDashboard.putNumber(type.toString() + " current limit (amps)", currentLimitAmps);
100+
101+
final double neoStallTorqueNewtonMeters = 2.6; //Empirical
102+
final double neoFreeCurrentAmps = 1.8; //Empirical
103+
final double neoStallCurrentAmps = 105; //Empirical
104+
105+
final double vortexStallTorqueNewtonMeters = 3.6; //theoretical?
106+
final double vortexFreeCurrentAmps = 3.6; //theoretical?
107+
final double vortexStallCurrentAmps = 211; //theoretical?
108+
109+
double currentLimitAmps = driveMotorType == MotorControllerType.SPARK_FLEX ? //Assumes that drive motor is either a NEO or NEO Vortex, will need a code struture change when we start using NEO 2.0 potentially for drive
110+
vortexFreeCurrentAmps + 2*motorTorqueLimitNewtonMeters / vortexStallTorqueNewtonMeters * (vortexStallCurrentAmps-vortexFreeCurrentAmps) :
111+
neoFreeCurrentAmps + 2*motorTorqueLimitNewtonMeters / neoStallTorqueNewtonMeters * (neoStallCurrentAmps-neoFreeCurrentAmps);
112+
105113
driveConfig.smartCurrentLimit(Math.min(50, (int)currentLimitAmps));
106114

107115
this.forwardSimpleMotorFF = new SimpleMotorFeedforward(config.kForwardVolts[arrIndex],

0 commit comments

Comments
 (0)