12#include <wpi/hal/SimDevice.hpp>
18#if defined(_WIN32) || defined(_WIN64)
20#pragma warning(disable : 4250)
35 std::string m_description;
38 mutable std::unique_ptr<wpiutils::MotorSafetyImplem> m_motorSafety{};
40 mutable std::recursive_mutex m_motorSafetyLock;
52 controls::NeutralOut m_neutralControl{};
53 controls::VoltageOut m_voltageControl{0_V};
55 wpi::hal::SimDevice m_simMotor;
56 wpi::hal::SimDouble m_simSupplyVoltage;
57 wpi::hal::SimDouble m_simDutyCycle;
58 wpi::hal::SimDouble m_simMotorVoltage;
59 wpi::hal::SimDouble m_simTorqueCurrent;
60 wpi::hal::SimDouble m_simSupplyCurrent;
62 wpi::hal::SimDevice m_simForwardLimit;
63 wpi::hal::SimBoolean m_simForwardLimitValue;
65 wpi::hal::SimDevice m_simReverseLimit;
66 wpi::hal::SimBoolean m_simReverseLimitValue;
68 wpi::hal::SimDevice m_simRotor;
69 wpi::hal::SimDouble m_simRotorPos;
70 wpi::hal::SimDouble m_simRotorRawPos;
71 wpi::hal::SimDouble m_simRotorVel;
72 wpi::hal::SimDouble m_simRotorAccel;
74 int32_t m_simPeriodicUid{-1};
75 std::vector<int32_t> m_simValueChangedUids;
77 static void OnValueChanged(
78 const char* name,
void *param, HAL_SimValueHandle handle,
79 HAL_Bool readonly,
const struct HAL_Value* value
81 static void OnPeriodic(
void* param);
84 wpiutils::MotorSafetyImplem &GetMotorSafety()
const;
117 SetControl(m_setterControl.WithOutput(throttle));
131 SetControl(m_voltageControl.WithOutput(voltage));
141 return m_dutyCycle.Refresh().GetValue();
220 return CoreTalonFX::SetControlPrivate(request);
224#if defined(_WIN32) || defined(_WIN64)
Class for getting information about an available CAN bus.
Definition CANBus.hpp:19
Represents a status signal with data of type T, and operations available to retrieve information abou...
Definition StatusSignal.hpp:563
Common interface implemented by all control requests.
Definition ControlRequest.hpp:27
Request a specified motor duty cycle.
Definition DutyCycleOut.hpp:23
static constexpr auto kDefaultSafetyExpiration
The default motor safety timeout IF calling application enables the feature.
Definition TalonFX.hpp:32
TalonFX(int deviceId, CANBus canbus)
Constructs a new Talon FX motor controller object.
void Feed()
Feed the motor safety object.
bool IsAlive() const
Determine of the motor is still operating or has timed out.
ctre::phoenix::StatusCode SetControlPrivate(controls::ControlRequest const &request) override
Definition TalonFX.hpp:217
void SetVoltage(wpi::units::volt_t voltage)
Sets the direct voltage output of the motor controller.
Definition TalonFX.hpp:129
wpi::units::second_t GetExpiration() const
Retrieve the timeout value for the corresponding motor safety object.
ctre::phoenix::StatusCode ConfigNeutralMode(signals::NeutralModeValue neutralMode, wpi::units::second_t timeoutSeconds=100_ms)
Sets the mode of operation when output is neutral or disabled.
virtual std::string GetDescription() const
Definition TalonFX.hpp:213
void SetExpiration(wpi::units::second_t expirationTime)
Set the expiration time for the corresponding motor safety object.
double GetThrottle() const
Gets the throttle of the motor controller.
Definition TalonFX.hpp:139
void Disable()
Disables the motor controller.
Definition TalonFX.hpp:146
bool IsSafetyEnabled() const
Return the state of the motor safety enabled flag.
void StopMotor()
Called to stop the motor when the timeout expires.
Definition TalonFX.hpp:209
static TalonFX None()
Constructs a stubbed-out TalonFX, where all status signals, controls, configs, etc.
Definition TalonFX.hpp:104
void SetSafetyEnabled(bool enabled)
Enable/disable motor safety for this device.
void SetThrottle(double throttle)
Sets the throttle of the motor controller.
Definition TalonFX.hpp:115
Class description for the Talon FX integrated motor controller.
Definition CoreTalonFX.hpp:3186
StatusSignal< wpi::units::scalar_t > & GetDutyCycle(bool refresh=true) final
The applied motor duty cycle.
ctre::phoenix::StatusCode SetControl(controls::DutyCycleOut const &request) final
Request a specified motor duty cycle.
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
Definition ExternalFeedbackConfigs.hpp:17
Definition ExternalFeedbackConfigs.hpp:16
Definition motor_constants.h:14
The state of the motor controller bridge when output is neutral or disabled.
Definition SpnEnums.hpp:1603