CTRE Phoenix C++ 5.35.1
Loading...
Searching...
No Matches
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 *
173 * [[deprecated("Use GetStatorCurrent/GetSupplyCurrent instead.")]]
174 *
175 * @return The output current (in amps).
176 */
177 virtual double GetOutputCurrent() = 0;
178
179 //----- velocity signal conditionaing ------//
180 /**
181 * Sets the period over which velocity measurements are taken.
182 *
183 * @param period
184 * Desired period for the velocity measurement. @see
185 * com.ctre.phoenix.motorcontrol.VelocityMeasPeriod
186 * @param timeoutMs
187 * Timeout value in ms. If nonzero, function will wait for
188 * config success and report an error if it times out.
189 * If zero, no blocking or checking is performed.
190 * @return Error Code generated by function. 0 indicates no error.
191 */
193 int timeoutMs = 0)= 0;
194 /**
195 * Sets the number of velocity samples used in the rolling average velocity
196 * measurement.
197 *
198 * @param windowSize
199 * Number of samples in the rolling average of velocity
200 * measurement. Valid values are 1,2,4,8,16,32. If another value
201 * is specified, it will truncate to nearest support value.
202 * @param timeoutMs
203 * Timeout value in ms. If nonzero, function will wait for config
204 * success and report an error if it times out. If zero, no
205 * blocking or checking is performed.
206 * @return Error Code generated by function. 0 indicates no error.
207 */
209 int timeoutMs = 0)= 0;
210
211 //------ remote limit switch ----------//
212 /**
213 * Configures the forward limit switch for a remote source. For example, a
214 * CAN motor controller may need to monitor the Limit-F pin of another Talon
215 * or CANifier.
216 *
217 * @param type
218 * Remote limit switch source. User can choose between a remote
219 * Talon SRX, CANifier, or deactivate the feature.
220 * @param normalOpenOrClose
221 * Setting for normally open, normally closed, or disabled. This
222 * setting matches the Phoenix Tuner drop down.
223 * @param deviceID
224 * Device ID of remote source (Talon SRX or CANifier device ID).
225 * @param timeoutMs
226 * Timeout value in ms. If nonzero, function will wait for config
227 * success and report an error if it times out. If zero, no
228 * blocking or checking is performed.
229 * @return Error Code generated by function. 0 indicates no error.
230 */
232 RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose,
233 int deviceID, int timeoutMs = 0) = 0;
234 /**
235 * Configures the reverse limit switch for a remote source. For example, a
236 * CAN motor controller may need to monitor the Limit-R pin of another Talon
237 * or CANifier.
238 *
239 * @param type
240 * Remote limit switch source. User can choose between a remote
241 * Talon SRX, CANifier, or deactivate the feature.
242 * @param normalOpenOrClose
243 * Setting for normally open, normally closed, or disabled. This
244 * setting matches the Phoenix Tuner drop down.
245 * @param deviceID
246 * Device ID of remote source (Talon SRX or CANifier device ID).
247 * @param timeoutMs
248 * Timeout value in ms. If nonzero, function will wait for config
249 * success and report an error if it times out. If zero, no
250 * blocking or checking is performed.
251 * @return Error Code generated by function. 0 indicates no error.
252 */
254 RemoteLimitSwitchSource type, LimitSwitchNormal normalOpenOrClose,
255 int deviceID, int timeoutMs = 0) = 0;
256
257 //------ local limit switch ----------//
258 /**
259 * Configures the forward limit switch for a remote source. For example, a
260 * CAN motor controller may need to monitor the Limit-F pin of another Talon
261 * or CANifier.
262 *
263 * @param type
264 * Remote limit switch source. User can choose between a remote
265 * Talon SRX, CANifier, or deactivate the feature.
266 * @param normalOpenOrClose
267 * Setting for normally open, normally closed, or disabled. This
268 * setting matches the Phoenix Tuner drop down.
269 * @param timeoutMs
270 * Timeout value in ms. If nonzero, function will wait for config
271 * success and report an error if it times out. If zero, no
272 * blocking or checking is performed.
273 * @return Error Code generated by function. 0 indicates no error.
274 */
276 LimitSwitchNormal normalOpenOrClose, int timeoutMs = 0)= 0;
277 /**
278 * Configures the reverse limit switch for a remote source. For example, a
279 * CAN motor controller may need to monitor the Limit-R pin of another Talon
280 * or CANifier.
281 *
282 * @param type
283 * Remote limit switch source. User can choose between a remote
284 * Talon SRX, CANifier, or deactivate the feature.
285 * @param normalOpenOrClose
286 * Setting for normally open, normally closed, or disabled. This
287 * setting matches the Phoenix Tuner drop down.
288 * @param timeoutMs
289 * Timeout value in ms. If nonzero, function will wait for config
290 * success and report an error if it times out. If zero, no
291 * blocking or checking is performed.
292 * @return Error Code generated by function. 0 indicates no error.
293 */
295 LimitSwitchNormal normalOpenOrClose, int timeoutMs = 0)= 0;
296
297 //------ soft limit ----------//
298 /* in parent */
299
300 //------ General Close loop ----------//
301 /* in parent */
302
303 //------ Motion Profile Settings used in Motion Magic and Motion Profile ----------//
304 /* in parent */
305
306 //------ Motion Profile Buffer ----------//
307 /* in parent */
308
309 //------ error ----------//
310 /* in parent */
311
312 //------ Faults ----------//
313 /* in parent */
314
315 //------ Firmware ----------//
316 /* in parent */
317
318 //------ Custom Persistent Params ----------//
319 /* in parent */
320
321 //------ Generic Param API, typically not used ----------//
322 /* in parent */
323
324 //------ Misc. ----------//
325 /* in parent */
326
327}; // class IMotorControllerEnhanced
328} // namespace motorcontrol
329} // namespace phoenix
330} // 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:131
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
WPI Compliant CANcoder class.
Definition CANCoderStatusFrame.h:4
Describes the desired stator current limiting behavior.
Definition SupplyCurrentLimitConfiguration.h:13