[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

@@ -103,7 +103,7 @@ classes:
* :meth:`curvatureDrive` is similar in concept to
``RobotDrive.drive`` with the addition of a quick turn
mode. However, it is not designed to give exactly the same response.
wpi::DifferentialDrive::WheelSpeeds:
wpi::DifferentialDrive::WheelVelocities:
attributes:
left:
right:

View File

@@ -2,7 +2,7 @@ classes:
wpi::ExpansionHubMotor:
methods:
ExpansionHubMotor:
SetPercentagePower:
SetDutyCycle:
SetVoltage:
SetPositionSetpoint:
SetVelocitySetpoint:

View File

@@ -12,8 +12,8 @@ classes:
std::span<wpi::AddressableLED::LEDData>, std::function<void (int, wpi::util::Color)> [const]:
Reversed:
OffsetBy:
ScrollAtRelativeSpeed:
ScrollAtAbsoluteSpeed:
ScrollAtRelativeVelocity:
ScrollAtAbsoluteVelocity:
Blink:
overloads:
wpi::units::second_t, wpi::units::second_t:

View File

@@ -30,7 +30,7 @@ classes:
StopMotor:
GetDescription:
InitSendable:
wpi::MecanumDrive::WheelSpeeds:
wpi::MecanumDrive::WheelVelocities:
attributes:
frontLeft:
frontRight:

View File

@@ -1,9 +1,9 @@
classes:
wpi::MotorController:
methods:
Set:
SetDutyCycle:
SetVoltage:
Get:
GetDutyCycle:
SetInverted:
GetInverted:
Disable:

View File

@@ -33,9 +33,9 @@ classes:
param_override:
args:
ignore: true
Set:
SetDutyCycle:
SetVoltage:
Get:
GetDutyCycle:
SetInverted:
GetInverted:
Disable:

View File

@@ -8,9 +8,8 @@ classes:
attributes:
m_pwm:
methods:
Set:
SetVoltage:
Get:
SetDutyCycle:
GetDutyCycle:
GetVoltage:
SetInverted:
GetInverted:
@@ -28,6 +27,6 @@ classes:
ignore: true
PWMMotorController:
InitSendable:
SetSpeed:
GetSpeed:
SetDutyCycleInternal:
GetDutyCycleInternal:
SetBounds:

View File

@@ -5,4 +5,4 @@ classes:
overloads:
const PWMMotorController&:
int:
GetSpeed:
GetDutyCycle:

View File

@@ -17,21 +17,21 @@ void PyMotorControllerGroup::Initialize() {
wpi::util::SendableRegistry::Add(this, "MotorControllerGroup", instances);
}
void PyMotorControllerGroup::Set(double speed) {
void PyMotorControllerGroup::SetDutyCycle(double dutyCycle) {
for (auto motorController : m_motorControllers) {
motorController->Set(m_isInverted ? -speed : speed);
motorController->SetDutyCycle(m_isInverted ? -dutyCycle : dutyCycle);
}
}
void PyMotorControllerGroup::SetVoltage(wpi::units::volt_t output) {
void PyMotorControllerGroup::SetVoltage(wpi::units::volt_t voltage) {
for (auto motorController : m_motorControllers) {
motorController->SetVoltage(m_isInverted ? -output : output);
motorController->SetVoltage(m_isInverted ? -voltage : voltage);
}
}
double PyMotorControllerGroup::Get() const {
double PyMotorControllerGroup::GetDutyCycle() const {
if (!m_motorControllers.empty()) {
return m_motorControllers.front()->Get() * (m_isInverted ? -1 : 1);
return m_motorControllers.front()->GetDutyCycle() * (m_isInverted ? -1 : 1);
}
return 0.0;
}
@@ -51,6 +51,6 @@ void PyMotorControllerGroup::Disable() {
void PyMotorControllerGroup::InitSendable(wpi::util::SendableBuilder& builder) {
builder.SetSmartDashboardType("Motor Controller");
builder.SetActuator(true);
builder.AddDoubleProperty("Value", [=, this]() { return Get(); },
[=, this](double value) { Set(value); });
builder.AddDoubleProperty("Value", [=, this]() { return GetDutyCycle(); },
[=, this](double value) { SetDutyCycle(value); });
}

View File

@@ -26,9 +26,9 @@ class PyMotorControllerGroup : public wpi::util::Sendable,
PyMotorControllerGroup(PyMotorControllerGroup&&) = default;
PyMotorControllerGroup& operator=(PyMotorControllerGroup&&) = default;
void Set(double speed) override;
void SetVoltage(wpi::units::volt_t output) override;
double Get() const override;
void SetDutyCycle(double dutyCycle) override;
void SetVoltage(wpi::units::volt_t voltage) override;
double GetDutyCycle() const override;
void SetInverted(bool isInverted) override;
bool GetInverted() const override;
void Disable() override;