[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

@@ -14,14 +14,15 @@ class DriveDistance
public:
/**
* Creates a new DriveDistance. This command will drive your your robot for a
* desired distance at a desired speed.
* desired distance at a desired velocity.
*
* @param speed The speed at which the robot will drive
* @param velocity The velocity at which the robot will drive
* @param distance The distance the robot will drive
* @param drive The drivetrain subsystem on which this command will run
*/
DriveDistance(double speed, wpi::units::meter_t distance, Drivetrain* drive)
: m_speed(speed), m_distance(distance), m_drive(drive) {
DriveDistance(double velocity, wpi::units::meter_t distance,
Drivetrain* drive)
: m_velocity(velocity), m_distance(distance), m_drive(drive) {
AddRequirements(m_drive);
}
@@ -31,7 +32,7 @@ class DriveDistance
bool IsFinished() override;
private:
double m_speed;
double m_velocity;
wpi::units::meter_t m_distance;
Drivetrain* m_drive;
};

View File

@@ -14,14 +14,15 @@ class DriveTime : public wpi::cmd::CommandHelper<wpi::cmd::Command, DriveTime> {
public:
/**
* Creates a new DriveTime. This command will drive your robot for a desired
* speed and time.
* velocity and time.
*
* @param speed The speed which the robot will drive. Negative is in reverse.
* @param velocity The velocity which the robot will drive. Negative is in
* reverse.
* @param time How much time to drive
* @param drive The drivetrain subsystem on which this command will run
*/
DriveTime(double speed, wpi::units::second_t time, Drivetrain* drive)
: m_speed(speed), m_duration(time), m_drive(drive) {
DriveTime(double velocity, wpi::units::second_t time, Drivetrain* drive)
: m_velocity(velocity), m_duration(time), m_drive(drive) {
AddRequirements(m_drive);
}
@@ -31,7 +32,7 @@ class DriveTime : public wpi::cmd::CommandHelper<wpi::cmd::Command, DriveTime> {
bool IsFinished() override;
private:
double m_speed;
double m_velocity;
wpi::units::second_t m_duration;
Drivetrain* m_drive;
wpi::Timer m_timer;

View File

@@ -15,19 +15,19 @@ class TeleopArcadeDrive
public:
/**
* Creates a new ArcadeDrive. This command will drive your robot according to
* the speed suppliers. This command does not terminate.
* the velocity suppliers. This command does not terminate.
*
* @param drivetrain The drivetrain subsystem on which this command will run
* @param xaxisSpeedSupplier Supplier of forward/backward speed
* @param zaxisRotateSupplier Supplier of rotational speed
* @param xaxisVelocitySupplier Supplier of forward/backward velocity
* @param zaxisRotateSupplier Supplier of rotational velocity
*/
TeleopArcadeDrive(Drivetrain* subsystem,
std::function<double()> xaxisSpeedSupplier,
std::function<double()> xaxisVelocitySupplier,
std::function<double()> zaxisRotateSupplier);
void Execute() override;
private:
Drivetrain* m_drive;
std::function<double()> m_xaxisSpeedSupplier;
std::function<double()> m_xaxisVelocitySupplier;
std::function<double()> m_zaxisRotateSupplier;
};

View File

@@ -15,14 +15,15 @@ class TurnDegrees
public:
/**
* Creates a new TurnDegrees. This command will turn your robot for a desired
* rotation (in degrees) and rotational speed.
* rotation (in degrees) and rotational velocity.
*
* @param speed The speed which the robot will drive. Negative is in reverse.
* @param velocity The velocity which the robot will drive. Negative is in
* reverse.
* @param angle Degrees to turn. Leverages encoders to compare distance.
* @param drive The drive subsystem on which this command will run
*/
TurnDegrees(double speed, wpi::units::degree_t angle, Drivetrain* drive)
: m_speed(speed), m_angle(angle), m_drive(drive) {
TurnDegrees(double velocity, wpi::units::degree_t angle, Drivetrain* drive)
: m_velocity(velocity), m_angle(angle), m_drive(drive) {
AddRequirements(m_drive);
}
@@ -32,7 +33,7 @@ class TurnDegrees
bool IsFinished() override;
private:
double m_speed;
double m_velocity;
wpi::units::degree_t m_angle;
Drivetrain* m_drive;

View File

@@ -15,12 +15,13 @@ class TurnTime : public wpi::cmd::CommandHelper<wpi::cmd::Command, TurnTime> {
/**
* Creates a new TurnTime.
*
* @param speed The speed which the robot will turn. Negative is in reverse.
* @param velocity The velocity which the robot will turn. Negative is in
* reverse.
* @param time How much time to turn
* @param drive The drive subsystem on which this command will run
*/
TurnTime(double speed, wpi::units::second_t time, Drivetrain* drive)
: m_speed(speed), m_duration(time), m_drive(drive) {
TurnTime(double velocity, wpi::units::second_t time, Drivetrain* drive)
: m_velocity(velocity), m_duration(time), m_drive(drive) {
AddRequirements(m_drive);
}
@@ -30,7 +31,7 @@ class TurnTime : public wpi::cmd::CommandHelper<wpi::cmd::Command, TurnTime> {
bool IsFinished() override;
private:
double m_speed;
double m_velocity;
wpi::units::second_t m_duration;
Drivetrain* m_drive;
wpi::Timer m_timer;

View File

@@ -32,10 +32,10 @@ class Drivetrain : public wpi::cmd::SubsystemBase {
/**
* Drives the robot using arcade controls.
*
* @param xaxisSpeed the commanded forward movement
* @param xaxisVelocity the commanded forward movement
* @param zaxisRotate the commanded rotation
*/
void ArcadeDrive(double xaxisSpeed, double zaxisRotate);
void ArcadeDrive(double xaxisVelocity, double zaxisRotate);
/**
* Resets the drive encoders to currently read a position of 0.
@@ -111,8 +111,8 @@ class Drivetrain : public wpi::cmd::SubsystemBase {
wpi::Encoder m_rightEncoder{6, 7};
wpi::DifferentialDrive m_drive{
[&](double output) { m_leftMotor.Set(output); },
[&](double output) { m_rightMotor.Set(output); }};
[&](double output) { m_leftMotor.SetDutyCycle(output); },
[&](double output) { m_rightMotor.SetDutyCycle(output); }};
wpi::xrp::XRPGyro m_gyro;
};