mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[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:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user