[wpilib] Enable ExpansionHub motors and servos on any set (#8619)

This more matches the existing FTC SDK. And removes the footgun of
needing to call set.
This commit is contained in:
Thad House
2026-02-17 20:19:52 -08:00
committed by GitHub
parent 1dbffb972f
commit af01a72725
4 changed files with 11 additions and 0 deletions

View File

@@ -158,6 +158,7 @@ public class ExpansionHubMotor implements AutoCloseable {
* @param power The power to drive the motor at
*/
public void setPercentagePower(double power) {
setEnabled(true);
m_modePublisher.set(kPercentageMode);
m_setpointPublisher.set(power);
}
@@ -169,6 +170,7 @@ public class ExpansionHubMotor implements AutoCloseable {
* @param voltage The voltage to drive the motor at
*/
public void setVoltage(Voltage voltage) {
setEnabled(true);
m_modePublisher.set(kVoltageMode);
m_setpointPublisher.set(voltage.in(Volts));
}
@@ -180,6 +182,7 @@ public class ExpansionHubMotor implements AutoCloseable {
* @param setpoint The position setpoint to drive the motor to
*/
public void setPositionSetpoint(double setpoint) {
setEnabled(true);
m_modePublisher.set(kPositionMode);
m_setpointPublisher.set(setpoint);
}
@@ -191,6 +194,7 @@ public class ExpansionHubMotor implements AutoCloseable {
* @param setpoint The velocity setpoint to drive the motor to
*/
public void setVelocitySetpoint(double setpoint) {
setEnabled(true);
m_modePublisher.set(kVelocityMode);
m_setpointPublisher.set(setpoint);
}

View File

@@ -107,6 +107,7 @@ public class ExpansionHubServo implements AutoCloseable {
int rawValue = (int) ((value * getFullRangeScaleFactor()) + m_minPwm);
setEnabled(true);
m_pulseWidthPublisher.set(rawValue);
}
@@ -142,6 +143,7 @@ public class ExpansionHubServo implements AutoCloseable {
* @param pulseWidth Pulse width
*/
public void setPulseWidth(Time pulseWidth) {
setEnabled(true);
m_pulseWidthPublisher.set((long) pulseWidth.in(Microseconds));
}