[wpilib] MotorControllerGroup: Override setVoltage (#4403)

This causes setVoltage to be called on the lower level motor contollers,
which is benefical in cases when they are smart motor controllers.
Previously, the default implementation (using the bus voltage and
calling set()) was used in this case.

This does slightly pessimize the case when the lower level motor
controllers use the default setVoltage implementation, but given the
prevalence of smart motor controllers, this seems like an overall win.
This commit is contained in:
Peter Johnson
2022-09-06 08:18:33 -07:00
committed by GitHub
parent f36162fddc
commit 65c8fbd452
3 changed files with 14 additions and 0 deletions

View File

@@ -54,6 +54,13 @@ public class MotorControllerGroup implements MotorController, Sendable, AutoClos
}
}
@Override
public void setVoltage(double outputVolts) {
for (MotorController motorController : m_motorControllers) {
motorController.setVoltage(m_isInverted ? -outputVolts : outputVolts);
}
}
@Override
public double get() {
if (m_motorControllers.length > 0) {