mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilibc] Clean up integration tests (#3400)
The command and shuffleboard integration tests were removed because their unit tests counterparts already provide adequate coverage. Java already removed these.
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
#include "frc/motorcontrol/Victor.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace frc;
|
||||
|
||||
enum MotorEncoderTestType { TEST_VICTOR, TEST_JAGUAR, TEST_TALON };
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, MotorEncoderTestType const& type) {
|
||||
@@ -45,38 +43,38 @@ static constexpr auto kMotorTime = 0.5_s;
|
||||
*/
|
||||
class MotorEncoderTest : public testing::TestWithParam<MotorEncoderTestType> {
|
||||
protected:
|
||||
MotorController* m_motorController;
|
||||
Encoder* m_encoder;
|
||||
LinearFilter<double>* m_filter;
|
||||
frc::MotorController* m_motorController;
|
||||
frc::Encoder* m_encoder;
|
||||
frc::LinearFilter<double>* m_filter;
|
||||
|
||||
void SetUp() override {
|
||||
MotorEncoderTest() {
|
||||
switch (GetParam()) {
|
||||
case TEST_VICTOR:
|
||||
m_motorController = new Victor(TestBench::kVictorChannel);
|
||||
m_encoder = new Encoder(TestBench::kVictorEncoderChannelA,
|
||||
TestBench::kVictorEncoderChannelB);
|
||||
m_motorController = new frc::Victor(TestBench::kVictorChannel);
|
||||
m_encoder = new frc::Encoder(TestBench::kVictorEncoderChannelA,
|
||||
TestBench::kVictorEncoderChannelB);
|
||||
break;
|
||||
|
||||
case TEST_JAGUAR:
|
||||
m_motorController = new Jaguar(TestBench::kJaguarChannel);
|
||||
m_encoder = new Encoder(TestBench::kJaguarEncoderChannelA,
|
||||
TestBench::kJaguarEncoderChannelB);
|
||||
m_motorController = new frc::Jaguar(TestBench::kJaguarChannel);
|
||||
m_encoder = new frc::Encoder(TestBench::kJaguarEncoderChannelA,
|
||||
TestBench::kJaguarEncoderChannelB);
|
||||
break;
|
||||
|
||||
case TEST_TALON:
|
||||
m_motorController = new Talon(TestBench::kTalonChannel);
|
||||
m_encoder = new Encoder(TestBench::kTalonEncoderChannelA,
|
||||
TestBench::kTalonEncoderChannelB);
|
||||
m_motorController = new frc::Talon(TestBench::kTalonChannel);
|
||||
m_encoder = new frc::Encoder(TestBench::kTalonEncoderChannelA,
|
||||
TestBench::kTalonEncoderChannelB);
|
||||
break;
|
||||
}
|
||||
m_filter =
|
||||
new LinearFilter<double>(LinearFilter<double>::MovingAverage(50));
|
||||
m_filter = new frc::LinearFilter<double>(
|
||||
frc::LinearFilter<double>::MovingAverage(50));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete m_motorController;
|
||||
delete m_encoder;
|
||||
~MotorEncoderTest() {
|
||||
delete m_filter;
|
||||
delete m_encoder;
|
||||
delete m_motorController;
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
@@ -94,7 +92,7 @@ TEST_P(MotorEncoderTest, Increment) {
|
||||
|
||||
/* Drive the motor controller briefly to move the encoder */
|
||||
m_motorController->Set(0.2f);
|
||||
Wait(kMotorTime);
|
||||
frc::Wait(kMotorTime);
|
||||
m_motorController->Set(0.0);
|
||||
|
||||
/* The encoder should be positive now */
|
||||
@@ -110,7 +108,7 @@ TEST_P(MotorEncoderTest, Decrement) {
|
||||
|
||||
/* Drive the motor controller briefly to move the encoder */
|
||||
m_motorController->Set(-0.2);
|
||||
Wait(kMotorTime);
|
||||
frc::Wait(kMotorTime);
|
||||
m_motorController->Set(0.0);
|
||||
|
||||
/* The encoder should be positive now */
|
||||
@@ -125,12 +123,12 @@ TEST_P(MotorEncoderTest, ClampSpeed) {
|
||||
Reset();
|
||||
|
||||
m_motorController->Set(2.0);
|
||||
Wait(kMotorTime);
|
||||
frc::Wait(kMotorTime);
|
||||
|
||||
EXPECT_FLOAT_EQ(1.0, m_motorController->Get());
|
||||
|
||||
m_motorController->Set(-2.0);
|
||||
Wait(kMotorTime);
|
||||
frc::Wait(kMotorTime);
|
||||
|
||||
EXPECT_FLOAT_EQ(-1.0, m_motorController->Get());
|
||||
}
|
||||
@@ -152,7 +150,7 @@ TEST_P(MotorEncoderTest, PositionPIDController) {
|
||||
m_motorController->Set(std::clamp(speed, -0.2, 0.2));
|
||||
}};
|
||||
pidRunner.StartPeriodic(pidController.GetPeriod());
|
||||
Wait(10_s);
|
||||
frc::Wait(10_s);
|
||||
pidRunner.Stop();
|
||||
|
||||
RecordProperty("PIDError", pidController.GetPositionError());
|
||||
@@ -179,7 +177,7 @@ TEST_P(MotorEncoderTest, VelocityPIDController) {
|
||||
m_motorController->Set(std::clamp(speed, -0.3, 0.3));
|
||||
}};
|
||||
pidRunner.StartPeriodic(pidController.GetPeriod());
|
||||
Wait(10_s);
|
||||
frc::Wait(10_s);
|
||||
pidRunner.Stop();
|
||||
RecordProperty("PIDError", pidController.GetPositionError());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user