mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[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:
@@ -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:
|
||||
|
||||
@@ -2,7 +2,7 @@ classes:
|
||||
wpi::ExpansionHubMotor:
|
||||
methods:
|
||||
ExpansionHubMotor:
|
||||
SetPercentagePower:
|
||||
SetDutyCycle:
|
||||
SetVoltage:
|
||||
SetPositionSetpoint:
|
||||
SetVelocitySetpoint:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -30,7 +30,7 @@ classes:
|
||||
StopMotor:
|
||||
GetDescription:
|
||||
InitSendable:
|
||||
wpi::MecanumDrive::WheelSpeeds:
|
||||
wpi::MecanumDrive::WheelVelocities:
|
||||
attributes:
|
||||
frontLeft:
|
||||
frontRight:
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
classes:
|
||||
wpi::MotorController:
|
||||
methods:
|
||||
Set:
|
||||
SetDutyCycle:
|
||||
SetVoltage:
|
||||
Get:
|
||||
GetDutyCycle:
|
||||
SetInverted:
|
||||
GetInverted:
|
||||
Disable:
|
||||
|
||||
@@ -33,9 +33,9 @@ classes:
|
||||
param_override:
|
||||
args:
|
||||
ignore: true
|
||||
Set:
|
||||
SetDutyCycle:
|
||||
SetVoltage:
|
||||
Get:
|
||||
GetDutyCycle:
|
||||
SetInverted:
|
||||
GetInverted:
|
||||
Disable:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -5,4 +5,4 @@ classes:
|
||||
overloads:
|
||||
const PWMMotorController&:
|
||||
int:
|
||||
GetSpeed:
|
||||
GetDutyCycle:
|
||||
|
||||
@@ -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); });
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user