[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

@@ -44,8 +44,8 @@ class Robot : public wpi::TimedRobot {
wpi::Spark rightLeader{2};
wpi::Spark rightFollower{3};
wpi::DifferentialDrive drive{
[&](double output) { leftLeader.SetDutyCycle(output); },
[&](double output) { rightLeader.SetDutyCycle(output); }};
[&](double output) { leftLeader.SetThrottle(output); },
[&](double output) { rightLeader.SetThrottle(output); }};
};
#ifndef RUNNING_WPILIB_TESTS

View File

@@ -17,9 +17,9 @@ class Robot : public wpi::TimedRobot {
// Runs the motor backwards at half velocity until the limit switch is
// pressed then turn off the motor and reset the encoder
if (!m_limit.Get()) {
m_spark.SetDutyCycle(-0.5);
m_spark.SetThrottle(-0.5);
} else {
m_spark.SetDutyCycle(0);
m_spark.SetThrottle(0);
m_encoder.Reset();
}
}

View File

@@ -36,14 +36,14 @@ class Robot : public wpi::TimedRobot {
// and there is not a ball at the kicker
&& !isBallAtKicker)
// activate the intake
.IfHigh([&intake = m_intake] { intake.SetDutyCycle(0.5); });
.IfHigh([&intake = m_intake] { intake.SetThrottle(0.5); });
// if the thumb button is not held
(!intakeButton
// or there is a ball in the kicker
|| isBallAtKicker)
// stop the intake
.IfHigh([&intake = m_intake] { intake.SetDutyCycle(0.0); });
.IfHigh([&intake = m_intake] { intake.SetThrottle(0.0); });
wpi::BooleanEvent shootTrigger{
&m_loop, [&joystick = m_joystick] { return joystick.GetTrigger(); }};
@@ -60,7 +60,7 @@ class Robot : public wpi::TimedRobot {
});
// if not, stop
(!shootTrigger).IfHigh([&shooter = m_shooter] {
shooter.SetDutyCycle(0.0);
shooter.SetThrottle(0.0);
});
wpi::BooleanEvent atTargetVelocity =
@@ -71,13 +71,13 @@ class Robot : public wpi::TimedRobot {
.Debounce(0.2_s);
// if we're at the target velocity, kick the ball into the shooter wheel
atTargetVelocity.IfHigh([&kicker = m_kicker] { kicker.SetDutyCycle(0.7); });
atTargetVelocity.IfHigh([&kicker = m_kicker] { kicker.SetThrottle(0.7); });
// when we stop being at the target velocity, it means the ball was shot
atTargetVelocity
.Falling()
// so stop the kicker
.IfHigh([&kicker = m_kicker] { kicker.SetDutyCycle(0.0); });
.IfHigh([&kicker = m_kicker] { kicker.SetThrottle(0.0); });
}
void RobotPeriodic() override { m_loop.Poll(); }

View File

@@ -52,7 +52,7 @@ class Robot : public wpi::TimedRobot {
// To update our simulation, we set motor voltage inputs, update the
// simulation, and write the simulated velocities to our simulated encoder
m_flywheelSim.SetInputVoltage(
m_flywheelMotor.GetDutyCycle() *
m_flywheelMotor.GetThrottle() *
wpi::units::volt_t{wpi::RobotController::GetInputVoltage()});
m_flywheelSim.Update(20_ms);
m_encoderSim.SetRate(m_flywheelSim.GetAngularVelocity().value());

View File

@@ -18,20 +18,20 @@ class Robot : public wpi::TimedRobot {
if (velocity > 0) {
if (m_toplimitSwitch.Get()) {
// We are going up and top limit is tripped so stop
m_motor.SetDutyCycle(0);
m_motor.SetThrottle(0);
} else {
// We are going up but top limit is not tripped so go at commanded
// velocity
m_motor.SetDutyCycle(velocity);
m_motor.SetThrottle(velocity);
}
} else {
if (m_bottomlimitSwitch.Get()) {
// We are going down and bottom limit is tripped so stop
m_motor.SetDutyCycle(0);
m_motor.SetThrottle(0);
} else {
// We are going down but bottom limit is not tripped so go at commanded
// velocity
m_motor.SetDutyCycle(velocity);
m_motor.SetThrottle(velocity);
}
}
}

View File

@@ -23,7 +23,7 @@
*/
class Robot : public wpi::TimedRobot {
public:
void TeleopPeriodic() override { m_motor.SetDutyCycle(m_stick.GetY()); }
void TeleopPeriodic() override { m_motor.SetThrottle(m_stick.GetY()); }
/*
* The RobotPeriodic function is called every control packet no matter the