CTRE Phoenix C++ 5.33.1
IMotorControllerEnhanced.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#pragma once
3
21
22namespace ctre {
23namespace phoenix {
24namespace motorcontrol {
25
26/**
27 * Interface for enhanced motor controllers
28 */
30public:
32 }
33
34 //------ Set output routines. ----------//
35 /* in parent */
36
37 //------ Invert behavior ----------//
38 /* in parent */
39
40 //----- Factory Default Configuration -----//
41 /* in parent */
42
43 //----- general output shaping ------------------//
44 /* in parent */
45
46 //------ Voltage Compensation ----------//
47 /* in parent */
48
49 //------ General Status ----------//
50 /* in parent */
51
52 //------ sensor selection ----------//
53 /* expand the options */
54 /**
55 * Select the feedback device for the motor controller.
56 *
57 * @param feedbackDevice
58 * Feedback Device to select.
59 * @param pidIdx
60 * 0 for Primary closed-loop. 1 for auxiliary closed-loop.
61 * @param timeoutMs
62 * Timeout value in ms. If nonzero, function will wait for
63 * config success and report an error if it times out.
64 * If zero, no blocking or checking is performed.
65 * @return Error Code generated by function. 0 indicates no error.
66 */
68 FeedbackDevice feedbackDevice, int pidIdx = 0, int timeoutMs = 0) = 0;
69 /**
70 * Select the feedback device for the motor controller.
71 *
72 * @param feedbackDevice
73 * Feedback Device to select.
74 * @param pidIdx
75 * 0 for Primary closed-loop. 1 for auxiliary closed-loop.
76 * @param timeoutMs
77 * Timeout value in ms. If nonzero, function will wait for
78 * config success and report an error if it times out.
79 * If zero, no blocking or checking is performed.
80 * @return Error Code generated by function. 0 indicates no error.
81 */
83 RemoteFeedbackDevice feedbackDevice, int pidIdx = 0, int timeoutMs = 0) = 0;
84
85 //------ Current Limit ----------//
86 /**
87 * Configures the supply-side current limit.
88 * @param currLimitCfg Current limit configuration
89 * @param timeoutMs
90 * Timeout value in ms. If nonzero, function will wait for
91 * config success and report an error if it times out.
92 * If zero, no blocking or checking is performed.
93 * @return Error Code generated by function. 0 indicates no error.
94 */
95 virtual ErrorCode ConfigSupplyCurrentLimit(const SupplyCurrentLimitConfiguration& currLimitConfigs, int timeoutMs = 50) = 0;
96
97 //------- sensor status --------- //
98 /* in parent */
99
100 //------ status frame period changes ----------//
101 /**
102 * Sets the period of the given status frame.
103 *
104 * User ensure CAN Bus utilization is not high.
105 *
106 * This setting is not persistent and is lost when device is reset. If this
107 * is a concern, calling application can use HasResetOccurred() to determine if the
108 * status frame needs to be reconfigured.
109 *
110 * @param frame
111 * Frame whose period is to be changed.
112 * @param periodMs
113 * Period in ms for the given frame.
114 * @param timeoutMs
115 * Timeout value in ms. If nonzero, function will wait for
116 * config success and report an error if it times out.
117 * If zero, no blocking or checking is performed.
118 * @return Error Code generated by function. 0 indicates no error.
119 */
120 virtual ErrorCode SetStatusFramePeriod(StatusFrame frame, uint8_t periodMs,
121 int timeoutMs = 0) = 0;
122 /**
123 * Sets the period of the given status frame.
124 *
125 * User ensure CAN Bus utilization is not high.
126 *
127 * This setting is not persistent and is lost when device is reset. If this
128 * is a concern, calling application can use HasResetOccurred() to determine if the
129 * status frame needs to be reconfigured.
130 *
131 * @param frame
132 * Frame whose period is to be changed.
133 * @param periodMs
134 * Period in ms for the given frame.
135 * @param timeoutMs
136 * Timeout value in ms. If nonzero, function will wait for
137 * config success and report an error if it times out.
138 * If zero, no blocking or checking is performed.
139 * @return Error Code generated by function. 0 indicates no error.
140 */
142 uint8_t periodMs, int timeoutMs = 0) = 0;
143 /**
144 * Gets the period of the given status frame.
145 *
146 * @param frame
147 * Frame to get the period of.
148 * @param timeoutMs
149 * Timeout value in ms. If nonzero, function will wait for
150 * config success and report an error if it times out.
151 * If zero, no blocking or checking is performed.
152 * @return Period of the given status frame.
153 */
154 virtual int GetStatusFramePeriod(StatusFrame frame, int timeoutMs = 0) = 0;
155 /**
156 * Gets the period of the given status frame.
157 *
158 * @param frame
159 * Frame to get the period of.
160 * @param timeoutMs
161 * Timeout value in ms. If nonzero, function will wait for
162 * config success and report an error if it times out.
163 * If zero, no blocking or checking is performed.
164 * @return Period of the given status frame.
165 */
166 virtual int GetStatusFramePeriod(StatusFrameEnhanced frame, int timeoutMs = 0) = 0;
167
168 //------ General Status ----------//
169 /**
170 * Gets the output current of the motor controller.
171 * In the case of TalonSRX class, this routine returns supply current for legacy reasons. In order to get the "true" output current, call GetStatorCurrent().
172 * In the case of TalonFX class, this routine returns the true output stator current.
173 *
174 * [[deprecated("Use GetStatorCurrent/GetSupplyCurrent instead.")]]
175 *
176 * @return The output current (in amps).
177 */
178 virtual double GetOutputCurrent() = 0;
179
180 //----- velocity signal conditionaing ------//
181 /**
182 * Sets the period over which velocity measurements are taken.
183 *
184 * @param period
185 * Desired period for the velocity measurement. @see
186 * com.ctre.phoenix.motorcontrol.VelocityMeasPeriod
187 * @param timeoutMs
188 * Timeout value in ms. If nonzero, function will wait for
189 * config success and report an error if it times out.
190 * If zero, no blocking or checking is performed.
191 * @return Error Code generated by function. 0 indicates no error.
192 */
194 int timeoutMs = 0)= 0;
195 /**
196 * Sets the number of velocity samples used in the rolling average velocity
197 * measurement.
198 *
199 * @param windowSize
200 * Number of samples in the rolling average of velocity
201 * measurement. Valid values are 1,2,4,8,16,32. If another value
202 * is specified, it will truncate to nearest support value.
203 * @param timeoutMs
204 * Timeout value in ms. If nonzero, function will wait for config
205 * success and report an error if it times out. If zero, no
206 * blocking or checking is performed.
207 * @return Error Code generated by function. 0 indicates no error.
208 */
210 int timeoutMs = 0)= 0;
211
212 //------ remote limit switch ----------//
213 /**
214 * Configures the forward limit switch for a remote source. For example, a
215 * CAN motor controller may need to monitor the Limit-F pin of another Talon
216 * or CANifier.
217 *
218 * @param type
219 * Remote limit switch source. User can choose between a remote
220 * Talon SRX, CANifier, or deactivate the feature.
221 * @param normalOpenOrClose
222 * Setting for normally open, normally closed, or disabled. This
223 * setting matches the Phoenix Tuner drop down.
224 * @param deviceID
225 * Device ID of remote source (Talon SRX or CANifier device ID).
226 * @param timeoutMs
227 * Timeout value in ms. If nonzero, function will wait for config
228 * success and report an error if it times out. If zero, no
229 * blocking or checking is performed.
230 * @return Error Code generated by function. 0 indicates no error.
231 */
233 RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose,
234 int deviceID, int timeoutMs = 0) = 0;
235 /**
236 * Configures the reverse limit switch for a remote source. For example, a
237 * CAN motor controller may need to monitor the Limit-R pin of another Talon
238 * or CANifier.
239 *
240 * @param type
241 * Remote limit switch source. User can choose between a remote
242 * Talon SRX, CANifier, or deactivate the feature.
243 * @param normalOpenOrClose
244 * Setting for normally open, normally closed, or disabled. This
245 * setting matches the Phoenix Tuner drop down.
246 * @param deviceID
247 * Device ID of remote source (Talon SRX or CANifier device ID).
248 * @param timeoutMs
249 * Timeout value in ms. If nonzero, function will wait for config
250 * success and report an error if it times out. If zero, no
251 * blocking or checking is performed.
252 * @return Error Code generated by function. 0 indicates no error.
253 */
255 RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose,
256 int deviceID, int timeoutMs = 0) = 0;
257
258 //------ local limit switch ----------//
259 /**
260 * Configures the forward limit switch for a remote source. For example, a
261 * CAN motor controller may need to monitor the Limit-F pin of another Talon
262 * or CANifier.
263 *
264 * @param type
265 * Remote limit switch source. User can choose between a remote
266 * Talon SRX, CANifier, or deactivate the feature.
267 * @param normalOpenOrClose
268 * Setting for normally open, normally closed, or disabled. This
269 * setting matches the Phoenix Tuner drop down.
270 * @param timeoutMs
271 * Timeout value in ms. If nonzero, function will wait for config
272 * success and report an error if it times out. If zero, no
273 * blocking or checking is performed.
274 * @return Error Code generated by function. 0 indicates no error.
275 */
277 LimitSwitchNormal normalOpenOrClose, int timeoutMs = 0)= 0;
278 /**
279 * Configures the reverse limit switch for a remote source. For example, a
280 * CAN motor controller may need to monitor the Limit-R pin of another Talon
281 * or CANifier.
282 *
283 * @param type
284 * Remote limit switch source. User can choose between a remote
285 * Talon SRX, CANifier, or deactivate the feature.
286 * @param normalOpenOrClose
287 * Setting for normally open, normally closed, or disabled. This
288 * setting matches the Phoenix Tuner drop down.
289 * @param timeoutMs
290 * Timeout value in ms. If nonzero, function will wait for config
291 * success and report an error if it times out. If zero, no
292 * blocking or checking is performed.
293 * @return Error Code generated by function. 0 indicates no error.
294 */
296 LimitSwitchNormal normalOpenOrClose, int timeoutMs = 0)= 0;
297
298 //------ soft limit ----------//
299 /* in parent */
300
301 //------ General Close loop ----------//
302 /* in parent */
303
304 //------ Motion Profile Settings used in Motion Magic and Motion Profile ----------//
305 /* in parent */
306
307 //------ Motion Profile Buffer ----------//
308 /* in parent */
309
310 //------ error ----------//
311 /* in parent */
312
313 //------ Faults ----------//
314 /* in parent */
315
316 //------ Firmware ----------//
317 /* in parent */
318
319 //------ Custom Persistent Params ----------//
320 /* in parent */
321
322 //------ Generic Param API, typically not used ----------//
323 /* in parent */
324
325 //------ Misc. ----------//
326 /* in parent */
327
328}; // class IMotorControllerEnhanced
329} // namespace motorcontrol
330} // namespace phoenix
331} // namespace ctre
Interface for enhanced motor controllers.
Definition: IMotorControllerEnhanced.h:29
virtual ErrorCode SetStatusFramePeriod(StatusFrameEnhanced frame, uint8_t periodMs, int timeoutMs=0)=0
Sets the period of the given status frame.
virtual ErrorCode ConfigVelocityMeasurementWindow(int windowSize, int timeoutMs=0)=0
Sets the number of velocity samples used in the rolling average velocity measurement.
virtual ErrorCode ConfigSelectedFeedbackSensor(RemoteFeedbackDevice feedbackDevice, int pidIdx=0, int timeoutMs=0)=0
Select the feedback device for the motor controller.
virtual ErrorCode ConfigReverseLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int timeoutMs=0)=0
Configures the reverse limit switch for a remote source.
virtual ~IMotorControllerEnhanced()
Definition: IMotorControllerEnhanced.h:31
virtual int GetStatusFramePeriod(StatusFrame frame, int timeoutMs=0)=0
Gets the period of the given status frame.
virtual ErrorCode ConfigForwardLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int deviceID, int timeoutMs=0)=0
Configures the forward limit switch for a remote source.
virtual ErrorCode ConfigReverseLimitSwitchSource(RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int deviceID, int timeoutMs=0)=0
Configures the reverse limit switch for a remote source.
virtual ErrorCode SetStatusFramePeriod(StatusFrame frame, uint8_t periodMs, int timeoutMs=0)=0
Sets the period of the given status frame.
virtual int GetStatusFramePeriod(StatusFrameEnhanced frame, int timeoutMs=0)=0
Gets the period of the given status frame.
virtual ErrorCode ConfigForwardLimitSwitchSource(LimitSwitchSource type, LimitSwitchNormal normalOpenOrClose, int timeoutMs=0)=0
Configures the forward limit switch for a remote source.
virtual double GetOutputCurrent()=0
Gets the output current of the motor controller.
virtual ErrorCode ConfigVelocityMeasurementPeriod(VelocityMeasPeriod period, int timeoutMs=0)=0
Sets the period over which velocity measurements are taken.
virtual ErrorCode ConfigSelectedFeedbackSensor(FeedbackDevice feedbackDevice, int pidIdx=0, int timeoutMs=0)=0
Select the feedback device for the motor controller.
virtual ErrorCode ConfigSupplyCurrentLimit(const SupplyCurrentLimitConfiguration &currLimitConfigs, int timeoutMs=50)=0
Configures the supply-side current limit.
Interface for motor controllers.
Definition: IMotorController.h:35
StatusFrameEnhanced
The different status frames available to enhanced motor controllers.
Definition: StatusFrame.h:11
LimitSwitchNormal
Choose whether the limit switch is normally open or normally closed.
Definition: LimitSwitchType.h:62
RemoteFeedbackDevice
Choose the remote feedback device for a motor controller.
Definition: FeedbackDevice.h:179
RemoteLimitSwitchSource
Remote Limit switch source enum.
Definition: LimitSwitchType.h:35
FeedbackDevice
Choose the feedback device for a motor controller.
Definition: FeedbackDevice.h:14
VelocityMeasPeriod
Velocity Measurement Periods.
Definition: VelocityMeasPeriod.h:13
StatusFrame
The different status frames available to motor controllers.
Definition: StatusFrame.h:99
LimitSwitchSource
Limit switch source enum.
Definition: LimitSwitchType.h:11
ErrorCode
Definition: ErrorCode.h:13
namespace ctre
Definition: paramEnum.h:5
Describes the desired stator current limiting behavior.
Definition: SupplyCurrentLimitConfiguration.h:13