[wpilib] Add getVoltage to PWMMotorController (#6044)

This commit is contained in:
Jade
2024-09-08 13:24:51 +08:00
committed by GitHub
parent 6e8feb154c
commit cd9922af49
3 changed files with 23 additions and 0 deletions

View File

@@ -37,6 +37,10 @@ double PWMMotorController::Get() const {
return m_pwm.GetSpeed() * (m_isInverted ? -1.0 : 1.0);
}
units::volt_t PWMMotorController::GetVoltage() const {
return Get() * RobotController::GetBatteryVoltage();
}
void PWMMotorController::SetInverted(bool isInverted) {
m_isInverted = isInverted;
}

View File

@@ -72,6 +72,15 @@ class PWMMotorController : public MotorController,
*/
double Get() const override;
/**
* Gets the voltage output of the motor controller, nominally between -12 V
* and 12 V.
*
* @return The voltage of the motor controller, nominally between -12 V and 12
* V.
*/
virtual units::volt_t GetVoltage() const;
void SetInverted(bool isInverted) override;
bool GetInverted() const override;