CTRE Phoenix C++ 5.33.1
WPI_TalonFX.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2/**
3 * WPI Compliant motor controller class.
4 * WPILIB's object model requires many interfaces to be implemented to use
5 * the various features.
6 * This includes...
7 * - Software PID loops running in the robot controller
8 * - LiveWindow/Test mode features
9 * - Motor Safety (auto-turn off of motor if Set stops getting called)
10 * - Single Parameter set that assumes a simple motor controller.
11 */
12#pragma once
13
16#include "ctre/phoenix/platform/Platform.hpp"
18
19
20//Turn off dominance warning
21#if _MSC_VER
22 #pragma warning(push)
23 #pragma warning(disable : 4250)
24#endif
25
26namespace ctre {
27namespace phoenix {
28namespace motorcontrol {
29namespace can {
30
31/**
32 * CTRE Talon FX Motor Controller when used on CAN Bus.
33 *
34 * @deprecated This device's Phoenix 5 API is deprecated for removal in the
35 * 2025 season. Users should update to Phoenix 6 firmware and migrate to the
36 * Phoenix 6 API. A migration guide is available at
37 * https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.
38 *
39 * If the Phoenix 5 API must be used for this device, the device must have 22.X
40 * firmware. This firmware is available in Tuner X after selecting Phoenix 5 in
41 * the firmware year dropdown.
42 */
43class [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
44 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
45 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
46WPI_TalonFX : public virtual TalonFX,
47 public virtual WPI_BaseMotorController
48{
49public:
50 /**
51 * Constructor for a WPI_TalonFX
52 * @param deviceNumber Device ID of TalonFX
53 * @param canbus Name of the CANbus; can be a CANivore device name or serial number.
54 * Pass in nothing or "rio" to use the roboRIO.
55 */
56 WPI_TalonFX(int deviceNumber, std::string const &canbus = "");
57 virtual ~WPI_TalonFX();
58
59 WPI_TalonFX() = delete;
60 WPI_TalonFX(WPI_TalonFX const &) = delete;
61 WPI_TalonFX &operator=(WPI_TalonFX const &) = delete;
62
63 /* ----- virtual re-directs ------- */
64 virtual void Set(double value);
65 [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
66 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
67 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
68 virtual void Set(ControlMode mode, double value);
69 [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
70 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
71 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
72 virtual void Set(ControlMode mode, double demand0, DemandType demand1Type, double demand1);
73 [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
74 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
75 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
76 virtual void Set(TalonFXControlMode mode, double value);
77 [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
78 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
79 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
80 virtual void Set(TalonFXControlMode mode, double demand0, DemandType demand1Type, double demand1);
81 virtual void SetVoltage(units::volt_t output);
82 [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
83 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
84 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
85 virtual void SetInverted(TalonFXInvertType invertType);
86 [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
87 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
88 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
89 virtual void SetInverted(InvertType invertType);
90 virtual void SetInverted(bool bInvert);
91 [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
92 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
93 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
94 virtual ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx = 0, int timeoutMs = 0);
95 [[deprecated("This device's Phoenix 5 API is deprecated for removal in the 2025 season."
96 "Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API."
97 "A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html")]]
98 virtual ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx = 0, int timeoutMs = 0);
99
100protected:
101
102private:
103
104 hal::SimDevice m_simMotor;
105 hal::SimDouble m_simPercOut;
106 hal::SimDouble m_simMotorOutputLeadVoltage;
107 hal::SimDouble m_simSupplyCurrent;
108 hal::SimDouble m_simMotorCurrent;
109 hal::SimDouble m_simVbat;
110
111 hal::SimDevice m_simIntegSens;
112 hal::SimDouble m_simIntegSensPos;
113 hal::SimDouble m_simIntegSensAbsPos;
114 hal::SimDouble m_simIntegSensRawPos;
115 hal::SimDouble m_simIntegSensVel;
116
117 hal::SimDevice m_simFwdLim;
118 hal::SimBoolean m_simFwdLimInit;
119 hal::SimBoolean m_simFwdLimInput;
120 hal::SimBoolean m_simFwdLimValue;
121
122 hal::SimDevice m_simRevLim;
123 hal::SimBoolean m_simRevLimInit;
124 hal::SimBoolean m_simRevLimInput;
125 hal::SimBoolean m_simRevLimValue;
126
127 static void OnValueChanged(const char* name, void* param, HAL_SimValueHandle handle,
128 HAL_Bool readonly, const struct HAL_Value* value);
129 static void OnPeriodic(void* param);
130
131};
132
133} // namespace can
134} // namespace motorcontrol
135} // namespace phoenix
136} // namespace ctre
137
138#if _MSC_VER
139 #pragma warning(pop)
140#endif
CTRE Talon FX Motor Controller when used on CAN Bus.
Definition: TalonFX.h:219
VEX Victor SPX Motor Controller when used on CAN Bus.
Definition: WPI_BaseMotorController.h:57
CTRE Talon FX Motor Controller when used on CAN Bus.
Definition: WPI_TalonFX.h:48
WPI_TalonFX(int deviceNumber, std::string const &canbus="")
Constructor for a WPI_TalonFX.
virtual ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx=0, int timeoutMs=0)
Select the remote feedback device for the motor controller.
virtual void Set(TalonFXControlMode mode, double value)
virtual void Set(ControlMode mode, double value)
Sets the appropriate output on the talon, depending on the mode.
virtual void SetInverted(InvertType invertType)
Inverts the hbridge output of the motor controller in relation to the master if present.
virtual void Set(ControlMode mode, double demand0, DemandType demand1Type, double demand1)
virtual void SetInverted(TalonFXInvertType invertType)
virtual void Set(double value)
Common interface for setting the speed of a simple speed controller.
virtual void SetVoltage(units::volt_t output)
Sets the voltage output of the SpeedController.
virtual ctre::phoenix::ErrorCode ConfigSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx=0, int timeoutMs=0)
Select the remote feedback device for the motor controller.
virtual void Set(TalonFXControlMode mode, double demand0, DemandType demand1Type, double demand1)
WPI_TalonFX & operator=(WPI_TalonFX const &)=delete
WPI_TalonFX(WPI_TalonFX const &)=delete
virtual void SetInverted(bool bInvert)
Inverts the hbridge output of the motor controller.
ControlMode
Choose the control mode for a motor controller.
Definition: ControlMode.h:11
DemandType
How to interpret a demand value.
Definition: DemandType.h:10
InvertType
Choose the invert type of the motor controller.
Definition: InvertType.h:14
RemoteFeedbackDevice
Choose the remote feedback device for a motor controller.
Definition: FeedbackDevice.h:179
FeedbackDevice
Choose the feedback device for a motor controller.
Definition: FeedbackDevice.h:14
TalonFXControlMode
Choose the control mode for a TalonFX / Falcon 500.
Definition: ControlMode.h:68
TalonFXInvertType
Choose the invert type for a Talon FX based integrated motor controller.
Definition: InvertType.h:37
ErrorCode
Definition: ErrorCode.h:13
namespace ctre
Definition: paramEnum.h:5