12#include <wpi/hal/SimDevice.hpp>
13#include <wpi/telemetry/TelemetryLoggable.hpp>
19#if defined(_WIN32) || defined(_WIN64)
21#pragma warning(disable : 4250)
36 std::string m_description;
39 mutable std::unique_ptr<wpiutils::MotorSafetyImplem> m_motorSafety{};
41 mutable std::recursive_mutex m_motorSafetyLock;
55 controls::NeutralOut m_neutralControl{};
56 controls::VoltageOut m_voltageControl{0_V};
58 wpi::hal::SimDevice m_simMotor;
59 wpi::hal::SimDouble m_simSupplyVoltage;
60 wpi::hal::SimDouble m_simDutyCycle;
61 wpi::hal::SimDouble m_simMotorVoltage;
62 wpi::hal::SimDouble m_simTorqueCurrent;
63 wpi::hal::SimDouble m_simSupplyCurrent;
65 wpi::hal::SimDevice m_simForwardLimit;
66 wpi::hal::SimBoolean m_simForwardLimitValue;
68 wpi::hal::SimDevice m_simReverseLimit;
69 wpi::hal::SimBoolean m_simReverseLimitValue;
71 wpi::hal::SimDevice m_simRotor;
72 wpi::hal::SimDouble m_simRotorPos;
73 wpi::hal::SimDouble m_simRotorRawPos;
74 wpi::hal::SimDouble m_simRotorVel;
75 wpi::hal::SimDouble m_simRotorAccel;
77 int32_t m_simPeriodicUid{-1};
78 std::vector<int32_t> m_simValueChangedUids;
80 static void OnValueChanged(
81 const char* name,
void *param, HAL_SimValueHandle handle,
82 HAL_Bool readonly,
const struct HAL_Value* value
84 static void OnPeriodic(
void* param);
87 wpiutils::MotorSafetyImplem &GetMotorSafety()
const;
120 SetControl(m_setterControl.WithOutput(throttle));
134 SetControl(m_voltageControl.WithOutput(voltage));
144 return m_dutyCycle.Refresh().GetValue();
223 void LogTo(wpi::telemetry::TelemetryTable &table)
const override;
237 return CoreTalonFX::SetControlPrivate(request);
241#if defined(_WIN32) || defined(_WIN64)
Class for getting information about an available CAN bus.
Definition CANBus.hpp:142
Represents a status signal with data of type T, and operations available to retrieve information abou...
Definition StatusSignal.hpp:523
Common interface implemented by all control requests.
Definition ControlRequest.hpp:27
Request a specified motor duty cycle.
Definition DutyCycleOut.hpp:23
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:234
void SetVoltage(wpi::units::volt_t voltage)
Sets the direct voltage output of the motor controller.
Definition TalonFX.hpp:132
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:216
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:142
std::string_view GetTelemetryType() const override
Gets the telemetry table type.
Definition TalonFX.hpp:230
void Disable()
Disables the motor controller.
Definition TalonFX.hpp:149
void LogTo(wpi::telemetry::TelemetryTable &table) const override
Logs the object to a wpi::telemetry::TelemetryTable.
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:212
static constexpr auto DEFAULT_SAFETY_EXPIRATION
The default motor safety timeout IF calling application enables the feature.
Definition TalonFX.hpp:33
static TalonFX None()
Constructs a stubbed-out TalonFX, where all status signals, controls, configs, etc.
Definition TalonFX.hpp:107
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:118
Class for the Talon FX integrated motor controller.
Definition CoreTalonFX.hpp:3182
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.
StatusSignal< wpi::units::turn_t > & GetPosition(bool refresh=true) final
Position of the device in mechanism rotations.
StatusSignal< wpi::units::turns_per_second_t > & GetVelocity(bool refresh=true) final
Velocity of the device in mechanism rotations per second.
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:1499