Skip to content

Commit

Permalink
[wpimath] Fix DCMotor.getSpeed() (#5061)
Browse files Browse the repository at this point in the history
This bug didn't occur in C++ because the units system caught it at
compile time.
  • Loading branch information
calcmogul committed Feb 5, 2023
1 parent b43ec87 commit 2f310a7
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -86,7 +86,8 @@ public double getVoltage(double torqueNm, double speedRadiansPerSec) {
* @return The speed of the motor.
*/
public double getSpeed(double torqueNm, double voltageInputVolts) {
return voltageInputVolts - 1.0 / KtNMPerAmp * torqueNm * rOhms * KvRadPerSecPerVolt;
return voltageInputVolts * KvRadPerSecPerVolt
- 1.0 / KtNMPerAmp * torqueNm * rOhms * KvRadPerSecPerVolt;
}

/**
Expand Down

0 comments on commit 2f310a7

Please sign in to comment.