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"
|
2025-03-20 19:23:22 -07:00
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/hal/SimDevice.h"
|
|
|
|
|
#include "wpi/simulation/SimDeviceSim.hpp"
|
2025-03-20 19:23:22 -07:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
using namespace wpi;
|
|
|
|
|
using namespace wpi::sim;
|
2025-03-20 19:23:22 -07:00
|
|
|
|
|
|
|
|
PWMMotorControllerSim::PWMMotorControllerSim(
|
|
|
|
|
const PWMMotorController& motorctrl)
|
|
|
|
|
: PWMMotorControllerSim(motorctrl.GetChannel()) {}
|
|
|
|
|
|
|
|
|
|
PWMMotorControllerSim::PWMMotorControllerSim(int channel) {
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::sim::SimDeviceSim deviceSim{"PWMMotorController", channel};
|
2026-03-06 14:19:15 -08:00
|
|
|
m_simDutyCycle = deviceSim.GetDouble("DutyCycle");
|
2025-03-20 19:23:22 -07:00
|
|
|
}
|
|
|
|
|
|
2026-03-06 14:19:15 -08:00
|
|
|
double PWMMotorControllerSim::GetDutyCycle() const {
|
|
|
|
|
return m_simDutyCycle.Get();
|
2025-03-20 19:23:22 -07:00
|
|
|
}
|