12#include "frc/MotorSafety.h"
13#include "frc/motorcontrol/MotorController.h"
14#include "wpi/sendable/Sendable.h"
15#include "wpi/sendable/SendableBuilder.h"
16#include "wpi/sendable/SendableHelper.h"
17#include <hal/SimDevice.h>
29 public frc::MotorController,
31 public wpi::SendableHelper<TalonFX>
41 std::string m_description;
44 mutable std::unique_ptr<wpiutils::MotorSafetyImplem> m_motorSafety{};
58 controls::NeutralOut m_brakeRef{};
59 controls::VoltageOut m_voltageControl{0_V};
61 hal::SimDevice m_simMotor;
62 hal::SimDouble m_simSupplyVoltage;
63 hal::SimDouble m_simDutyCycle;
64 hal::SimDouble m_simMotorVoltage;
65 hal::SimDouble m_simTorqueCurrent;
66 hal::SimDouble m_simSupplyCurrent;
68 hal::SimDevice m_simForwardLimit;
69 hal::SimBoolean m_simForwardLimitValue;
71 hal::SimDevice m_simReverseLimit;
72 hal::SimBoolean m_simReverseLimitValue;
74 hal::SimDevice m_simRotor;
75 hal::SimDouble m_simRotorPos;
76 hal::SimDouble m_simRotorRawPos;
77 hal::SimDouble m_simRotorVel;
78 hal::SimDouble m_simRotorAccel;
80 int32_t m_simPeriodicUid{-1};
81 std::vector<int32_t> m_simValueChangedUids;
83 static void OnValueChanged(
const char* name,
void *param, HAL_SimValueHandle handle,
84 HAL_Bool readonly,
const struct HAL_Value* value);
85 static void OnPeriodic(
void* param);
88 wpiutils::MotorSafetyImplem &GetMotorSafety()
const;
109 TalonFX(
int deviceId, std::string canbus =
"");
120 void Set(
double speed)
override;
132 double Get()
const override;
Abstract Control Request class that other control requests extend for use.
Definition: ControlRequest.hpp:28
Request a specified motor duty cycle.
Definition: DutyCycleOut.hpp:28
Class description for the Talon FX integrated motor controller.
Definition: TalonFX.hpp:32
ctre::phoenix::StatusCode SetControlPrivate(controls::ControlRequest &request) override
static constexpr auto kDefaultSafetyExpiration
The default motor safety timeout IF calling application enables the feature.
Definition: TalonFX.hpp:38
void SetInverted(bool isInverted) override
Common interface for inverting direction of a motor controller.
void Feed()
Feed the motor safety object.
TalonFX & operator=(TalonFX &&)=default
void StopMotor() override
Common interface to stop motor movement until Set is called again.
bool IsAlive() const
Determine of the motor is still operating or has timed out.
void Disable() override
Common interface for disabling a motor controller.
void InitSendable(wpi::SendableBuilder &builder) override
TalonFX(int deviceId, std::string canbus="")
Constructs a new Talon FX motor controller object.
void SetNeutralMode(signals::NeutralModeValue neutralMode)
Sets the mode of operation when output is neutral or disabled.
bool IsSafetyEnabled() const
Return the state of the motor safety enabled flag.
void SetVoltage(units::volt_t volts) override
Common interface for seting the direct voltage output of a motor controller.
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.
TalonFX(TalonFX &&)=default
bool GetInverted() const override
Common interface for returning the inversion state of a motor controller.
void Set(double speed) override
Common interface for setting the speed of a motor controller.
void SetSafetyEnabled(bool enabled)
Enable/disable motor safety for this device.
std::string GetDescription() const
double Get() const override
Common interface for getting the current set speed of a motor controller.
Class description for the Talon FX integrated motor controller.
Definition: CoreTalonFX.hpp:2734
StatusSignal< units::dimensionless::scalar_t > & GetDutyCycle()
The applied motor duty cycle.
The state of the motor controller bridge when output is neutral or disabled.
Definition: SpnEnums.hpp:1537
Definition: string_util.hpp:15