[sim] Create Left/Right drivetrain current accessors (#3001)

This commit is contained in:
PJ Reiniger
2020-12-29 23:46:51 -05:00
committed by GitHub
parent b60eb1544b
commit 66782e2317
3 changed files with 29 additions and 4 deletions

View File

@@ -90,7 +90,7 @@ Pose2d DifferentialDrivetrainSim::GetPose() const {
units::meter_t(GetOutput(State::kY)), GetHeading());
}
units::ampere_t DifferentialDrivetrainSim::GetCurrentDraw() const {
units::ampere_t DifferentialDrivetrainSim::GetLeftCurrentDraw() const {
auto loadIleft =
m_motor.Current(units::radians_per_second_t(m_x(State::kLeftVelocity) *
m_currentGearing /
@@ -98,6 +98,10 @@ units::ampere_t DifferentialDrivetrainSim::GetCurrentDraw() const {
units::volt_t(m_u(0))) *
wpi::sgn(m_u(0));
return loadIleft;
}
units::ampere_t DifferentialDrivetrainSim::GetRightCurrentDraw() const {
auto loadIRight =
m_motor.Current(units::radians_per_second_t(m_x(State::kRightVelocity) *
m_currentGearing /
@@ -105,7 +109,10 @@ units::ampere_t DifferentialDrivetrainSim::GetCurrentDraw() const {
units::volt_t(m_u(1))) *
wpi::sgn(m_u(1));
return loadIleft + loadIRight;
return loadIRight;
}
units::ampere_t DifferentialDrivetrainSim::GetCurrentDraw() const {
return GetLeftCurrentDraw() + GetRightCurrentDraw();
}
void DifferentialDrivetrainSim::SetState(