[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

@@ -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;