[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

@@ -10,12 +10,10 @@
#include "Constants.hpp"
#include "Robot.hpp"
#include "wpi/hal/DriverStationTypes.h"
#include "wpi/hal/simulation/MockHooks.h"
#include "wpi/simulation/DriverStationSim.hpp"
#include "wpi/simulation/JoystickSim.hpp"
#include "wpi/simulation/PWMMotorControllerSim.hpp"
#include "wpi/simulation/SimHooks.hpp"
#include "wpi/units/length.hpp"
#include "wpi/units/time.hpp"
#include "wpi/util/Preferences.hpp"
@@ -136,7 +134,7 @@ TEST_P(ArmSimulationTest, Teleop) {
wpi::sim::StepTiming(3_s);
ASSERT_NEAR(0.0, m_motorSim.GetSpeed(), 0.05);
ASSERT_NEAR(0.0, m_motorSim.GetDutyCycle(), 0.05);
EXPECT_NEAR(kMinAngle.value(), m_encoderSim.GetDistance(), 2.0);
}
}

View File

@@ -118,7 +118,7 @@ TEST_F(ElevatorSimulationTest, Teleop) {
// advance 75 timesteps
wpi::sim::StepTiming(1.5_s);
ASSERT_NEAR(0.0, m_motorSim.GetSpeed(), 0.05);
ASSERT_NEAR(0.0, m_motorSim.GetDutyCycle(), 0.05);
ASSERT_NEAR(0.0, m_encoderSim.GetDistance(), 0.05);
}
}

View File

@@ -2,7 +2,6 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <string>
#include <thread>
#include <gtest/gtest.h>
@@ -48,7 +47,7 @@ class PotentiometerPIDTest : public testing::Test {
public:
void SimPeriodicBefore() {
m_elevatorSim.SetInputVoltage(m_motorSim.GetSpeed() *
m_elevatorSim.SetInputVoltage(m_motorSim.GetDutyCycle() *
wpi::RobotController::GetBatteryVoltage());
m_elevatorSim.Update(20_ms);

View File

@@ -26,13 +26,14 @@ TEST_F(IntakeTest, DoesntWorkWhenClosed) {
intake.Activate(0.5); // try to activate the motor
EXPECT_DOUBLE_EQ(
0.0,
simMotor.GetSpeed()); // make sure that the value set to the motor is 0
simMotor
.GetDutyCycle()); // make sure that the value set to the motor is 0
}
TEST_F(IntakeTest, WorksWhenOpen) {
intake.Deploy();
intake.Activate(0.5);
EXPECT_DOUBLE_EQ(0.5, simMotor.GetSpeed());
EXPECT_DOUBLE_EQ(0.5, simMotor.GetDutyCycle());
}
TEST_F(IntakeTest, Retract) {