[wpimath] Replace Speeds with Velocities (#8479)

I left "free speed" alone since that's the technical term for it. In
general, velocity is a vector quantity, and speed is a magnitude (i.e.,
a strictly positive value).

This PR also replaces the speed verbiage in MotorController with duty
cycle.

Fixes #8423.
This commit is contained in:
Tyler Veness
2026-03-06 14:19:15 -08:00
committed by GitHub
parent 1e39f39128
commit 9bd9656871
594 changed files with 8073 additions and 7875 deletions

View File

@@ -45,6 +45,6 @@ void RapidReactCommandBot::ConfigureBindings() {
wpi::cmd::CommandPtr RapidReactCommandBot::GetAutonomousCommand() {
return m_drive
.DriveDistanceCommand(AutoConstants::kDriveDistance,
AutoConstants::kDriveSpeed)
AutoConstants::kDriveVelocity)
.WithTimeout(AutoConstants::kTimeout);
}

View File

@@ -43,14 +43,14 @@ wpi::cmd::CommandPtr Drive::ArcadeDriveCommand(std::function<double()> fwd,
}
wpi::cmd::CommandPtr Drive::DriveDistanceCommand(wpi::units::meter_t distance,
double speed) {
double velocity) {
return RunOnce([this] {
// Reset encoders at the start of the command
m_leftEncoder.Reset();
m_rightEncoder.Reset();
})
// Drive forward at specified speed
.AndThen(Run([this, speed] { m_drive.ArcadeDrive(speed, 0.0); }))
// Drive forward at specified velocity
.AndThen(Run([this, velocity] { m_drive.ArcadeDrive(velocity, 0.0); }))
.Until([this, distance] {
return wpi::units::math::max(
wpi::units::meter_t(m_leftEncoder.GetDistance()),

View File

@@ -6,7 +6,7 @@
wpi::cmd::CommandPtr Intake::IntakeCommand() {
return RunOnce([this] { m_piston.Set(wpi::DoubleSolenoid::kForward); })
.AndThen(Run([this] { m_motor.Set(1.0); }))
.AndThen(Run([this] { m_motor.SetDutyCycle(1.0); }))
.WithName("Intake");
}

View File

@@ -34,6 +34,6 @@ wpi::cmd::CommandPtr Shooter::ShootCommand(
// run the feeder
wpi::cmd::cmd::WaitUntil([this] {
return m_shooterFeedback.AtSetpoint();
}).AndThen([this] { m_feederMotor.Set(1.0); }))
}).AndThen([this] { m_feederMotor.SetDutyCycle(1.0); }))
.WithName("Shoot");
}

View File

@@ -10,5 +10,5 @@ Storage::Storage() {
}
wpi::cmd::CommandPtr Storage::RunCommand() {
return Run([this] { m_motor.Set(1.0); }).WithName("Run");
return Run([this] { m_motor.SetDutyCycle(1.0); }).WithName("Run");
}

View File

@@ -80,7 +80,7 @@ inline constexpr wpi::units::volt_t kS = 0.05_V;
// Should have value 12V at free speed
inline constexpr auto kV = 12_V / kShooterFree;
inline constexpr double kFeederSpeed = 0.5;
inline constexpr double kFeederVelocity = 0.5;
} // namespace ShooterConstants
namespace OIConstants {
@@ -90,5 +90,5 @@ inline constexpr int kDriverControllerPort = 0;
namespace AutoConstants {
constexpr wpi::units::second_t kTimeout = 3_s;
constexpr wpi::units::meter_t kDriveDistance = 2_m;
constexpr double kDriveSpeed = 0.5;
constexpr double kDriveVelocity = 0.5;
} // namespace AutoConstants

View File

@@ -32,13 +32,13 @@ class Drive : public wpi::cmd::SubsystemBase {
/**
* Returns a command that drives the robot forward a specified distance at a
* specified speed.
* specified velocity.
*
* @param distance The distance to drive forward in meters
* @param speed The fraction of max speed at which to drive
* @param velocity The fraction of max velocity at which to drive
*/
wpi::cmd::CommandPtr DriveDistanceCommand(wpi::units::meter_t distance,
double speed);
double velocity);
/**
* Returns a command that turns to robot to the specified angle using a motion
@@ -55,8 +55,8 @@ class Drive : public wpi::cmd::SubsystemBase {
wpi::PWMSparkMax m_rightFollower{DriveConstants::kRightMotor2Port};
wpi::DifferentialDrive m_drive{
[&](double output) { m_leftLeader.Set(output); },
[&](double output) { m_rightLeader.Set(output); }};
[&](double output) { m_leftLeader.SetDutyCycle(output); },
[&](double output) { m_rightLeader.SetDutyCycle(output); }};
wpi::Encoder m_leftEncoder{DriveConstants::kLeftEncoderPorts[0],
DriveConstants::kLeftEncoderPorts[1],