[wpilib] Rename MotorController setDutyCycle() to setThrottle() (#8720)

Fixes #8716.
This commit is contained in:
Tyler Veness
2026-04-09 22:28:01 -07:00
committed by GitHub
parent a4e035ba64
commit b6849a8da3
160 changed files with 659 additions and 706 deletions

View File

@@ -76,7 +76,7 @@ class Arm:
# In this method, we update our simulation of what our arm is doing
# First, we set our "inputs" (voltages)
self.armSim.setInput(
[self.motor.getDutyCycle() * wpilib.RobotController.getBatteryVoltage()]
[self.motor.getThrottle() * wpilib.RobotController.getBatteryVoltage()]
)
# Next, we update it. The standard loop time is 20ms.
@@ -111,4 +111,4 @@ class Arm:
self.motor.setVoltage(pidOutput)
def stop(self) -> None:
self.motor.setDutyCycle(0.0)
self.motor.setThrottle(0.0)

View File

@@ -244,8 +244,8 @@ class Drivetrain:
# simulation, and write the simulated positions and velocities to our
# simulated encoder and gyro.
self.drivetrainSimulator.setInputs(
self.leftLeader.getDutyCycle() * wpilib.RobotController.getInputVoltage(),
self.rightLeader.getDutyCycle() * wpilib.RobotController.getInputVoltage(),
self.leftLeader.getThrottle() * wpilib.RobotController.getInputVoltage(),
self.rightLeader.getThrottle() * wpilib.RobotController.getInputVoltage(),
)
self.drivetrainSimulator.update(0.02)

View File

@@ -84,7 +84,7 @@ class Elevator:
# In this method, we update our simulation of what our elevator is doing
# First, we set our "inputs" (voltages)
self.elevatorSim.setInputVoltage(
self.motorSim.getDutyCycle() * wpilib.RobotController.getBatteryVoltage()
self.motorSim.getThrottle() * wpilib.RobotController.getBatteryVoltage()
)
# Next, we update it. The standard loop time is 20ms.
@@ -120,7 +120,7 @@ class Elevator:
def stop(self) -> None:
"""Stop the control loop and motor output."""
self.motor.setDutyCycle(0.0)
self.motor.setThrottle(0.0)
def reset(self) -> None:
"""Reset Exponential profile to begin from current position on enable."""

View File

@@ -68,7 +68,7 @@ class Elevator:
# In this method, we update our simulation of what our elevator is doing
# First, we set our "inputs" (voltages)
self.elevatorSim.setInputVoltage(
self.motorSim.getDutyCycle() * wpilib.RobotController.getBatteryVoltage()
self.motorSim.getThrottle() * wpilib.RobotController.getBatteryVoltage()
)
# Next, we update it. The standard loop time is 20ms.
@@ -99,7 +99,7 @@ class Elevator:
def stop(self) -> None:
"""Stop the control loop and motor output."""
self.controller.setGoal(0.0)
self.motor.setDutyCycle(0.0)
self.motor.setThrottle(0.0)
def updateTelemetry(self) -> None:
"""Update telemetry, including the mechanism visualization."""

View File

@@ -102,7 +102,7 @@ class MyRobot(wpilib.TimedRobot):
# To update our simulation, we set motor voltage inputs, update the
# simulation, and write the simulated velocities to our simulated encoder
self.flywheelSim.setInputVoltage(
self.flywheelMotor.getDutyCycle() * wpilib.RobotController.getInputVoltage()
self.flywheelMotor.getThrottle() * wpilib.RobotController.getInputVoltage()
)
self.flywheelSim.update(0.02)
self.encoderSim.setRate(self.flywheelSim.getAngularVelocity())

View File

@@ -56,5 +56,5 @@ class MyRobot(wpilib.TimedRobot):
self.wrist.setAngle(self.wristPot.get())
def teleopPeriodic(self):
self.elevatorMotor.setDutyCycle(self.joystick.getRawAxis(0))
self.wristMotor.setDutyCycle(self.joystick.getRawAxis(1))
self.elevatorMotor.setThrottle(self.joystick.getRawAxis(0))
self.wristMotor.setThrottle(self.joystick.getRawAxis(1))

View File

@@ -43,4 +43,4 @@ class MyRobot(wpilib.TimedRobot):
wpilib.SmartDashboard.putNumber("Encoder", self.encoder.getDistance())
def teleopPeriodic(self):
self.motor.setDutyCycle(self.joystick.getY())
self.motor.setThrottle(self.joystick.getY())

View File

@@ -145,8 +145,8 @@ class Drivetrain:
# simulated encoder and gyro. We negate the right side so that positive
# voltages make the right side move forward.
self.drivetrainSimulator.setInputs(
self.leftLeader.getDutyCycle() * wpilib.RobotController.getInputVoltage(),
self.rightLeader.getDutyCycle() * wpilib.RobotController.getInputVoltage(),
self.leftLeader.getThrottle() * wpilib.RobotController.getInputVoltage(),
self.rightLeader.getThrottle() * wpilib.RobotController.getInputVoltage(),
)
self.drivetrainSimulator.update(0.02)

View File

@@ -93,7 +93,7 @@ class Shooter(Subsystem):
)
+ self.shooter_feedforward.calculate(target_velocity_radians)
)
self.feeder_motor.setDutyCycle(ShooterConstants.kFeederVelocity)
self.feeder_motor.setThrottle(ShooterConstants.kFeederVelocity)
def _stop_motors(interrupted: bool) -> None:
self.shooter_motor.stopMotor()

View File

@@ -20,17 +20,17 @@ class Intake:
)
def deploy(self) -> None:
self.piston.setDutyCycle(wpilib.DoubleSolenoid.Value.FORWARD)
self.piston.setThrottle(wpilib.DoubleSolenoid.Value.FORWARD)
def retract(self) -> None:
self.piston.setDutyCycle(wpilib.DoubleSolenoid.Value.REVERSE)
self.motor.setDutyCycle(0) # turn off the motor
self.piston.setThrottle(wpilib.DoubleSolenoid.Value.REVERSE)
self.motor.setThrottle(0) # turn off the motor
def activate(self, velocity: float) -> None:
if self.isDeployed():
self.motor.setDutyCycle(velocity)
self.motor.setThrottle(velocity)
else: # if piston isn't open, do nothing
self.motor.setDutyCycle(0)
self.motor.setThrottle(0)
def isDeployed(self) -> bool:
return self.piston.get() == wpilib.DoubleSolenoid.Value.FORWARD

View File

@@ -32,7 +32,7 @@ class Drivetrain(commands2.Subsystem):
# Set up the differential drive controller
self.drive = wpilib.DifferentialDrive(
self.leftMotor.setDutyCycle, self.rightMotor.setDutyCycle
self.leftMotor.setThrottle, self.rightMotor.setThrottle
)
# TODO: these don't work