mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -18,7 +18,7 @@
|
||||
#include "wpi/smartdashboard/SmartDashboard.hpp"
|
||||
#include "wpi/util/Alert.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
using enum Alert::AlertType;
|
||||
class AlertsTest : public ::testing::Test {
|
||||
public:
|
||||
@@ -52,7 +52,7 @@ class AlertsTest : public ::testing::Test {
|
||||
activeAlerts.end();
|
||||
}
|
||||
|
||||
void Update() { frc::SmartDashboard::UpdateValues(); }
|
||||
void Update() { wpi::SmartDashboard::UpdateValues(); }
|
||||
|
||||
private:
|
||||
std::string GetSubtableName(Alert::AlertType type) {
|
||||
@@ -68,8 +68,8 @@ class AlertsTest : public ::testing::Test {
|
||||
}
|
||||
}
|
||||
|
||||
const nt::StringArraySubscriber GetSubscriberForType(Alert::AlertType type) {
|
||||
return nt::NetworkTableInstance::GetDefault()
|
||||
const wpi::nt::StringArraySubscriber GetSubscriberForType(Alert::AlertType type) {
|
||||
return wpi::nt::NetworkTableInstance::GetDefault()
|
||||
.GetStringArrayTopic(fmt::format("/SmartDashboard/{}/{}",
|
||||
GetGroupName(), GetSubtableName(type)))
|
||||
.Subscribe({});
|
||||
@@ -158,16 +158,16 @@ TEST_F(AlertsTest, SetTextWhileSet) {
|
||||
}
|
||||
|
||||
TEST_F(AlertsTest, SetTextDoesNotAffectFirstOrderSort) {
|
||||
frc::sim::PauseTiming();
|
||||
wpi::sim::PauseTiming();
|
||||
|
||||
auto a = MakeAlert("A", kError);
|
||||
auto b = MakeAlert("B", kError);
|
||||
auto c = MakeAlert("C", kError);
|
||||
|
||||
a.Set(true);
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
b.Set(true);
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
c.Set(true);
|
||||
|
||||
auto expectedEndState = GetActiveAlerts(kError);
|
||||
@@ -176,7 +176,7 @@ TEST_F(AlertsTest, SetTextDoesNotAffectFirstOrderSort) {
|
||||
b.SetText("AFTER");
|
||||
|
||||
EXPECT_STATE(kError, expectedEndState);
|
||||
frc::sim::ResumeTiming();
|
||||
wpi::sim::ResumeTiming();
|
||||
}
|
||||
|
||||
TEST_F(AlertsTest, MoveAssign) {
|
||||
@@ -209,42 +209,42 @@ TEST_F(AlertsTest, MoveConstruct) {
|
||||
}
|
||||
|
||||
TEST_F(AlertsTest, SortOrder) {
|
||||
frc::sim::PauseTiming();
|
||||
wpi::sim::PauseTiming();
|
||||
auto a = MakeAlert("A", kInfo);
|
||||
auto b = MakeAlert("B", kInfo);
|
||||
auto c = MakeAlert("C", kInfo);
|
||||
a.Set(true);
|
||||
EXPECT_STATE(kInfo, "A");
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
b.Set(true);
|
||||
EXPECT_STATE(kInfo, "B", "A");
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
c.Set(true);
|
||||
EXPECT_STATE(kInfo, "C", "B", "A");
|
||||
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
c.Set(false);
|
||||
EXPECT_STATE(kInfo, "B", "A");
|
||||
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
c.Set(true);
|
||||
EXPECT_STATE(kInfo, "C", "B", "A");
|
||||
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
a.Set(false);
|
||||
EXPECT_STATE(kInfo, "C", "B");
|
||||
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
b.Set(false);
|
||||
EXPECT_STATE(kInfo, "C");
|
||||
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
b.Set(true);
|
||||
EXPECT_STATE(kInfo, "B", "C");
|
||||
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
a.Set(true);
|
||||
EXPECT_STATE(kInfo, "A", "B", "C");
|
||||
|
||||
frc::sim::ResumeTiming();
|
||||
wpi::sim::ResumeTiming();
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "wpi/simulation/AnalogInputSim.hpp"
|
||||
#include "wpi/simulation/RoboRioSim.hpp"
|
||||
|
||||
namespace frc {
|
||||
using namespace frc::sim;
|
||||
namespace wpi {
|
||||
using namespace wpi::sim;
|
||||
TEST(AnalogPotentiometerTest, InitializeWithAnalogInput) {
|
||||
HAL_Initialize(500, 0);
|
||||
|
||||
@@ -78,7 +78,7 @@ TEST(AnalogPotentiometerTest, WithModifiedBatteryVoltage) {
|
||||
EXPECT_EQ(90, pot.Get());
|
||||
|
||||
// Simulate a lower battery voltage
|
||||
RoboRioSim::SetUserVoltage3V3(units::volt_t{2.5});
|
||||
RoboRioSim::SetUserVoltage3V3(wpi::units::volt_t{2.5});
|
||||
|
||||
sim.SetVoltage(2.5);
|
||||
EXPECT_EQ(270.0, pot.Get());
|
||||
@@ -89,4 +89,4 @@ TEST(AnalogPotentiometerTest, WithModifiedBatteryVoltage) {
|
||||
sim.SetVoltage(0.0);
|
||||
EXPECT_EQ(90.0, pot.Get());
|
||||
}
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "wpi/hardware/pneumatic/PneumaticsControlModule.hpp"
|
||||
#include "wpi/hardware/pneumatic/Solenoid.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
TEST(DoubleSolenoidCTRETest, ValidInitialization) {
|
||||
DoubleSolenoid solenoid{0, 3, frc::PneumaticsModuleType::CTREPCM, 2, 3};
|
||||
DoubleSolenoid solenoid{0, 3, wpi::PneumaticsModuleType::CTREPCM, 2, 3};
|
||||
solenoid.Set(DoubleSolenoid::kReverse);
|
||||
EXPECT_EQ(DoubleSolenoid::kReverse, solenoid.Get());
|
||||
|
||||
@@ -25,29 +25,29 @@ TEST(DoubleSolenoidCTRETest, ValidInitialization) {
|
||||
|
||||
TEST(DoubleSolenoidCTRETest, ThrowForwardPortAlreadyInitialized) {
|
||||
// Single solenoid that is reused for forward port
|
||||
Solenoid solenoid{0, 5, frc::PneumaticsModuleType::CTREPCM, 2};
|
||||
EXPECT_THROW(DoubleSolenoid(0, 5, frc::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
Solenoid solenoid{0, 5, wpi::PneumaticsModuleType::CTREPCM, 2};
|
||||
EXPECT_THROW(DoubleSolenoid(0, 5, wpi::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(DoubleSolenoidCTRETest, ThrowReversePortAlreadyInitialized) {
|
||||
// Single solenoid that is reused for forward port
|
||||
Solenoid solenoid{0, 6, frc::PneumaticsModuleType::CTREPCM, 3};
|
||||
EXPECT_THROW(DoubleSolenoid(6, frc::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
Solenoid solenoid{0, 6, wpi::PneumaticsModuleType::CTREPCM, 3};
|
||||
EXPECT_THROW(DoubleSolenoid(6, wpi::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(DoubleSolenoidCTRETest, ThrowBothPortsAlreadyInitialized) {
|
||||
PneumaticsControlModule pcm{0, 6};
|
||||
// Single solenoid that is reused for forward port
|
||||
Solenoid solenoid0(0, 6, frc::PneumaticsModuleType::CTREPCM, 2);
|
||||
Solenoid solenoid1(0, 6, frc::PneumaticsModuleType::CTREPCM, 3);
|
||||
EXPECT_THROW(DoubleSolenoid(6, frc::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
Solenoid solenoid0(0, 6, wpi::PneumaticsModuleType::CTREPCM, 2);
|
||||
Solenoid solenoid1(0, 6, wpi::PneumaticsModuleType::CTREPCM, 3);
|
||||
EXPECT_THROW(DoubleSolenoid(6, wpi::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(DoubleSolenoidCTRETest, Toggle) {
|
||||
DoubleSolenoid solenoid{0, 4, frc::PneumaticsModuleType::CTREPCM, 2, 3};
|
||||
DoubleSolenoid solenoid{0, 4, wpi::PneumaticsModuleType::CTREPCM, 2, 3};
|
||||
// Bootstrap it into reverse
|
||||
solenoid.Set(DoubleSolenoid::kReverse);
|
||||
|
||||
@@ -64,12 +64,12 @@ TEST(DoubleSolenoidCTRETest, Toggle) {
|
||||
}
|
||||
|
||||
TEST(DoubleSolenoidCTRETest, InvalidForwardPort) {
|
||||
EXPECT_THROW(DoubleSolenoid(0, 0, frc::PneumaticsModuleType::CTREPCM, 100, 1),
|
||||
EXPECT_THROW(DoubleSolenoid(0, 0, wpi::PneumaticsModuleType::CTREPCM, 100, 1),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(DoubleSolenoidCTRETest, InvalidReversePort) {
|
||||
EXPECT_THROW(DoubleSolenoid(0, 0, frc::PneumaticsModuleType::CTREPCM, 0, 100),
|
||||
EXPECT_THROW(DoubleSolenoid(0, 0, wpi::PneumaticsModuleType::CTREPCM, 0, 100),
|
||||
std::runtime_error);
|
||||
}
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "wpi/hardware/pneumatic/PneumaticsControlModule.hpp"
|
||||
#include "wpi/hardware/pneumatic/Solenoid.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
TEST(DoubleSolenoidREVTest, ValidInitialization) {
|
||||
DoubleSolenoid solenoid{0, 3, frc::PneumaticsModuleType::CTREPCM, 2, 3};
|
||||
DoubleSolenoid solenoid{0, 3, wpi::PneumaticsModuleType::CTREPCM, 2, 3};
|
||||
solenoid.Set(DoubleSolenoid::kReverse);
|
||||
EXPECT_EQ(DoubleSolenoid::kReverse, solenoid.Get());
|
||||
|
||||
@@ -25,29 +25,29 @@ TEST(DoubleSolenoidREVTest, ValidInitialization) {
|
||||
|
||||
TEST(DoubleSolenoidREVTest, ThrowForwardPortAlreadyInitialized) {
|
||||
// Single solenoid that is reused for forward port
|
||||
Solenoid solenoid{0, 5, frc::PneumaticsModuleType::CTREPCM, 2};
|
||||
EXPECT_THROW(DoubleSolenoid(5, frc::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
Solenoid solenoid{0, 5, wpi::PneumaticsModuleType::CTREPCM, 2};
|
||||
EXPECT_THROW(DoubleSolenoid(5, wpi::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(DoubleSolenoidREVTest, ThrowReversePortAlreadyInitialized) {
|
||||
// Single solenoid that is reused for forward port
|
||||
Solenoid solenoid{0, 6, frc::PneumaticsModuleType::CTREPCM, 3};
|
||||
EXPECT_THROW(DoubleSolenoid(6, frc::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
Solenoid solenoid{0, 6, wpi::PneumaticsModuleType::CTREPCM, 3};
|
||||
EXPECT_THROW(DoubleSolenoid(6, wpi::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(DoubleSolenoidREVTest, ThrowBothPortsAlreadyInitialized) {
|
||||
PneumaticsControlModule pcm{0, 6};
|
||||
// Single solenoid that is reused for forward port
|
||||
Solenoid solenoid0(0, 6, frc::PneumaticsModuleType::CTREPCM, 2);
|
||||
Solenoid solenoid1(0, 6, frc::PneumaticsModuleType::CTREPCM, 3);
|
||||
EXPECT_THROW(DoubleSolenoid(6, frc::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
Solenoid solenoid0(0, 6, wpi::PneumaticsModuleType::CTREPCM, 2);
|
||||
Solenoid solenoid1(0, 6, wpi::PneumaticsModuleType::CTREPCM, 3);
|
||||
EXPECT_THROW(DoubleSolenoid(6, wpi::PneumaticsModuleType::CTREPCM, 2, 3),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(DoubleSolenoidREVTest, Toggle) {
|
||||
DoubleSolenoid solenoid{0, 4, frc::PneumaticsModuleType::CTREPCM, 2, 3};
|
||||
DoubleSolenoid solenoid{0, 4, wpi::PneumaticsModuleType::CTREPCM, 2, 3};
|
||||
// Bootstrap it into reverse
|
||||
solenoid.Set(DoubleSolenoid::kReverse);
|
||||
|
||||
@@ -64,12 +64,12 @@ TEST(DoubleSolenoidREVTest, Toggle) {
|
||||
}
|
||||
|
||||
TEST(DoubleSolenoidREVTest, InvalidForwardPort) {
|
||||
EXPECT_THROW(DoubleSolenoid(0, 0, frc::PneumaticsModuleType::CTREPCM, 100, 1),
|
||||
EXPECT_THROW(DoubleSolenoid(0, 0, wpi::PneumaticsModuleType::CTREPCM, 100, 1),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(DoubleSolenoidREVTest, InvalidReversePort) {
|
||||
EXPECT_THROW(DoubleSolenoid(0, 0, frc::PneumaticsModuleType::CTREPCM, 0, 100),
|
||||
EXPECT_THROW(DoubleSolenoid(0, 0, wpi::PneumaticsModuleType::CTREPCM, 0, 100),
|
||||
std::runtime_error);
|
||||
}
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -16,16 +16,16 @@ class IsJoystickConnectedParametersTest
|
||||
: public ::testing::TestWithParam<std::tuple<int, int, int, bool>> {};
|
||||
|
||||
TEST_P(IsJoystickConnectedParametersTest, IsJoystickConnected) {
|
||||
frc::sim::DriverStationSim::SetJoystickAxesMaximumIndex(
|
||||
wpi::sim::DriverStationSim::SetJoystickAxesMaximumIndex(
|
||||
1, std::get<0>(GetParam()));
|
||||
frc::sim::DriverStationSim::SetJoystickButtonsMaximumIndex(
|
||||
wpi::sim::DriverStationSim::SetJoystickButtonsMaximumIndex(
|
||||
1, std::get<1>(GetParam()));
|
||||
frc::sim::DriverStationSim::SetJoystickPOVsMaximumIndex(
|
||||
wpi::sim::DriverStationSim::SetJoystickPOVsMaximumIndex(
|
||||
1, std::get<2>(GetParam()));
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
|
||||
ASSERT_EQ(std::get<3>(GetParam()),
|
||||
frc::DriverStation::IsJoystickConnected(1));
|
||||
wpi::DriverStation::IsJoystickConnected(1));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(IsConnectedTests, IsJoystickConnectedParametersTest,
|
||||
@@ -44,16 +44,16 @@ TEST_P(JoystickConnectionWarningTest, JoystickConnectionWarnings) {
|
||||
::testing::internal::CaptureStderr();
|
||||
|
||||
// Set FMS and Silence settings
|
||||
frc::sim::DriverStationSim::SetFmsAttached(std::get<0>(GetParam()));
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::DriverStation::SilenceJoystickConnectionWarning(std::get<1>(GetParam()));
|
||||
wpi::sim::DriverStationSim::SetFmsAttached(std::get<0>(GetParam()));
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::DriverStation::SilenceJoystickConnectionWarning(std::get<1>(GetParam()));
|
||||
|
||||
// Create joystick and attempt to retrieve button.
|
||||
frc::Joystick joystick(0);
|
||||
wpi::Joystick joystick(0);
|
||||
joystick.GetRawButton(1);
|
||||
|
||||
frc::sim::StepTiming(1_s);
|
||||
EXPECT_EQ(frc::DriverStation::IsJoystickConnectionWarningSilenced(),
|
||||
wpi::sim::StepTiming(1_s);
|
||||
EXPECT_EQ(wpi::DriverStation::IsJoystickConnectionWarningSilenced(),
|
||||
std::get<2>(GetParam()));
|
||||
EXPECT_EQ(::testing::internal::GetCapturedStderr().substr(
|
||||
0, std::get<3>(GetParam()).size()),
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "wpi/driverstation/GenericHID.hpp"
|
||||
#include "wpi/simulation/GenericHIDSim.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
using RumbleType = GenericHID::RumbleType;
|
||||
static constexpr double kEpsilon = 0.0001;
|
||||
TEST(GenericHIDTest, RumbleRange) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "JoystickTestMacros.hpp"
|
||||
#include "wpi/simulation/JoystickSim.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
// https://github.com/wpilibsuite/allwpilib/issues/1550
|
||||
TEST(JoystickTest, FastDeconstruction) {
|
||||
@@ -52,18 +52,18 @@ TEST(JoystickTest, GetDirection) {
|
||||
joysim.SetX(0.5);
|
||||
joysim.SetY(0);
|
||||
joysim.NotifyNewData();
|
||||
ASSERT_NEAR(units::radian_t{90_deg}.value(), joy.GetDirection().value(),
|
||||
ASSERT_NEAR(wpi::units::radian_t{90_deg}.value(), joy.GetDirection().value(),
|
||||
0.001);
|
||||
|
||||
joysim.SetX(0);
|
||||
joysim.SetY(-.5);
|
||||
joysim.NotifyNewData();
|
||||
ASSERT_NEAR(units::radian_t{0_deg}.value(), joy.GetDirection().value(),
|
||||
ASSERT_NEAR(wpi::units::radian_t{0_deg}.value(), joy.GetDirection().value(),
|
||||
0.001);
|
||||
|
||||
joysim.SetX(0.5);
|
||||
joysim.SetY(-0.5);
|
||||
joysim.NotifyNewData();
|
||||
ASSERT_NEAR(units::radian_t{45_deg}.value(), joy.GetDirection().value(),
|
||||
ASSERT_NEAR(wpi::units::radian_t{45_deg}.value(), joy.GetDirection().value(),
|
||||
0.001);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/util/MathExtras.hpp"
|
||||
#include "wpi/util/timestamp.h"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
static LEDPattern whiteYellowPurple{[](auto data, auto writer) {
|
||||
for (size_t led = 0; led < data.size(); led++) {
|
||||
@@ -187,7 +187,7 @@ TEST(LEDPatternTest, ScrollRelativeForward) {
|
||||
|
||||
// Scrolling at 1/256th of the buffer per second,
|
||||
// or 1 individual diode per second
|
||||
auto scroll = pattern.ScrollAtRelativeSpeed(units::hertz_t{1 / 256.0});
|
||||
auto scroll = pattern.ScrollAtRelativeSpeed(wpi::units::hertz_t{1 / 256.0});
|
||||
|
||||
static uint64_t now = 0ull;
|
||||
WPI_SetNowImpl([] { return now; });
|
||||
@@ -210,7 +210,7 @@ TEST(LEDPatternTest, ScrollRelativeForward) {
|
||||
// t=2, channel value = (254, 255, 0, ..., 252, 253)
|
||||
// t=255, channel value = (1, 2, 3, ..., 255, 0)
|
||||
// t=256, channel value = (0, 1, 2, ..., 254, 255)
|
||||
int ch = frc::FloorMod(static_cast<int>(led - time), 256);
|
||||
int ch = wpi::math::FloorMod(static_cast<int>(led - time), 256);
|
||||
AssertIndexColor(buffer, led, Color{ch, ch, ch});
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ TEST(LEDPatternTest, ScrollRelativeBackward) {
|
||||
|
||||
// Scrolling at 1/256th of the buffer per second,
|
||||
// or 1 individual diode per second
|
||||
auto scroll = pattern.ScrollAtRelativeSpeed(units::hertz_t{-1 / 256.0});
|
||||
auto scroll = pattern.ScrollAtRelativeSpeed(wpi::units::hertz_t{-1 / 256.0});
|
||||
|
||||
static uint64_t now = 0ull;
|
||||
WPI_SetNowImpl([] { return now; });
|
||||
@@ -253,7 +253,7 @@ TEST(LEDPatternTest, ScrollRelativeBackward) {
|
||||
// t=2, channel value = (254, 255, 0, ..., 252, 253)
|
||||
// t=255, channel value = (1, 2, 3, ..., 255, 0)
|
||||
// t=256, channel value = (0, 1, 2, ..., 254, 255)
|
||||
int ch = frc::FloorMod(static_cast<int>(led + time), 256);
|
||||
int ch = wpi::math::FloorMod(static_cast<int>(led + time), 256);
|
||||
AssertIndexColor(buffer, led, Color{ch, ch, ch});
|
||||
}
|
||||
}
|
||||
@@ -297,7 +297,7 @@ TEST(LEDPatternTest, ScrollAbsoluteForward) {
|
||||
// t=2, channel value = (254, 255, 0, ..., 252, 253)
|
||||
// t=255, channel value = (1, 2, 3, ..., 255, 0)
|
||||
// t=256, channel value = (0, 1, 2, ..., 254, 255)
|
||||
int ch = frc::FloorMod(static_cast<int>(led - time), 256);
|
||||
int ch = wpi::math::FloorMod(static_cast<int>(led - time), 256);
|
||||
AssertIndexColor(buffer, led, Color{ch, ch, ch});
|
||||
}
|
||||
}
|
||||
@@ -341,7 +341,7 @@ TEST(LEDPatternTest, ScrollAbsoluteBackward) {
|
||||
// t=2, channel value = (254, 255, 0, ..., 252, 253)
|
||||
// t=255, channel value = (1, 2, 3, ..., 255, 0)
|
||||
// t=256, channel value = (0, 1, 2, ..., 254, 255)
|
||||
int ch = frc::FloorMod(static_cast<int>(led + time), 256);
|
||||
int ch = wpi::math::FloorMod(static_cast<int>(led + time), 256);
|
||||
AssertIndexColor(buffer, led, Color{ch, ch, ch});
|
||||
}
|
||||
}
|
||||
@@ -874,7 +874,7 @@ TEST(LEDPatternTest, RelativeScrollingMask) {
|
||||
|
||||
auto pattern = LEDPattern::Steps(colorSteps)
|
||||
.Mask(LEDPattern::Steps(maskSteps))
|
||||
.ScrollAtRelativeSpeed(units::hertz_t{1e6 / 8.0});
|
||||
.ScrollAtRelativeSpeed(wpi::units::hertz_t{1e6 / 8.0});
|
||||
|
||||
pattern.ApplyTo(buffer);
|
||||
|
||||
@@ -1029,7 +1029,7 @@ TEST(LEDPatternTest, AbsoluteScrollingMask) {
|
||||
|
||||
void AssertIndexColor(std::span<AddressableLED::LEDData> data, int index,
|
||||
Color color) {
|
||||
frc::Color8Bit color8bit{color};
|
||||
wpi::Color8Bit color8bit{color};
|
||||
|
||||
EXPECT_EQ(color8bit.red, data[index].r & 0xFF);
|
||||
EXPECT_EQ(color8bit.green, data[index].g & 0xFF);
|
||||
@@ -1037,7 +1037,7 @@ void AssertIndexColor(std::span<AddressableLED::LEDData> data, int index,
|
||||
}
|
||||
|
||||
Color LerpColors(Color a, Color b, double t) {
|
||||
return Color{wpi::Lerp(a.red, b.red, t), wpi::Lerp(a.green, b.green, t),
|
||||
wpi::Lerp(a.blue, b.blue, t)};
|
||||
return Color{wpi::util::Lerp(a.red, b.red, t), wpi::util::Lerp(a.green, b.green, t),
|
||||
wpi::util::Lerp(a.blue, b.blue, t)};
|
||||
}
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/simulation/SimHooks.hpp"
|
||||
#include "wpi/system/Notifier.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "JoystickTestMacros.hpp"
|
||||
#include "wpi/simulation/PS4ControllerSim.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
BUTTON_TEST(PS4Controller, SquareButton)
|
||||
BUTTON_TEST(PS4Controller, CrossButton)
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "JoystickTestMacros.hpp"
|
||||
#include "wpi/simulation/PS5ControllerSim.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
BUTTON_TEST(PS5Controller, SquareButton)
|
||||
BUTTON_TEST(PS5Controller, CrossButton)
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
|
||||
TEST(ScopedTracerTest, Timing) {
|
||||
wpi::SmallString<128> buf;
|
||||
wpi::raw_svector_ostream os(buf);
|
||||
wpi::util::SmallString<128> buf;
|
||||
wpi::util::raw_svector_ostream os(buf);
|
||||
|
||||
frc::sim::PauseTiming();
|
||||
wpi::sim::PauseTiming();
|
||||
{
|
||||
frc::ScopedTracer tracer("timing_test", os);
|
||||
frc::sim::StepTiming(1.5_s);
|
||||
wpi::ScopedTracer tracer("timing_test", os);
|
||||
wpi::sim::StepTiming(1.5_s);
|
||||
}
|
||||
frc::sim::ResumeTiming();
|
||||
wpi::sim::ResumeTiming();
|
||||
|
||||
std::string_view out = os.str();
|
||||
EXPECT_TRUE(wpi::starts_with(out, "\ttiming_test: 1.5"));
|
||||
EXPECT_TRUE(wpi::util::starts_with(out, "\ttiming_test: 1.5"));
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "wpi/hardware/range/SharpIR.hpp"
|
||||
#include "wpi/simulation/SharpIRSim.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
TEST(SharpIRTest, SimDevices) {
|
||||
SharpIR s = SharpIR::GP2Y0A02YK0F(1);
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "wpi/hardware/pneumatic/PneumaticsControlModule.hpp"
|
||||
#include "wpi/hardware/pneumatic/Solenoid.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
TEST(SolenoidCTRETest, ValidInitialization) {
|
||||
Solenoid solenoid{0, 3, frc::PneumaticsModuleType::CTREPCM, 2};
|
||||
Solenoid solenoid{0, 3, wpi::PneumaticsModuleType::CTREPCM, 2};
|
||||
EXPECT_EQ(2, solenoid.GetChannel());
|
||||
|
||||
solenoid.Set(true);
|
||||
@@ -22,24 +22,24 @@ TEST(SolenoidCTRETest, ValidInitialization) {
|
||||
}
|
||||
|
||||
TEST(SolenoidCTRETest, DoubleInitialization) {
|
||||
Solenoid solenoid{0, 3, frc::PneumaticsModuleType::CTREPCM, 2};
|
||||
EXPECT_THROW(Solenoid(0, 3, frc::PneumaticsModuleType::CTREPCM, 2),
|
||||
Solenoid solenoid{0, 3, wpi::PneumaticsModuleType::CTREPCM, 2};
|
||||
EXPECT_THROW(Solenoid(0, 3, wpi::PneumaticsModuleType::CTREPCM, 2),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(SolenoidCTRETest, DoubleInitializationFromDoubleSolenoid) {
|
||||
DoubleSolenoid solenoid{0, 3, frc::PneumaticsModuleType::CTREPCM, 2, 3};
|
||||
EXPECT_THROW(Solenoid(0, 3, frc::PneumaticsModuleType::CTREPCM, 2),
|
||||
DoubleSolenoid solenoid{0, 3, wpi::PneumaticsModuleType::CTREPCM, 2, 3};
|
||||
EXPECT_THROW(Solenoid(0, 3, wpi::PneumaticsModuleType::CTREPCM, 2),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(SolenoidCTRETest, InvalidChannel) {
|
||||
EXPECT_THROW(Solenoid(0, 3, frc::PneumaticsModuleType::CTREPCM, 100),
|
||||
EXPECT_THROW(Solenoid(0, 3, wpi::PneumaticsModuleType::CTREPCM, 100),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(SolenoidCTRETest, Toggle) {
|
||||
Solenoid solenoid{0, 3, frc::PneumaticsModuleType::CTREPCM, 2};
|
||||
Solenoid solenoid{0, 3, wpi::PneumaticsModuleType::CTREPCM, 2};
|
||||
solenoid.Set(true);
|
||||
EXPECT_TRUE(solenoid.Get());
|
||||
|
||||
@@ -49,4 +49,4 @@ TEST(SolenoidCTRETest, Toggle) {
|
||||
solenoid.Toggle();
|
||||
EXPECT_TRUE(solenoid.Get());
|
||||
}
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "wpi/hardware/pneumatic/PneumaticsControlModule.hpp"
|
||||
#include "wpi/hardware/pneumatic/Solenoid.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
TEST(SolenoidREVTest, ValidInitialization) {
|
||||
Solenoid solenoid{0, 3, frc::PneumaticsModuleType::REVPH, 2};
|
||||
Solenoid solenoid{0, 3, wpi::PneumaticsModuleType::REVPH, 2};
|
||||
EXPECT_EQ(2, solenoid.GetChannel());
|
||||
|
||||
solenoid.Set(true);
|
||||
@@ -22,24 +22,24 @@ TEST(SolenoidREVTest, ValidInitialization) {
|
||||
}
|
||||
|
||||
TEST(SolenoidREVTest, DoubleInitialization) {
|
||||
Solenoid solenoid{0, 3, frc::PneumaticsModuleType::REVPH, 2};
|
||||
EXPECT_THROW(Solenoid(0, 3, frc::PneumaticsModuleType::REVPH, 2),
|
||||
Solenoid solenoid{0, 3, wpi::PneumaticsModuleType::REVPH, 2};
|
||||
EXPECT_THROW(Solenoid(0, 3, wpi::PneumaticsModuleType::REVPH, 2),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(SolenoidREVTest, DoubleInitializationFromDoubleSolenoid) {
|
||||
DoubleSolenoid solenoid{0, 3, frc::PneumaticsModuleType::REVPH, 2, 3};
|
||||
EXPECT_THROW(Solenoid(0, 3, frc::PneumaticsModuleType::REVPH, 2),
|
||||
DoubleSolenoid solenoid{0, 3, wpi::PneumaticsModuleType::REVPH, 2, 3};
|
||||
EXPECT_THROW(Solenoid(0, 3, wpi::PneumaticsModuleType::REVPH, 2),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(SolenoidREVTest, InvalidChannel) {
|
||||
EXPECT_THROW(Solenoid(0, 3, frc::PneumaticsModuleType::REVPH, 100),
|
||||
EXPECT_THROW(Solenoid(0, 3, wpi::PneumaticsModuleType::REVPH, 100),
|
||||
std::runtime_error);
|
||||
}
|
||||
|
||||
TEST(SolenoidREVTest, Toggle) {
|
||||
Solenoid solenoid{0, 3, frc::PneumaticsModuleType::REVPH, 2};
|
||||
Solenoid solenoid{0, 3, wpi::PneumaticsModuleType::REVPH, 2};
|
||||
solenoid.Set(true);
|
||||
EXPECT_TRUE(solenoid.Get());
|
||||
|
||||
@@ -49,4 +49,4 @@ TEST(SolenoidREVTest, Toggle) {
|
||||
solenoid.Toggle();
|
||||
EXPECT_TRUE(solenoid.Get());
|
||||
}
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
void BooleanCallback::HandleCallback(std::string_view name,
|
||||
const HAL_Value* value) {
|
||||
@@ -82,4 +82,4 @@ void DoubleCallback::HandleCallback(std::string_view name,
|
||||
m_lastValue = value->data.v_double;
|
||||
}
|
||||
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
#include "wpi/simulation/DriverStationSim.hpp"
|
||||
#include "wpi/simulation/SimHooks.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
inline constexpr auto kPeriod = 20_ms;
|
||||
|
||||
namespace {
|
||||
class TimedRobotTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override { frc::sim::PauseTiming(); }
|
||||
void SetUp() override { wpi::sim::PauseTiming(); }
|
||||
|
||||
void TearDown() override { frc::sim::ResumeTiming(); }
|
||||
void TearDown() override { wpi::sim::ResumeTiming(); }
|
||||
};
|
||||
|
||||
class MockRobot : public TimedRobot {
|
||||
@@ -85,9 +85,9 @@ TEST_F(TimedRobotTest, DisabledMode) {
|
||||
|
||||
std::thread robotThread{[&] { robot.StartCompetition(); }};
|
||||
|
||||
frc::sim::DriverStationSim::SetEnabled(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
wpi::sim::DriverStationSim::SetEnabled(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
@@ -107,7 +107,7 @@ TEST_F(TimedRobotTest, DisabledMode) {
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
@@ -127,7 +127,7 @@ TEST_F(TimedRobotTest, DisabledMode) {
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
@@ -156,11 +156,11 @@ TEST_F(TimedRobotTest, AutonomousMode) {
|
||||
|
||||
std::thread robotThread{[&] { robot.StartCompetition(); }};
|
||||
|
||||
frc::sim::DriverStationSim::SetEnabled(true);
|
||||
frc::sim::DriverStationSim::SetAutonomous(true);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
wpi::sim::DriverStationSim::SetEnabled(true);
|
||||
wpi::sim::DriverStationSim::SetAutonomous(true);
|
||||
wpi::sim::DriverStationSim::SetTest(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
@@ -180,7 +180,7 @@ TEST_F(TimedRobotTest, AutonomousMode) {
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
@@ -200,7 +200,7 @@ TEST_F(TimedRobotTest, AutonomousMode) {
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
@@ -229,11 +229,11 @@ TEST_F(TimedRobotTest, TeleopMode) {
|
||||
|
||||
std::thread robotThread{[&] { robot.StartCompetition(); }};
|
||||
|
||||
frc::sim::DriverStationSim::SetEnabled(true);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
wpi::sim::DriverStationSim::SetEnabled(true);
|
||||
wpi::sim::DriverStationSim::SetAutonomous(false);
|
||||
wpi::sim::DriverStationSim::SetTest(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
@@ -253,7 +253,7 @@ TEST_F(TimedRobotTest, TeleopMode) {
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
@@ -273,7 +273,7 @@ TEST_F(TimedRobotTest, TeleopMode) {
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
@@ -301,11 +301,11 @@ TEST_F(TimedRobotTest, TestMode) {
|
||||
MockRobot robot;
|
||||
std::thread robotThread{[&] { robot.StartCompetition(); }};
|
||||
|
||||
frc::sim::DriverStationSim::SetEnabled(true);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(true);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
wpi::sim::DriverStationSim::SetEnabled(true);
|
||||
wpi::sim::DriverStationSim::SetAutonomous(false);
|
||||
wpi::sim::DriverStationSim::SetTest(true);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
@@ -325,7 +325,7 @@ TEST_F(TimedRobotTest, TestMode) {
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
@@ -345,7 +345,7 @@ TEST_F(TimedRobotTest, TestMode) {
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
@@ -365,11 +365,11 @@ TEST_F(TimedRobotTest, TestMode) {
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::DriverStationSim::SetEnabled(false);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::sim::StepTiming(20_ms); // Wait for Notifiers
|
||||
wpi::sim::DriverStationSim::SetEnabled(false);
|
||||
wpi::sim::DriverStationSim::SetAutonomous(false);
|
||||
wpi::sim::DriverStationSim::SetTest(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::StepTiming(20_ms); // Wait for Notifiers
|
||||
|
||||
EXPECT_EQ(1u, robot.m_simulationInitCount);
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
@@ -399,11 +399,11 @@ TEST_F(TimedRobotTest, ModeChange) {
|
||||
std::thread robotThread{[&] { robot.StartCompetition(); }};
|
||||
|
||||
// Start in disabled
|
||||
frc::sim::DriverStationSim::SetEnabled(false);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
wpi::sim::DriverStationSim::SetEnabled(false);
|
||||
wpi::sim::DriverStationSim::SetAutonomous(false);
|
||||
wpi::sim::DriverStationSim::SetTest(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousInitCount);
|
||||
@@ -415,7 +415,7 @@ TEST_F(TimedRobotTest, ModeChange) {
|
||||
EXPECT_EQ(0u, robot.m_teleopExitCount);
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(0u, robot.m_autonomousInitCount);
|
||||
@@ -428,12 +428,12 @@ TEST_F(TimedRobotTest, ModeChange) {
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
// Transition to autonomous
|
||||
frc::sim::DriverStationSim::SetEnabled(true);
|
||||
frc::sim::DriverStationSim::SetAutonomous(true);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::SetEnabled(true);
|
||||
wpi::sim::DriverStationSim::SetAutonomous(true);
|
||||
wpi::sim::DriverStationSim::SetTest(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousInitCount);
|
||||
@@ -446,12 +446,12 @@ TEST_F(TimedRobotTest, ModeChange) {
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
// Transition to teleop
|
||||
frc::sim::DriverStationSim::SetEnabled(true);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::SetEnabled(true);
|
||||
wpi::sim::DriverStationSim::SetAutonomous(false);
|
||||
wpi::sim::DriverStationSim::SetTest(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousInitCount);
|
||||
@@ -464,12 +464,12 @@ TEST_F(TimedRobotTest, ModeChange) {
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
// Transition to test
|
||||
frc::sim::DriverStationSim::SetEnabled(true);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(true);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::SetEnabled(true);
|
||||
wpi::sim::DriverStationSim::SetAutonomous(false);
|
||||
wpi::sim::DriverStationSim::SetTest(true);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousInitCount);
|
||||
@@ -482,12 +482,12 @@ TEST_F(TimedRobotTest, ModeChange) {
|
||||
EXPECT_EQ(0u, robot.m_testExitCount);
|
||||
|
||||
// Transition to disabled
|
||||
frc::sim::DriverStationSim::SetEnabled(false);
|
||||
frc::sim::DriverStationSim::SetAutonomous(false);
|
||||
frc::sim::DriverStationSim::SetTest(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::SetEnabled(false);
|
||||
wpi::sim::DriverStationSim::SetAutonomous(false);
|
||||
wpi::sim::DriverStationSim::SetTest(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
|
||||
frc::sim::StepTiming(kPeriod);
|
||||
wpi::sim::StepTiming(kPeriod);
|
||||
|
||||
EXPECT_EQ(2u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_autonomousInitCount);
|
||||
@@ -511,21 +511,21 @@ TEST_F(TimedRobotTest, AddPeriodic) {
|
||||
|
||||
std::thread robotThread{[&] { robot.StartCompetition(); }};
|
||||
|
||||
frc::sim::DriverStationSim::SetEnabled(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
wpi::sim::DriverStationSim::SetEnabled(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
|
||||
EXPECT_EQ(0u, callbackCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod / 2.0);
|
||||
wpi::sim::StepTiming(kPeriod / 2.0);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
|
||||
EXPECT_EQ(1u, callbackCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod / 2.0);
|
||||
wpi::sim::StepTiming(kPeriod / 2.0);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
|
||||
@@ -550,33 +550,33 @@ TEST_F(TimedRobotTest, AddPeriodicWithOffset) {
|
||||
|
||||
std::thread robotThread{[&] { robot.StartCompetition(); }};
|
||||
|
||||
frc::sim::DriverStationSim::SetEnabled(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
wpi::sim::DriverStationSim::SetEnabled(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
|
||||
EXPECT_EQ(0u, callbackCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod * 3.0 / 8.0);
|
||||
wpi::sim::StepTiming(kPeriod * 3.0 / 8.0);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
|
||||
EXPECT_EQ(0u, callbackCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod * 3.0 / 8.0);
|
||||
wpi::sim::StepTiming(kPeriod * 3.0 / 8.0);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(0u, robot.m_disabledPeriodicCount);
|
||||
EXPECT_EQ(1u, callbackCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod / 4.0);
|
||||
wpi::sim::StepTiming(kPeriod / 4.0);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
|
||||
EXPECT_EQ(1u, callbackCount);
|
||||
|
||||
frc::sim::StepTiming(kPeriod / 4.0);
|
||||
wpi::sim::StepTiming(kPeriod / 4.0);
|
||||
|
||||
EXPECT_EQ(1u, robot.m_disabledInitCount);
|
||||
EXPECT_EQ(1u, robot.m_disabledPeriodicCount);
|
||||
|
||||
@@ -8,17 +8,17 @@
|
||||
|
||||
#include "wpi/simulation/SimHooks.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
namespace {
|
||||
class TimerTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
frc::sim::PauseTiming();
|
||||
frc::sim::RestartTiming();
|
||||
wpi::sim::PauseTiming();
|
||||
wpi::sim::RestartTiming();
|
||||
}
|
||||
|
||||
void TearDown() override { frc::sim::ResumeTiming(); }
|
||||
void TearDown() override { wpi::sim::ResumeTiming(); }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -29,19 +29,19 @@ TEST_F(TimerTest, StartStop) {
|
||||
// Verify timer is initialized as stopped
|
||||
EXPECT_EQ(timer.Get(), 0_s);
|
||||
EXPECT_FALSE(timer.IsRunning());
|
||||
frc::sim::StepTiming(500_ms);
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
EXPECT_EQ(timer.Get(), 0_s);
|
||||
EXPECT_FALSE(timer.IsRunning());
|
||||
|
||||
// Verify timer increments after it's started
|
||||
timer.Start();
|
||||
frc::sim::StepTiming(500_ms);
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
EXPECT_EQ(timer.Get(), 500_ms);
|
||||
EXPECT_TRUE(timer.IsRunning());
|
||||
|
||||
// Verify timer stops incrementing after it's stopped
|
||||
timer.Stop();
|
||||
frc::sim::StepTiming(500_ms);
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
EXPECT_EQ(timer.Get(), 500_ms);
|
||||
EXPECT_FALSE(timer.IsRunning());
|
||||
}
|
||||
@@ -52,7 +52,7 @@ TEST_F(TimerTest, Reset) {
|
||||
|
||||
// Advance timer to 500 ms
|
||||
EXPECT_EQ(timer.Get(), 0_s);
|
||||
frc::sim::StepTiming(500_ms);
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
EXPECT_EQ(timer.Get(), 500_ms);
|
||||
|
||||
// Verify timer reports 0 ms after reset
|
||||
@@ -60,13 +60,13 @@ TEST_F(TimerTest, Reset) {
|
||||
EXPECT_EQ(timer.Get(), 0_s);
|
||||
|
||||
// Verify timer continues incrementing
|
||||
frc::sim::StepTiming(500_ms);
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
EXPECT_EQ(timer.Get(), 500_ms);
|
||||
|
||||
// Verify timer doesn't start incrementing after reset if it was stopped
|
||||
timer.Stop();
|
||||
timer.Reset();
|
||||
frc::sim::StepTiming(500_ms);
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
EXPECT_EQ(timer.Get(), 0_ms);
|
||||
}
|
||||
|
||||
@@ -77,13 +77,13 @@ TEST_F(TimerTest, HasElapsed) {
|
||||
EXPECT_TRUE(timer.HasElapsed(0_s));
|
||||
|
||||
// Verify timer doesn't report elapsed time when stopped
|
||||
frc::sim::StepTiming(500_ms);
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
EXPECT_FALSE(timer.HasElapsed(400_ms));
|
||||
|
||||
timer.Start();
|
||||
|
||||
// Verify timer reports >= 400 ms has elapsed after multiple calls
|
||||
frc::sim::StepTiming(500_ms);
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
EXPECT_TRUE(timer.HasElapsed(400_ms));
|
||||
EXPECT_TRUE(timer.HasElapsed(400_ms));
|
||||
}
|
||||
@@ -95,26 +95,26 @@ TEST_F(TimerTest, AdvanceIfElapsed) {
|
||||
EXPECT_TRUE(timer.AdvanceIfElapsed(0_s));
|
||||
|
||||
// Verify timer doesn't report elapsed time when stopped
|
||||
frc::sim::StepTiming(500_ms);
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
EXPECT_FALSE(timer.AdvanceIfElapsed(400_ms));
|
||||
|
||||
timer.Start();
|
||||
|
||||
// Verify timer reports >= 400 ms has elapsed for only first call
|
||||
frc::sim::StepTiming(500_ms);
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
EXPECT_TRUE(timer.AdvanceIfElapsed(400_ms));
|
||||
EXPECT_FALSE(timer.AdvanceIfElapsed(400_ms));
|
||||
|
||||
// Verify timer reports >= 400 ms has elapsed for two calls
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
EXPECT_TRUE(timer.AdvanceIfElapsed(400_ms));
|
||||
EXPECT_TRUE(timer.AdvanceIfElapsed(400_ms));
|
||||
EXPECT_FALSE(timer.AdvanceIfElapsed(400_ms));
|
||||
}
|
||||
|
||||
TEST_F(TimerTest, GetFPGATimestamp) {
|
||||
auto start = frc::Timer::GetFPGATimestamp();
|
||||
frc::sim::StepTiming(500_ms);
|
||||
auto end = frc::Timer::GetFPGATimestamp();
|
||||
auto start = wpi::Timer::GetFPGATimestamp();
|
||||
wpi::sim::StepTiming(500_ms);
|
||||
auto end = wpi::Timer::GetFPGATimestamp();
|
||||
EXPECT_EQ(start + 500_ms, end);
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
#include "wpi/simulation/DriverStationSim.hpp"
|
||||
#include "wpi/simulation/SimHooks.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
namespace {
|
||||
class TimesliceRobotTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override { frc::sim::PauseTiming(); }
|
||||
void SetUp() override { wpi::sim::PauseTiming(); }
|
||||
|
||||
void TearDown() override { frc::sim::ResumeTiming(); }
|
||||
void TearDown() override { wpi::sim::ResumeTiming(); }
|
||||
};
|
||||
|
||||
class MockRobot : public TimesliceRobot {
|
||||
@@ -52,33 +52,33 @@ TEST_F(TimesliceRobotTest, Schedule) {
|
||||
|
||||
std::thread robotThread{[&] { robot.StartCompetition(); }};
|
||||
|
||||
frc::sim::DriverStationSim::SetEnabled(false);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
frc::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
wpi::sim::DriverStationSim::SetEnabled(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
|
||||
// Functions scheduled with addPeriodic() are delayed by one period before
|
||||
// their first run (5 ms for this test's callbacks here and 20 ms for
|
||||
// robotPeriodic()).
|
||||
frc::sim::StepTiming(5_ms);
|
||||
wpi::sim::StepTiming(5_ms);
|
||||
|
||||
EXPECT_EQ(0u, robot.m_robotPeriodicCount);
|
||||
EXPECT_EQ(0u, callbackCount1);
|
||||
EXPECT_EQ(0u, callbackCount2);
|
||||
|
||||
// Step to 1.5 ms
|
||||
frc::sim::StepTiming(1.5_ms);
|
||||
wpi::sim::StepTiming(1.5_ms);
|
||||
EXPECT_EQ(0u, robot.m_robotPeriodicCount);
|
||||
EXPECT_EQ(0u, callbackCount1);
|
||||
EXPECT_EQ(0u, callbackCount2);
|
||||
|
||||
// Step to 2.25 ms
|
||||
frc::sim::StepTiming(0.75_ms);
|
||||
wpi::sim::StepTiming(0.75_ms);
|
||||
EXPECT_EQ(0u, robot.m_robotPeriodicCount);
|
||||
EXPECT_EQ(1u, callbackCount1);
|
||||
EXPECT_EQ(0u, callbackCount2);
|
||||
|
||||
// Step to 2.75 ms
|
||||
frc::sim::StepTiming(0.5_ms);
|
||||
wpi::sim::StepTiming(0.5_ms);
|
||||
EXPECT_EQ(0u, robot.m_robotPeriodicCount);
|
||||
EXPECT_EQ(1u, callbackCount1);
|
||||
EXPECT_EQ(1u, callbackCount2);
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
|
||||
class UnitNetworkTablesTest : public ::testing::Test {
|
||||
public:
|
||||
UnitNetworkTablesTest() : inst{nt::NetworkTableInstance::Create()} {}
|
||||
~UnitNetworkTablesTest() override { nt::NetworkTableInstance::Destroy(inst); }
|
||||
nt::NetworkTableInstance inst;
|
||||
UnitNetworkTablesTest() : inst{wpi::nt::NetworkTableInstance::Create()} {}
|
||||
~UnitNetworkTablesTest() override { wpi::nt::NetworkTableInstance::Destroy(inst); }
|
||||
wpi::nt::NetworkTableInstance inst;
|
||||
};
|
||||
|
||||
TEST_F(UnitNetworkTablesTest, Publish) {
|
||||
auto topic = nt::UnitTopic<units::meter_t>{inst.GetTopic("meterTest")};
|
||||
auto topic = wpi::nt::UnitTopic<wpi::units::meter_t>{inst.GetTopic("meterTest")};
|
||||
auto pub = topic.Publish();
|
||||
pub.Set(2_m);
|
||||
ASSERT_EQ(topic.GetProperty("unit"), "meter");
|
||||
@@ -25,7 +25,7 @@ TEST_F(UnitNetworkTablesTest, Publish) {
|
||||
}
|
||||
|
||||
TEST_F(UnitNetworkTablesTest, SubscribeDouble) {
|
||||
auto topic = nt::UnitTopic<units::meter_t>{inst.GetTopic("meterTest")};
|
||||
auto topic = wpi::nt::UnitTopic<wpi::units::meter_t>{inst.GetTopic("meterTest")};
|
||||
auto pub = topic.Publish();
|
||||
auto sub = inst.GetDoubleTopic("meterTest").Subscribe(0);
|
||||
ASSERT_EQ(sub.Get(), 0);
|
||||
@@ -35,7 +35,7 @@ TEST_F(UnitNetworkTablesTest, SubscribeDouble) {
|
||||
}
|
||||
|
||||
TEST_F(UnitNetworkTablesTest, SubscribeUnit) {
|
||||
auto topic = nt::UnitTopic<units::meter_t>{inst.GetTopic("meterTest")};
|
||||
auto topic = wpi::nt::UnitTopic<wpi::units::meter_t>{inst.GetTopic("meterTest")};
|
||||
auto pub = topic.Publish();
|
||||
auto sub = topic.Subscribe(0_m);
|
||||
ASSERT_EQ(sub.Get(), 0_m);
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
|
||||
#include "wpi/simulation/SimHooks.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
namespace {
|
||||
class WatchdogTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override { frc::sim::PauseTiming(); }
|
||||
void SetUp() override { wpi::sim::PauseTiming(); }
|
||||
|
||||
void TearDown() override { frc::sim::ResumeTiming(); }
|
||||
void TearDown() override { wpi::sim::ResumeTiming(); }
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -29,7 +29,7 @@ TEST_F(WatchdogTest, EnableDisable) {
|
||||
|
||||
// Run 1
|
||||
watchdog.Enable();
|
||||
frc::sim::StepTiming(0.2_s);
|
||||
wpi::sim::StepTiming(0.2_s);
|
||||
watchdog.Disable();
|
||||
|
||||
EXPECT_EQ(0u, watchdogCounter) << "Watchdog triggered early";
|
||||
@@ -37,7 +37,7 @@ TEST_F(WatchdogTest, EnableDisable) {
|
||||
// Run 2
|
||||
watchdogCounter = 0;
|
||||
watchdog.Enable();
|
||||
frc::sim::StepTiming(0.4_s);
|
||||
wpi::sim::StepTiming(0.4_s);
|
||||
watchdog.Disable();
|
||||
|
||||
EXPECT_EQ(1u, watchdogCounter)
|
||||
@@ -46,7 +46,7 @@ TEST_F(WatchdogTest, EnableDisable) {
|
||||
// Run 3
|
||||
watchdogCounter = 0;
|
||||
watchdog.Enable();
|
||||
frc::sim::StepTiming(1_s);
|
||||
wpi::sim::StepTiming(1_s);
|
||||
watchdog.Disable();
|
||||
|
||||
EXPECT_EQ(1u, watchdogCounter)
|
||||
@@ -59,9 +59,9 @@ TEST_F(WatchdogTest, Reset) {
|
||||
Watchdog watchdog(0.4_s, [&] { watchdogCounter++; });
|
||||
|
||||
watchdog.Enable();
|
||||
frc::sim::StepTiming(0.2_s);
|
||||
wpi::sim::StepTiming(0.2_s);
|
||||
watchdog.Reset();
|
||||
frc::sim::StepTiming(0.2_s);
|
||||
wpi::sim::StepTiming(0.2_s);
|
||||
watchdog.Disable();
|
||||
|
||||
EXPECT_EQ(0u, watchdogCounter) << "Watchdog triggered early";
|
||||
@@ -73,13 +73,13 @@ TEST_F(WatchdogTest, SetTimeout) {
|
||||
Watchdog watchdog(1_s, [&] { watchdogCounter++; });
|
||||
|
||||
watchdog.Enable();
|
||||
frc::sim::StepTiming(0.2_s);
|
||||
wpi::sim::StepTiming(0.2_s);
|
||||
watchdog.SetTimeout(0.2_s);
|
||||
|
||||
EXPECT_EQ(0.2_s, watchdog.GetTimeout());
|
||||
EXPECT_EQ(0u, watchdogCounter) << "Watchdog triggered early";
|
||||
|
||||
frc::sim::StepTiming(0.3_s);
|
||||
wpi::sim::StepTiming(0.3_s);
|
||||
watchdog.Disable();
|
||||
|
||||
EXPECT_EQ(1u, watchdogCounter)
|
||||
@@ -92,7 +92,7 @@ TEST_F(WatchdogTest, IsExpired) {
|
||||
watchdog.Enable();
|
||||
|
||||
EXPECT_FALSE(watchdog.IsExpired());
|
||||
frc::sim::StepTiming(0.3_s);
|
||||
wpi::sim::StepTiming(0.3_s);
|
||||
EXPECT_TRUE(watchdog.IsExpired());
|
||||
|
||||
watchdog.Disable();
|
||||
@@ -110,9 +110,9 @@ TEST_F(WatchdogTest, Epochs) {
|
||||
// Run 1
|
||||
watchdog.Enable();
|
||||
watchdog.AddEpoch("Epoch 1");
|
||||
frc::sim::StepTiming(0.1_s);
|
||||
wpi::sim::StepTiming(0.1_s);
|
||||
watchdog.AddEpoch("Epoch 2");
|
||||
frc::sim::StepTiming(0.1_s);
|
||||
wpi::sim::StepTiming(0.1_s);
|
||||
watchdog.AddEpoch("Epoch 3");
|
||||
watchdog.Disable();
|
||||
|
||||
@@ -121,9 +121,9 @@ TEST_F(WatchdogTest, Epochs) {
|
||||
// Run 2
|
||||
watchdog.Enable();
|
||||
watchdog.AddEpoch("Epoch 1");
|
||||
frc::sim::StepTiming(0.2_s);
|
||||
wpi::sim::StepTiming(0.2_s);
|
||||
watchdog.Reset();
|
||||
frc::sim::StepTiming(0.2_s);
|
||||
wpi::sim::StepTiming(0.2_s);
|
||||
watchdog.AddEpoch("Epoch 2");
|
||||
watchdog.Disable();
|
||||
|
||||
@@ -138,13 +138,13 @@ TEST_F(WatchdogTest, MultiWatchdog) {
|
||||
Watchdog watchdog2(0.6_s, [&] { watchdogCounter2++; });
|
||||
|
||||
watchdog2.Enable();
|
||||
frc::sim::StepTiming(0.25_s);
|
||||
wpi::sim::StepTiming(0.25_s);
|
||||
EXPECT_EQ(0u, watchdogCounter1) << "Watchdog triggered early";
|
||||
EXPECT_EQ(0u, watchdogCounter2) << "Watchdog triggered early";
|
||||
|
||||
// Sleep enough such that only the watchdog enabled later times out first
|
||||
watchdog1.Enable();
|
||||
frc::sim::StepTiming(0.25_s);
|
||||
wpi::sim::StepTiming(0.25_s);
|
||||
watchdog1.Disable();
|
||||
watchdog2.Disable();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "JoystickTestMacros.hpp"
|
||||
#include "wpi/simulation/XboxControllerSim.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
BUTTON_TEST(XboxController, LeftBumperButton)
|
||||
BUTTON_TEST(XboxController, RightBumperButton)
|
||||
|
||||
@@ -9,240 +9,240 @@
|
||||
|
||||
TEST(DifferentialDriveTest, ArcadeDriveIK) {
|
||||
// Forward
|
||||
auto speeds = frc::DifferentialDrive::ArcadeDriveIK(1.0, 0.0, false);
|
||||
auto speeds = wpi::DifferentialDrive::ArcadeDriveIK(1.0, 0.0, false);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Forward left turn
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(0.5, 0.5, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(0.5, 0.5, false);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.5, speeds.right);
|
||||
|
||||
// Forward right turn
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(0.5, -0.5, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(0.5, -0.5, false);
|
||||
EXPECT_DOUBLE_EQ(0.5, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.right);
|
||||
|
||||
// Backward
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(-1.0, 0.0, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(-1.0, 0.0, false);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
|
||||
// Backward left turn
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(-0.5, 0.5, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(-0.5, 0.5, false);
|
||||
EXPECT_DOUBLE_EQ(-0.5, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.right);
|
||||
|
||||
// Backward right turn
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(-0.5, -0.5, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(-0.5, -0.5, false);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-0.5, speeds.right);
|
||||
|
||||
// Left turn (xSpeed with negative sign)
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(-0.0, 1.0, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(-0.0, 1.0, false);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Left turn (xSpeed with positive sign)
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(0.0, 1.0, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(0.0, 1.0, false);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Right turn (xSpeed with negative sign)
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(-0.0, -1.0, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(-0.0, -1.0, false);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
|
||||
// Right turn (xSpeed with positive sign)
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(0.0, -1.0, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(0.0, -1.0, false);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, ArcadeDriveIKSquared) {
|
||||
// Forward
|
||||
auto speeds = frc::DifferentialDrive::ArcadeDriveIK(1.0, 0.0, true);
|
||||
auto speeds = wpi::DifferentialDrive::ArcadeDriveIK(1.0, 0.0, true);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Forward left turn
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(0.5, 0.5, true);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(0.5, 0.5, true);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.25, speeds.right);
|
||||
|
||||
// Forward right turn
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(0.5, -0.5, true);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(0.5, -0.5, true);
|
||||
EXPECT_DOUBLE_EQ(0.25, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.right);
|
||||
|
||||
// Backward
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(-1.0, 0.0, true);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(-1.0, 0.0, true);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
|
||||
// Backward left turn
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(-0.5, 0.5, true);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(-0.5, 0.5, true);
|
||||
EXPECT_DOUBLE_EQ(-0.25, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.right);
|
||||
|
||||
// Backward right turn
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(-0.5, -0.5, true);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(-0.5, -0.5, true);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-0.25, speeds.right);
|
||||
|
||||
// Left turn (xSpeed with negative sign)
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(-0.0, 1.0, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(-0.0, 1.0, false);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Left turn (xSpeed with positive sign)
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(0.0, 1.0, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(0.0, 1.0, false);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Right turn (xSpeed with negative sign)
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(-0.0, -1.0, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(-0.0, -1.0, false);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
|
||||
// Right turn (xSpeed with positive sign)
|
||||
speeds = frc::DifferentialDrive::ArcadeDriveIK(0.0, -1.0, false);
|
||||
speeds = wpi::DifferentialDrive::ArcadeDriveIK(0.0, -1.0, false);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, CurvatureDriveIK) {
|
||||
// Forward
|
||||
auto speeds = frc::DifferentialDrive::CurvatureDriveIK(1.0, 0.0, false);
|
||||
auto speeds = wpi::DifferentialDrive::CurvatureDriveIK(1.0, 0.0, false);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Forward left turn
|
||||
speeds = frc::DifferentialDrive::CurvatureDriveIK(0.5, 0.5, false);
|
||||
speeds = wpi::DifferentialDrive::CurvatureDriveIK(0.5, 0.5, false);
|
||||
EXPECT_DOUBLE_EQ(0.25, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.75, speeds.right);
|
||||
|
||||
// Forward right turn
|
||||
speeds = frc::DifferentialDrive::CurvatureDriveIK(0.5, -0.5, false);
|
||||
speeds = wpi::DifferentialDrive::CurvatureDriveIK(0.5, -0.5, false);
|
||||
EXPECT_DOUBLE_EQ(0.75, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.25, speeds.right);
|
||||
|
||||
// Backward
|
||||
speeds = frc::DifferentialDrive::CurvatureDriveIK(-1.0, 0.0, false);
|
||||
speeds = wpi::DifferentialDrive::CurvatureDriveIK(-1.0, 0.0, false);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
|
||||
// Backward left turn
|
||||
speeds = frc::DifferentialDrive::CurvatureDriveIK(-0.5, 0.5, false);
|
||||
speeds = wpi::DifferentialDrive::CurvatureDriveIK(-0.5, 0.5, false);
|
||||
EXPECT_DOUBLE_EQ(-0.75, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-0.25, speeds.right);
|
||||
|
||||
// Backward right turn
|
||||
speeds = frc::DifferentialDrive::CurvatureDriveIK(-0.5, -0.5, false);
|
||||
speeds = wpi::DifferentialDrive::CurvatureDriveIK(-0.5, -0.5, false);
|
||||
EXPECT_DOUBLE_EQ(-0.25, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-0.75, speeds.right);
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, CurvatureDriveIKTurnInPlace) {
|
||||
// Forward
|
||||
auto speeds = frc::DifferentialDrive::CurvatureDriveIK(1.0, 0.0, true);
|
||||
auto speeds = wpi::DifferentialDrive::CurvatureDriveIK(1.0, 0.0, true);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Forward left turn
|
||||
speeds = frc::DifferentialDrive::CurvatureDriveIK(0.5, 0.5, true);
|
||||
speeds = wpi::DifferentialDrive::CurvatureDriveIK(0.5, 0.5, true);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Forward right turn
|
||||
speeds = frc::DifferentialDrive::CurvatureDriveIK(0.5, -0.5, true);
|
||||
speeds = wpi::DifferentialDrive::CurvatureDriveIK(0.5, -0.5, true);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.right);
|
||||
|
||||
// Backward
|
||||
speeds = frc::DifferentialDrive::CurvatureDriveIK(-1.0, 0.0, true);
|
||||
speeds = wpi::DifferentialDrive::CurvatureDriveIK(-1.0, 0.0, true);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
|
||||
// Backward left turn
|
||||
speeds = frc::DifferentialDrive::CurvatureDriveIK(-0.5, 0.5, true);
|
||||
speeds = wpi::DifferentialDrive::CurvatureDriveIK(-0.5, 0.5, true);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.right);
|
||||
|
||||
// Backward right turn
|
||||
speeds = frc::DifferentialDrive::CurvatureDriveIK(-0.5, -0.5, true);
|
||||
speeds = wpi::DifferentialDrive::CurvatureDriveIK(-0.5, -0.5, true);
|
||||
EXPECT_DOUBLE_EQ(0.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, TankDriveIK) {
|
||||
// Forward
|
||||
auto speeds = frc::DifferentialDrive::TankDriveIK(1.0, 1.0, false);
|
||||
auto speeds = wpi::DifferentialDrive::TankDriveIK(1.0, 1.0, false);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Forward left turn
|
||||
speeds = frc::DifferentialDrive::TankDriveIK(0.5, 1.0, false);
|
||||
speeds = wpi::DifferentialDrive::TankDriveIK(0.5, 1.0, false);
|
||||
EXPECT_DOUBLE_EQ(0.5, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Forward right turn
|
||||
speeds = frc::DifferentialDrive::TankDriveIK(1.0, 0.5, false);
|
||||
speeds = wpi::DifferentialDrive::TankDriveIK(1.0, 0.5, false);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.5, speeds.right);
|
||||
|
||||
// Backward
|
||||
speeds = frc::DifferentialDrive::TankDriveIK(-1.0, -1.0, false);
|
||||
speeds = wpi::DifferentialDrive::TankDriveIK(-1.0, -1.0, false);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
|
||||
// Backward left turn
|
||||
speeds = frc::DifferentialDrive::TankDriveIK(-0.5, -1.0, false);
|
||||
speeds = wpi::DifferentialDrive::TankDriveIK(-0.5, -1.0, false);
|
||||
EXPECT_DOUBLE_EQ(-0.5, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
|
||||
// Backward right turn
|
||||
speeds = frc::DifferentialDrive::TankDriveIK(-0.5, 1.0, false);
|
||||
speeds = wpi::DifferentialDrive::TankDriveIK(-0.5, 1.0, false);
|
||||
EXPECT_DOUBLE_EQ(-0.5, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, TankDriveIKSquared) {
|
||||
// Forward
|
||||
auto speeds = frc::DifferentialDrive::TankDriveIK(1.0, 1.0, true);
|
||||
auto speeds = wpi::DifferentialDrive::TankDriveIK(1.0, 1.0, true);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Forward left turn
|
||||
speeds = frc::DifferentialDrive::TankDriveIK(0.5, 1.0, true);
|
||||
speeds = wpi::DifferentialDrive::TankDriveIK(0.5, 1.0, true);
|
||||
EXPECT_DOUBLE_EQ(0.25, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.right);
|
||||
|
||||
// Forward right turn
|
||||
speeds = frc::DifferentialDrive::TankDriveIK(1.0, 0.5, true);
|
||||
speeds = wpi::DifferentialDrive::TankDriveIK(1.0, 0.5, true);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(0.25, speeds.right);
|
||||
|
||||
// Backward
|
||||
speeds = frc::DifferentialDrive::TankDriveIK(-1.0, -1.0, true);
|
||||
speeds = wpi::DifferentialDrive::TankDriveIK(-1.0, -1.0, true);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
|
||||
// Backward left turn
|
||||
speeds = frc::DifferentialDrive::TankDriveIK(-0.5, -1.0, true);
|
||||
speeds = wpi::DifferentialDrive::TankDriveIK(-0.5, -1.0, true);
|
||||
EXPECT_DOUBLE_EQ(-0.25, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.right);
|
||||
|
||||
// Backward right turn
|
||||
speeds = frc::DifferentialDrive::TankDriveIK(-1.0, -0.5, true);
|
||||
speeds = wpi::DifferentialDrive::TankDriveIK(-1.0, -0.5, true);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.left);
|
||||
EXPECT_DOUBLE_EQ(-0.25, speeds.right);
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, ArcadeDrive) {
|
||||
frc::MockPWMMotorController left;
|
||||
frc::MockPWMMotorController right;
|
||||
frc::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
wpi::MockPWMMotorController left;
|
||||
wpi::MockPWMMotorController right;
|
||||
wpi::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
[&](double output) { right.Set(output); }};
|
||||
drive.SetDeadband(0.0);
|
||||
|
||||
@@ -278,9 +278,9 @@ TEST(DifferentialDriveTest, ArcadeDrive) {
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, ArcadeDriveSquared) {
|
||||
frc::MockPWMMotorController left;
|
||||
frc::MockPWMMotorController right;
|
||||
frc::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
wpi::MockPWMMotorController left;
|
||||
wpi::MockPWMMotorController right;
|
||||
wpi::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
[&](double output) { right.Set(output); }};
|
||||
drive.SetDeadband(0.0);
|
||||
|
||||
@@ -316,9 +316,9 @@ TEST(DifferentialDriveTest, ArcadeDriveSquared) {
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, CurvatureDrive) {
|
||||
frc::MockPWMMotorController left;
|
||||
frc::MockPWMMotorController right;
|
||||
frc::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
wpi::MockPWMMotorController left;
|
||||
wpi::MockPWMMotorController right;
|
||||
wpi::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
[&](double output) { right.Set(output); }};
|
||||
drive.SetDeadband(0.0);
|
||||
|
||||
@@ -354,9 +354,9 @@ TEST(DifferentialDriveTest, CurvatureDrive) {
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, CurvatureDriveTurnInPlace) {
|
||||
frc::MockPWMMotorController left;
|
||||
frc::MockPWMMotorController right;
|
||||
frc::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
wpi::MockPWMMotorController left;
|
||||
wpi::MockPWMMotorController right;
|
||||
wpi::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
[&](double output) { right.Set(output); }};
|
||||
drive.SetDeadband(0.0);
|
||||
|
||||
@@ -392,9 +392,9 @@ TEST(DifferentialDriveTest, CurvatureDriveTurnInPlace) {
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, TankDrive) {
|
||||
frc::MockPWMMotorController left;
|
||||
frc::MockPWMMotorController right;
|
||||
frc::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
wpi::MockPWMMotorController left;
|
||||
wpi::MockPWMMotorController right;
|
||||
wpi::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
[&](double output) { right.Set(output); }};
|
||||
drive.SetDeadband(0.0);
|
||||
|
||||
@@ -430,9 +430,9 @@ TEST(DifferentialDriveTest, TankDrive) {
|
||||
}
|
||||
|
||||
TEST(DifferentialDriveTest, TankDriveSquared) {
|
||||
frc::MockPWMMotorController left;
|
||||
frc::MockPWMMotorController right;
|
||||
frc::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
wpi::MockPWMMotorController left;
|
||||
wpi::MockPWMMotorController right;
|
||||
wpi::DifferentialDrive drive{[&](double output) { left.Set(output); },
|
||||
[&](double output) { right.Set(output); }};
|
||||
drive.SetDeadband(0.0);
|
||||
|
||||
|
||||
@@ -9,35 +9,35 @@
|
||||
|
||||
TEST(MecanumDriveTest, CartesianIK) {
|
||||
// Forward
|
||||
auto speeds = frc::MecanumDrive::DriveCartesianIK(1.0, 0.0, 0.0);
|
||||
auto speeds = wpi::MecanumDrive::DriveCartesianIK(1.0, 0.0, 0.0);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontRight);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearRight);
|
||||
|
||||
// Left
|
||||
speeds = frc::MecanumDrive::DriveCartesianIK(0.0, -1.0, 0.0);
|
||||
speeds = wpi::MecanumDrive::DriveCartesianIK(0.0, -1.0, 0.0);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.frontLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontRight);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearLeft);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.rearRight);
|
||||
|
||||
// Right
|
||||
speeds = frc::MecanumDrive::DriveCartesianIK(0.0, 1.0, 0.0);
|
||||
speeds = wpi::MecanumDrive::DriveCartesianIK(0.0, 1.0, 0.0);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontLeft);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.frontRight);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.rearLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearRight);
|
||||
|
||||
// Rotate CCW
|
||||
speeds = frc::MecanumDrive::DriveCartesianIK(0.0, 0.0, -1.0);
|
||||
speeds = wpi::MecanumDrive::DriveCartesianIK(0.0, 0.0, -1.0);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.frontLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontRight);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.rearLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearRight);
|
||||
|
||||
// Rotate CW
|
||||
speeds = frc::MecanumDrive::DriveCartesianIK(0.0, 0.0, 1.0);
|
||||
speeds = wpi::MecanumDrive::DriveCartesianIK(0.0, 0.0, 1.0);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontLeft);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.frontRight);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearLeft);
|
||||
@@ -46,35 +46,35 @@ TEST(MecanumDriveTest, CartesianIK) {
|
||||
|
||||
TEST(MecanumDriveTest, CartesianIKGyro90CW) {
|
||||
// Forward in global frame; left in robot frame
|
||||
auto speeds = frc::MecanumDrive::DriveCartesianIK(1.0, 0.0, 0.0, 90_deg);
|
||||
auto speeds = wpi::MecanumDrive::DriveCartesianIK(1.0, 0.0, 0.0, 90_deg);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.frontLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontRight);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearLeft);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.rearRight);
|
||||
|
||||
// Left in global frame; backward in robot frame
|
||||
speeds = frc::MecanumDrive::DriveCartesianIK(0.0, -1.0, 0.0, 90_deg);
|
||||
speeds = wpi::MecanumDrive::DriveCartesianIK(0.0, -1.0, 0.0, 90_deg);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.frontLeft);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.frontRight);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.rearLeft);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.rearRight);
|
||||
|
||||
// Right in global frame; forward in robot frame
|
||||
speeds = frc::MecanumDrive::DriveCartesianIK(0.0, 1.0, 0.0, 90_deg);
|
||||
speeds = wpi::MecanumDrive::DriveCartesianIK(0.0, 1.0, 0.0, 90_deg);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontRight);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearRight);
|
||||
|
||||
// Rotate CCW
|
||||
speeds = frc::MecanumDrive::DriveCartesianIK(0.0, 0.0, -1.0, 90_deg);
|
||||
speeds = wpi::MecanumDrive::DriveCartesianIK(0.0, 0.0, -1.0, 90_deg);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.frontLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontRight);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.rearLeft);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearRight);
|
||||
|
||||
// Rotate CW
|
||||
speeds = frc::MecanumDrive::DriveCartesianIK(0.0, 0.0, 1.0, 90_deg);
|
||||
speeds = wpi::MecanumDrive::DriveCartesianIK(0.0, 0.0, 1.0, 90_deg);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.frontLeft);
|
||||
EXPECT_DOUBLE_EQ(-1.0, speeds.frontRight);
|
||||
EXPECT_DOUBLE_EQ(1.0, speeds.rearLeft);
|
||||
@@ -82,11 +82,11 @@ TEST(MecanumDriveTest, CartesianIKGyro90CW) {
|
||||
}
|
||||
|
||||
TEST(MecanumDriveTest, Cartesian) {
|
||||
frc::MockPWMMotorController fl;
|
||||
frc::MockPWMMotorController rl;
|
||||
frc::MockPWMMotorController fr;
|
||||
frc::MockPWMMotorController rr;
|
||||
frc::MecanumDrive drive{[&](double output) { fl.Set(output); },
|
||||
wpi::MockPWMMotorController fl;
|
||||
wpi::MockPWMMotorController rl;
|
||||
wpi::MockPWMMotorController fr;
|
||||
wpi::MockPWMMotorController rr;
|
||||
wpi::MecanumDrive drive{[&](double output) { fl.Set(output); },
|
||||
[&](double output) { rl.Set(output); },
|
||||
[&](double output) { fr.Set(output); },
|
||||
[&](double output) { rr.Set(output); }};
|
||||
@@ -129,11 +129,11 @@ TEST(MecanumDriveTest, Cartesian) {
|
||||
}
|
||||
|
||||
TEST(MecanumDriveTest, CartesianGyro90CW) {
|
||||
frc::MockPWMMotorController fl;
|
||||
frc::MockPWMMotorController rl;
|
||||
frc::MockPWMMotorController fr;
|
||||
frc::MockPWMMotorController rr;
|
||||
frc::MecanumDrive drive{[&](double output) { fl.Set(output); },
|
||||
wpi::MockPWMMotorController fl;
|
||||
wpi::MockPWMMotorController rl;
|
||||
wpi::MockPWMMotorController fr;
|
||||
wpi::MockPWMMotorController rr;
|
||||
wpi::MecanumDrive drive{[&](double output) { fl.Set(output); },
|
||||
[&](double output) { rl.Set(output); },
|
||||
[&](double output) { fr.Set(output); },
|
||||
[&](double output) { rr.Set(output); }};
|
||||
@@ -176,11 +176,11 @@ TEST(MecanumDriveTest, CartesianGyro90CW) {
|
||||
}
|
||||
|
||||
TEST(MecanumDriveTest, Polar) {
|
||||
frc::MockPWMMotorController fl;
|
||||
frc::MockPWMMotorController rl;
|
||||
frc::MockPWMMotorController fr;
|
||||
frc::MockPWMMotorController rr;
|
||||
frc::MecanumDrive drive{[&](double output) { fl.Set(output); },
|
||||
wpi::MockPWMMotorController fl;
|
||||
wpi::MockPWMMotorController rl;
|
||||
wpi::MockPWMMotorController fr;
|
||||
wpi::MockPWMMotorController rr;
|
||||
wpi::MecanumDrive drive{[&](double output) { fl.Set(output); },
|
||||
[&](double output) { rl.Set(output); },
|
||||
[&](double output) { fr.Set(output); },
|
||||
[&](double output) { rr.Set(output); }};
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/event/BooleanEvent.hpp"
|
||||
#include "wpi/event/EventLoop.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
TEST(BooleanEventTest, BinaryCompositions) {
|
||||
EventLoop loop;
|
||||
|
||||
@@ -7,18 +7,18 @@
|
||||
#include "wpi/event/EventLoop.hpp"
|
||||
#include "wpi/system/Errors.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
TEST(EventLoopTest, ConcurrentModification) {
|
||||
EventLoop loop;
|
||||
|
||||
loop.Bind([&loop] { ASSERT_THROW(loop.Bind([] {}), frc::RuntimeError); });
|
||||
loop.Bind([&loop] { ASSERT_THROW(loop.Bind([] {}), wpi::RuntimeError); });
|
||||
|
||||
loop.Poll();
|
||||
|
||||
loop.Clear();
|
||||
|
||||
loop.Bind([&loop] { ASSERT_THROW(loop.Clear(), frc::RuntimeError); });
|
||||
loop.Bind([&loop] { ASSERT_THROW(loop.Clear(), wpi::RuntimeError); });
|
||||
|
||||
loop.Poll();
|
||||
}
|
||||
|
||||
@@ -9,20 +9,20 @@
|
||||
#include "wpi/nt/BooleanTopic.hpp"
|
||||
#include "wpi/nt/NetworkTableInstance.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
class NetworkBooleanEventTest : public ::testing::Test {
|
||||
public:
|
||||
NetworkBooleanEventTest() {
|
||||
m_inst = nt::NetworkTableInstance::Create();
|
||||
m_inst = wpi::nt::NetworkTableInstance::Create();
|
||||
m_inst.StartLocal();
|
||||
}
|
||||
|
||||
~NetworkBooleanEventTest() override {
|
||||
nt::NetworkTableInstance::Destroy(m_inst);
|
||||
wpi::nt::NetworkTableInstance::Destroy(m_inst);
|
||||
}
|
||||
|
||||
nt::NetworkTableInstance m_inst;
|
||||
wpi::nt::NetworkTableInstance m_inst;
|
||||
};
|
||||
|
||||
TEST_F(NetworkBooleanEventTest, Set) {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "wpi/hal/HALBase.h"
|
||||
|
||||
#ifndef __FRC_SYSTEMCORE__
|
||||
namespace frc::impl {
|
||||
namespace wpi::impl {
|
||||
void ResetMotorSafety();
|
||||
}
|
||||
#endif
|
||||
@@ -17,7 +17,7 @@ int main(int argc, char** argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
int ret = RUN_ALL_TESTS();
|
||||
#ifndef __FRC_SYSTEMCORE__
|
||||
frc::impl::ResetMotorSafety();
|
||||
wpi::impl::ResetMotorSafety();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "motorcontrol/MockMotorController.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
void MockMotorController::Set(double speed) {
|
||||
m_speed = m_isInverted ? -speed : speed;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "motorcontrol/MockPWMMotorController.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
void MockPWMMotorController::Set(double speed) {
|
||||
m_speed = m_isInverted ? -speed : speed;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "motorcontrol/MockMotorController.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace wpi;
|
||||
|
||||
enum MotorControllerGroupTestType { TEST_ONE, TEST_TWO, TEST_THREE };
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/hal/HAL.h"
|
||||
#include "wpi/hardware/led/AddressableLED.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(AddressableLEDSimTest, InitializationCallback) {
|
||||
HAL_Initialize(500, 0);
|
||||
@@ -120,4 +120,4 @@ TEST(AddressableLEDSimTest, SetData) {
|
||||
EXPECT_EQ(0xFF, simData[2].b);
|
||||
}
|
||||
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
#include "wpi/units/math.hpp"
|
||||
|
||||
#define EXPECT_NEAR_UNITS(val1, val2, eps) \
|
||||
EXPECT_LE(units::math::abs(val1 - val2), eps)
|
||||
EXPECT_LE(wpi::units::math::abs(val1 - val2), eps)
|
||||
|
||||
TEST(AnalogEncoderSimTest, Basic) {
|
||||
frc::AnalogInput ai(0);
|
||||
frc::AnalogEncoder encoder{ai, 360, 0};
|
||||
frc::sim::AnalogEncoderSim encoderSim{encoder};
|
||||
wpi::AnalogInput ai(0);
|
||||
wpi::AnalogEncoder encoder{ai, 360, 0};
|
||||
wpi::sim::AnalogEncoderSim encoderSim{encoder};
|
||||
|
||||
encoderSim.Set(180);
|
||||
EXPECT_NEAR(encoder.Get(), 180, 1E-8);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/hal/HAL.h"
|
||||
#include "wpi/hardware/discrete/AnalogInput.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(AnalogInputSimTest, SetInitialized) {
|
||||
HAL_Initialize(500, 0);
|
||||
@@ -92,4 +92,4 @@ TEST(AnalogInputSimTest, SetAverageBits) {
|
||||
EXPECT_EQ(3504, callback.GetLastValue());
|
||||
}
|
||||
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hardware/pneumatic/DoubleSolenoid.hpp"
|
||||
#include "wpi/hardware/pneumatic/PneumaticsControlModule.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(CTREPCMSimTest, InitializedCallback) {
|
||||
CTREPCMSim sim;
|
||||
@@ -33,7 +33,7 @@ TEST(CTREPCMSimTest, SolenoidOutput) {
|
||||
CTREPCMSim sim(pcm);
|
||||
sim.ResetData();
|
||||
|
||||
DoubleSolenoid doubleSolenoid{0, frc::PneumaticsModuleType::CTREPCM, 3, 4};
|
||||
DoubleSolenoid doubleSolenoid{0, wpi::PneumaticsModuleType::CTREPCM, 3, 4};
|
||||
|
||||
BooleanCallback callback3;
|
||||
BooleanCallback callback4;
|
||||
@@ -147,4 +147,4 @@ TEST(CTREPCMSimTest, SetCompressorCurrent) {
|
||||
EXPECT_TRUE(callback.WasTriggered());
|
||||
EXPECT_EQ(35.04, callback.GetLastValue());
|
||||
}
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
#include "wpi/system/RobotController.hpp"
|
||||
|
||||
TEST(DCMotorSimTest, VoltageSteadyState) {
|
||||
frc::DCMotor gearbox = frc::DCMotor::NEO(1);
|
||||
auto plant = frc::LinearSystemId::DCMotorSystem(
|
||||
frc::DCMotor::NEO(1), units::kilogram_square_meter_t{0.0005}, 1.0);
|
||||
frc::sim::DCMotorSim sim{plant, gearbox};
|
||||
wpi::math::DCMotor gearbox = wpi::math::DCMotor::NEO(1);
|
||||
auto plant = wpi::math::LinearSystemId::DCMotorSystem(
|
||||
wpi::math::DCMotor::NEO(1), wpi::units::kilogram_square_meter_t{0.0005}, 1.0);
|
||||
wpi::sim::DCMotorSim sim{plant, gearbox};
|
||||
|
||||
frc::Encoder encoder{0, 1};
|
||||
frc::sim::EncoderSim encoderSim{encoder};
|
||||
frc::PWMVictorSPX motor{0};
|
||||
wpi::Encoder encoder{0, 1};
|
||||
wpi::sim::EncoderSim encoderSim{encoder};
|
||||
wpi::PWMVictorSPX motor{0};
|
||||
|
||||
frc::sim::RoboRioSim::ResetData();
|
||||
wpi::sim::RoboRioSim::ResetData();
|
||||
encoderSim.ResetData();
|
||||
|
||||
// Spin-up
|
||||
@@ -33,10 +33,10 @@ TEST(DCMotorSimTest, VoltageSteadyState) {
|
||||
motor.SetVoltage(12_V);
|
||||
|
||||
// Then, SimulationPeriodic runs
|
||||
frc::sim::RoboRioSim::SetVInVoltage(
|
||||
frc::sim::BatterySim::Calculate({sim.GetCurrentDraw()}));
|
||||
wpi::sim::RoboRioSim::SetVInVoltage(
|
||||
wpi::sim::BatterySim::Calculate({sim.GetCurrentDraw()}));
|
||||
sim.SetInputVoltage(motor.Get() *
|
||||
frc::RobotController::GetBatteryVoltage());
|
||||
wpi::RobotController::GetBatteryVoltage());
|
||||
sim.Update(20_ms);
|
||||
encoderSim.SetRate(sim.GetAngularVelocity().value());
|
||||
}
|
||||
@@ -49,10 +49,10 @@ TEST(DCMotorSimTest, VoltageSteadyState) {
|
||||
motor.SetVoltage(0_V);
|
||||
|
||||
// Then, SimulationPeriodic runs
|
||||
frc::sim::RoboRioSim::SetVInVoltage(
|
||||
frc::sim::BatterySim::Calculate({sim.GetCurrentDraw()}));
|
||||
wpi::sim::RoboRioSim::SetVInVoltage(
|
||||
wpi::sim::BatterySim::Calculate({sim.GetCurrentDraw()}));
|
||||
sim.SetInputVoltage(motor.Get() *
|
||||
frc::RobotController::GetBatteryVoltage());
|
||||
wpi::RobotController::GetBatteryVoltage());
|
||||
sim.Update(20_ms);
|
||||
encoderSim.SetRate(sim.GetAngularVelocity().value());
|
||||
}
|
||||
@@ -61,18 +61,18 @@ TEST(DCMotorSimTest, VoltageSteadyState) {
|
||||
}
|
||||
|
||||
TEST(DCMotorSimTest, PositionFeedbackControl) {
|
||||
frc::DCMotor gearbox = frc::DCMotor::NEO(1);
|
||||
auto plant = frc::LinearSystemId::DCMotorSystem(
|
||||
frc::DCMotor::NEO(1), units::kilogram_square_meter_t{0.0005}, 1.0);
|
||||
frc::sim::DCMotorSim sim{plant, gearbox};
|
||||
wpi::math::DCMotor gearbox = wpi::math::DCMotor::NEO(1);
|
||||
auto plant = wpi::math::LinearSystemId::DCMotorSystem(
|
||||
wpi::math::DCMotor::NEO(1), wpi::units::kilogram_square_meter_t{0.0005}, 1.0);
|
||||
wpi::sim::DCMotorSim sim{plant, gearbox};
|
||||
|
||||
frc::PIDController controller{0.04, 0.0, 0.001};
|
||||
wpi::math::PIDController controller{0.04, 0.0, 0.001};
|
||||
|
||||
frc::Encoder encoder{0, 1};
|
||||
frc::sim::EncoderSim encoderSim{encoder};
|
||||
frc::PWMVictorSPX motor{0};
|
||||
wpi::Encoder encoder{0, 1};
|
||||
wpi::sim::EncoderSim encoderSim{encoder};
|
||||
wpi::PWMVictorSPX motor{0};
|
||||
|
||||
frc::sim::RoboRioSim::ResetData();
|
||||
wpi::sim::RoboRioSim::ResetData();
|
||||
encoderSim.ResetData();
|
||||
|
||||
for (int i = 0; i < 140; i++) {
|
||||
@@ -80,10 +80,10 @@ TEST(DCMotorSimTest, PositionFeedbackControl) {
|
||||
motor.Set(controller.Calculate(encoder.GetDistance(), 750));
|
||||
|
||||
// Then, SimulationPeriodic runs
|
||||
frc::sim::RoboRioSim::SetVInVoltage(
|
||||
frc::sim::BatterySim::Calculate({sim.GetCurrentDraw()}));
|
||||
wpi::sim::RoboRioSim::SetVInVoltage(
|
||||
wpi::sim::BatterySim::Calculate({sim.GetCurrentDraw()}));
|
||||
sim.SetInputVoltage(motor.Get() *
|
||||
frc::RobotController::GetBatteryVoltage());
|
||||
wpi::RobotController::GetBatteryVoltage());
|
||||
sim.Update(20_ms);
|
||||
encoderSim.SetDistance(sim.GetAngularPosition().value());
|
||||
encoderSim.SetRate(sim.GetAngularVelocity().value());
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hardware/discrete/DigitalInput.hpp"
|
||||
#include "wpi/hardware/discrete/DigitalOutput.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(DIOSimTest, Initialization) {
|
||||
HAL_Initialize(500, 0);
|
||||
@@ -77,4 +77,4 @@ TEST(DIOSimTest, Output) {
|
||||
EXPECT_TRUE(valueCallback.WasTriggered());
|
||||
EXPECT_FALSE(valueCallback.GetLastValue());
|
||||
}
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -18,29 +18,29 @@
|
||||
#include "wpi/units/moment_of_inertia.hpp"
|
||||
|
||||
TEST(DifferentialDrivetrainSimTest, Convergence) {
|
||||
auto motor = frc::DCMotor::NEO(2);
|
||||
auto plant = frc::LinearSystemId::DrivetrainVelocitySystem(
|
||||
auto motor = wpi::math::DCMotor::NEO(2);
|
||||
auto plant = wpi::math::LinearSystemId::DrivetrainVelocitySystem(
|
||||
motor, 50_kg, 2_in, 12_in, 0.5_kg_sq_m, 1.0);
|
||||
|
||||
frc::DifferentialDriveKinematics kinematics{24_in};
|
||||
frc::sim::DifferentialDrivetrainSim sim{
|
||||
wpi::math::DifferentialDriveKinematics kinematics{24_in};
|
||||
wpi::sim::DifferentialDrivetrainSim sim{
|
||||
plant, 24_in, motor,
|
||||
1.0, 2_in, {0.001, 0.001, 0.0001, 0.1, 0.1, 0.005, 0.005}};
|
||||
|
||||
frc::LinearPlantInversionFeedforward feedforward{plant, 20_ms};
|
||||
frc::LTVUnicycleController feedback{20_ms};
|
||||
wpi::math::LinearPlantInversionFeedforward feedforward{plant, 20_ms};
|
||||
wpi::math::LTVUnicycleController feedback{20_ms};
|
||||
|
||||
feedforward.Reset(frc::Vectord<2>{0.0, 0.0});
|
||||
feedforward.Reset(wpi::math::Vectord<2>{0.0, 0.0});
|
||||
|
||||
// Ground truth.
|
||||
frc::Vectord<7> groundTruthX = frc::Vectord<7>::Zero();
|
||||
wpi::math::Vectord<7> groundTruthX = wpi::math::Vectord<7>::Zero();
|
||||
|
||||
frc::TrajectoryConfig config{1_mps, 1_mps_sq};
|
||||
wpi::math::TrajectoryConfig config{1_mps, 1_mps_sq};
|
||||
config.AddConstraint(
|
||||
frc::DifferentialDriveKinematicsConstraint(kinematics, 1_mps));
|
||||
wpi::math::DifferentialDriveKinematicsConstraint(kinematics, 1_mps));
|
||||
|
||||
auto trajectory = frc::TrajectoryGenerator::GenerateTrajectory(
|
||||
frc::Pose2d{}, {}, frc::Pose2d{2_m, 2_m, 0_rad}, config);
|
||||
auto trajectory = wpi::math::TrajectoryGenerator::GenerateTrajectory(
|
||||
wpi::math::Pose2d{}, {}, wpi::math::Pose2d{2_m, 2_m, 0_rad}, config);
|
||||
|
||||
for (auto t = 0_s; t < trajectory.TotalTime(); t += 20_ms) {
|
||||
auto state = trajectory.Sample(t);
|
||||
@@ -48,34 +48,34 @@ TEST(DifferentialDrivetrainSimTest, Convergence) {
|
||||
|
||||
auto [l, r] = kinematics.ToWheelSpeeds(feedbackOut);
|
||||
auto voltages =
|
||||
feedforward.Calculate(frc::Vectord<2>{l.value(), r.value()});
|
||||
feedforward.Calculate(wpi::math::Vectord<2>{l.value(), r.value()});
|
||||
|
||||
// Sim periodic code.
|
||||
sim.SetInputs(units::volt_t{voltages(0, 0)}, units::volt_t{voltages(1, 0)});
|
||||
sim.SetInputs(wpi::units::volt_t{voltages(0, 0)}, wpi::units::volt_t{voltages(1, 0)});
|
||||
sim.Update(20_ms);
|
||||
|
||||
// Update ground truth.
|
||||
groundTruthX = frc::RKDP(
|
||||
[&sim](const auto& x, const auto& u) -> frc::Vectord<7> {
|
||||
groundTruthX = wpi::math::RKDP(
|
||||
[&sim](const auto& x, const auto& u) -> wpi::math::Vectord<7> {
|
||||
return sim.Dynamics(x, u);
|
||||
},
|
||||
groundTruthX, voltages, 20_ms);
|
||||
}
|
||||
|
||||
// 2 inch tolerance is OK since our ground truth is an approximation of the
|
||||
// ODE solution using RKDP anyway
|
||||
// ODE solution using wpi::math::RKDP anyway
|
||||
EXPECT_NEAR(groundTruthX(0, 0), sim.GetPose().X().value(), 0.05);
|
||||
EXPECT_NEAR(groundTruthX(1, 0), sim.GetPose().Y().value(), 0.05);
|
||||
EXPECT_NEAR(groundTruthX(2, 0), sim.GetHeading().Radians().value(), 0.01);
|
||||
}
|
||||
|
||||
TEST(DifferentialDrivetrainSimTest, Current) {
|
||||
auto motor = frc::DCMotor::NEO(2);
|
||||
auto plant = frc::LinearSystemId::DrivetrainVelocitySystem(
|
||||
auto motor = wpi::math::DCMotor::NEO(2);
|
||||
auto plant = wpi::math::LinearSystemId::DrivetrainVelocitySystem(
|
||||
motor, 50_kg, 2_in, 12_in, 0.5_kg_sq_m, 1.0);
|
||||
|
||||
frc::DifferentialDriveKinematics kinematics{24_in};
|
||||
frc::sim::DifferentialDrivetrainSim sim{plant, 24_in, motor, 1.0, 2_in};
|
||||
wpi::math::DifferentialDriveKinematics kinematics{24_in};
|
||||
wpi::sim::DifferentialDrivetrainSim sim{plant, 24_in, motor, 1.0, 2_in};
|
||||
|
||||
sim.SetInputs(-12_V, 12_V);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
@@ -97,12 +97,12 @@ TEST(DifferentialDrivetrainSimTest, Current) {
|
||||
}
|
||||
|
||||
TEST(DifferentialDrivetrainSimTest, ModelStability) {
|
||||
auto motor = frc::DCMotor::NEO(2);
|
||||
auto plant = frc::LinearSystemId::DrivetrainVelocitySystem(
|
||||
auto motor = wpi::math::DCMotor::NEO(2);
|
||||
auto plant = wpi::math::LinearSystemId::DrivetrainVelocitySystem(
|
||||
motor, 50_kg, 2_in, 12_in, 2_kg_sq_m, 5.0);
|
||||
|
||||
frc::DifferentialDriveKinematics kinematics{24_in};
|
||||
frc::sim::DifferentialDrivetrainSim sim{plant, 24_in, motor, 1.0, 2_in};
|
||||
wpi::math::DifferentialDriveKinematics kinematics{24_in};
|
||||
wpi::sim::DifferentialDrivetrainSim sim{plant, 24_in, motor, 1.0, 2_in};
|
||||
|
||||
sim.SetInputs(2_V, 4_V);
|
||||
|
||||
@@ -111,5 +111,5 @@ TEST(DifferentialDrivetrainSimTest, ModelStability) {
|
||||
sim.Update(20_ms);
|
||||
}
|
||||
|
||||
EXPECT_LT(units::math::abs(sim.GetPose().Translation().Norm()), 100_m);
|
||||
EXPECT_LT(wpi::units::math::abs(sim.GetPose().Translation().Norm()), 100_m);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/hal/HAL.h"
|
||||
#include "wpi/hardware/discrete/DigitalOutput.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(DigitalPWMSimTest, Initialize) {
|
||||
HAL_Initialize(500, 0);
|
||||
@@ -54,4 +54,4 @@ TEST(DigitalPWMSimTest, SetPin) {
|
||||
EXPECT_EQ(191, callback.GetLastValue());
|
||||
}
|
||||
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#include "wpi/simulation/DriverStationSim.hpp"
|
||||
#include "wpi/simulation/SimHooks.hpp"
|
||||
|
||||
using namespace frc;
|
||||
using namespace frc::sim;
|
||||
using namespace wpi;
|
||||
using namespace wpi::sim;
|
||||
|
||||
TEST(DriverStationTest, Enabled) {
|
||||
HAL_Initialize(500, 0);
|
||||
@@ -138,7 +138,7 @@ TEST(DriverStationTest, AllianceStationId) {
|
||||
// Unknown
|
||||
allianceStation = HAL_AllianceStationID_kUnknown;
|
||||
DriverStationSim::SetAllianceStationId(allianceStation);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId());
|
||||
EXPECT_FALSE(DriverStation::GetAlliance().has_value());
|
||||
EXPECT_FALSE(DriverStation::GetLocation().has_value());
|
||||
@@ -148,7 +148,7 @@ TEST(DriverStationTest, AllianceStationId) {
|
||||
// B1
|
||||
allianceStation = HAL_AllianceStationID_kBlue1;
|
||||
DriverStationSim::SetAllianceStationId(allianceStation);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId());
|
||||
EXPECT_EQ(DriverStation::kBlue, DriverStation::GetAlliance());
|
||||
EXPECT_EQ(1, DriverStation::GetLocation());
|
||||
@@ -158,7 +158,7 @@ TEST(DriverStationTest, AllianceStationId) {
|
||||
// B2
|
||||
allianceStation = HAL_AllianceStationID_kBlue2;
|
||||
DriverStationSim::SetAllianceStationId(allianceStation);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId());
|
||||
EXPECT_EQ(DriverStation::kBlue, DriverStation::GetAlliance());
|
||||
EXPECT_EQ(2, DriverStation::GetLocation());
|
||||
@@ -168,7 +168,7 @@ TEST(DriverStationTest, AllianceStationId) {
|
||||
// B3
|
||||
allianceStation = HAL_AllianceStationID_kBlue3;
|
||||
DriverStationSim::SetAllianceStationId(allianceStation);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId());
|
||||
EXPECT_EQ(DriverStation::kBlue, DriverStation::GetAlliance());
|
||||
EXPECT_EQ(3, DriverStation::GetLocation());
|
||||
@@ -178,7 +178,7 @@ TEST(DriverStationTest, AllianceStationId) {
|
||||
// R1
|
||||
allianceStation = HAL_AllianceStationID_kRed1;
|
||||
DriverStationSim::SetAllianceStationId(allianceStation);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId());
|
||||
EXPECT_EQ(DriverStation::kRed, DriverStation::GetAlliance());
|
||||
EXPECT_EQ(1, DriverStation::GetLocation());
|
||||
@@ -188,7 +188,7 @@ TEST(DriverStationTest, AllianceStationId) {
|
||||
// R2
|
||||
allianceStation = HAL_AllianceStationID_kRed2;
|
||||
DriverStationSim::SetAllianceStationId(allianceStation);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId());
|
||||
EXPECT_EQ(DriverStation::kRed, DriverStation::GetAlliance());
|
||||
EXPECT_EQ(2, DriverStation::GetLocation());
|
||||
@@ -198,7 +198,7 @@ TEST(DriverStationTest, AllianceStationId) {
|
||||
// R3
|
||||
allianceStation = HAL_AllianceStationID_kRed3;
|
||||
DriverStationSim::SetAllianceStationId(allianceStation);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
EXPECT_EQ(allianceStation, DriverStationSim::GetAllianceStationId());
|
||||
EXPECT_EQ(DriverStation::kRed, DriverStation::GetAlliance());
|
||||
EXPECT_EQ(3, DriverStation::GetLocation());
|
||||
@@ -233,7 +233,7 @@ TEST(DriverStationTest, MatchTime) {
|
||||
false);
|
||||
constexpr double kTestTime = 19.174;
|
||||
DriverStationSim::SetMatchTime(kTestTime);
|
||||
frc::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
EXPECT_EQ(kTestTime, DriverStationSim::GetMatchTime());
|
||||
EXPECT_EQ(kTestTime, DriverStation::GetMatchTime().value());
|
||||
EXPECT_TRUE(callback.WasTriggered());
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/hal/HAL.h"
|
||||
#include "wpi/hardware/rotation/DutyCycleEncoder.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(DutyCycleEncoderSimTest, Set) {
|
||||
HAL_Initialize(500, 0);
|
||||
@@ -34,4 +34,4 @@ TEST(DutyCycleEncoderSimTest, SetIsConnected) {
|
||||
EXPECT_FALSE(enc.IsConnected());
|
||||
}
|
||||
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hardware/discrete/DigitalInput.hpp"
|
||||
#include "wpi/hardware/rotation/DutyCycle.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(DutyCycleSimTest, Initialization) {
|
||||
HAL_Initialize(500, 0);
|
||||
@@ -64,4 +64,4 @@ TEST(DutyCycleSimTest, SetOutput) {
|
||||
EXPECT_EQ(229.174, callback.GetLastValue());
|
||||
}
|
||||
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -17,23 +17,23 @@
|
||||
#include "wpi/units/time.hpp"
|
||||
|
||||
#define EXPECT_NEAR_UNITS(val1, val2, eps) \
|
||||
EXPECT_LE(units::math::abs(val1 - val2), eps)
|
||||
EXPECT_LE(wpi::units::math::abs(val1 - val2), eps)
|
||||
|
||||
TEST(ElevatorSimTest, StateSpaceSim) {
|
||||
frc::sim::ElevatorSim sim(frc::DCMotor::Vex775Pro(4), 14.67, 8_kg, 0.75_in,
|
||||
wpi::sim::ElevatorSim sim(wpi::math::DCMotor::Vex775Pro(4), 14.67, 8_kg, 0.75_in,
|
||||
0_m, 3_m, true, 0_m, {0.01});
|
||||
frc::PIDController controller(10, 0.0, 0.0);
|
||||
wpi::math::PIDController controller(10, 0.0, 0.0);
|
||||
|
||||
frc::PWMVictorSPX motor(0);
|
||||
frc::Encoder encoder(0, 1);
|
||||
frc::sim::EncoderSim encoderSim(encoder);
|
||||
wpi::PWMVictorSPX motor(0);
|
||||
wpi::Encoder encoder(0, 1);
|
||||
wpi::sim::EncoderSim encoderSim(encoder);
|
||||
|
||||
for (size_t i = 0; i < 100; ++i) {
|
||||
controller.SetSetpoint(2.0);
|
||||
auto nextVoltage = controller.Calculate(encoderSim.GetDistance());
|
||||
motor.Set(nextVoltage / frc::RobotController::GetInputVoltage());
|
||||
motor.Set(nextVoltage / wpi::RobotController::GetInputVoltage());
|
||||
|
||||
frc::Vectord<1> u{motor.Get() * frc::RobotController::GetInputVoltage()};
|
||||
wpi::math::Vectord<1> u{motor.Get() * wpi::RobotController::GetInputVoltage()};
|
||||
sim.SetInput(u);
|
||||
sim.Update(20_ms);
|
||||
|
||||
@@ -46,7 +46,7 @@ TEST(ElevatorSimTest, StateSpaceSim) {
|
||||
|
||||
TEST(ElevatorSimTest, InitialState) {
|
||||
constexpr auto startingHeight = 0.5_m;
|
||||
frc::sim::ElevatorSim sim(frc::DCMotor::KrakenX60(2), 20, 8_kg, 0.1_m, 0_m,
|
||||
wpi::sim::ElevatorSim sim(wpi::math::DCMotor::KrakenX60(2), 20, 8_kg, 0.1_m, 0_m,
|
||||
1_m, true, startingHeight, {0.01, 0.0});
|
||||
|
||||
EXPECT_DOUBLE_EQ(startingHeight.value(), sim.GetPosition().value());
|
||||
@@ -54,10 +54,10 @@ TEST(ElevatorSimTest, InitialState) {
|
||||
}
|
||||
|
||||
TEST(ElevatorSimTest, MinMax) {
|
||||
frc::sim::ElevatorSim sim(frc::DCMotor::Vex775Pro(4), 14.67, 8_kg, 0.75_in,
|
||||
wpi::sim::ElevatorSim sim(wpi::math::DCMotor::Vex775Pro(4), 14.67, 8_kg, 0.75_in,
|
||||
0_m, 1_m, true, 0_m, {0.01});
|
||||
for (size_t i = 0; i < 100; ++i) {
|
||||
sim.SetInput(frc::Vectord<1>{0.0});
|
||||
sim.SetInput(wpi::math::Vectord<1>{0.0});
|
||||
sim.Update(20_ms);
|
||||
|
||||
auto height = sim.GetPosition();
|
||||
@@ -65,7 +65,7 @@ TEST(ElevatorSimTest, MinMax) {
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < 100; ++i) {
|
||||
sim.SetInput(frc::Vectord<1>{12.0});
|
||||
sim.SetInput(wpi::math::Vectord<1>{12.0});
|
||||
sim.Update(20_ms);
|
||||
|
||||
auto height = sim.GetPosition();
|
||||
@@ -74,21 +74,21 @@ TEST(ElevatorSimTest, MinMax) {
|
||||
}
|
||||
|
||||
TEST(ElevatorSimTest, Stability) {
|
||||
frc::sim::ElevatorSim sim{
|
||||
frc::DCMotor::Vex775Pro(4), 100, 4_kg, 0.5_in, 0_m, 10_m, false, 0_m};
|
||||
wpi::sim::ElevatorSim sim{
|
||||
wpi::math::DCMotor::Vex775Pro(4), 100, 4_kg, 0.5_in, 0_m, 10_m, false, 0_m};
|
||||
|
||||
sim.SetState(frc::Vectord<2>{0.0, 0.0});
|
||||
sim.SetInput(frc::Vectord<1>{12.0});
|
||||
sim.SetState(wpi::math::Vectord<2>{0.0, 0.0});
|
||||
sim.SetInput(wpi::math::Vectord<1>{12.0});
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
sim.Update(20_ms);
|
||||
}
|
||||
|
||||
frc::LinearSystem<2, 1, 1> system =
|
||||
frc::LinearSystemId::ElevatorSystem(frc::DCMotor::Vex775Pro(4), 4_kg,
|
||||
wpi::math::LinearSystem<2, 1, 1> system =
|
||||
wpi::math::LinearSystemId::ElevatorSystem(wpi::math::DCMotor::Vex775Pro(4), 4_kg,
|
||||
0.5_in, 100)
|
||||
.Slice(0);
|
||||
EXPECT_NEAR_UNITS(
|
||||
units::meter_t{system.CalculateX(frc::Vectord<2>{0.0, 0.0},
|
||||
frc::Vectord<1>{12.0}, 20_ms * 50)(0)},
|
||||
wpi::units::meter_t{system.CalculateX(wpi::math::Vectord<2>{0.0, 0.0},
|
||||
wpi::math::Vectord<1>{12.0}, 20_ms * 50)(0)},
|
||||
sim.GetPosition(), 1_cm);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hardware/rotation/Encoder.hpp"
|
||||
#include "wpi/util/deprecated.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
namespace {
|
||||
constexpr double kDefaultDistancePerPulse = .0005;
|
||||
@@ -232,4 +232,4 @@ TEST(EncoderSimTest, Reset) {
|
||||
EXPECT_EQ(0, encoder.GetDistance());
|
||||
}
|
||||
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/hal/HAL.h"
|
||||
#include "wpi/hardware/power/PowerDistribution.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(PowerDistributionSimTest, Initialize) {
|
||||
HAL_Initialize(500, 0);
|
||||
@@ -22,7 +22,7 @@ TEST(PowerDistributionSimTest, Initialize) {
|
||||
BooleanCallback callback;
|
||||
|
||||
auto cb = sim.RegisterInitializedCallback(callback.GetCallback(), false);
|
||||
PowerDistribution pdp(0, 2, frc::PowerDistribution::ModuleType::kCTRE);
|
||||
PowerDistribution pdp(0, 2, wpi::PowerDistribution::ModuleType::kCTRE);
|
||||
EXPECT_TRUE(sim.GetInitialized());
|
||||
EXPECT_TRUE(callback.WasTriggered());
|
||||
EXPECT_TRUE(callback.GetLastValue());
|
||||
@@ -35,7 +35,7 @@ TEST(PowerDistributionSimTest, Initialize) {
|
||||
|
||||
TEST(PowerDistributionSimTest, SetTemperature) {
|
||||
HAL_Initialize(500, 0);
|
||||
PowerDistribution pdp{0, 2, frc::PowerDistribution::ModuleType::kCTRE};
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::kCTRE};
|
||||
PowerDistributionSim sim(pdp);
|
||||
|
||||
DoubleCallback callback;
|
||||
@@ -50,7 +50,7 @@ TEST(PowerDistributionSimTest, SetTemperature) {
|
||||
|
||||
TEST(PowerDistributionSimTest, SetVoltage) {
|
||||
HAL_Initialize(500, 0);
|
||||
PowerDistribution pdp{0, 2, frc::PowerDistribution::ModuleType::kCTRE};
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::kCTRE};
|
||||
PowerDistributionSim sim(pdp);
|
||||
|
||||
DoubleCallback callback;
|
||||
@@ -65,7 +65,7 @@ TEST(PowerDistributionSimTest, SetVoltage) {
|
||||
|
||||
TEST(PowerDistributionSimTest, SetCurrent) {
|
||||
HAL_Initialize(500, 0);
|
||||
PowerDistribution pdp{0, 2, frc::PowerDistribution::ModuleType::kCTRE};
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::kCTRE};
|
||||
PowerDistributionSim sim(pdp);
|
||||
|
||||
for (int channel = 0; channel < HAL_GetNumCTREPDPChannels(); ++channel) {
|
||||
@@ -84,7 +84,7 @@ TEST(PowerDistributionSimTest, SetCurrent) {
|
||||
|
||||
TEST(PowerDistributionSimTest, GetAllCurrents) {
|
||||
HAL_Initialize(500, 0);
|
||||
PowerDistribution pdp{0, 2, frc::PowerDistribution::ModuleType::kRev};
|
||||
PowerDistribution pdp{0, 2, wpi::PowerDistribution::ModuleType::kRev};
|
||||
PowerDistributionSim sim(pdp);
|
||||
|
||||
// setup
|
||||
@@ -103,4 +103,4 @@ TEST(PowerDistributionSimTest, GetAllCurrents) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
#include "wpi/hal/HAL.h"
|
||||
#include "wpi/hardware/motor/Spark.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
TEST(PWMMotorControllerSimTest, TestMotor) {
|
||||
frc::Spark spark{0};
|
||||
frc::sim::PWMMotorControllerSim sim{spark};
|
||||
wpi::Spark spark{0};
|
||||
wpi::sim::PWMMotorControllerSim sim{spark};
|
||||
|
||||
spark.Set(0);
|
||||
EXPECT_EQ(0, sim.GetSpeed());
|
||||
@@ -23,4 +23,4 @@ TEST(PWMMotorControllerSimTest, TestMotor) {
|
||||
spark.Set(-0.785);
|
||||
EXPECT_EQ(-0.785, sim.GetSpeed());
|
||||
}
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/hal/HAL.h"
|
||||
#include "wpi/hardware/discrete/PWM.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(PWMSimTest, Initialize) {
|
||||
HAL_Initialize(500, 0);
|
||||
@@ -61,4 +61,4 @@ TEST(PWMSimTest, SetOutputPeriod) {
|
||||
EXPECT_EQ(3504, callback.GetLastValue());
|
||||
}
|
||||
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/hardware/pneumatic/DoubleSolenoid.hpp"
|
||||
#include "wpi/hardware/pneumatic/PneumaticHub.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(REVPHSimTest, InitializedCallback) {
|
||||
REVPHSim sim;
|
||||
@@ -33,7 +33,7 @@ TEST(REVPHSimTest, SolenoidOutput) {
|
||||
REVPHSim sim(ph);
|
||||
sim.ResetData();
|
||||
|
||||
DoubleSolenoid doubleSolenoid{0, 1, frc::PneumaticsModuleType::REVPH, 3, 4};
|
||||
DoubleSolenoid doubleSolenoid{0, 1, wpi::PneumaticsModuleType::REVPH, 3, 4};
|
||||
|
||||
BooleanCallback callback3;
|
||||
BooleanCallback callback4;
|
||||
@@ -191,4 +191,4 @@ TEST(REVPHSimTest, SetCompressorCurrent) {
|
||||
EXPECT_TRUE(callback.WasTriggered());
|
||||
EXPECT_EQ(35.04, callback.GetLastValue());
|
||||
}
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/hal/HALBase.h"
|
||||
#include "wpi/system/RobotController.hpp"
|
||||
|
||||
namespace frc::sim {
|
||||
namespace wpi::sim {
|
||||
|
||||
TEST(RoboRioSimTest, SetVin) {
|
||||
RoboRioSim::ResetData();
|
||||
@@ -23,7 +23,7 @@ TEST(RoboRioSimTest, SetVin) {
|
||||
voltageCallback.GetCallback(), false);
|
||||
constexpr double kTestVoltage = 1.91;
|
||||
|
||||
RoboRioSim::SetVInVoltage(units::volt_t{kTestVoltage});
|
||||
RoboRioSim::SetVInVoltage(wpi::units::volt_t{kTestVoltage});
|
||||
EXPECT_TRUE(voltageCallback.WasTriggered());
|
||||
EXPECT_EQ(kTestVoltage, voltageCallback.GetLastValue());
|
||||
EXPECT_EQ(kTestVoltage, RoboRioSim::GetVInVoltage().value());
|
||||
@@ -38,7 +38,7 @@ TEST(RoboRioSimTest, SetBrownout) {
|
||||
voltageCallback.GetCallback(), false);
|
||||
constexpr double kTestVoltage = 1.91;
|
||||
|
||||
RoboRioSim::SetBrownoutVoltage(units::volt_t{kTestVoltage});
|
||||
RoboRioSim::SetBrownoutVoltage(wpi::units::volt_t{kTestVoltage});
|
||||
EXPECT_TRUE(voltageCallback.WasTriggered());
|
||||
EXPECT_EQ(kTestVoltage, voltageCallback.GetLastValue());
|
||||
EXPECT_EQ(kTestVoltage, RoboRioSim::GetBrownoutVoltage().value());
|
||||
@@ -64,13 +64,13 @@ TEST(RoboRioSimTest, Set3V3) {
|
||||
constexpr double kTestCurrent = 174;
|
||||
constexpr int kTestFaults = 229;
|
||||
|
||||
RoboRioSim::SetUserVoltage3V3(units::volt_t{kTestVoltage});
|
||||
RoboRioSim::SetUserVoltage3V3(wpi::units::volt_t{kTestVoltage});
|
||||
EXPECT_TRUE(voltageCallback.WasTriggered());
|
||||
EXPECT_EQ(kTestVoltage, voltageCallback.GetLastValue());
|
||||
EXPECT_EQ(kTestVoltage, RoboRioSim::GetUserVoltage3V3().value());
|
||||
EXPECT_EQ(kTestVoltage, RobotController::GetVoltage3V3());
|
||||
|
||||
RoboRioSim::SetUserCurrent3V3(units::ampere_t{kTestCurrent});
|
||||
RoboRioSim::SetUserCurrent3V3(wpi::units::ampere_t{kTestCurrent});
|
||||
EXPECT_TRUE(currentCallback.WasTriggered());
|
||||
EXPECT_EQ(kTestCurrent, currentCallback.GetLastValue());
|
||||
EXPECT_EQ(kTestCurrent, RoboRioSim::GetUserCurrent3V3().value());
|
||||
@@ -97,7 +97,7 @@ TEST(RoboRioSimTest, SetCPUTemp) {
|
||||
RoboRioSim::RegisterCPUTempCallback(callback.GetCallback(), false);
|
||||
constexpr double kCPUTemp = 100.0;
|
||||
|
||||
RoboRioSim::SetCPUTemp(units::celsius_t{kCPUTemp});
|
||||
RoboRioSim::SetCPUTemp(wpi::units::celsius_t{kCPUTemp});
|
||||
EXPECT_TRUE(callback.WasTriggered());
|
||||
EXPECT_EQ(kCPUTemp, callback.GetLastValue());
|
||||
EXPECT_EQ(kCPUTemp, RoboRioSim::GetCPUTemp().value());
|
||||
@@ -156,4 +156,4 @@ TEST(RoboRioSimTest, SetComments) {
|
||||
EXPECT_EQ(kCommentsTruncated, RobotController::GetComments());
|
||||
}
|
||||
|
||||
} // namespace frc::sim
|
||||
} // namespace wpi::sim
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
#include "wpi/hal/SimDevice.h"
|
||||
#include "wpi/simulation/SimDeviceSim.hpp"
|
||||
|
||||
using namespace frc::sim;
|
||||
using namespace wpi::sim;
|
||||
|
||||
TEST(SimDeviceSimTest, Basic) {
|
||||
hal::SimDevice dev{"test"};
|
||||
hal::SimBoolean devBool = dev.CreateBoolean("bool", false, false);
|
||||
wpi::hal::SimDevice dev{"test"};
|
||||
wpi::hal::SimBoolean devBool = dev.CreateBoolean("bool", false, false);
|
||||
|
||||
SimDeviceSim sim{"test"};
|
||||
hal::SimBoolean simBool = sim.GetBoolean("bool");
|
||||
wpi::hal::SimBoolean simBool = sim.GetBoolean("bool");
|
||||
EXPECT_FALSE(simBool.Get());
|
||||
simBool.Set(true);
|
||||
EXPECT_TRUE(devBool.Get());
|
||||
@@ -25,7 +25,7 @@ TEST(SimDeviceSimTest, Basic) {
|
||||
}
|
||||
|
||||
TEST(SimDeviceSimTest, EnumerateDevices) {
|
||||
hal::SimDevice dev{"test"};
|
||||
wpi::hal::SimDevice dev{"test"};
|
||||
|
||||
bool foundit = false;
|
||||
SimDeviceSim::EnumerateDevices(
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "wpi/simulation/PowerDistributionSim.hpp"
|
||||
#include "wpi/simulation/RoboRioSim.hpp"
|
||||
|
||||
using namespace frc::sim;
|
||||
using namespace wpi::sim;
|
||||
|
||||
TEST(SimInitializationTest, AllInitialize) {
|
||||
HAL_Initialize(500, 0);
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#include "wpi/simulation/SingleJointedArmSim.hpp"
|
||||
|
||||
TEST(SingleJointedArmTest, Disabled) {
|
||||
frc::sim::SingleJointedArmSim sim(frc::DCMotor::Vex775Pro(2), 300, 3_kg_sq_m,
|
||||
wpi::sim::SingleJointedArmSim sim(wpi::math::DCMotor::Vex775Pro(2), 300, 3_kg_sq_m,
|
||||
30_in, -180_deg, 0_deg, true, 90_deg);
|
||||
sim.SetState(frc::Vectord<2>{0.0, 0.0});
|
||||
sim.SetState(wpi::math::Vectord<2>{0.0, 0.0});
|
||||
|
||||
for (size_t i = 0; i < 12 / 0.02; ++i) {
|
||||
sim.SetInput(frc::Vectord<1>{0.0});
|
||||
sim.SetInput(wpi::math::Vectord<1>{0.0});
|
||||
sim.Update(20_ms);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ TEST(SingleJointedArmTest, Disabled) {
|
||||
|
||||
TEST(SingleJointedArmTest, InitialState) {
|
||||
constexpr auto startingAngle = 45_deg;
|
||||
frc::sim::SingleJointedArmSim sim(frc::DCMotor::KrakenX60(2), 125, 3_kg_sq_m,
|
||||
wpi::sim::SingleJointedArmSim sim(wpi::math::DCMotor::KrakenX60(2), 125, 3_kg_sq_m,
|
||||
30_in, 0_deg, 90_deg, true, startingAngle);
|
||||
|
||||
EXPECT_EQ(startingAngle, sim.GetAngle());
|
||||
|
||||
@@ -22,31 +22,31 @@
|
||||
#include "wpi/units/angular_velocity.hpp"
|
||||
|
||||
TEST(StateSpaceSimTest, FlywheelSim) {
|
||||
const frc::LinearSystem<1, 1, 1> plant =
|
||||
frc::LinearSystemId::IdentifyVelocitySystem<units::radian>(
|
||||
const wpi::math::LinearSystem<1, 1, 1> plant =
|
||||
wpi::math::LinearSystemId::IdentifyVelocitySystem<wpi::units::radian>(
|
||||
0.02_V / 1_rad_per_s, 0.01_V / 1_rad_per_s_sq);
|
||||
frc::sim::FlywheelSim sim{plant, frc::DCMotor::NEO(2)};
|
||||
frc::PIDController controller{0.2, 0.0, 0.0};
|
||||
frc::SimpleMotorFeedforward<units::radian> feedforward{
|
||||
wpi::sim::FlywheelSim sim{plant, wpi::math::DCMotor::NEO(2)};
|
||||
wpi::math::PIDController controller{0.2, 0.0, 0.0};
|
||||
wpi::math::SimpleMotorFeedforward<wpi::units::radian> feedforward{
|
||||
0_V, 0.02_V / 1_rad_per_s, 0.01_V / 1_rad_per_s_sq};
|
||||
frc::Encoder encoder{0, 1};
|
||||
frc::sim::EncoderSim encoderSim{encoder};
|
||||
frc::PWMVictorSPX motor{0};
|
||||
wpi::Encoder encoder{0, 1};
|
||||
wpi::sim::EncoderSim encoderSim{encoder};
|
||||
wpi::PWMVictorSPX motor{0};
|
||||
|
||||
frc::sim::RoboRioSim::ResetData();
|
||||
wpi::sim::RoboRioSim::ResetData();
|
||||
encoderSim.ResetData();
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
// RobotPeriodic runs first
|
||||
auto voltageOut = controller.Calculate(encoder.GetRate(), 200.0);
|
||||
motor.SetVoltage(units::volt_t{voltageOut} +
|
||||
motor.SetVoltage(wpi::units::volt_t{voltageOut} +
|
||||
feedforward.Calculate(200_rad_per_s));
|
||||
|
||||
// Then, SimulationPeriodic runs
|
||||
frc::sim::RoboRioSim::SetVInVoltage(
|
||||
frc::sim::BatterySim::Calculate({sim.GetCurrentDraw()}));
|
||||
wpi::sim::RoboRioSim::SetVInVoltage(
|
||||
wpi::sim::BatterySim::Calculate({sim.GetCurrentDraw()}));
|
||||
sim.SetInput(
|
||||
frc::Vectord<1>{motor.Get() * frc::RobotController::GetInputVoltage()});
|
||||
wpi::math::Vectord<1>{motor.Get() * wpi::RobotController::GetInputVoltage()});
|
||||
sim.Update(20_ms);
|
||||
encoderSim.SetRate(sim.GetAngularVelocity().value());
|
||||
}
|
||||
|
||||
@@ -14,61 +14,61 @@
|
||||
class Mechanism2dTest;
|
||||
|
||||
TEST(Mechanism2dTest, Canvas) {
|
||||
frc::Mechanism2d mechanism{5, 10};
|
||||
auto dimsEntry = nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
wpi::Mechanism2d mechanism{5, 10};
|
||||
auto dimsEntry = wpi::nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
"/SmartDashboard/mechanism/dims");
|
||||
auto colorEntry = nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
auto colorEntry = wpi::nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
"/SmartDashboard/mechanism/backgroundColor");
|
||||
frc::SmartDashboard::PutData("mechanism", &mechanism);
|
||||
frc::SmartDashboard::UpdateValues();
|
||||
wpi::SmartDashboard::PutData("mechanism", &mechanism);
|
||||
wpi::SmartDashboard::UpdateValues();
|
||||
EXPECT_EQ(5.0, dimsEntry.GetDoubleArray({})[0]);
|
||||
EXPECT_EQ(10.0, dimsEntry.GetDoubleArray({})[1]);
|
||||
EXPECT_EQ("#000020", colorEntry.GetString(""));
|
||||
mechanism.SetBackgroundColor({255, 255, 255});
|
||||
frc::SmartDashboard::UpdateValues();
|
||||
wpi::SmartDashboard::UpdateValues();
|
||||
EXPECT_EQ("#FFFFFF", colorEntry.GetString(""));
|
||||
}
|
||||
|
||||
TEST(Mechanism2dTest, Root) {
|
||||
frc::Mechanism2d mechanism{5, 10};
|
||||
auto xEntry = nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
wpi::Mechanism2d mechanism{5, 10};
|
||||
auto xEntry = wpi::nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
"/SmartDashboard/mechanism/root/x");
|
||||
auto yEntry = nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
auto yEntry = wpi::nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
"/SmartDashboard/mechanism/root/y");
|
||||
frc::MechanismRoot2d* root = mechanism.GetRoot("root", 1, 2);
|
||||
frc::SmartDashboard::PutData("mechanism", &mechanism);
|
||||
frc::SmartDashboard::UpdateValues();
|
||||
wpi::MechanismRoot2d* root = mechanism.GetRoot("root", 1, 2);
|
||||
wpi::SmartDashboard::PutData("mechanism", &mechanism);
|
||||
wpi::SmartDashboard::UpdateValues();
|
||||
EXPECT_EQ(1.0, xEntry.GetDouble(0.0));
|
||||
EXPECT_EQ(2.0, yEntry.GetDouble(0.0));
|
||||
root->SetPosition(2, 4);
|
||||
frc::SmartDashboard::UpdateValues();
|
||||
wpi::SmartDashboard::UpdateValues();
|
||||
EXPECT_EQ(2.0, xEntry.GetDouble(0.0));
|
||||
EXPECT_EQ(4.0, yEntry.GetDouble(0.0));
|
||||
}
|
||||
|
||||
TEST(Mechanism2dTest, Ligament) {
|
||||
frc::Mechanism2d mechanism{5, 10};
|
||||
auto angleEntry = nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
wpi::Mechanism2d mechanism{5, 10};
|
||||
auto angleEntry = wpi::nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
"/SmartDashboard/mechanism/root/ligament/angle");
|
||||
auto colorEntry = nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
auto colorEntry = wpi::nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
"/SmartDashboard/mechanism/root/ligament/color");
|
||||
auto lengthEntry = nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
auto lengthEntry = wpi::nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
"/SmartDashboard/mechanism/root/ligament/length");
|
||||
auto weightEntry = nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
auto weightEntry = wpi::nt::NetworkTableInstance::GetDefault().GetEntry(
|
||||
"/SmartDashboard/mechanism/root/ligament/weight");
|
||||
frc::MechanismRoot2d* root = mechanism.GetRoot("root", 1, 2);
|
||||
frc::MechanismLigament2d* ligament = root->Append<frc::MechanismLigament2d>(
|
||||
"ligament", 3, units::degree_t{90}, 1, frc::Color8Bit{255, 255, 255});
|
||||
frc::SmartDashboard::PutData("mechanism", &mechanism);
|
||||
wpi::MechanismRoot2d* root = mechanism.GetRoot("root", 1, 2);
|
||||
wpi::MechanismLigament2d* ligament = root->Append<wpi::MechanismLigament2d>(
|
||||
"ligament", 3, wpi::units::degree_t{90}, 1, wpi::Color8Bit{255, 255, 255});
|
||||
wpi::SmartDashboard::PutData("mechanism", &mechanism);
|
||||
EXPECT_EQ(ligament->GetAngle(), angleEntry.GetDouble(0.0));
|
||||
EXPECT_EQ(ligament->GetColor().HexString(), colorEntry.GetString(""));
|
||||
EXPECT_EQ(ligament->GetLength(), lengthEntry.GetDouble(0.0));
|
||||
EXPECT_EQ(ligament->GetLineWeight(), weightEntry.GetDouble(0.0));
|
||||
ligament->SetAngle(units::degree_t{45});
|
||||
ligament->SetAngle(wpi::units::degree_t{45});
|
||||
ligament->SetColor({0, 0, 0});
|
||||
ligament->SetLength(2);
|
||||
ligament->SetLineWeight(4);
|
||||
frc::SmartDashboard::UpdateValues();
|
||||
wpi::SmartDashboard::UpdateValues();
|
||||
EXPECT_EQ(ligament->GetAngle(), angleEntry.GetDouble(0.0));
|
||||
EXPECT_EQ(ligament->GetColor().HexString(), colorEntry.GetString(""));
|
||||
EXPECT_EQ(ligament->GetLength(), lengthEntry.GetDouble(0.0));
|
||||
@@ -77,7 +77,7 @@ TEST(Mechanism2dTest, Ligament) {
|
||||
colorEntry.SetString("#FF00FF");
|
||||
lengthEntry.SetDouble(4.0);
|
||||
weightEntry.SetDouble(6.0);
|
||||
frc::SmartDashboard::UpdateValues();
|
||||
wpi::SmartDashboard::UpdateValues();
|
||||
EXPECT_EQ(ligament->GetAngle(), angleEntry.GetDouble(0.0));
|
||||
EXPECT_EQ(ligament->GetColor().HexString(), colorEntry.GetString(""));
|
||||
EXPECT_EQ(ligament->GetLength(), lengthEntry.GetDouble(0.0));
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
class SendableChooserTest : public ::testing::TestWithParam<int> {};
|
||||
|
||||
TEST_P(SendableChooserTest, ReturnsSelected) {
|
||||
frc::SendableChooser<int> chooser;
|
||||
frc::sim::SendableChooserSim chooserSim{
|
||||
wpi::SendableChooser<int> chooser;
|
||||
wpi::sim::SendableChooserSim chooserSim{
|
||||
fmt::format("/SmartDashboard/ReturnsSelectedChooser{}/", GetParam())};
|
||||
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
@@ -25,16 +25,16 @@ TEST_P(SendableChooserTest, ReturnsSelected) {
|
||||
}
|
||||
chooser.SetDefaultOption("0", 0);
|
||||
|
||||
frc::SmartDashboard::PutData(
|
||||
wpi::SmartDashboard::PutData(
|
||||
fmt::format("ReturnsSelectedChooser{}", GetParam()), &chooser);
|
||||
frc::SmartDashboard::UpdateValues();
|
||||
wpi::SmartDashboard::UpdateValues();
|
||||
chooserSim.SetSelected(std::to_string(GetParam()));
|
||||
frc::SmartDashboard::UpdateValues();
|
||||
wpi::SmartDashboard::UpdateValues();
|
||||
EXPECT_EQ(GetParam(), chooser.GetSelected());
|
||||
}
|
||||
|
||||
TEST(SendableChooserTest, DefaultIsReturnedOnNoSelect) {
|
||||
frc::SendableChooser<int> chooser;
|
||||
wpi::SendableChooser<int> chooser;
|
||||
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
chooser.AddOption(std::to_string(i), i);
|
||||
@@ -48,7 +48,7 @@ TEST(SendableChooserTest, DefaultIsReturnedOnNoSelect) {
|
||||
|
||||
TEST(SendableChooserTest,
|
||||
DefaultConstructableIsReturnedOnNoSelectAndNoDefault) {
|
||||
frc::SendableChooser<int> chooser;
|
||||
wpi::SendableChooser<int> chooser;
|
||||
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
chooser.AddOption(std::to_string(i), i);
|
||||
@@ -58,8 +58,8 @@ TEST(SendableChooserTest,
|
||||
}
|
||||
|
||||
TEST(SendableChooserTest, ChangeListener) {
|
||||
frc::SendableChooser<int> chooser;
|
||||
frc::sim::SendableChooserSim chooserSim{
|
||||
wpi::SendableChooser<int> chooser;
|
||||
wpi::sim::SendableChooserSim chooserSim{
|
||||
"/SmartDashboard/ChangeListenerChooser/"};
|
||||
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
@@ -68,10 +68,10 @@ TEST(SendableChooserTest, ChangeListener) {
|
||||
int currentVal = 0;
|
||||
chooser.OnChange([&](int val) { currentVal = val; });
|
||||
|
||||
frc::SmartDashboard::PutData("ChangeListenerChooser", &chooser);
|
||||
frc::SmartDashboard::UpdateValues();
|
||||
wpi::SmartDashboard::PutData("ChangeListenerChooser", &chooser);
|
||||
wpi::SmartDashboard::UpdateValues();
|
||||
chooserSim.SetSelected("3");
|
||||
frc::SmartDashboard::UpdateValues();
|
||||
wpi::SmartDashboard::UpdateValues();
|
||||
|
||||
EXPECT_EQ(3, currentVal);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/util/Color8Bit.hpp"
|
||||
|
||||
TEST(Color8BitTest, ConstructDefault) {
|
||||
constexpr frc::Color8Bit color;
|
||||
constexpr wpi::Color8Bit color;
|
||||
|
||||
EXPECT_EQ(0, color.red);
|
||||
EXPECT_EQ(0, color.green);
|
||||
@@ -17,7 +17,7 @@ TEST(Color8BitTest, ConstructDefault) {
|
||||
}
|
||||
|
||||
TEST(Color8BitTest, ConstructFromInts) {
|
||||
constexpr frc::Color8Bit color{255, 128, 64};
|
||||
constexpr wpi::Color8Bit color{255, 128, 64};
|
||||
|
||||
EXPECT_EQ(255, color.red);
|
||||
EXPECT_EQ(128, color.green);
|
||||
@@ -25,7 +25,7 @@ TEST(Color8BitTest, ConstructFromInts) {
|
||||
}
|
||||
|
||||
TEST(Color8BitTest, ConstructFromColor) {
|
||||
constexpr frc::Color8Bit color{frc::Color{255, 128, 64}};
|
||||
constexpr wpi::Color8Bit color{wpi::Color{255, 128, 64}};
|
||||
|
||||
EXPECT_EQ(255, color.red);
|
||||
EXPECT_EQ(128, color.green);
|
||||
@@ -33,24 +33,24 @@ TEST(Color8BitTest, ConstructFromColor) {
|
||||
}
|
||||
|
||||
TEST(Color8BitTest, ConstructFromHexString) {
|
||||
constexpr frc::Color8Bit color{"#FF8040"};
|
||||
constexpr wpi::Color8Bit color{"#FF8040"};
|
||||
|
||||
EXPECT_EQ(255, color.red);
|
||||
EXPECT_EQ(128, color.green);
|
||||
EXPECT_EQ(64, color.blue);
|
||||
|
||||
// No leading #
|
||||
EXPECT_THROW(frc::Color8Bit{"112233"}, std::invalid_argument);
|
||||
EXPECT_THROW(wpi::Color8Bit{"112233"}, std::invalid_argument);
|
||||
|
||||
// Too long
|
||||
EXPECT_THROW(frc::Color8Bit{"#11223344"}, std::invalid_argument);
|
||||
EXPECT_THROW(wpi::Color8Bit{"#11223344"}, std::invalid_argument);
|
||||
|
||||
// Invalid hex characters
|
||||
EXPECT_THROW(frc::Color8Bit{"#$$$$$$"}, std::invalid_argument);
|
||||
EXPECT_THROW(wpi::Color8Bit{"#$$$$$$"}, std::invalid_argument);
|
||||
}
|
||||
|
||||
TEST(Color8BitTest, ImplicitConversionToColor) {
|
||||
frc::Color color = frc::Color8Bit{255, 128, 64};
|
||||
wpi::Color color = wpi::Color8Bit{255, 128, 64};
|
||||
|
||||
EXPECT_NEAR(1.0, color.red, 1e-2);
|
||||
EXPECT_NEAR(0.5, color.green, 1e-2);
|
||||
@@ -58,13 +58,13 @@ TEST(Color8BitTest, ImplicitConversionToColor) {
|
||||
}
|
||||
|
||||
TEST(Color8BitTest, ToHexString) {
|
||||
constexpr frc::Color8Bit color1{255, 128, 64};
|
||||
constexpr wpi::Color8Bit color1{255, 128, 64};
|
||||
EXPECT_EQ("#FF8040", color1.HexString());
|
||||
|
||||
// Ensure conversion to std::string works
|
||||
[[maybe_unused]]
|
||||
std::string str = color1.HexString();
|
||||
|
||||
frc::Color8Bit color2{255, 128, 64};
|
||||
wpi::Color8Bit color2{255, 128, 64};
|
||||
EXPECT_EQ("#FF8040", color2.HexString());
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "wpi/util/Color.hpp"
|
||||
|
||||
TEST(ColorTest, ConstructDefault) {
|
||||
constexpr frc::Color color;
|
||||
constexpr wpi::Color color;
|
||||
|
||||
EXPECT_DOUBLE_EQ(0.0, color.red);
|
||||
EXPECT_DOUBLE_EQ(0.0, color.green);
|
||||
@@ -18,7 +18,7 @@ TEST(ColorTest, ConstructDefault) {
|
||||
|
||||
TEST(ColorTest, ConstructFromDoubles) {
|
||||
{
|
||||
constexpr frc::Color color{1.0, 0.5, 0.25};
|
||||
constexpr wpi::Color color{1.0, 0.5, 0.25};
|
||||
|
||||
EXPECT_NEAR(1.0, color.red, 1e-2);
|
||||
EXPECT_NEAR(0.5, color.green, 1e-2);
|
||||
@@ -26,7 +26,7 @@ TEST(ColorTest, ConstructFromDoubles) {
|
||||
}
|
||||
|
||||
{
|
||||
constexpr frc::Color color{1.0, 0.0, 0.0};
|
||||
constexpr wpi::Color color{1.0, 0.0, 0.0};
|
||||
|
||||
// Check for exact match to ensure round-and-clamp is correct
|
||||
EXPECT_EQ(1.0, color.red);
|
||||
@@ -36,7 +36,7 @@ TEST(ColorTest, ConstructFromDoubles) {
|
||||
}
|
||||
|
||||
TEST(ColorTest, ConstructFromInts) {
|
||||
constexpr frc::Color color{255, 128, 64};
|
||||
constexpr wpi::Color color{255, 128, 64};
|
||||
|
||||
EXPECT_NEAR(1.0, color.red, 1e-2);
|
||||
EXPECT_NEAR(0.5, color.green, 1e-2);
|
||||
@@ -44,24 +44,24 @@ TEST(ColorTest, ConstructFromInts) {
|
||||
}
|
||||
|
||||
TEST(ColorTest, ConstructFromHexString) {
|
||||
constexpr frc::Color color{"#FF8040"};
|
||||
constexpr wpi::Color color{"#FF8040"};
|
||||
|
||||
EXPECT_NEAR(1.0, color.red, 1e-2);
|
||||
EXPECT_NEAR(0.5, color.green, 1e-2);
|
||||
EXPECT_NEAR(0.25, color.blue, 1e-2);
|
||||
|
||||
// No leading #
|
||||
EXPECT_THROW(frc::Color{"112233"}, std::invalid_argument);
|
||||
EXPECT_THROW(wpi::Color{"112233"}, std::invalid_argument);
|
||||
|
||||
// Too long
|
||||
EXPECT_THROW(frc::Color{"#11223344"}, std::invalid_argument);
|
||||
EXPECT_THROW(wpi::Color{"#11223344"}, std::invalid_argument);
|
||||
|
||||
// Invalid hex characters
|
||||
EXPECT_THROW(frc::Color{"#$$$$$$"}, std::invalid_argument);
|
||||
EXPECT_THROW(wpi::Color{"#$$$$$$"}, std::invalid_argument);
|
||||
}
|
||||
|
||||
TEST(ColorTest, FromHSV) {
|
||||
constexpr frc::Color color = frc::Color::FromHSV(90, 128, 64);
|
||||
constexpr wpi::Color color = wpi::Color::FromHSV(90, 128, 64);
|
||||
|
||||
EXPECT_DOUBLE_EQ(0.125732421875, color.red);
|
||||
EXPECT_DOUBLE_EQ(0.251220703125, color.green);
|
||||
@@ -69,13 +69,13 @@ TEST(ColorTest, FromHSV) {
|
||||
}
|
||||
|
||||
TEST(ColorTest, ToHexString) {
|
||||
constexpr frc::Color color1{255, 128, 64};
|
||||
constexpr wpi::Color color1{255, 128, 64};
|
||||
EXPECT_EQ("#FF8040", color1.HexString());
|
||||
|
||||
// Ensure conversion to std::string works
|
||||
[[maybe_unused]]
|
||||
std::string str = color1.HexString();
|
||||
|
||||
frc::Color color2{255, 128, 64};
|
||||
wpi::Color color2{255, 128, 64};
|
||||
EXPECT_EQ("#FF8040", color2.HexString());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user