Skip to content

Commit

Permalink
CPP updates
Browse files Browse the repository at this point in the history
  • Loading branch information
narmstro2020 committed Mar 31, 2024
1 parent 04842b4 commit 5e6f485
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wpilibc/src/main/native/cpp/simulation/DCMotorSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ units::ampere_t DCMotorSim::GetCurrentDraw() const {
}

units::kilogram_square_meter_t DCMotorSim::GetMomentOfInertia() const {
return m_gearing * m_gearbox.Kt / (m_gearbox.R * m_plant.B(0,0));
return units::kilogram_square_meter_t{m_gearing * m_gearbox.Kt.value() / (m_gearbox.R.value() * m_plant.B(0,0))};
}

void DCMotorSim::SetInputVoltage(units::volt_t voltage) {
SetInput(Vectord<1>{voltage.value()});
}

units::volt_t DCMotorSim::GetInputVoltage() const {
return GetInput(0);
return units::volt_t{GetInput(0)};
}
2 changes: 2 additions & 0 deletions wpilibc/src/test/native/cpp/simulation/DCMotorSimTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
#include "frc/simulation/EncoderSim.h"
#include "frc/simulation/RoboRioSim.h"


TEST(DCMotorSimTest, VoltageSteadyState) {
frc::DCMotor gearbox = frc::DCMotor::NEO(1);
frc::LinearSystemId.
frc::sim::DCMotorSim sim{gearbox, 1.0,
units::kilogram_square_meter_t{0.0005}};

Expand Down

0 comments on commit 5e6f485

Please sign in to comment.