2025-03-20 19:23:22 -07:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
|
2025-11-11 18:05:12 -08:00
|
|
|
// clang-format off
|
|
|
|
|
#include "wpi/simulation/PWMMotorControllerSim.hpp"
|
|
|
|
|
// clang-format on
|
2025-03-20 19:23:22 -07:00
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/hardware/motor/Spark.hpp"
|
2025-03-20 19:23:22 -07:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
namespace wpi::sim {
|
2025-03-20 19:23:22 -07:00
|
|
|
TEST(PWMMotorControllerSimTest, TestMotor) {
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::Spark spark{0};
|
|
|
|
|
wpi::sim::PWMMotorControllerSim sim{spark};
|
2025-03-20 19:23:22 -07:00
|
|
|
|
2026-04-09 22:28:01 -07:00
|
|
|
spark.SetThrottle(0);
|
|
|
|
|
EXPECT_EQ(0, sim.GetThrottle());
|
2025-03-20 19:23:22 -07:00
|
|
|
|
2026-04-09 22:28:01 -07:00
|
|
|
spark.SetThrottle(0.354);
|
|
|
|
|
EXPECT_EQ(0.354, sim.GetThrottle());
|
2025-03-20 19:23:22 -07:00
|
|
|
|
2026-04-09 22:28:01 -07:00
|
|
|
spark.SetThrottle(-0.785);
|
|
|
|
|
EXPECT_EQ(-0.785, sim.GetThrottle());
|
2025-03-20 19:23:22 -07:00
|
|
|
}
|
2025-11-07 20:00:05 -05:00
|
|
|
} // namespace wpi::sim
|