mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +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:
@@ -55,12 +55,12 @@ class DCMotor {
|
||||
units::radians_per_second_t freeSpeed, int numMotors = 1)
|
||||
: nominalVoltage(nominalVoltage),
|
||||
stallTorque(stallTorque * numMotors),
|
||||
stallCurrent(stallCurrent),
|
||||
freeCurrent(freeCurrent),
|
||||
stallCurrent(stallCurrent * numMotors),
|
||||
freeCurrent(freeCurrent * numMotors),
|
||||
freeSpeed(freeSpeed),
|
||||
R(nominalVoltage / stallCurrent),
|
||||
Kv(freeSpeed / (nominalVoltage - R * freeCurrent)),
|
||||
Kt(stallTorque * numMotors / stallCurrent) {}
|
||||
R(nominalVoltage / this->stallCurrent),
|
||||
Kv(freeSpeed / (nominalVoltage - R * this->freeCurrent)),
|
||||
Kt(this->stallTorque / this->stallCurrent) {}
|
||||
|
||||
/**
|
||||
* Returns current drawn by motor with given speed and input voltage.
|
||||
|
||||
Reference in New Issue
Block a user