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-07 19:56:21 -05:00
|
|
|
#include "wpi/simulation/PWMMotorControllerSim.hpp" // NOLINT(build/include_order)
|
2025-03-20 19:23:22 -07:00
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
2025-11-07 19:57:55 -05:00
|
|
|
#include "wpi/hal/HAL.h"
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/hardware/motor/Spark.hpp"
|
2025-03-20 19:23:22 -07:00
|
|
|
|
|
|
|
|
namespace frc::sim {
|
|
|
|
|
TEST(PWMMotorControllerSimTest, TestMotor) {
|
|
|
|
|
frc::Spark spark{0};
|
|
|
|
|
frc::sim::PWMMotorControllerSim sim{spark};
|
|
|
|
|
|
|
|
|
|
spark.Set(0);
|
|
|
|
|
EXPECT_EQ(0, sim.GetSpeed());
|
|
|
|
|
|
|
|
|
|
spark.Set(0.354);
|
|
|
|
|
EXPECT_EQ(0.354, sim.GetSpeed());
|
|
|
|
|
|
|
|
|
|
spark.Set(-0.785);
|
|
|
|
|
EXPECT_EQ(-0.785, sim.GetSpeed());
|
|
|
|
|
}
|
|
|
|
|
} // namespace frc::sim
|