mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user