[wpimath] Make Java DCMotor API consistent with C++ and fix motor calcs (#3046)

The stall torque, stall current, and free current are now multiplied by
the number of motors instead of just the stall torque. This produces the
same values for Kt and Kv regardless of the number of motors; the motor
resistance still affects the system response.

For an elevator model, the response should be the same as before since a
factor of "number of motors" shows up in the same place in the
acceleration calculation, but the current calculation will also be
correct now.
This commit is contained in:
Tyler Veness
2021-01-05 18:28:57 -08:00
committed by GitHub
parent 377b7065aa
commit d8652cfd4f
5 changed files with 72 additions and 84 deletions

View File

@@ -39,10 +39,8 @@ public class ExtendedKalmanFilterTest {
final var J = 5.6; // Robot moment of inertia
final var C1 =
-Math.pow(gr, 2)
* motors.m_KtNMPerAmp
/ (motors.m_KvRadPerSecPerVolt * motors.m_rOhms * r * r);
final var C2 = gr * motors.m_KtNMPerAmp / (motors.m_rOhms * r);
-Math.pow(gr, 2) * motors.KtNMPerAmp / (motors.KvRadPerSecPerVolt * motors.rOhms * r * r);
final var C2 = gr * motors.KtNMPerAmp / (motors.rOhms * r);
final var k1 = 1.0 / m + rb * rb / J;
final var k2 = 1.0 / m - rb * rb / J;

View File

@@ -43,9 +43,9 @@ public class UnscentedKalmanFilterTest {
var C1 =
-Math.pow(gHigh, 2)
* motors.m_KtNMPerAmp
/ (motors.m_KvRadPerSecPerVolt * motors.m_rOhms * r * r);
var C2 = gHigh * motors.m_KtNMPerAmp / (motors.m_rOhms * r);
* motors.KtNMPerAmp
/ (motors.KvRadPerSecPerVolt * motors.rOhms * r * r);
var C2 = gHigh * motors.KtNMPerAmp / (motors.rOhms * r);
var c = x.get(2, 0);
var s = x.get(3, 0);