12#include "frc/MotorSafety.h"
13#include "wpi/sendable/Sendable.h"
14#include "wpi/sendable/SendableBuilder.h"
15#include "wpi/sendable/SendableHelper.h"
16#include <hal/SimDevice.h>
24#if defined(_WIN32) || defined(_WIN64)
26#pragma warning(disable : 4250)
34 public wpi::SendableHelper<TalonFX>
44 std::string m_description;
47 mutable std::unique_ptr<wpiutils::MotorSafetyImplem> m_motorSafety{};
49 mutable std::recursive_mutex m_motorSafetyLock;
61 controls::NeutralOut m_brakeRef{};
62 controls::VoltageOut m_voltageControl{0_V};
64 hal::SimDevice m_simMotor;
65 hal::SimDouble m_simSupplyVoltage;
66 hal::SimDouble m_simDutyCycle;
67 hal::SimDouble m_simMotorVoltage;
68 hal::SimDouble m_simTorqueCurrent;
69 hal::SimDouble m_simSupplyCurrent;
71 hal::SimDevice m_simForwardLimit;
72 hal::SimBoolean m_simForwardLimitValue;
74 hal::SimDevice m_simReverseLimit;
75 hal::SimBoolean m_simReverseLimitValue;
77 hal::SimDevice m_simRotor;
78 hal::SimDouble m_simRotorPos;
79 hal::SimDouble m_simRotorRawPos;
80 hal::SimDouble m_simRotorVel;
81 hal::SimDouble m_simRotorAccel;
83 int32_t m_simPeriodicUid{-1};
84 std::vector<int32_t> m_simValueChangedUids;
86 static void OnValueChanged(
87 const char* name,
void *param, HAL_SimValueHandle handle,
88 HAL_Bool readonly,
const struct HAL_Value* value
90 static void OnPeriodic(
void* param);
93 wpiutils::MotorSafetyImplem &GetMotorSafety()
const;
121 "Constructing devices with a CAN bus string is deprecated for removal "
122 "in the 2027 season. Construct devices using a CANBus instance instead."
222#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:474
Common interface implemented by all control requests.
Definition ControlRequest.hpp:27
Request a specified motor duty cycle.
Definition DutyCycleOut.hpp:23
Class description for the Talon FX integrated motor controller.
Definition TalonFX.hpp:35
double Get() const
Common interface for getting the current set speed of a motor controller.
static constexpr auto kDefaultSafetyExpiration
The default motor safety timeout IF calling application enables the feature.
Definition TalonFX.hpp:41
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
void InitSendable(wpi::SendableBuilder &builder) override
virtual std::string GetDescription() const
void Disable()
Common interface for disabling a motor controller.
TalonFX(int deviceId, CANBus canbus={})
Constructs a new Talon FX motor controller object.
bool IsSafetyEnabled() const
Return the state of the motor safety enabled flag.
TalonFX(int deviceId, std::string canbus)
Constructs a new Talon FX motor controller object.
void SetExpiration(units::second_t expirationTime)
Set the expiration time for the corresponding motor safety object.
units::second_t GetExpiration() const
Retrieve the timeout value for the corresponding motor safety object.
void Set(double speed)
Common interface for setting the speed of a motor controller.
void StopMotor()
Common interface to stop motor movement until Set is called again.
ctre::phoenix::StatusCode SetNeutralMode(signals::NeutralModeValue neutralMode, units::second_t timeoutSeconds=100_ms)
Sets the mode of operation when output is neutral or disabled.
void SetSafetyEnabled(bool enabled)
Enable/disable motor safety for this device.
void SetVoltage(units::volt_t volts)
Common interface for seting the direct voltage output of a motor controller.
Class description for the Talon FX integrated motor controller.
Definition CoreTalonFX.hpp:3113
StatusSignal< units::dimensionless::scalar_t > & GetDutyCycle(bool refresh=true) final
The applied motor duty cycle.
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
Definition motor_constants.h:14
The state of the motor controller bridge when output is neutral or disabled.
Definition SpnEnums.hpp:1603