Fix DCMotor equations to use freeCurrent#8395
Fix DCMotor equations to use freeCurrent#8395tervay wants to merge 1 commit intowpilibsuite:mainfrom
Conversation
a2baa06 to
06ae8fa
Compare
| @@ -122,7 +122,7 @@ public double getVoltage(double torqueNm, double speedRadiansPerSec) { | |||
| */ | |||
| public double getSpeed(double torqueNm, double voltageInputVolts) { | |||
| return voltageInputVolts * KvRadPerSecPerVolt | |||
There was a problem hiding this comment.
This doesn't seem right, since plugging in a torque and voltage of zero results in a nonzero speed.
There was a problem hiding this comment.
free current scales with voltage right?
There was a problem hiding this comment.
I don't know. I was only ever taught about free current with respect to the free speed at the test voltage. I'm unable to find more info online either.
|
Shouldn't these equations also technically be multiplying the free current by the sign of the velocity? Otherwise, the free current makes the model behavior asymmetric for positive and negative speeds. The problem with doing that is the DC motor model becomes nonlinear instead of linear, which violates modeling assumptions everywhere else in the library. |
probably, yes, in ReCalc I simply pretend negative speeds don't exist so i overlooked this. will fix |
| */ | ||
| public double getTorque(double currentAmpere) { | ||
| return currentAmpere * KtNMPerAmp; | ||
| return (currentAmpere - freeCurrentAmps) * KtNMPerAmp; |
There was a problem hiding this comment.
This returns a negative torque at 0 A, but at 0 velocity, 0 A actually corresponds to 0 torque. (This and getSpeed() are what makes accounting for free current so difficult/annoying.)
DCMotorwasn't usingfreeCurrent; this meant that trying to get the torque of a motor at freeSpeed would be a nonzero torque. This fixes it and adds a handful of possibly over-parameterized tests. (Wanted to make sure the math works on a variety of motor specs.)Draft until I can fix all the tests.