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>
29 public wpi::SendableHelper<TalonFX>
39 std::string m_description;
42 mutable std::unique_ptr<wpiutils::MotorSafetyImplem> m_motorSafety{};
44 mutable std::recursive_mutex m_motorSafetyLock;
56 controls::NeutralOut m_brakeRef{};
57 controls::VoltageOut m_voltageControl{0
_V};
59 hal::SimDevice m_simMotor;
60 hal::SimDouble m_simSupplyVoltage;
61 hal::SimDouble m_simDutyCycle;
62 hal::SimDouble m_simMotorVoltage;
63 hal::SimDouble m_simTorqueCurrent;
64 hal::SimDouble m_simSupplyCurrent;
66 hal::SimDevice m_simForwardLimit;
67 hal::SimBoolean m_simForwardLimitValue;
69 hal::SimDevice m_simReverseLimit;
70 hal::SimBoolean m_simReverseLimitValue;
72 hal::SimDevice m_simRotor;
73 hal::SimDouble m_simRotorPos;
74 hal::SimDouble m_simRotorRawPos;
75 hal::SimDouble m_simRotorVel;
76 hal::SimDouble m_simRotorAccel;
79 std::vector<int32_t> m_simValueChangedUids;
83 static void OnPeriodic(
void*
param);
86 wpiutils::MotorSafetyImplem &GetMotorSafety()
const;
159 [[deprecated(
"This API is deprecated for removal in 2026."
160 " Since invert is a config, apply the invert setting as part of a full configs::TalonFXConfiguration object."
161 " Invert can be found in the MotorOutput config group.")]]
177 [[deprecated(
"This API is deprecated for removal in 2026."
178 " Since invert is a config, read the invert setting as part of a full configs::TalonFXConfiguration object"
179 " or using a configs::MotorOutputConfigs object."
180 " Applied invert, which may not match the invert config for followers, can also be fetched using GetAppliedRotorPolarity.")]]
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:657
Abstract Control Request class that other control requests extend for use.
Definition ControlRequest.hpp:29
Request a specified motor duty cycle.
Definition DutyCycleOut.hpp:28
StatusSignal< T > & LookupStatusSignal(uint16_t spn, std::string signalName, bool reportOnConstruction, bool refresh)
Definition ParentDevice.hpp:553
Class description for the Talon FX integrated motor controller.
Definition TalonFX.hpp:30
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:36
TalonFX(int deviceId, CANBus canbus)
Constructs a new Talon FX motor controller object.
Definition TalonFX.hpp:110
void Feed()
Feed the motor safety object.
bool IsAlive() const
Determine of the motor is still operating or has timed out.
void InitSendable(wpi::SendableBuilder &builder) override
TalonFX(int deviceId, std::string canbus="")
Constructs a new Talon FX motor controller object.
bool GetInverted() const
Common interface for returning the inversion state of a motor controller.
void Disable()
Common interface for disabling a motor controller.
bool IsSafetyEnabled() const
Return the state of the motor safety enabled flag.
void SetExpiration(units::second_t expirationTime)
Set the expiration time for the corresponding motor safety object.
ctre::phoenix::StatusCode SetInverted(bool isInverted)
Common interface for inverting direction of a motor controller.
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.
ctre::phoenix::StatusCode SetControlPrivate(const controls::ControlRequest &request) override
void SetSafetyEnabled(bool enabled)
Enable/disable motor safety for this device.
std::string GetDescription() const
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:2932
StatusSignal< units::dimensionless::scalar_t > & GetDutyCycle(bool refresh=true) override
The applied motor duty cycle.
The state of the motor controller bridge when output is neutral or disabled.
Definition SpnEnums.hpp:2202
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
Definition StatusCodes.h:18