[wpimath] Fix ElevatorSim::GetCurrentDraw() in C++ (#8370)

The Kv calculation in C++ was missing a negative sign compared to the Java implementation.
This commit is contained in:
Benjamin Hall
2025-11-13 13:48:43 -05:00
committed by GitHub
parent b8d6bc2eb1
commit 95cb38e6df
3 changed files with 25 additions and 1 deletions

View File

@@ -88,7 +88,7 @@ units::ampere_t ElevatorSim::GetCurrentDraw() const {
double kA = 1.0 / m_plant.B(1, 0);
using Kv_t = units::unit_t<units::compound_unit<
units::volt, units::inverse<units::meters_per_second>>>;
Kv_t Kv = Kv_t{kA * m_plant.A(1, 1)};
Kv_t Kv = Kv_t{-kA * m_plant.A(1, 1)};
units::meters_per_second_t velocity{m_x(1)};
units::radians_per_second_t motorVelocity = velocity * Kv * m_gearbox.Kv;