mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user