[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

@@ -201,18 +201,26 @@ public class DifferentialDrivetrainSim {
return getOutput(State.kLeftVelocity);
}
public double getCurrentDrawAmps() {
public double getLeftCurrentDrawAmps() {
var loadIleft = m_motor.getCurrent(
getState(State.kLeftVelocity) * m_currentGearing / m_wheelRadiusMeters,
m_u.get(0, 0)) * Math.signum(m_u.get(0, 0));
return loadIleft;
}
public double getRightCurrentDrawAmps() {
var loadIright = m_motor.getCurrent(
getState(State.kRightVelocity) * m_currentGearing / m_wheelRadiusMeters,
m_u.get(1, 0)) * Math.signum(m_u.get(1, 0));
return loadIleft + loadIright;
return loadIright;
}
public double getCurrentDrawAmps() {
return getLeftCurrentDrawAmps() + getRightCurrentDrawAmps();
}
public double getCurrentGearing() {
return m_currentGearing;
}