Loading [MathJax]/extensions/tex2jax.js
CTRE Phoenix 6 C++ 23.10.0-alpha-8
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Configs.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
14#include <sstream>
15#include <map>
16#include <string>
17
18namespace ctre {
19namespace phoenix6 {
20
21namespace hardware { namespace core { class CoreCANcoder; } }
22namespace configs { class SlotConfigs; }
23
24namespace configs {
25
27{
28public:
29 virtual std::string ToString() const = 0;
30 friend std::ostream &operator<<(std::ostream &str, const ParentConfiguration &v)
31 {
32 str << v.ToString();
33 return str;
34 }
35 virtual ctre::phoenix::StatusCode Deserialize(const std::string &string) = 0;
36};
37
38
39/**
40 * \brief Configs that affect the magnet sensor and how to interpret
41 * it.
42 *
43 * \details Includes sensor range and other configs related to sensor.
44 */
46{
47public:
48 /**
49 * \brief Direction of the sensor to determine positive facing the LED
50 * side of the CANcoder.
51 *
52 */
54 /**
55 * \brief This offset is added to the reported position, allowing the
56 * application to trim the zero position. When set to the default
57 * value of zero, position reports zero when magnet north pole aligns
58 * with the LED.
59 *
60 * Minimum Value: -1
61 * Maximum Value: 1
62 * Default Value: 0
63 * Units: rotations
64 */
65 double MagnetOffset = 0;
66 /**
67 * \brief The range of the absolute sensor, either [0, 1) or [-0.5,
68 * 0.5).
69 *
70 */
72
73
74
75 std::string ToString() const override
76 {
77 std::stringstream ss;
78 ss << "{" << std::endl;
79 ss << "Config Group: MagnetSensor" << std::endl;
80 ss << "Name: \"SensorDirection\" Value: \"" << SensorDirection << "\"" << std::endl;
81 ss << "Name: \"MagnetOffset\" Value: \"" << MagnetOffset << "rotations\"" << std::endl;
82 ss << "Name: \"AbsoluteSensorRange\" Value: \"" << AbsoluteSensorRange << "\"" << std::endl;
83 ss << "}" << std::endl;
84 return ss.str();
85 }
86
87 std::string Serialize() const override
88 {
89 std::stringstream ss;
90 char *ref;
91 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CANcoder_SensorDirection, SensorDirection.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
92 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANCoder_MagnetOffset, MagnetOffset, &ref); if (ref != nullptr) { ss << ref; free(ref); }
93 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CANcoder_AbsoluteSensorRange, AbsoluteSensorRange.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
94 return ss.str();
95 }
96
97 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
98 {
99 const char *string_c_str = to_deserialize.c_str();
100 size_t string_length = to_deserialize.length();
101 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CANcoder_SensorDirection, string_c_str, string_length, &SensorDirection.value);
102 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANCoder_MagnetOffset, string_c_str, string_length, &MagnetOffset);
103 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CANcoder_AbsoluteSensorRange, string_c_str, string_length, &AbsoluteSensorRange.value);
104 return 0;
105 }
106};
107
108
109/**
110 * \brief Configs for Pigeon 2's Mount Pose configuration.
111 *
112 * \details These configs allow the Pigeon2 to be mounted in whatever
113 * orientation that's desired and ensure the reported
114 * Yaw/Pitch/Roll is from the robot's reference.
115 */
117{
118public:
119 /**
120 * \brief The mounting calibration yaw-component
121 *
122 * Minimum Value: -360
123 * Maximum Value: 360
124 * Default Value: 0
125 * Units: deg
126 */
127 double MountPoseYaw = 0;
128 /**
129 * \brief The mounting calibration pitch-component
130 *
131 * Minimum Value: -360
132 * Maximum Value: 360
133 * Default Value: 0
134 * Units: deg
135 */
136 double MountPosePitch = 0;
137 /**
138 * \brief The mounting calibration roll-component
139 *
140 * Minimum Value: -360
141 * Maximum Value: 360
142 * Default Value: 0
143 * Units: deg
144 */
145 double MountPoseRoll = 0;
146
147
148
149 std::string ToString() const override
150 {
151 std::stringstream ss;
152 ss << "{" << std::endl;
153 ss << "Config Group: MountPose" << std::endl;
154 ss << "Name: \"MountPoseYaw\" Value: \"" << MountPoseYaw << "deg\"" << std::endl;
155 ss << "Name: \"MountPosePitch\" Value: \"" << MountPosePitch << "deg\"" << std::endl;
156 ss << "Name: \"MountPoseRoll\" Value: \"" << MountPoseRoll << "deg\"" << std::endl;
157 ss << "}" << std::endl;
158 return ss.str();
159 }
160
161 std::string Serialize() const override
162 {
163 std::stringstream ss;
164 char *ref;
165 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseYaw, MountPoseYaw, &ref); if (ref != nullptr) { ss << ref; free(ref); }
166 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPosePitch, MountPosePitch, &ref); if (ref != nullptr) { ss << ref; free(ref); }
167 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseRoll, MountPoseRoll, &ref); if (ref != nullptr) { ss << ref; free(ref); }
168 return ss.str();
169 }
170
171 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
172 {
173 const char *string_c_str = to_deserialize.c_str();
174 size_t string_length = to_deserialize.length();
175 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseYaw, string_c_str, string_length, &MountPoseYaw);
176 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPosePitch, string_c_str, string_length, &MountPosePitch);
177 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseRoll, string_c_str, string_length, &MountPoseRoll);
178 return 0;
179 }
180};
181
182
183/**
184 * \brief Configs to trim the Pigeon2's gyroscope.
185 *
186 * \details Pigeon2 allows the user to trim the gyroscope's
187 * sensitivity. While this isn't necessary for the Pigeon2,
188 * as it comes calibrated out-of-the-box, users can make use
189 * of this to make the Pigeon2 even more accurate for their
190 * application.
191 */
193{
194public:
195 /**
196 * \brief The gyro scalar component for the X axis
197 *
198 * Minimum Value: -180
199 * Maximum Value: 180
200 * Default Value: 0
201 * Units: deg per rotation
202 */
203 double GyroScalarX = 0;
204 /**
205 * \brief The gyro scalar component for the Y axis
206 *
207 * Minimum Value: -180
208 * Maximum Value: 180
209 * Default Value: 0
210 * Units: deg per rotation
211 */
212 double GyroScalarY = 0;
213 /**
214 * \brief The gyro scalar component for the Z axis
215 *
216 * Minimum Value: -180
217 * Maximum Value: 180
218 * Default Value: 0
219 * Units: deg per rotation
220 */
221 double GyroScalarZ = 0;
222
223
224
225 std::string ToString() const override
226 {
227 std::stringstream ss;
228 ss << "{" << std::endl;
229 ss << "Config Group: GyroTrim" << std::endl;
230 ss << "Name: \"GyroScalarX\" Value: \"" << GyroScalarX << "deg per rotation\"" << std::endl;
231 ss << "Name: \"GyroScalarY\" Value: \"" << GyroScalarY << "deg per rotation\"" << std::endl;
232 ss << "Name: \"GyroScalarZ\" Value: \"" << GyroScalarZ << "deg per rotation\"" << std::endl;
233 ss << "}" << std::endl;
234 return ss.str();
235 }
236
237 std::string Serialize() const override
238 {
239 std::stringstream ss;
240 char *ref;
241 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarX, GyroScalarX, &ref); if (ref != nullptr) { ss << ref; free(ref); }
242 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarY, GyroScalarY, &ref); if (ref != nullptr) { ss << ref; free(ref); }
243 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarZ, GyroScalarZ, &ref); if (ref != nullptr) { ss << ref; free(ref); }
244 return ss.str();
245 }
246
247 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
248 {
249 const char *string_c_str = to_deserialize.c_str();
250 size_t string_length = to_deserialize.length();
251 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarX, string_c_str, string_length, &GyroScalarX);
252 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarY, string_c_str, string_length, &GyroScalarY);
253 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarZ, string_c_str, string_length, &GyroScalarZ);
254 return 0;
255 }
256};
257
258
259/**
260 * \brief Configs to enable/disable various features of the Pigeon2.
261 *
262 * \details These configs allow the user to enable or disable various
263 * aspects of the Pigeon2.
264 */
266{
267public:
268 /**
269 * \brief Turns on or off the magnetometer fusing for 9-axis. FRC
270 * users are not recommended to turn this on, as the magnetic
271 * influence of the robot will likely negatively affect the
272 * performance of the Pigeon2.
273 *
274 * Default Value: False
275 */
276 bool EnableCompass = false;
277 /**
278 * \brief Disables using the temperature compensation feature
279 *
280 * Default Value: False
281 */
283 /**
284 * \brief Disables using the no-motion calibration feature
285 *
286 * Default Value: False
287 */
289
290
291
292 std::string ToString() const override
293 {
294 std::stringstream ss;
295 ss << "{" << std::endl;
296 ss << "Config Group: Pigeon2Features" << std::endl;
297 ss << "Name: \"EnableCompass\" Value: \"" << EnableCompass << "\"" << std::endl;
298 ss << "Name: \"DisableTemperatureCompensation\" Value: \"" << DisableTemperatureCompensation << "\"" << std::endl;
299 ss << "Name: \"DisableNoMotionCalibration\" Value: \"" << DisableNoMotionCalibration << "\"" << std::endl;
300 ss << "}" << std::endl;
301 return ss.str();
302 }
303
304 std::string Serialize() const override
305 {
306 std::stringstream ss;
307 char *ref;
308 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2UseCompass, EnableCompass, &ref); if (ref != nullptr) { ss << ref; free(ref); }
309 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableTemperatureCompensation, DisableTemperatureCompensation, &ref); if (ref != nullptr) { ss << ref; free(ref); }
310 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableNoMotionCalibration, DisableNoMotionCalibration, &ref); if (ref != nullptr) { ss << ref; free(ref); }
311 return ss.str();
312 }
313
314 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
315 {
316 const char *string_c_str = to_deserialize.c_str();
317 size_t string_length = to_deserialize.length();
318 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2UseCompass, string_c_str, string_length, &EnableCompass);
319 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableTemperatureCompensation, string_c_str, string_length, &DisableTemperatureCompensation);
320 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableNoMotionCalibration, string_c_str, string_length, &DisableNoMotionCalibration);
321 return 0;
322 }
323};
324
325
326/**
327 * \brief Configs that directly affect motor-output.
328 *
329 * \details Includes Motor Invert and various limit features.
330 */
332{
333public:
334 /**
335 * \brief Invert state of the device
336 *
337 */
339 /**
340 * \brief The state of the motor controller bridge when output is
341 * neutral or disabled.
342 *
343 */
345 /**
346 * \brief Configures the output deadband percentage.
347 *
348 * Minimum Value: 0.0
349 * Maximum Value: 0.25
350 * Default Value: 0
351 * Units: fractional
352 */
354 /**
355 * \brief Maximum (forward) output during duty cycle based control
356 * modes.
357 *
358 * Minimum Value: -1.0
359 * Maximum Value: 1.0
360 * Default Value: 1
361 * Units: fractional
362 */
364 /**
365 * \brief Minimum (reverse) output during duty cycle based control
366 * modes.
367 *
368 * Minimum Value: -1.0
369 * Maximum Value: 1.0
370 * Default Value: -1
371 * Units: fractional
372 */
374
375
376
377 std::string ToString() const override
378 {
379 std::stringstream ss;
380 ss << "{" << std::endl;
381 ss << "Config Group: MotorOutput" << std::endl;
382 ss << "Name: \"Inverted\" Value: \"" << Inverted << "\"" << std::endl;
383 ss << "Name: \"NeutralMode\" Value: \"" << NeutralMode << "\"" << std::endl;
384 ss << "Name: \"DutyCycleNeutralDeadband\" Value: \"" << DutyCycleNeutralDeadband << "fractional\"" << std::endl;
385 ss << "Name: \"PeakForwardDutyCycle\" Value: \"" << PeakForwardDutyCycle << "fractional\"" << std::endl;
386 ss << "Name: \"PeakReverseDutyCycle\" Value: \"" << PeakReverseDutyCycle << "fractional\"" << std::endl;
387 ss << "}" << std::endl;
388 return ss.str();
389 }
390
391 std::string Serialize() const override
392 {
393 std::stringstream ss;
394 char *ref;
395 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_Inverted, Inverted.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
396 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_NeutralMode, NeutralMode.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
397 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleNeutralDB, DutyCycleNeutralDeadband, &ref); if (ref != nullptr) { ss << ref; free(ref); }
398 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardDC, PeakForwardDutyCycle, &ref); if (ref != nullptr) { ss << ref; free(ref); }
399 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseDC, PeakReverseDutyCycle, &ref); if (ref != nullptr) { ss << ref; free(ref); }
400 return ss.str();
401 }
402
403 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
404 {
405 const char *string_c_str = to_deserialize.c_str();
406 size_t string_length = to_deserialize.length();
407 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_Inverted, string_c_str, string_length, &Inverted.value);
408 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_NeutralMode, string_c_str, string_length, &NeutralMode.value);
409 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleNeutralDB, string_c_str, string_length, &DutyCycleNeutralDeadband);
410 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardDC, string_c_str, string_length, &PeakForwardDutyCycle);
411 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseDC, string_c_str, string_length, &PeakReverseDutyCycle);
412 return 0;
413 }
414};
415
416
417/**
418 * \brief Configs that directly affect current limiting features.
419 *
420 * \details Contains the supply/stator current limit thresholds and
421 * whether to enable them or not.
422 */
424{
425public:
426 /**
427 * \brief The amount of current allowed in the motor (motoring and
428 * regen current). This is only applicable for non-torque current
429 * control modes. Note this requires the corresponding enable to be
430 * true.
431 *
432 * Minimum Value: 0.0
433 * Maximum Value: 800.0
434 * Default Value: 0
435 * Units: A
436 */
438 /**
439 * \brief Enable motor stator current limiting.
440 *
441 * Default Value: False
442 */
444 /**
445 * \brief The amount of supply current allowed. This is only
446 * applicable for non-torque current control modes. Note this
447 * requires the corresponding enable to be true. Use
448 * SupplyCurrentThreshold and SupplyTimeThreshold to allow brief
449 * periods of high-current before limiting occurs.
450 *
451 * Minimum Value: 0.0
452 * Maximum Value: 800.0
453 * Default Value: 0
454 * Units: A
455 */
457 /**
458 * \brief Enable motor supply current limiting.
459 *
460 * Default Value: False
461 */
463 /**
464 * \brief Delay supply current limiting until current exceeds this
465 * threshold for longer than SupplyTimeThreshold. This allows current
466 * draws above SupplyCurrentLimit for a fixed period of time. This
467 * has no effect if SupplyCurrentLimit is greater than this value.
468 *
469 * Minimum Value: 0.0
470 * Maximum Value: 511
471 * Default Value: 0
472 * Units: A
473 */
475 /**
476 * \brief Allows unlimited current for a period of time before current
477 * limiting occurs. Current threshold is the maximum of
478 * SupplyCurrentThreshold and SupplyCurrentLimit.
479 *
480 * Minimum Value: 0.0
481 * Maximum Value: 1.275
482 * Default Value: 0
483 * Units: sec
484 */
486
487
488
489 std::string ToString() const override
490 {
491 std::stringstream ss;
492 ss << "{" << std::endl;
493 ss << "Config Group: CurrentLimits" << std::endl;
494 ss << "Name: \"StatorCurrentLimit\" Value: \"" << StatorCurrentLimit << "A\"" << std::endl;
495 ss << "Name: \"StatorCurrentLimitEnable\" Value: \"" << StatorCurrentLimitEnable << "\"" << std::endl;
496 ss << "Name: \"SupplyCurrentLimit\" Value: \"" << SupplyCurrentLimit << "A\"" << std::endl;
497 ss << "Name: \"SupplyCurrentLimitEnable\" Value: \"" << SupplyCurrentLimitEnable << "\"" << std::endl;
498 ss << "Name: \"SupplyCurrentThreshold\" Value: \"" << SupplyCurrentThreshold << "A\"" << std::endl;
499 ss << "Name: \"SupplyTimeThreshold\" Value: \"" << SupplyTimeThreshold << "sec\"" << std::endl;
500 ss << "}" << std::endl;
501 return ss.str();
502 }
503
504 std::string Serialize() const override
505 {
506 std::stringstream ss;
507 char *ref;
508 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_StatorCurrentLimit, StatorCurrentLimit, &ref); if (ref != nullptr) { ss << ref; free(ref); }
509 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_StatorCurrLimitEn, StatorCurrentLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
510 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrentLimit, SupplyCurrentLimit, &ref); if (ref != nullptr) { ss << ref; free(ref); }
511 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrLimitEn, SupplyCurrentLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
512 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrThres, SupplyCurrentThreshold, &ref); if (ref != nullptr) { ss << ref; free(ref); }
513 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyTimeThres, SupplyTimeThreshold, &ref); if (ref != nullptr) { ss << ref; free(ref); }
514 return ss.str();
515 }
516
517 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
518 {
519 const char *string_c_str = to_deserialize.c_str();
520 size_t string_length = to_deserialize.length();
521 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_StatorCurrentLimit, string_c_str, string_length, &StatorCurrentLimit);
522 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_StatorCurrLimitEn, string_c_str, string_length, &StatorCurrentLimitEnable);
523 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrentLimit, string_c_str, string_length, &SupplyCurrentLimit);
524 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrLimitEn, string_c_str, string_length, &SupplyCurrentLimitEnable);
525 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrThres, string_c_str, string_length, &SupplyCurrentThreshold);
526 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyTimeThres, string_c_str, string_length, &SupplyTimeThreshold);
527 return 0;
528 }
529};
530
531
532/**
533 * \brief Voltage-specific configs
534 *
535 * \details Voltage-specific configs
536 */
538{
539public:
540 /**
541 * \brief The time constant (in seconds) of the low-pass filter for
542 * the supply voltage.
543 *
544 * \details This impacts the filtering for the reported supply
545 * voltage, and any control strategies that use the supply voltage
546 * (such as voltage control on a motor controller).
547 *
548 * Minimum Value: 0.0
549 * Maximum Value: 0.1
550 * Default Value: 0
551 * Units: sec
552 */
554 /**
555 * \brief Maximum (forward) output during voltage based control modes.
556 *
557 * Minimum Value: -16
558 * Maximum Value: 16
559 * Default Value: 16
560 * Units: V
561 */
563 /**
564 * \brief Minimum (reverse) output during voltage based control modes.
565 *
566 * Minimum Value: -16
567 * Maximum Value: 16
568 * Default Value: -16
569 * Units: V
570 */
571 double PeakReverseVoltage = -16;
572
573
574
575 std::string ToString() const override
576 {
577 std::stringstream ss;
578 ss << "{" << std::endl;
579 ss << "Config Group: Voltage" << std::endl;
580 ss << "Name: \"SupplyVoltageTimeConstant\" Value: \"" << SupplyVoltageTimeConstant << "sec\"" << std::endl;
581 ss << "Name: \"PeakForwardVoltage\" Value: \"" << PeakForwardVoltage << "V\"" << std::endl;
582 ss << "Name: \"PeakReverseVoltage\" Value: \"" << PeakReverseVoltage << "V\"" << std::endl;
583 ss << "}" << std::endl;
584 return ss.str();
585 }
586
587 std::string Serialize() const override
588 {
589 std::stringstream ss;
590 char *ref;
591 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyVLowpassTau, SupplyVoltageTimeConstant, &ref); if (ref != nullptr) { ss << ref; free(ref); }
592 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardV, PeakForwardVoltage, &ref); if (ref != nullptr) { ss << ref; free(ref); }
593 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseV, PeakReverseVoltage, &ref); if (ref != nullptr) { ss << ref; free(ref); }
594 return ss.str();
595 }
596
597 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
598 {
599 const char *string_c_str = to_deserialize.c_str();
600 size_t string_length = to_deserialize.length();
601 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyVLowpassTau, string_c_str, string_length, &SupplyVoltageTimeConstant);
602 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardV, string_c_str, string_length, &PeakForwardVoltage);
603 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseV, string_c_str, string_length, &PeakReverseVoltage);
604 return 0;
605 }
606};
607
608
609/**
610 * \brief Configs to control the maximum and minimum applied torque
611 * when using Torque Current control types.
612 *
613 * \details Similar to peak output, but for the TorqueCurrentFOC
614 * control type requests.
615 */
617{
618public:
619 /**
620 * \brief Maximum (forward) output during torque current based control
621 * modes.
622 *
623 * Minimum Value: -800
624 * Maximum Value: 800
625 * Default Value: 800
626 * Units: A
627 */
629 /**
630 * \brief Minimum (reverse) output during torque current based control
631 * modes.
632 *
633 * Minimum Value: -800
634 * Maximum Value: 800
635 * Default Value: -800
636 * Units: A
637 */
639 /**
640 * \brief Configures the output deadband during torque current based
641 * control modes.
642 *
643 * Minimum Value: 0
644 * Maximum Value: 25
645 * Default Value: 0.0
646 * Units: A
647 */
649
650
651
652 std::string ToString() const override
653 {
654 std::stringstream ss;
655 ss << "{" << std::endl;
656 ss << "Config Group: TorqueCurrent" << std::endl;
657 ss << "Name: \"PeakForwardTorqueCurrent\" Value: \"" << PeakForwardTorqueCurrent << "A\"" << std::endl;
658 ss << "Name: \"PeakReverseTorqueCurrent\" Value: \"" << PeakReverseTorqueCurrent << "A\"" << std::endl;
659 ss << "Name: \"TorqueNeutralDeadband\" Value: \"" << TorqueNeutralDeadband << "A\"" << std::endl;
660 ss << "}" << std::endl;
661 return ss.str();
662 }
663
664 std::string Serialize() const override
665 {
666 std::stringstream ss;
667 char *ref;
668 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForTorqCurr, PeakForwardTorqueCurrent, &ref); if (ref != nullptr) { ss << ref; free(ref); }
669 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakRevTorqCurr, PeakReverseTorqueCurrent, &ref); if (ref != nullptr) { ss << ref; free(ref); }
670 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueNeutralDB, TorqueNeutralDeadband, &ref); if (ref != nullptr) { ss << ref; free(ref); }
671 return ss.str();
672 }
673
674 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
675 {
676 const char *string_c_str = to_deserialize.c_str();
677 size_t string_length = to_deserialize.length();
678 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForTorqCurr, string_c_str, string_length, &PeakForwardTorqueCurrent);
679 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakRevTorqCurr, string_c_str, string_length, &PeakReverseTorqueCurrent);
680 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueNeutralDB, string_c_str, string_length, &TorqueNeutralDeadband);
681 return 0;
682 }
683};
684
685
686/**
687 * \brief Configs that affect the feedback of this motor controller.
688 *
689 * \details Includes feedback sensor source, any offsets for the
690 * feedback sensor, and various ratios to describe the
691 * relationship between the sensor and the mechanism for
692 * closed looping.
693 */
695{
696public:
697 /**
698 * \brief This offset is applied to the absolute integrated rotor
699 * sensor. This can be used to zero the rotor in applications that
700 * are within one rotor rotation.
701 *
702 * Minimum Value: -1
703 * Maximum Value: 1
704 * Default Value: 0.0
705 * Units: rotations
706 */
708 /**
709 * \brief This is the ratio of sensor rotations to the mechanism's
710 * output. This is equivalent to the mechanism's gear ratio if the
711 * sensor is located on the input of a gearbox. If sensor is on the
712 * output of a gearbox, then this is typically set to 1. Note if this
713 * is set to zero, device will reset back to one.
714 *
715 * Minimum Value: -1000
716 * Maximum Value: 1000
717 * Default Value: 1.0
718 * Units: scalar
719 */
721 /**
722 * \brief Talon FX is capable of fusing a remote CANcoder with its
723 * rotor sensor to produce a high-bandwidth sensor source. This
724 * feature requires specifying the ratio between the remote sensor and
725 * the motor rotor. Note if this is set to zero, device will reset
726 * back to one.
727 *
728 * Minimum Value: -1000
729 * Maximum Value: 1000
730 * Default Value: 1.0
731 * Units: scalar
732 */
733 double RotorToSensorRatio = 1.0;
734 /**
735 * \brief Choose what sensor source is reported via API and used by
736 * closed-loop and limit features. The default is RotorSensor, which
737 * uses the internal rotor sensor in the Talon FX. Choose
738 * RemoteCANcoder to use another CANcoder on the same CAN bus (this
739 * also requires setting FeedbackRemoteSensorID). Talon FX will
740 * update its position and velocity whenever CANcoder publishes its
741 * information on CAN bus. Choose FusedCANcoder (requires Phoenix
742 * Pro) and Talon FX will fuse another CANcoder's information with the
743 * internal rotor, which provides the best possible position and
744 * velocity for accuracy and bandwidth (note this requires setting
745 * FeedbackRemoteSensorID). FusedCANcoder was developed for
746 * applications such as swerve-azimuth. Choose SyncCANcoder (requires
747 * Phoenix Pro) and Talon FX will synchronize its internal rotor
748 * position against another CANcoder, then continue to use the rotor
749 * sensor for closed loop control (note this requires setting
750 * FeedbackRemoteSensorID). The TalonFX will report if its internal
751 * position differs significantly from the reported CANcoder position.
752 * SyncCANcoder was developed for mechanisms where there is a risk of
753 * the CANcoder failing in such a way that it reports a position that
754 * does not match the mechanism, such as the sensor mounting assembly
755 * breaking off. Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
756 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
757 * also requires setting FeedbackRemoteSensorID). Talon FX will
758 * update its position to match the selected value whenever Pigeon2
759 * publishes its information on CAN bus. Note that the Talon FX
760 * position will be in rotations and not degrees.
761 *
762 * \details Note: When the Talon Source is changed to FusedCANcoder,
763 * the Talon needs a period of time to fuse before sensor-based
764 * (soft-limit, closed loop, etc.) features are used. This period of
765 * time is determined by the update frequency of the CANcoder's
766 * Position signal.
767 *
768 */
770 /**
771 * \brief Device ID of which remote device to use. This is not used
772 * if the Sensor Source is the internal rotor sensor.
773 *
774 * Minimum Value: 0
775 * Maximum Value: 62
776 * Default Value: 0
777 * Units:
778 */
780
781 /**
782 * \brief Helper method to configure this feedback group to use Fused
783 * CANcoder by passing in the CANcoder object
784 *
785 * \param device CANcoder reference to use for FusedCANcoder
786 */
788
789 /**
790 * \brief Helper method to configure this feedback group to use Remote
791 * CANcoder by passing in the CANcoder object
792 *
793 * \param device CANcoder reference to use for FusedCANcoder
794 */
796
797
798
799 std::string ToString() const override
800 {
801 std::stringstream ss;
802 ss << "{" << std::endl;
803 ss << "Config Group: Feedback" << std::endl;
804 ss << "Name: \"FeedbackRotorOffset\" Value: \"" << FeedbackRotorOffset << "rotations\"" << std::endl;
805 ss << "Name: \"SensorToMechanismRatio\" Value: \"" << SensorToMechanismRatio << "scalar\"" << std::endl;
806 ss << "Name: \"RotorToSensorRatio\" Value: \"" << RotorToSensorRatio << "scalar\"" << std::endl;
807 ss << "Name: \"FeedbackSensorSource\" Value: \"" << FeedbackSensorSource << "\"" << std::endl;
808 ss << "Name: \"FeedbackRemoteSensorID\" Value: \"" << FeedbackRemoteSensorID << "\"" << std::endl;
809 ss << "}" << std::endl;
810 return ss.str();
811 }
812
813 std::string Serialize() const override
814 {
815 std::stringstream ss;
816 char *ref;
817 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_FeedbackRotorOffset, FeedbackRotorOffset, &ref); if (ref != nullptr) { ss << ref; free(ref); }
818 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SensorToMechanismRatio, SensorToMechanismRatio, &ref); if (ref != nullptr) { ss << ref; free(ref); }
819 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_RotorToSensorRatio, RotorToSensorRatio, &ref); if (ref != nullptr) { ss << ref; free(ref); }
820 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackSensorSource, FeedbackSensorSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
821 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackRemoteSensorID, FeedbackRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
822 return ss.str();
823 }
824
825 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
826 {
827 const char *string_c_str = to_deserialize.c_str();
828 size_t string_length = to_deserialize.length();
829 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_FeedbackRotorOffset, string_c_str, string_length, &FeedbackRotorOffset);
830 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SensorToMechanismRatio, string_c_str, string_length, &SensorToMechanismRatio);
831 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_RotorToSensorRatio, string_c_str, string_length, &RotorToSensorRatio);
832 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackSensorSource, string_c_str, string_length, &FeedbackSensorSource.value);
833 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackRemoteSensorID, string_c_str, string_length, &FeedbackRemoteSensorID);
834 return 0;
835 }
836};
837
838
839/**
840 * \brief Configs related to sensors used for differential control of
841 * a mechanism.
842 *
843 * \details Includes the differential sensor sources and IDs.
844 */
846{
847public:
848 /**
849 * \brief Choose what sensor source is used for differential control
850 * of a mechanism. The default is Disabled. All other options
851 * require setting the DifferentialTalonFXSensorID, as the average of
852 * this Talon FX's sensor and the remote TalonFX's sensor is used for
853 * the differential controller's primary targets. Choose
854 * RemoteTalonFX_Diff to use another TalonFX on the same CAN bus.
855 * Talon FX will update its differential position and velocity
856 * whenever the remote TalonFX publishes its information on CAN bus.
857 * The differential controller will use the difference between this
858 * TalonFX's sensor and the remote Talon FX's sensor for the
859 * differential component of the output. Choose RemotePigeon2_Yaw,
860 * RemotePigeon2_Pitch, and RemotePigeon2_Roll to use another Pigeon2
861 * on the same CAN bus (this also requires setting
862 * DifferentialRemoteSensorID). Talon FX will update its differential
863 * position to match the selected value whenever Pigeon2 publishes its
864 * information on CAN bus. Note that the Talon FX differential
865 * position will be in rotations and not degrees. Choose
866 * RemoteCANcoder to use another CANcoder on the same CAN bus (this
867 * also requires setting DifferentialRemoteSensorID). Talon FX will
868 * update its differential position and velocity to match the CANcoder
869 * whenever CANcoder publishes its information on CAN bus.
870 *
871 */
873 /**
874 * \brief Device ID of which remote Talon FX to use. This is used
875 * when the Differential Sensor Source is not disabled.
876 *
877 * Minimum Value: 0
878 * Maximum Value: 62
879 * Default Value: 0
880 * Units:
881 */
883 /**
884 * \brief Device ID of which remote sensor to use on the differential
885 * axis. This is used when the Differential Sensor Source is not
886 * RemoteTalonFX_Diff.
887 *
888 * Minimum Value: 0
889 * Maximum Value: 62
890 * Default Value: 0
891 * Units:
892 */
894
895
896
897 std::string ToString() const override
898 {
899 std::stringstream ss;
900 ss << "{" << std::endl;
901 ss << "Config Group: DifferentialSensors" << std::endl;
902 ss << "Name: \"DifferentialSensorSource\" Value: \"" << DifferentialSensorSource << "\"" << std::endl;
903 ss << "Name: \"DifferentialTalonFXSensorID\" Value: \"" << DifferentialTalonFXSensorID << "\"" << std::endl;
904 ss << "Name: \"DifferentialRemoteSensorID\" Value: \"" << DifferentialRemoteSensorID << "\"" << std::endl;
905 ss << "}" << std::endl;
906 return ss.str();
907 }
908
909 std::string Serialize() const override
910 {
911 std::stringstream ss;
912 char *ref;
913 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialSensorSource, DifferentialSensorSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
914 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialTalonFXSensorID, DifferentialTalonFXSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
915 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialRemoteSensorID, DifferentialRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
916 return ss.str();
917 }
918
919 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
920 {
921 const char *string_c_str = to_deserialize.c_str();
922 size_t string_length = to_deserialize.length();
923 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialSensorSource, string_c_str, string_length, &DifferentialSensorSource.value);
924 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialTalonFXSensorID, string_c_str, string_length, &DifferentialTalonFXSensorID);
925 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialRemoteSensorID, string_c_str, string_length, &DifferentialRemoteSensorID);
926 return 0;
927 }
928};
929
930
931/**
932 * \brief Configs related to constants used for differential control
933 * of a mechanism.
934 *
935 * \details Includes the differential peak outputs.
936 */
938{
939public:
940 /**
941 * \brief Maximum differential output during duty cycle based
942 * differential control modes.
943 *
944 * Minimum Value: 0.0
945 * Maximum Value: 2.0
946 * Default Value: 2
947 * Units: fractional
948 */
950 /**
951 * \brief Maximum differential output during voltage based
952 * differential control modes.
953 *
954 * Minimum Value: 0.0
955 * Maximum Value: 32
956 * Default Value: 32
957 * Units: V
958 */
960 /**
961 * \brief Maximum differential output during torque current based
962 * differential control modes.
963 *
964 * Minimum Value: 0.0
965 * Maximum Value: 1600
966 * Default Value: 1600
967 * Units: A
968 */
970
971
972
973 std::string ToString() const override
974 {
975 std::stringstream ss;
976 ss << "{" << std::endl;
977 ss << "Config Group: DifferentialConstants" << std::endl;
978 ss << "Name: \"PeakDifferentialDutyCycle\" Value: \"" << PeakDifferentialDutyCycle << "fractional\"" << std::endl;
979 ss << "Name: \"PeakDifferentialVoltage\" Value: \"" << PeakDifferentialVoltage << "V\"" << std::endl;
980 ss << "Name: \"PeakDifferentialTorqueCurrent\" Value: \"" << PeakDifferentialTorqueCurrent << "A\"" << std::endl;
981 ss << "}" << std::endl;
982 return ss.str();
983 }
984
985 std::string Serialize() const override
986 {
987 std::stringstream ss;
988 char *ref;
989 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffDC, PeakDifferentialDutyCycle, &ref); if (ref != nullptr) { ss << ref; free(ref); }
990 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffV, PeakDifferentialVoltage, &ref); if (ref != nullptr) { ss << ref; free(ref); }
991 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffTorqCurr, PeakDifferentialTorqueCurrent, &ref); if (ref != nullptr) { ss << ref; free(ref); }
992 return ss.str();
993 }
994
995 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
996 {
997 const char *string_c_str = to_deserialize.c_str();
998 size_t string_length = to_deserialize.length();
999 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffDC, string_c_str, string_length, &PeakDifferentialDutyCycle);
1000 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffV, string_c_str, string_length, &PeakDifferentialVoltage);
1001 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffTorqCurr, string_c_str, string_length, &PeakDifferentialTorqueCurrent);
1002 return 0;
1003 }
1004};
1005
1006
1007/**
1008 * \brief Configs that affect the open-loop control of this motor
1009 * controller.
1010 *
1011 * \details Open-loop ramp rates for the various control types.
1012 */
1014{
1015public:
1016 /**
1017 * \brief If non-zero, this determines how much time to ramp from 0%
1018 * output to 100% during open-loop modes.
1019 *
1020 * Minimum Value: 0
1021 * Maximum Value: 1
1022 * Default Value: 0
1023 * Units: sec
1024 */
1026 /**
1027 * \brief If non-zero, this determines how much time to ramp from 0V
1028 * output to 12V during open-loop modes.
1029 *
1030 * Minimum Value: 0
1031 * Maximum Value: 1
1032 * Default Value: 0
1033 * Units: sec
1034 */
1036 /**
1037 * \brief If non-zero, this determines how much time to ramp from 0A
1038 * output to 300A during open-loop modes.
1039 *
1040 * Minimum Value: 0
1041 * Maximum Value: 10
1042 * Default Value: 0
1043 * Units: sec
1044 */
1046
1047
1048
1049 std::string ToString() const override
1050 {
1051 std::stringstream ss;
1052 ss << "{" << std::endl;
1053 ss << "Config Group: OpenLoopRamps" << std::endl;
1054 ss << "Name: \"DutyCycleOpenLoopRampPeriod\" Value: \"" << DutyCycleOpenLoopRampPeriod << "sec\"" << std::endl;
1055 ss << "Name: \"VoltageOpenLoopRampPeriod\" Value: \"" << VoltageOpenLoopRampPeriod << "sec\"" << std::endl;
1056 ss << "Name: \"TorqueOpenLoopRampPeriod\" Value: \"" << TorqueOpenLoopRampPeriod << "sec\"" << std::endl;
1057 ss << "}" << std::endl;
1058 return ss.str();
1059 }
1060
1061 std::string Serialize() const override
1062 {
1063 std::stringstream ss;
1064 char *ref;
1065 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleOpenLoopRampPeriod, DutyCycleOpenLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1066 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageOpenLoopRampPeriod, VoltageOpenLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1067 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueOpenLoopRampPeriod, TorqueOpenLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1068 return ss.str();
1069 }
1070
1071 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1072 {
1073 const char *string_c_str = to_deserialize.c_str();
1074 size_t string_length = to_deserialize.length();
1075 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleOpenLoopRampPeriod, string_c_str, string_length, &DutyCycleOpenLoopRampPeriod);
1076 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageOpenLoopRampPeriod, string_c_str, string_length, &VoltageOpenLoopRampPeriod);
1077 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueOpenLoopRampPeriod, string_c_str, string_length, &TorqueOpenLoopRampPeriod);
1078 return 0;
1079 }
1080};
1081
1082
1083/**
1084 * \brief Configs that affect the closed-loop control of this motor
1085 * controller.
1086 *
1087 * \details Closed-loop ramp rates for the various control types.
1088 */
1090{
1091public:
1092 /**
1093 * \brief If non-zero, this determines how much time to ramp from 0%
1094 * output to 100% during closed-loop modes.
1095 *
1096 * Minimum Value: 0
1097 * Maximum Value: 1
1098 * Default Value: 0
1099 * Units: sec
1100 */
1102 /**
1103 * \brief If non-zero, this determines how much time to ramp from 0V
1104 * output to 12V during closed-loop modes.
1105 *
1106 * Minimum Value: 0
1107 * Maximum Value: 1
1108 * Default Value: 0
1109 * Units: sec
1110 */
1112 /**
1113 * \brief If non-zero, this determines how much time to ramp from 0A
1114 * output to 300A during closed-loop modes.
1115 *
1116 * Minimum Value: 0
1117 * Maximum Value: 10
1118 * Default Value: 0
1119 * Units: sec
1120 */
1122
1123
1124
1125 std::string ToString() const override
1126 {
1127 std::stringstream ss;
1128 ss << "{" << std::endl;
1129 ss << "Config Group: ClosedLoopRamps" << std::endl;
1130 ss << "Name: \"DutyCycleClosedLoopRampPeriod\" Value: \"" << DutyCycleClosedLoopRampPeriod << "sec\"" << std::endl;
1131 ss << "Name: \"VoltageClosedLoopRampPeriod\" Value: \"" << VoltageClosedLoopRampPeriod << "sec\"" << std::endl;
1132 ss << "Name: \"TorqueClosedLoopRampPeriod\" Value: \"" << TorqueClosedLoopRampPeriod << "sec\"" << std::endl;
1133 ss << "}" << std::endl;
1134 return ss.str();
1135 }
1136
1137 std::string Serialize() const override
1138 {
1139 std::stringstream ss;
1140 char *ref;
1141 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleClosedLoopRampPeriod, DutyCycleClosedLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1142 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageClosedLoopRampPeriod, VoltageClosedLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1143 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueClosedLoopRampPeriod, TorqueClosedLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1144 return ss.str();
1145 }
1146
1147 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1148 {
1149 const char *string_c_str = to_deserialize.c_str();
1150 size_t string_length = to_deserialize.length();
1151 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleClosedLoopRampPeriod, string_c_str, string_length, &DutyCycleClosedLoopRampPeriod);
1152 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageClosedLoopRampPeriod, string_c_str, string_length, &VoltageClosedLoopRampPeriod);
1153 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueClosedLoopRampPeriod, string_c_str, string_length, &TorqueClosedLoopRampPeriod);
1154 return 0;
1155 }
1156};
1157
1158
1159/**
1160 * \brief Configs that change how the motor controller behaves under
1161 * different limit switch statse.
1162 *
1163 * \details Includes configs such as enabling limit switches,
1164 * configuring the remote sensor ID, the source, and the
1165 * position to set on limit.
1166 */
1168{
1169public:
1170 /**
1171 * \brief Determines if limit is normally-open (default) or
1172 * normally-closed.
1173 *
1174 */
1176 /**
1177 * \brief If enabled, the position is auto-set to a specific value,
1178 * specified by ForwardLimitAutosetPositionValue
1179 *
1180 * Default Value: False
1181 */
1183 /**
1184 * \brief The value to auto-set the position to. This has no effect
1185 * if ForwardLimitAutosetPositionEnable is false.
1186 *
1187 * Minimum Value: -3.4e+38
1188 * Maximum Value: 3.4e+38
1189 * Default Value: 0
1190 * Units: rotations
1191 */
1193 /**
1194 * \brief If enabled, motor output is set to neutral when forward
1195 * limit switch is asseted and positive output is requested.
1196 *
1197 * Default Value: True
1198 */
1200 /**
1201 * \brief Determines where to poll the forward limit switch. This
1202 * defaults to the limit switch pin on the limit switch connector.
1203 *
1204 */
1206 /**
1207 * \brief Device ID of the device if using remote limit switch
1208 * features.
1209 *
1210 * Minimum Value: 0
1211 * Maximum Value: 62
1212 * Default Value: 0
1213 * Units:
1214 */
1216 /**
1217 * \brief Determines if limit is normally-open (default) or
1218 * normally-closed.
1219 *
1220 */
1222 /**
1223 * \brief If enabled, the position is auto-set to a specific value,
1224 * specified by ReverseLimitAutosetPositionValue
1225 *
1226 * Default Value: False
1227 */
1229 /**
1230 * \brief The value to auto-set the position to. This has no effect
1231 * if ReverseLimitAutosetPositionEnable is false.
1232 *
1233 * Minimum Value: -3.4e+38
1234 * Maximum Value: 3.4e+38
1235 * Default Value: 0
1236 * Units: rotations
1237 */
1239 /**
1240 * \brief If enabled, motor output is set to neutral when reverse
1241 * limit switch is asseted and positive output is requested.
1242 *
1243 * Default Value: True
1244 */
1246 /**
1247 * \brief Determines where to poll the reverse limit switch. This
1248 * defaults to the limit switch pin on the limit switch connector.
1249 *
1250 */
1252 /**
1253 * \brief Device ID of the device if using remote limit switch
1254 * features.
1255 *
1256 * Minimum Value: 0
1257 * Maximum Value: 62
1258 * Default Value: 0
1259 * Units:
1260 */
1262
1263
1264
1265 std::string ToString() const override
1266 {
1267 std::stringstream ss;
1268 ss << "{" << std::endl;
1269 ss << "Config Group: HardwareLimitSwitch" << std::endl;
1270 ss << "Name: \"ForwardLimitType\" Value: \"" << ForwardLimitType << "\"" << std::endl;
1271 ss << "Name: \"ForwardLimitAutosetPositionEnable\" Value: \"" << ForwardLimitAutosetPositionEnable << "\"" << std::endl;
1272 ss << "Name: \"ForwardLimitAutosetPositionValue\" Value: \"" << ForwardLimitAutosetPositionValue << "rotations\"" << std::endl;
1273 ss << "Name: \"ForwardLimitEnable\" Value: \"" << ForwardLimitEnable << "\"" << std::endl;
1274 ss << "Name: \"ForwardLimitSource\" Value: \"" << ForwardLimitSource << "\"" << std::endl;
1275 ss << "Name: \"ForwardLimitRemoteSensorID\" Value: \"" << ForwardLimitRemoteSensorID << "\"" << std::endl;
1276 ss << "Name: \"ReverseLimitType\" Value: \"" << ReverseLimitType << "\"" << std::endl;
1277 ss << "Name: \"ReverseLimitAutosetPositionEnable\" Value: \"" << ReverseLimitAutosetPositionEnable << "\"" << std::endl;
1278 ss << "Name: \"ReverseLimitAutosetPositionValue\" Value: \"" << ReverseLimitAutosetPositionValue << "rotations\"" << std::endl;
1279 ss << "Name: \"ReverseLimitEnable\" Value: \"" << ReverseLimitEnable << "\"" << std::endl;
1280 ss << "Name: \"ReverseLimitSource\" Value: \"" << ReverseLimitSource << "\"" << std::endl;
1281 ss << "Name: \"ReverseLimitRemoteSensorID\" Value: \"" << ReverseLimitRemoteSensorID << "\"" << std::endl;
1282 ss << "}" << std::endl;
1283 return ss.str();
1284 }
1285
1286 std::string Serialize() const override
1287 {
1288 std::stringstream ss;
1289 char *ref;
1290 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitType, ForwardLimitType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1291 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosEnable, ForwardLimitAutosetPositionEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1292 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosValue, ForwardLimitAutosetPositionValue, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1293 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitEnable, ForwardLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1294 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitSource, ForwardLimitSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1295 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitRemoteSensorID, ForwardLimitRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1296 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitType, ReverseLimitType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1297 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosEnable, ReverseLimitAutosetPositionEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1298 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosValue, ReverseLimitAutosetPositionValue, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1299 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitEnable, ReverseLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1300 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitSource, ReverseLimitSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1301 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitRemoteSensorID, ReverseLimitRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1302 return ss.str();
1303 }
1304
1305 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1306 {
1307 const char *string_c_str = to_deserialize.c_str();
1308 size_t string_length = to_deserialize.length();
1309 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitType, string_c_str, string_length, &ForwardLimitType.value);
1310 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosEnable, string_c_str, string_length, &ForwardLimitAutosetPositionEnable);
1311 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosValue, string_c_str, string_length, &ForwardLimitAutosetPositionValue);
1312 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitEnable, string_c_str, string_length, &ForwardLimitEnable);
1313 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitSource, string_c_str, string_length, &ForwardLimitSource.value);
1314 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitRemoteSensorID, string_c_str, string_length, &ForwardLimitRemoteSensorID);
1315 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitType, string_c_str, string_length, &ReverseLimitType.value);
1316 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosEnable, string_c_str, string_length, &ReverseLimitAutosetPositionEnable);
1317 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosValue, string_c_str, string_length, &ReverseLimitAutosetPositionValue);
1318 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitEnable, string_c_str, string_length, &ReverseLimitEnable);
1319 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitSource, string_c_str, string_length, &ReverseLimitSource.value);
1320 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitRemoteSensorID, string_c_str, string_length, &ReverseLimitRemoteSensorID);
1321 return 0;
1322 }
1323};
1324
1325
1326/**
1327 * \brief Configs that affect audible components of the device.
1328 *
1329 * \details Includes configuration for the beep on boot.
1330 */
1332{
1333public:
1334 /**
1335 * \brief If true, the TalonFX will beep during boot-up. This is
1336 * useful for general debugging, and defaults to true. If rotor is
1337 * moving during boot-up, the beep will not occur regardless of this
1338 * setting.
1339 *
1340 * Default Value: True
1341 */
1342 bool BeepOnBoot = true;
1343 /**
1344 * \brief If true, the TalonFX will beep during configuration API
1345 * calls if device is disabled. This is useful for general debugging,
1346 * and defaults to true. Note that if the rotor is moving, the beep
1347 * will not occur regardless of this setting.
1348 *
1349 * Default Value: True
1350 */
1351 bool BeepOnConfig = true;
1352 /**
1353 * \brief If true, the TalonFX will allow Orchestra and MusicTone
1354 * requests during disabled state. This can be used to address corner
1355 * cases when music features are needed when disabled. This setting
1356 * defaults to false. Note that if the rotor is moving, music
1357 * features are always disabled regardless of this setting.
1358 *
1359 * Default Value: False
1360 */
1362
1363
1364
1365 std::string ToString() const override
1366 {
1367 std::stringstream ss;
1368 ss << "{" << std::endl;
1369 ss << "Config Group: Audio" << std::endl;
1370 ss << "Name: \"BeepOnBoot\" Value: \"" << BeepOnBoot << "\"" << std::endl;
1371 ss << "Name: \"BeepOnConfig\" Value: \"" << BeepOnConfig << "\"" << std::endl;
1372 ss << "Name: \"AllowMusicDurDisable\" Value: \"" << AllowMusicDurDisable << "\"" << std::endl;
1373 ss << "}" << std::endl;
1374 return ss.str();
1375 }
1376
1377 std::string Serialize() const override
1378 {
1379 std::stringstream ss;
1380 char *ref;
1381 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnBoot, BeepOnBoot, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1382 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnConfig, BeepOnConfig, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1383 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_AllowMusicDurDisable, AllowMusicDurDisable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1384 return ss.str();
1385 }
1386
1387 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1388 {
1389 const char *string_c_str = to_deserialize.c_str();
1390 size_t string_length = to_deserialize.length();
1391 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnBoot, string_c_str, string_length, &BeepOnBoot);
1392 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnConfig, string_c_str, string_length, &BeepOnConfig);
1393 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_AllowMusicDurDisable, string_c_str, string_length, &AllowMusicDurDisable);
1394 return 0;
1395 }
1396};
1397
1398
1399/**
1400 * \brief Configs that affect how software-limit switches behave.
1401 *
1402 * \details Includes enabling software-limit switches and the
1403 * threshold at which they're tripped.
1404 */
1406{
1407public:
1408 /**
1409 * \brief If enabled, the motor output is set to neutral if position
1410 * exceeds ForwardSoftLimitThreshold and forward output is requested.
1411 *
1412 * Default Value: False
1413 */
1415 /**
1416 * \brief If enabled, the motor output is set to neutral if position
1417 * exceeds ReverseSoftLimitThreshold and reverse output is requested.
1418 *
1419 * Default Value: False
1420 */
1422 /**
1423 * \brief Position threshold for forward soft limit features.
1424 * ForwardSoftLimitEnable must be enabled for this to take effect.
1425 *
1426 * Minimum Value: -3.4e+38
1427 * Maximum Value: 3.4e+38
1428 * Default Value: 0
1429 * Units: rotations
1430 */
1432 /**
1433 * \brief Position threshold for reverse soft limit features.
1434 * ReverseSoftLimitEnable must be enabled for this to take effect.
1435 *
1436 * Minimum Value: -3.4e+38
1437 * Maximum Value: 3.4e+38
1438 * Default Value: 0
1439 * Units: rotations
1440 */
1442
1443
1444
1445 std::string ToString() const override
1446 {
1447 std::stringstream ss;
1448 ss << "{" << std::endl;
1449 ss << "Config Group: SoftwareLimitSwitch" << std::endl;
1450 ss << "Name: \"ForwardSoftLimitEnable\" Value: \"" << ForwardSoftLimitEnable << "\"" << std::endl;
1451 ss << "Name: \"ReverseSoftLimitEnable\" Value: \"" << ReverseSoftLimitEnable << "\"" << std::endl;
1452 ss << "Name: \"ForwardSoftLimitThreshold\" Value: \"" << ForwardSoftLimitThreshold << "rotations\"" << std::endl;
1453 ss << "Name: \"ReverseSoftLimitThreshold\" Value: \"" << ReverseSoftLimitThreshold << "rotations\"" << std::endl;
1454 ss << "}" << std::endl;
1455 return ss.str();
1456 }
1457
1458 std::string Serialize() const override
1459 {
1460 std::stringstream ss;
1461 char *ref;
1462 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitEnable, ForwardSoftLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1463 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitEnable, ReverseSoftLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1464 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitThreshold, ForwardSoftLimitThreshold, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1465 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitThreshold, ReverseSoftLimitThreshold, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1466 return ss.str();
1467 }
1468
1469 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1470 {
1471 const char *string_c_str = to_deserialize.c_str();
1472 size_t string_length = to_deserialize.length();
1473 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitEnable, string_c_str, string_length, &ForwardSoftLimitEnable);
1474 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitEnable, string_c_str, string_length, &ReverseSoftLimitEnable);
1475 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitThreshold, string_c_str, string_length, &ForwardSoftLimitThreshold);
1476 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitThreshold, string_c_str, string_length, &ReverseSoftLimitThreshold);
1477 return 0;
1478 }
1479};
1480
1481
1482/**
1483 * \brief Configs for Motion Magic®.
1484 *
1485 * \details Includes Velocity, Acceleration, and Jerk parameters.
1486 */
1488{
1489public:
1490 /**
1491 * \brief This is the maximum velocity Motion Magic® based control
1492 * modes are allowed to use.
1493 *
1494 * Minimum Value: 0
1495 * Maximum Value: 9999
1496 * Default Value: 0
1497 * Units: rps
1498 */
1500 /**
1501 * \brief This is the target acceleration Motion Magic® based control
1502 * modes are allowed to use.
1503 *
1504 * Minimum Value: 0
1505 * Maximum Value: 9999
1506 * Default Value: 0
1507 * Units: rot per sec²
1508 */
1510 /**
1511 * \brief This is the target jerk (acceleration derivative) Motion
1512 * Magic® based control modes are allowed to use. This allows Motion
1513 * Magic® support of S-Curves. If this is set to zero, then Motion
1514 * Magic® will not apply a Jerk limit.
1515 *
1516 * Minimum Value: 0
1517 * Maximum Value: 9999
1518 * Default Value: 0
1519 * Units: rot per sec³
1520 */
1522
1523
1524
1525 std::string ToString() const override
1526 {
1527 std::stringstream ss;
1528 ss << "{" << std::endl;
1529 ss << "Config Group: MotionMagic" << std::endl;
1530 ss << "Name: \"MotionMagicCruiseVelocity\" Value: \"" << MotionMagicCruiseVelocity << "rps\"" << std::endl;
1531 ss << "Name: \"MotionMagicAcceleration\" Value: \"" << MotionMagicAcceleration << "rot per sec²\"" << std::endl;
1532 ss << "Name: \"MotionMagicJerk\" Value: \"" << MotionMagicJerk << "rot per sec³\"" << std::endl;
1533 ss << "}" << std::endl;
1534 return ss.str();
1535 }
1536
1537 std::string Serialize() const override
1538 {
1539 std::stringstream ss;
1540 char *ref;
1541 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicCruiseVelocity, MotionMagicCruiseVelocity, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1542 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicAcceleration, MotionMagicAcceleration, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1543 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicJerk, MotionMagicJerk, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1544 return ss.str();
1545 }
1546
1547 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1548 {
1549 const char *string_c_str = to_deserialize.c_str();
1550 size_t string_length = to_deserialize.length();
1551 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicCruiseVelocity, string_c_str, string_length, &MotionMagicCruiseVelocity);
1552 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicAcceleration, string_c_str, string_length, &MotionMagicAcceleration);
1553 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicJerk, string_c_str, string_length, &MotionMagicJerk);
1554 return 0;
1555 }
1556};
1557
1558
1559/**
1560 * \brief Custom Params.
1561 *
1562 * \details Custom paramaters that have no real impact on controller.
1563 */
1565{
1566public:
1567 /**
1568 * \brief Custom parameter 0. This is provided to allow
1569 * end-applications to store persistent information in the device.
1570 *
1571 * Minimum Value: -32768
1572 * Maximum Value: 32767
1573 * Default Value: 0
1574 * Units:
1575 */
1577 /**
1578 * \brief Custom parameter 1. This is provided to allow
1579 * end-applications to store persistent information in the device.
1580 *
1581 * Minimum Value: -32768
1582 * Maximum Value: 32767
1583 * Default Value: 0
1584 * Units:
1585 */
1587
1588
1589
1590 std::string ToString() const override
1591 {
1592 std::stringstream ss;
1593 ss << "{" << std::endl;
1594 ss << "Config Group: CustomParams" << std::endl;
1595 ss << "Name: \"CustomParam0\" Value: \"" << CustomParam0 << "\"" << std::endl;
1596 ss << "Name: \"CustomParam1\" Value: \"" << CustomParam1 << "\"" << std::endl;
1597 ss << "}" << std::endl;
1598 return ss.str();
1599 }
1600
1601 std::string Serialize() const override
1602 {
1603 std::stringstream ss;
1604 char *ref;
1605 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CustomParam0, CustomParam0, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1606 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CustomParam1, CustomParam1, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1607 return ss.str();
1608 }
1609
1610 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1611 {
1612 const char *string_c_str = to_deserialize.c_str();
1613 size_t string_length = to_deserialize.length();
1614 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CustomParam0, string_c_str, string_length, &CustomParam0);
1615 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CustomParam1, string_c_str, string_length, &CustomParam1);
1616 return 0;
1617 }
1618};
1619
1620
1621/**
1622 * \brief Configs that affect general behavior during closed-looping.
1623 *
1624 * \details Includes Continuous Wrap features.
1625 */
1627{
1628public:
1629 /**
1630 * \brief Wrap position error within [-0.5,+0.5) mechanism rotations.
1631 * Typically used for continuous position closed-loops like swerve
1632 * azimuth.
1633 *
1634 * \details This uses the mechanism rotation value. If there is a gear
1635 * ratio between the sensor and the mechanism, make sure to apply a
1636 * SensorToMechanismRatio so the closed loop operates on the full
1637 * rotation.
1638 *
1639 * Default Value: False
1640 */
1641 bool ContinuousWrap = false;
1642
1643
1644
1645 std::string ToString() const override
1646 {
1647 std::stringstream ss;
1648 ss << "{" << std::endl;
1649 ss << "Config Group: ClosedLoopGeneral" << std::endl;
1650 ss << "Name: \"ContinuousWrap\" Value: \"" << ContinuousWrap << "\"" << std::endl;
1651 ss << "}" << std::endl;
1652 return ss.str();
1653 }
1654
1655 std::string Serialize() const override
1656 {
1657 std::stringstream ss;
1658 char *ref;
1659 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ContinuousWrap, ContinuousWrap, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1660 return ss.str();
1661 }
1662
1663 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1664 {
1665 const char *string_c_str = to_deserialize.c_str();
1666 size_t string_length = to_deserialize.length();
1667 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ContinuousWrap, string_c_str, string_length, &ContinuousWrap);
1668 return 0;
1669 }
1670};
1671
1672
1673/**
1674 * \brief Gains for the specified slot.
1675 *
1676 * \details If this slot is selected, these gains are used in closed
1677 * loop control requests.
1678 */
1680{
1681public:
1682 /**
1683 * \brief Proportional Gain
1684 *
1685 * \details The units for this gain is dependent on the control mode.
1686 * Since this gain is multiplied by error in the input, the units
1687 * should be defined as units of output per unit of input error. For
1688 * example, when controlling velocity using a duty cycle closed loop,
1689 * the units for the proportional gain will be duty cycle per rps of
1690 * error, or 1/rps.
1691 *
1692 * Minimum Value: 0
1693 * Maximum Value: 3.4e+38
1694 * Default Value: 0
1695 * Units:
1696 */
1697 double kP = 0;
1698 /**
1699 * \brief Integral Gain
1700 *
1701 * \details The units for this gain is dependent on the control mode.
1702 * Since this gain is multiplied by error in the input integrated over
1703 * time (in units of seconds), the units should be defined as units of
1704 * output per unit of integrated input error. For example, when
1705 * controlling velocity using a duty cycle closed loop, integrating
1706 * velocity over time results in rps * s = rotations. Therefore, the
1707 * units for the integral gain will be duty cycle per rotation of
1708 * accumulated error, or 1/rot.
1709 *
1710 * Minimum Value: 0
1711 * Maximum Value: 3.4e+38
1712 * Default Value: 0
1713 * Units:
1714 */
1715 double kI = 0;
1716 /**
1717 * \brief Derivative Gain
1718 *
1719 * \details The units for this gain is dependent on the control mode.
1720 * Since this gain is multiplied by the derivative of error in the
1721 * input with respect to time (in units of seconds), the units should
1722 * be defined as units of output per unit of the differentiated input
1723 * error. For example, when controlling velocity using a duty cycle
1724 * closed loop, the derivative of velocity with respect to time is
1725 * rps/s, which is acceleration. Therefore, the units for the
1726 * derivative gain will be duty cycle per unit of acceleration error,
1727 * or 1/(rps/s).
1728 *
1729 * Minimum Value: 0
1730 * Maximum Value: 3.4e+38
1731 * Default Value: 0
1732 * Units:
1733 */
1734 double kD = 0;
1735 /**
1736 * \brief Static Feedforward Gain
1737 *
1738 * \details This is added to the closed loop output. The sign is
1739 * determined by target velocity. The unit for this constant is
1740 * dependent on the control mode, typically fractional duty cycle,
1741 * voltage, or torque current.
1742 *
1743 * Minimum Value: -512
1744 * Maximum Value: 511
1745 * Default Value: 0
1746 * Units:
1747 */
1748 double kS = 0;
1749 /**
1750 * \brief Velocity Feedforward Gain
1751 *
1752 * \details The units for this gain is dependent on the control mode.
1753 * Since this gain is multiplied by the requested velocity, the units
1754 * should be defined as units of output per unit of requested input
1755 * velocity. For example, when controlling velocity using a duty cycle
1756 * closed loop, the units for the velocity feedfoward gain will be
1757 * duty cycle per requested rps, or 1/rps.
1758 *
1759 * Minimum Value: 0
1760 * Maximum Value: 3.4e+38
1761 * Default Value: 0
1762 * Units:
1763 */
1764 double kV = 0;
1765 /**
1766 * \brief Acceleration Feedforward Gain
1767 *
1768 * \details The units for this gain is dependent on the control mode.
1769 * Since this gain is multiplied by the requested acceleration, the
1770 * units should be defined as units of output per unit of requested
1771 * input acceleration. For example, when controlling velocity using a
1772 * duty cycle closed loop, the units for the acceleration feedfoward
1773 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
1774 *
1775 * Minimum Value: 0
1776 * Maximum Value: 3.4e+38
1777 * Default Value: 0
1778 * Units:
1779 */
1780 double kA = 0;
1781 /**
1782 * \brief Gravity Feedforward Gain
1783 *
1784 * \details This is added to the closed loop output. The sign is
1785 * determined by the type of gravity feedforward. The unit for this
1786 * constant is dependent on the control mode, typically fractional
1787 * duty cycle, voltage, or torque current.
1788 *
1789 * Minimum Value: -512
1790 * Maximum Value: 511
1791 * Default Value: 0
1792 * Units:
1793 */
1794 double kG = 0;
1795 /**
1796 * \brief Gravity Feedforward Type
1797 *
1798 * \details This determines the type of the gravity feedforward.
1799 * Choose Elevator_Static for systems where the gravity feedforward is
1800 * constant, such as an elevator. The gravity feedforward output will
1801 * always have the same sign. Choose Arm_Cosine for systems where the
1802 * gravity feedforward is dependent on the angular position of the
1803 * mechanism, such as an arm. The gravity feedforward output will vary
1804 * depending on the mechanism angular position. Note that the sensor
1805 * offset and ratios must be configured so that the sensor reports a
1806 * position of 0 when the mechanism is horizonal (parallel to the
1807 * ground), and the reported sensor position is 1:1 with the
1808 * mechanism.
1809 *
1810 */
1812
1813 static Slot0Configs From(const SlotConfigs& value);
1814
1815 std::string ToString() const override
1816 {
1817 std::stringstream ss;
1818 ss << "{" << std::endl;
1819 ss << "Config Group: Slot0" << std::endl;
1820 ss << "Name: \"kP\" Value: \"" << kP << "\"" << std::endl;
1821 ss << "Name: \"kI\" Value: \"" << kI << "\"" << std::endl;
1822 ss << "Name: \"kD\" Value: \"" << kD << "\"" << std::endl;
1823 ss << "Name: \"kS\" Value: \"" << kS << "\"" << std::endl;
1824 ss << "Name: \"kV\" Value: \"" << kV << "\"" << std::endl;
1825 ss << "Name: \"kA\" Value: \"" << kA << "\"" << std::endl;
1826 ss << "Name: \"kG\" Value: \"" << kG << "\"" << std::endl;
1827 ss << "Name: \"GravityType\" Value: \"" << GravityType << "\"" << std::endl;
1828 ss << "}" << std::endl;
1829 return ss.str();
1830 }
1831
1832 std::string Serialize() const override
1833 {
1834 std::stringstream ss;
1835 char *ref;
1836 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kP, kP, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1837 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kI, kI, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1838 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kD, kD, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1839 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kS, kS, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1840 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kV, kV, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1841 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kA, kA, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1842 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kG, kG, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1843 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot0_kG_Type, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1844 return ss.str();
1845 }
1846
1847 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1848 {
1849 const char *string_c_str = to_deserialize.c_str();
1850 size_t string_length = to_deserialize.length();
1851 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kP, string_c_str, string_length, &kP);
1852 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kI, string_c_str, string_length, &kI);
1853 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kD, string_c_str, string_length, &kD);
1854 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kS, string_c_str, string_length, &kS);
1855 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kV, string_c_str, string_length, &kV);
1856 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kA, string_c_str, string_length, &kA);
1857 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kG, string_c_str, string_length, &kG);
1858 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot0_kG_Type, string_c_str, string_length, &GravityType.value);
1859 return 0;
1860 }
1861};
1862
1863
1864/**
1865 * \brief Gains for the specified slot.
1866 *
1867 * \details If this slot is selected, these gains are used in closed
1868 * loop control requests.
1869 */
1871{
1872public:
1873 /**
1874 * \brief Proportional Gain
1875 *
1876 * \details The units for this gain is dependent on the control mode.
1877 * Since this gain is multiplied by error in the input, the units
1878 * should be defined as units of output per unit of input error. For
1879 * example, when controlling velocity using a duty cycle closed loop,
1880 * the units for the proportional gain will be duty cycle per rps, or
1881 * 1/rps.
1882 *
1883 * Minimum Value: 0
1884 * Maximum Value: 3.4e+38
1885 * Default Value: 0
1886 * Units:
1887 */
1888 double kP = 0;
1889 /**
1890 * \brief Integral Gain
1891 *
1892 * \details The units for this gain is dependent on the control mode.
1893 * Since this gain is multiplied by error in the input integrated over
1894 * time (in units of seconds), the units should be defined as units of
1895 * output per unit of integrated input error. For example, when
1896 * controlling velocity using a duty cycle closed loop, integrating
1897 * velocity over time results in rps * s = rotations. Therefore, the
1898 * units for the integral gain will be duty cycle per rotation of
1899 * accumulated error, or 1/rot.
1900 *
1901 * Minimum Value: 0
1902 * Maximum Value: 3.4e+38
1903 * Default Value: 0
1904 * Units:
1905 */
1906 double kI = 0;
1907 /**
1908 * \brief Derivative Gain
1909 *
1910 * \details The units for this gain is dependent on the control mode.
1911 * Since this gain is multiplied by the derivative of error in the
1912 * input with respect to time (in units of seconds), the units should
1913 * be defined as units of output per unit of the differentiated input
1914 * error. For example, when controlling velocity using a duty cycle
1915 * closed loop, the derivative of velocity with respect to time is
1916 * rps/s, which is acceleration. Therefore, the units for the
1917 * derivative gain will be duty cycle per unit of acceleration error,
1918 * or 1/(rps/s).
1919 *
1920 * Minimum Value: 0
1921 * Maximum Value: 3.4e+38
1922 * Default Value: 0
1923 * Units:
1924 */
1925 double kD = 0;
1926 /**
1927 * \brief Static Feedforward Gain
1928 *
1929 * \details This is added to the closed loop output. The sign is
1930 * determined by target velocity. The unit for this constant is
1931 * dependent on the control mode, typically fractional duty cycle,
1932 * voltage, or torque current.
1933 *
1934 * Minimum Value: -512
1935 * Maximum Value: 511
1936 * Default Value: 0
1937 * Units:
1938 */
1939 double kS = 0;
1940 /**
1941 * \brief Velocity Feedforward Gain
1942 *
1943 * \details The units for this gain is dependent on the control mode.
1944 * Since this gain is multiplied by the requested velocity, the units
1945 * should be defined as units of output per unit of requested input
1946 * velocity. For example, when controlling velocity using a duty cycle
1947 * closed loop, the units for the velocity feedfoward gain will be
1948 * duty cycle per requested rps, or 1/rps.
1949 *
1950 * Minimum Value: 0
1951 * Maximum Value: 3.4e+38
1952 * Default Value: 0
1953 * Units:
1954 */
1955 double kV = 0;
1956 /**
1957 * \brief Acceleration Feedforward Gain
1958 *
1959 * \details The units for this gain is dependent on the control mode.
1960 * Since this gain is multiplied by the requested acceleration, the
1961 * units should be defined as units of output per unit of requested
1962 * input acceleration. For example, when controlling velocity using a
1963 * duty cycle closed loop, the units for the acceleration feedfoward
1964 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
1965 *
1966 * Minimum Value: 0
1967 * Maximum Value: 3.4e+38
1968 * Default Value: 0
1969 * Units:
1970 */
1971 double kA = 0;
1972 /**
1973 * \brief Gravity Feedforward Gain
1974 *
1975 * \details This is added to the closed loop output. The sign is
1976 * determined by the type of gravity feedforward. The unit for this
1977 * constant is dependent on the control mode, typically fractional
1978 * duty cycle, voltage, or torque current.
1979 *
1980 * Minimum Value: -512
1981 * Maximum Value: 511
1982 * Default Value: 0
1983 * Units:
1984 */
1985 double kG = 0;
1986 /**
1987 * \brief Gravity Feedforward Type
1988 *
1989 * \details This determines the type of the gravity feedforward.
1990 * Choose Elevator_Static for systems where the gravity feedforward is
1991 * constant, such as an elevator. The gravity feedforward output will
1992 * always be positive. Choose Arm_Cosine for systems where the gravity
1993 * feedforward is dependent on the angular position of the mechanism,
1994 * such as an arm. The gravity feedforward output will vary depending
1995 * on the mechanism angular position. Note that the sensor offset and
1996 * ratios must be configured so that the sensor position is 0 when the
1997 * mechanism is horizonal, and one rotation of the mechanism
1998 * corresponds to one rotation of the sensor position.
1999 *
2000 */
2002
2003 static Slot1Configs From(const SlotConfigs& value);
2004
2005 std::string ToString() const override
2006 {
2007 std::stringstream ss;
2008 ss << "{" << std::endl;
2009 ss << "Config Group: Slot1" << std::endl;
2010 ss << "Name: \"kP\" Value: \"" << kP << "\"" << std::endl;
2011 ss << "Name: \"kI\" Value: \"" << kI << "\"" << std::endl;
2012 ss << "Name: \"kD\" Value: \"" << kD << "\"" << std::endl;
2013 ss << "Name: \"kS\" Value: \"" << kS << "\"" << std::endl;
2014 ss << "Name: \"kV\" Value: \"" << kV << "\"" << std::endl;
2015 ss << "Name: \"kA\" Value: \"" << kA << "\"" << std::endl;
2016 ss << "Name: \"kG\" Value: \"" << kG << "\"" << std::endl;
2017 ss << "Name: \"GravityType\" Value: \"" << GravityType << "\"" << std::endl;
2018 ss << "}" << std::endl;
2019 return ss.str();
2020 }
2021
2022 std::string Serialize() const override
2023 {
2024 std::stringstream ss;
2025 char *ref;
2026 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kP, kP, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2027 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kI, kI, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2028 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kD, kD, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2029 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kS, kS, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2030 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kV, kV, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2031 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kA, kA, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2032 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kG, kG, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2033 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot1_kG_Type, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2034 return ss.str();
2035 }
2036
2037 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
2038 {
2039 const char *string_c_str = to_deserialize.c_str();
2040 size_t string_length = to_deserialize.length();
2041 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kP, string_c_str, string_length, &kP);
2042 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kI, string_c_str, string_length, &kI);
2043 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kD, string_c_str, string_length, &kD);
2044 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kS, string_c_str, string_length, &kS);
2045 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kV, string_c_str, string_length, &kV);
2046 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kA, string_c_str, string_length, &kA);
2047 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kG, string_c_str, string_length, &kG);
2048 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot1_kG_Type, string_c_str, string_length, &GravityType.value);
2049 return 0;
2050 }
2051};
2052
2053
2054/**
2055 * \brief Gains for the specified slot.
2056 *
2057 * \details If this slot is selected, these gains are used in closed
2058 * loop control requests.
2059 */
2061{
2062public:
2063 /**
2064 * \brief Proportional Gain
2065 *
2066 * \details The units for this gain is dependent on the control mode.
2067 * Since this gain is multiplied by error in the input, the units
2068 * should be defined as units of output per unit of input error. For
2069 * example, when controlling velocity using a duty cycle closed loop,
2070 * the units for the proportional gain will be duty cycle per rps, or
2071 * 1/rps.
2072 *
2073 * Minimum Value: 0
2074 * Maximum Value: 3.4e+38
2075 * Default Value: 0
2076 * Units:
2077 */
2078 double kP = 0;
2079 /**
2080 * \brief Integral Gain
2081 *
2082 * \details The units for this gain is dependent on the control mode.
2083 * Since this gain is multiplied by error in the input integrated over
2084 * time (in units of seconds), the units should be defined as units of
2085 * output per unit of integrated input error. For example, when
2086 * controlling velocity using a duty cycle closed loop, integrating
2087 * velocity over time results in rps * s = rotations. Therefore, the
2088 * units for the integral gain will be duty cycle per rotation of
2089 * accumulated error, or 1/rot.
2090 *
2091 * Minimum Value: 0
2092 * Maximum Value: 3.4e+38
2093 * Default Value: 0
2094 * Units:
2095 */
2096 double kI = 0;
2097 /**
2098 * \brief Derivative Gain
2099 *
2100 * \details The units for this gain is dependent on the control mode.
2101 * Since this gain is multiplied by the derivative of error in the
2102 * input with respect to time (in units of seconds), the units should
2103 * be defined as units of output per unit of the differentiated input
2104 * error. For example, when controlling velocity using a duty cycle
2105 * closed loop, the derivative of velocity with respect to time is
2106 * rps/s, which is acceleration. Therefore, the units for the
2107 * derivative gain will be duty cycle per unit of acceleration error,
2108 * or 1/(rps/s).
2109 *
2110 * Minimum Value: 0
2111 * Maximum Value: 3.4e+38
2112 * Default Value: 0
2113 * Units:
2114 */
2115 double kD = 0;
2116 /**
2117 * \brief Static Feedforward Gain
2118 *
2119 * \details This is added to the closed loop output. The sign is
2120 * determined by target velocity. The unit for this constant is
2121 * dependent on the control mode, typically fractional duty cycle,
2122 * voltage, or torque current.
2123 *
2124 * Minimum Value: -512
2125 * Maximum Value: 511
2126 * Default Value: 0
2127 * Units:
2128 */
2129 double kS = 0;
2130 /**
2131 * \brief Velocity Feedforward Gain
2132 *
2133 * \details The units for this gain is dependent on the control mode.
2134 * Since this gain is multiplied by the requested velocity, the units
2135 * should be defined as units of output per unit of requested input
2136 * velocity. For example, when controlling velocity using a duty cycle
2137 * closed loop, the units for the velocity feedfoward gain will be
2138 * duty cycle per requested rps, or 1/rps.
2139 *
2140 * Minimum Value: 0
2141 * Maximum Value: 3.4e+38
2142 * Default Value: 0
2143 * Units:
2144 */
2145 double kV = 0;
2146 /**
2147 * \brief Acceleration Feedforward Gain
2148 *
2149 * \details The units for this gain is dependent on the control mode.
2150 * Since this gain is multiplied by the requested acceleration, the
2151 * units should be defined as units of output per unit of requested
2152 * input acceleration. For example, when controlling velocity using a
2153 * duty cycle closed loop, the units for the acceleration feedfoward
2154 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
2155 *
2156 * Minimum Value: 0
2157 * Maximum Value: 3.4e+38
2158 * Default Value: 0
2159 * Units:
2160 */
2161 double kA = 0;
2162 /**
2163 * \brief Gravity Feedforward Gain
2164 *
2165 * \details This is added to the closed loop output. The sign is
2166 * determined by the type of gravity feedforward. The unit for this
2167 * constant is dependent on the control mode, typically fractional
2168 * duty cycle, voltage, or torque current.
2169 *
2170 * Minimum Value: -512
2171 * Maximum Value: 511
2172 * Default Value: 0
2173 * Units:
2174 */
2175 double kG = 0;
2176 /**
2177 * \brief Gravity Feedforward Type
2178 *
2179 * \details This determines the type of the gravity feedforward.
2180 * Choose Elevator_Static for systems where the gravity feedforward is
2181 * constant, such as an elevator. The gravity feedforward output will
2182 * always be positive. Choose Arm_Cosine for systems where the gravity
2183 * feedforward is dependent on the angular position of the mechanism,
2184 * such as an arm. The gravity feedforward output will vary depending
2185 * on the mechanism angular position. Note that the sensor offset and
2186 * ratios must be configured so that the sensor position is 0 when the
2187 * mechanism is horizonal, and one rotation of the mechanism
2188 * corresponds to one rotation of the sensor position.
2189 *
2190 */
2192
2193 static Slot2Configs From(const SlotConfigs& value);
2194
2195 std::string ToString() const override
2196 {
2197 std::stringstream ss;
2198 ss << "{" << std::endl;
2199 ss << "Config Group: Slot2" << std::endl;
2200 ss << "Name: \"kP\" Value: \"" << kP << "\"" << std::endl;
2201 ss << "Name: \"kI\" Value: \"" << kI << "\"" << std::endl;
2202 ss << "Name: \"kD\" Value: \"" << kD << "\"" << std::endl;
2203 ss << "Name: \"kS\" Value: \"" << kS << "\"" << std::endl;
2204 ss << "Name: \"kV\" Value: \"" << kV << "\"" << std::endl;
2205 ss << "Name: \"kA\" Value: \"" << kA << "\"" << std::endl;
2206 ss << "Name: \"kG\" Value: \"" << kG << "\"" << std::endl;
2207 ss << "Name: \"GravityType\" Value: \"" << GravityType << "\"" << std::endl;
2208 ss << "}" << std::endl;
2209 return ss.str();
2210 }
2211
2212 std::string Serialize() const override
2213 {
2214 std::stringstream ss;
2215 char *ref;
2216 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kP, kP, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2217 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kI, kI, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2218 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kD, kD, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2219 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kS, kS, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2220 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kV, kV, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2221 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kA, kA, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2222 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kG, kG, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2223 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot2_kG_Type, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2224 return ss.str();
2225 }
2226
2227 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
2228 {
2229 const char *string_c_str = to_deserialize.c_str();
2230 size_t string_length = to_deserialize.length();
2231 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kP, string_c_str, string_length, &kP);
2232 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kI, string_c_str, string_length, &kI);
2233 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kD, string_c_str, string_length, &kD);
2234 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kS, string_c_str, string_length, &kS);
2235 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kV, string_c_str, string_length, &kV);
2236 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kA, string_c_str, string_length, &kA);
2237 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kG, string_c_str, string_length, &kG);
2238 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot2_kG_Type, string_c_str, string_length, &GravityType.value);
2239 return 0;
2240 }
2241};
2242
2243/**
2244 * \brief Gains for the specified slot.
2245 *
2246 * \details If this slot is selected, these gains are used in closed
2247 * loop control requests.
2248 */
2250{
2251 struct SlotSpns
2252 {
2253 int kPSpn;
2254 int kISpn;
2255 int kDSpn;
2256 int kSSpn;
2257 int kVSpn;
2258 int kASpn;
2259 int kGSpn;
2260 int GravityTypeSpn;
2261 };
2262
2263 std::map<int, SlotSpns> genericMap{
2264 {0, SlotSpns{
2265 ctre::phoenix6::spns::SpnValue::Slot0_kP,
2266 ctre::phoenix6::spns::SpnValue::Slot0_kI,
2267 ctre::phoenix6::spns::SpnValue::Slot0_kD,
2268 ctre::phoenix6::spns::SpnValue::Slot0_kS,
2269 ctre::phoenix6::spns::SpnValue::Slot0_kV,
2270 ctre::phoenix6::spns::SpnValue::Slot0_kA,
2271 ctre::phoenix6::spns::SpnValue::Slot0_kG,
2272 ctre::phoenix6::spns::SpnValue::Slot0_kG_Type,
2273 }},
2274
2275 {1, SlotSpns{
2276 ctre::phoenix6::spns::SpnValue::Slot1_kP,
2277 ctre::phoenix6::spns::SpnValue::Slot1_kI,
2278 ctre::phoenix6::spns::SpnValue::Slot1_kD,
2279 ctre::phoenix6::spns::SpnValue::Slot1_kS,
2280 ctre::phoenix6::spns::SpnValue::Slot1_kV,
2281 ctre::phoenix6::spns::SpnValue::Slot1_kA,
2282 ctre::phoenix6::spns::SpnValue::Slot1_kG,
2283 ctre::phoenix6::spns::SpnValue::Slot1_kG_Type,
2284 }},
2285
2286 {2, SlotSpns{
2287 ctre::phoenix6::spns::SpnValue::Slot2_kP,
2288 ctre::phoenix6::spns::SpnValue::Slot2_kI,
2289 ctre::phoenix6::spns::SpnValue::Slot2_kD,
2290 ctre::phoenix6::spns::SpnValue::Slot2_kS,
2291 ctre::phoenix6::spns::SpnValue::Slot2_kV,
2292 ctre::phoenix6::spns::SpnValue::Slot2_kA,
2293 ctre::phoenix6::spns::SpnValue::Slot2_kG,
2294 ctre::phoenix6::spns::SpnValue::Slot2_kG_Type,
2295 }},
2296
2297 };
2298
2299public:
2300 /**
2301 * \brief Proportional Gain
2302 *
2303 * \details The units for this gain is dependent on the control mode.
2304 * Since this gain is multiplied by error in the input, the units
2305 * should be defined as units of output per unit of input error. For
2306 * example, when controlling velocity using a duty cycle closed loop,
2307 * the units for the proportional gain will be duty cycle per rps of
2308 * error, or 1/rps.
2309 *
2310 * Minimum Value: 0
2311 * Maximum Value: 3.4e+38
2312 * Default Value: 0
2313 * Units:
2314 */
2315 double kP = 0;
2316 /**
2317 * \brief Integral Gain
2318 *
2319 * \details The units for this gain is dependent on the control mode.
2320 * Since this gain is multiplied by error in the input integrated over
2321 * time (in units of seconds), the units should be defined as units of
2322 * output per unit of integrated input error. For example, when
2323 * controlling velocity using a duty cycle closed loop, integrating
2324 * velocity over time results in rps * s = rotations. Therefore, the
2325 * units for the integral gain will be duty cycle per rotation of
2326 * accumulated error, or 1/rot.
2327 *
2328 * Minimum Value: 0
2329 * Maximum Value: 3.4e+38
2330 * Default Value: 0
2331 * Units:
2332 */
2333 double kI = 0;
2334 /**
2335 * \brief Derivative Gain
2336 *
2337 * \details The units for this gain is dependent on the control mode.
2338 * Since this gain is multiplied by the derivative of error in the
2339 * input with respect to time (in units of seconds), the units should
2340 * be defined as units of output per unit of the differentiated input
2341 * error. For example, when controlling velocity using a duty cycle
2342 * closed loop, the derivative of velocity with respect to time is
2343 * rps/s, which is acceleration. Therefore, the units for the
2344 * derivative gain will be duty cycle per unit of acceleration error,
2345 * or 1/(rps/s).
2346 *
2347 * Minimum Value: 0
2348 * Maximum Value: 3.4e+38
2349 * Default Value: 0
2350 * Units:
2351 */
2352 double kD = 0;
2353 /**
2354 * \brief Static Feedforward Gain
2355 *
2356 * \details This is added to the closed loop output. The sign is
2357 * determined by target velocity. The unit for this constant is
2358 * dependent on the control mode, typically fractional duty cycle,
2359 * voltage, or torque current.
2360 *
2361 * Minimum Value: -512
2362 * Maximum Value: 511
2363 * Default Value: 0
2364 * Units:
2365 */
2366 double kS = 0;
2367 /**
2368 * \brief Velocity Feedforward Gain
2369 *
2370 * \details The units for this gain is dependent on the control mode.
2371 * Since this gain is multiplied by the requested velocity, the units
2372 * should be defined as units of output per unit of requested input
2373 * velocity. For example, when controlling velocity using a duty cycle
2374 * closed loop, the units for the velocity feedfoward gain will be
2375 * duty cycle per requested rps, or 1/rps.
2376 *
2377 * Minimum Value: 0
2378 * Maximum Value: 3.4e+38
2379 * Default Value: 0
2380 * Units:
2381 */
2382 double kV = 0;
2383 /**
2384 * \brief Acceleration Feedforward Gain
2385 *
2386 * \details The units for this gain is dependent on the control mode.
2387 * Since this gain is multiplied by the requested acceleration, the
2388 * units should be defined as units of output per unit of requested
2389 * input acceleration. For example, when controlling velocity using a
2390 * duty cycle closed loop, the units for the acceleration feedfoward
2391 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
2392 *
2393 * Minimum Value: 0
2394 * Maximum Value: 3.4e+38
2395 * Default Value: 0
2396 * Units:
2397 */
2398 double kA = 0;
2399 /**
2400 * \brief Gravity Feedforward Gain
2401 *
2402 * \details This is added to the closed loop output. The sign is
2403 * determined by the type of gravity feedforward. The unit for this
2404 * constant is dependent on the control mode, typically fractional
2405 * duty cycle, voltage, or torque current.
2406 *
2407 * Minimum Value: -512
2408 * Maximum Value: 511
2409 * Default Value: 0
2410 * Units:
2411 */
2412 double kG = 0;
2413 /**
2414 * \brief Gravity Feedforward Type
2415 *
2416 * \details This determines the type of the gravity feedforward.
2417 * Choose Elevator_Static for systems where the gravity feedforward is
2418 * constant, such as an elevator. The gravity feedforward output will
2419 * always have the same sign. Choose Arm_Cosine for systems where the
2420 * gravity feedforward is dependent on the angular position of the
2421 * mechanism, such as an arm. The gravity feedforward output will vary
2422 * depending on the mechanism angular position. Note that the sensor
2423 * offset and ratios must be configured so that the sensor reports a
2424 * position of 0 when the mechanism is horizonal (parallel to the
2425 * ground), and the reported sensor position is 1:1 with the
2426 * mechanism.
2427 *
2428 */
2430
2431
2432 /**
2433 * \brief Chooses which slot these configs are for.
2434 */
2435 int SlotNumber = 0;
2436
2437 static SlotConfigs From(const Slot0Configs& value);
2438 static SlotConfigs From(const Slot1Configs& value);
2439 static SlotConfigs From(const Slot2Configs& value);
2440
2441 std::string ToString() const
2442 {
2443 std::stringstream ss;
2444 ss << "{" << std::endl;
2445 ss << "Config Group: Slot" << std::endl;
2446 ss << "Name: \"kP\" Value: \"" << kP << "\"" << std::endl;
2447 ss << "Name: \"kI\" Value: \"" << kI << "\"" << std::endl;
2448 ss << "Name: \"kD\" Value: \"" << kD << "\"" << std::endl;
2449 ss << "Name: \"kS\" Value: \"" << kS << "\"" << std::endl;
2450 ss << "Name: \"kV\" Value: \"" << kV << "\"" << std::endl;
2451 ss << "Name: \"kA\" Value: \"" << kA << "\"" << std::endl;
2452 ss << "Name: \"kG\" Value: \"" << kG << "\"" << std::endl;
2453 ss << "Name: \"GravityType\" Value: \"" << GravityType << "\"" << std::endl;
2454 ss << "}" << std::endl;
2455 return ss.str();
2456 }
2457
2458 std::string Serialize() const
2459 {
2460 std::stringstream ss;
2461 SlotSpns currentSpns = genericMap.at(SlotNumber);
2462 char *ref;
2463 c_ctre_phoenix6_serialize_double(currentSpns.kPSpn, kP, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2464 c_ctre_phoenix6_serialize_double(currentSpns.kISpn, kI, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2465 c_ctre_phoenix6_serialize_double(currentSpns.kDSpn, kD, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2466 c_ctre_phoenix6_serialize_double(currentSpns.kSSpn, kS, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2467 c_ctre_phoenix6_serialize_double(currentSpns.kVSpn, kV, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2468 c_ctre_phoenix6_serialize_double(currentSpns.kASpn, kA, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2469 c_ctre_phoenix6_serialize_double(currentSpns.kGSpn, kG, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2470 c_ctre_phoenix6_serialize_int(currentSpns.GravityTypeSpn, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2471 return ss.str();
2472 }
2473
2474 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize)
2475 {
2476 const char *string_c_str = to_deserialize.c_str();
2477 size_t string_length = to_deserialize.length();
2478 SlotSpns currentSpns = genericMap.at(SlotNumber);
2479 c_ctre_phoenix6_deserialize_double(currentSpns.kPSpn, string_c_str, string_length, &kP);
2480 c_ctre_phoenix6_deserialize_double(currentSpns.kISpn, string_c_str, string_length, &kI);
2481 c_ctre_phoenix6_deserialize_double(currentSpns.kDSpn, string_c_str, string_length, &kD);
2482 c_ctre_phoenix6_deserialize_double(currentSpns.kSSpn, string_c_str, string_length, &kS);
2483 c_ctre_phoenix6_deserialize_double(currentSpns.kVSpn, string_c_str, string_length, &kV);
2484 c_ctre_phoenix6_deserialize_double(currentSpns.kASpn, string_c_str, string_length, &kA);
2485 c_ctre_phoenix6_deserialize_double(currentSpns.kGSpn, string_c_str, string_length, &kG);
2486 c_ctre_phoenix6_deserialize_int(currentSpns.GravityTypeSpn, string_c_str, string_length, &GravityType.value);
2487 return 0;
2488 }
2489};
2490
2491
2492}
2493}
2494}
ii that the Software will be uninterrupted or error free
Definition: CTRE_LICENSE.txt:191
CTREXPORT int c_ctre_phoenix6_deserialize_double(int spn, const char *str, uint32_t strlen, double *val)
CTREXPORT int c_ctre_phoenix6_serialize_int(int spn, int value, char **str)
CTREXPORT int c_ctre_phoenix6_serialize_bool(int spn, bool value, char **str)
CTREXPORT int c_ctre_phoenix6_deserialize_bool(int spn, const char *str, uint32_t strlen, bool *val)
CTREXPORT int c_ctre_phoenix6_deserialize_int(int spn, const char *str, uint32_t strlen, int *val)
CTREXPORT int c_ctre_phoenix6_serialize_double(int spn, double value, char **str)
Definition: Serializable.hpp:15
Configs that affect audible components of the device.
Definition: Configs.hpp:1332
bool BeepOnConfig
If true, the TalonFX will beep during configuration API calls if device is disabled.
Definition: Configs.hpp:1351
bool AllowMusicDurDisable
If true, the TalonFX will allow Orchestra and MusicTone requests during disabled state.
Definition: Configs.hpp:1361
std::string Serialize() const override
Definition: Configs.hpp:1377
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1387
std::string ToString() const override
Definition: Configs.hpp:1365
bool BeepOnBoot
If true, the TalonFX will beep during boot-up.
Definition: Configs.hpp:1342
Configs that affect general behavior during closed-looping.
Definition: Configs.hpp:1627
bool ContinuousWrap
Wrap position error within [-0.5,+0.5) mechanism rotations.
Definition: Configs.hpp:1641
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1663
std::string ToString() const override
Definition: Configs.hpp:1645
std::string Serialize() const override
Definition: Configs.hpp:1655
Configs that affect the closed-loop control of this motor controller.
Definition: Configs.hpp:1090
double TorqueClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0A output to 300A during closed-loop modes.
Definition: Configs.hpp:1121
std::string Serialize() const override
Definition: Configs.hpp:1137
double VoltageClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0V output to 12V during closed-loop modes.
Definition: Configs.hpp:1111
double DutyCycleClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0% output to 100% during closed-loop modes.
Definition: Configs.hpp:1101
std::string ToString() const override
Definition: Configs.hpp:1125
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1147
Configs that directly affect current limiting features.
Definition: Configs.hpp:424
bool StatorCurrentLimitEnable
Enable motor stator current limiting.
Definition: Configs.hpp:443
double StatorCurrentLimit
The amount of current allowed in the motor (motoring and regen current).
Definition: Configs.hpp:437
double SupplyCurrentLimit
The amount of supply current allowed.
Definition: Configs.hpp:456
double SupplyCurrentThreshold
Delay supply current limiting until current exceeds this threshold for longer than SupplyTimeThreshol...
Definition: Configs.hpp:474
std::string Serialize() const override
Definition: Configs.hpp:504
double SupplyTimeThreshold
Allows unlimited current for a period of time before current limiting occurs.
Definition: Configs.hpp:485
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:517
std::string ToString() const override
Definition: Configs.hpp:489
bool SupplyCurrentLimitEnable
Enable motor supply current limiting.
Definition: Configs.hpp:462
Custom Params.
Definition: Configs.hpp:1565
std::string ToString() const override
Definition: Configs.hpp:1590
int CustomParam0
Custom parameter 0.
Definition: Configs.hpp:1576
std::string Serialize() const override
Definition: Configs.hpp:1601
int CustomParam1
Custom parameter 1.
Definition: Configs.hpp:1586
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1610
Configs related to constants used for differential control of a mechanism.
Definition: Configs.hpp:938
std::string Serialize() const override
Definition: Configs.hpp:985
std::string ToString() const override
Definition: Configs.hpp:973
double PeakDifferentialDutyCycle
Maximum differential output during duty cycle based differential control modes.
Definition: Configs.hpp:949
double PeakDifferentialTorqueCurrent
Maximum differential output during torque current based differential control modes.
Definition: Configs.hpp:969
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:995
double PeakDifferentialVoltage
Maximum differential output during voltage based differential control modes.
Definition: Configs.hpp:959
Configs related to sensors used for differential control of a mechanism.
Definition: Configs.hpp:846
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:919
std::string Serialize() const override
Definition: Configs.hpp:909
std::string ToString() const override
Definition: Configs.hpp:897
signals::DifferentialSensorSourceValue DifferentialSensorSource
Choose what sensor source is used for differential control of a mechanism.
Definition: Configs.hpp:872
int DifferentialRemoteSensorID
Device ID of which remote sensor to use on the differential axis.
Definition: Configs.hpp:893
int DifferentialTalonFXSensorID
Device ID of which remote Talon FX to use.
Definition: Configs.hpp:882
Configs that affect the feedback of this motor controller.
Definition: Configs.hpp:695
std::string ToString() const override
Definition: Configs.hpp:799
double FeedbackRotorOffset
This offset is applied to the absolute integrated rotor sensor.
Definition: Configs.hpp:707
signals::FeedbackSensorSourceValue FeedbackSensorSource
Choose what sensor source is reported via API and used by closed-loop and limit features.
Definition: Configs.hpp:769
FeedbackConfigs & WithRemoteCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use Remote CANcoder by passing in the CANcoder obje...
double SensorToMechanismRatio
This is the ratio of sensor rotations to the mechanism's output.
Definition: Configs.hpp:720
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:825
std::string Serialize() const override
Definition: Configs.hpp:813
double RotorToSensorRatio
Talon FX is capable of fusing a remote CANcoder with its rotor sensor to produce a high-bandwidth sen...
Definition: Configs.hpp:733
int FeedbackRemoteSensorID
Device ID of which remote device to use.
Definition: Configs.hpp:779
FeedbackConfigs & WithFusedCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use Fused CANcoder by passing in the CANcoder objec...
Configs to trim the Pigeon2's gyroscope.
Definition: Configs.hpp:193
std::string Serialize() const override
Definition: Configs.hpp:237
std::string ToString() const override
Definition: Configs.hpp:225
double GyroScalarX
The gyro scalar component for the X axis.
Definition: Configs.hpp:203
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:247
double GyroScalarZ
The gyro scalar component for the Z axis.
Definition: Configs.hpp:221
double GyroScalarY
The gyro scalar component for the Y axis.
Definition: Configs.hpp:212
Configs that change how the motor controller behaves under different limit switch statse.
Definition: Configs.hpp:1168
std::string ToString() const override
Definition: Configs.hpp:1265
signals::ForwardLimitTypeValue ForwardLimitType
Determines if limit is normally-open (default) or normally-closed.
Definition: Configs.hpp:1175
signals::ForwardLimitSourceValue ForwardLimitSource
Determines where to poll the forward limit switch.
Definition: Configs.hpp:1205
bool ForwardLimitEnable
If enabled, motor output is set to neutral when forward limit switch is asseted and positive output i...
Definition: Configs.hpp:1199
bool ReverseLimitAutosetPositionEnable
If enabled, the position is auto-set to a specific value, specified by ReverseLimitAutosetPositionVal...
Definition: Configs.hpp:1228
bool ForwardLimitAutosetPositionEnable
If enabled, the position is auto-set to a specific value, specified by ForwardLimitAutosetPositionVal...
Definition: Configs.hpp:1182
signals::ReverseLimitTypeValue ReverseLimitType
Determines if limit is normally-open (default) or normally-closed.
Definition: Configs.hpp:1221
double ReverseLimitAutosetPositionValue
The value to auto-set the position to.
Definition: Configs.hpp:1238
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1305
int ForwardLimitRemoteSensorID
Device ID of the device if using remote limit switch features.
Definition: Configs.hpp:1215
double ForwardLimitAutosetPositionValue
The value to auto-set the position to.
Definition: Configs.hpp:1192
signals::ReverseLimitSourceValue ReverseLimitSource
Determines where to poll the reverse limit switch.
Definition: Configs.hpp:1251
std::string Serialize() const override
Definition: Configs.hpp:1286
bool ReverseLimitEnable
If enabled, motor output is set to neutral when reverse limit switch is asseted and positive output i...
Definition: Configs.hpp:1245
int ReverseLimitRemoteSensorID
Device ID of the device if using remote limit switch features.
Definition: Configs.hpp:1261
Configs that affect the magnet sensor and how to interpret it.
Definition: Configs.hpp:46
std::string Serialize() const override
Definition: Configs.hpp:87
signals::AbsoluteSensorRangeValue AbsoluteSensorRange
The range of the absolute sensor, either [0, 1) or [-0.5, 0.5).
Definition: Configs.hpp:71
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:97
double MagnetOffset
This offset is added to the reported position, allowing the application to trim the zero position.
Definition: Configs.hpp:65
std::string ToString() const override
Definition: Configs.hpp:75
signals::SensorDirectionValue SensorDirection
Direction of the sensor to determine positive facing the LED side of the CANcoder.
Definition: Configs.hpp:53
Configs for Motion Magic®.
Definition: Configs.hpp:1488
double MotionMagicCruiseVelocity
This is the maximum velocity Motion Magic® based control modes are allowed to use.
Definition: Configs.hpp:1499
std::string Serialize() const override
Definition: Configs.hpp:1537
double MotionMagicJerk
This is the target jerk (acceleration derivative) Motion Magic® based control modes are allowed to us...
Definition: Configs.hpp:1521
double MotionMagicAcceleration
This is the target acceleration Motion Magic® based control modes are allowed to use.
Definition: Configs.hpp:1509
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1547
std::string ToString() const override
Definition: Configs.hpp:1525
Configs that directly affect motor-output.
Definition: Configs.hpp:332
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:403
double PeakForwardDutyCycle
Maximum (forward) output during duty cycle based control modes.
Definition: Configs.hpp:363
double DutyCycleNeutralDeadband
Configures the output deadband percentage.
Definition: Configs.hpp:353
signals::NeutralModeValue NeutralMode
The state of the motor controller bridge when output is neutral or disabled.
Definition: Configs.hpp:344
double PeakReverseDutyCycle
Minimum (reverse) output during duty cycle based control modes.
Definition: Configs.hpp:373
std::string ToString() const override
Definition: Configs.hpp:377
signals::InvertedValue Inverted
Invert state of the device.
Definition: Configs.hpp:338
std::string Serialize() const override
Definition: Configs.hpp:391
Configs for Pigeon 2's Mount Pose configuration.
Definition: Configs.hpp:117
double MountPoseYaw
The mounting calibration yaw-component.
Definition: Configs.hpp:127
double MountPosePitch
The mounting calibration pitch-component.
Definition: Configs.hpp:136
std::string ToString() const override
Definition: Configs.hpp:149
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:171
double MountPoseRoll
The mounting calibration roll-component.
Definition: Configs.hpp:145
std::string Serialize() const override
Definition: Configs.hpp:161
Configs that affect the open-loop control of this motor controller.
Definition: Configs.hpp:1014
std::string Serialize() const override
Definition: Configs.hpp:1061
double DutyCycleOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0% output to 100% during open-loop modes.
Definition: Configs.hpp:1025
std::string ToString() const override
Definition: Configs.hpp:1049
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1071
double VoltageOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0V output to 12V during open-loop modes.
Definition: Configs.hpp:1035
double TorqueOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0A output to 300A during open-loop modes.
Definition: Configs.hpp:1045
friend std::ostream & operator<<(std::ostream &str, const ParentConfiguration &v)
Definition: Configs.hpp:30
virtual ctre::phoenix::StatusCode Deserialize(const std::string &string)=0
virtual std::string ToString() const =0
Configs to enable/disable various features of the Pigeon2.
Definition: Configs.hpp:266
bool DisableTemperatureCompensation
Disables using the temperature compensation feature.
Definition: Configs.hpp:282
std::string ToString() const override
Definition: Configs.hpp:292
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:314
std::string Serialize() const override
Definition: Configs.hpp:304
bool DisableNoMotionCalibration
Disables using the no-motion calibration feature.
Definition: Configs.hpp:288
bool EnableCompass
Turns on or off the magnetometer fusing for 9-axis.
Definition: Configs.hpp:276
Gains for the specified slot.
Definition: Configs.hpp:1680
static Slot0Configs From(const SlotConfigs &value)
std::string ToString() const override
Definition: Configs.hpp:1815
signals::GravityTypeValue GravityType
Gravity Feedforward Type.
Definition: Configs.hpp:1811
double kD
Derivative Gain.
Definition: Configs.hpp:1734
double kG
Gravity Feedforward Gain.
Definition: Configs.hpp:1794
double kV
Velocity Feedforward Gain.
Definition: Configs.hpp:1764
double kI
Integral Gain.
Definition: Configs.hpp:1715
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1847
double kA
Acceleration Feedforward Gain.
Definition: Configs.hpp:1780
double kP
Proportional Gain.
Definition: Configs.hpp:1697
std::string Serialize() const override
Definition: Configs.hpp:1832
double kS
Static Feedforward Gain.
Definition: Configs.hpp:1748
Gains for the specified slot.
Definition: Configs.hpp:1871
std::string Serialize() const override
Definition: Configs.hpp:2022
static Slot1Configs From(const SlotConfigs &value)
double kD
Derivative Gain.
Definition: Configs.hpp:1925
double kI
Integral Gain.
Definition: Configs.hpp:1906
double kS
Static Feedforward Gain.
Definition: Configs.hpp:1939
double kA
Acceleration Feedforward Gain.
Definition: Configs.hpp:1971
double kG
Gravity Feedforward Gain.
Definition: Configs.hpp:1985
std::string ToString() const override
Definition: Configs.hpp:2005
double kP
Proportional Gain.
Definition: Configs.hpp:1888
signals::GravityTypeValue GravityType
Gravity Feedforward Type.
Definition: Configs.hpp:2001
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:2037
double kV
Velocity Feedforward Gain.
Definition: Configs.hpp:1955
Gains for the specified slot.
Definition: Configs.hpp:2061
double kV
Velocity Feedforward Gain.
Definition: Configs.hpp:2145
std::string Serialize() const override
Definition: Configs.hpp:2212
signals::GravityTypeValue GravityType
Gravity Feedforward Type.
Definition: Configs.hpp:2191
double kP
Proportional Gain.
Definition: Configs.hpp:2078
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:2227
double kI
Integral Gain.
Definition: Configs.hpp:2096
double kA
Acceleration Feedforward Gain.
Definition: Configs.hpp:2161
double kG
Gravity Feedforward Gain.
Definition: Configs.hpp:2175
double kS
Static Feedforward Gain.
Definition: Configs.hpp:2129
static Slot2Configs From(const SlotConfigs &value)
std::string ToString() const override
Definition: Configs.hpp:2195
double kD
Derivative Gain.
Definition: Configs.hpp:2115
Gains for the specified slot.
Definition: Configs.hpp:2250
static SlotConfigs From(const Slot2Configs &value)
std::string ToString() const
Definition: Configs.hpp:2441
double kP
Proportional Gain.
Definition: Configs.hpp:2315
static SlotConfigs From(const Slot1Configs &value)
double kG
Gravity Feedforward Gain.
Definition: Configs.hpp:2412
double kI
Integral Gain.
Definition: Configs.hpp:2333
double kA
Acceleration Feedforward Gain.
Definition: Configs.hpp:2398
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize)
Definition: Configs.hpp:2474
double kD
Derivative Gain.
Definition: Configs.hpp:2352
int SlotNumber
Chooses which slot these configs are for.
Definition: Configs.hpp:2435
double kV
Velocity Feedforward Gain.
Definition: Configs.hpp:2382
std::string Serialize() const
Definition: Configs.hpp:2458
static SlotConfigs From(const Slot0Configs &value)
signals::GravityTypeValue GravityType
Gravity Feedforward Type.
Definition: Configs.hpp:2429
double kS
Static Feedforward Gain.
Definition: Configs.hpp:2366
Configs that affect how software-limit switches behave.
Definition: Configs.hpp:1406
double ForwardSoftLimitThreshold
Position threshold for forward soft limit features.
Definition: Configs.hpp:1431
std::string ToString() const override
Definition: Configs.hpp:1445
double ReverseSoftLimitThreshold
Position threshold for reverse soft limit features.
Definition: Configs.hpp:1441
std::string Serialize() const override
Definition: Configs.hpp:1458
bool ReverseSoftLimitEnable
If enabled, the motor output is set to neutral if position exceeds ReverseSoftLimitThreshold and reve...
Definition: Configs.hpp:1421
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1469
bool ForwardSoftLimitEnable
If enabled, the motor output is set to neutral if position exceeds ForwardSoftLimitThreshold and forw...
Definition: Configs.hpp:1414
Configs to control the maximum and minimum applied torque when using Torque Current control types.
Definition: Configs.hpp:617
std::string ToString() const override
Definition: Configs.hpp:652
double TorqueNeutralDeadband
Configures the output deadband during torque current based control modes.
Definition: Configs.hpp:648
double PeakForwardTorqueCurrent
Maximum (forward) output during torque current based control modes.
Definition: Configs.hpp:628
std::string Serialize() const override
Definition: Configs.hpp:664
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:674
double PeakReverseTorqueCurrent
Minimum (reverse) output during torque current based control modes.
Definition: Configs.hpp:638
Voltage-specific configs.
Definition: Configs.hpp:538
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:597
double PeakReverseVoltage
Minimum (reverse) output during voltage based control modes.
Definition: Configs.hpp:571
std::string Serialize() const override
Definition: Configs.hpp:587
std::string ToString() const override
Definition: Configs.hpp:575
double PeakForwardVoltage
Maximum (forward) output during voltage based control modes.
Definition: Configs.hpp:562
double SupplyVoltageTimeConstant
The time constant (in seconds) of the low-pass filter for the supply voltage.
Definition: Configs.hpp:553
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CoreCANcoder.hpp:476
The range of the absolute sensor, either [0, 1) or [-0.5, 0.5).
Definition: SpnEnums.hpp:682
static constexpr int Unsigned_0To1
Definition: SpnEnums.hpp:686
Choose what sensor source is used for differential control of a mechanism.
Definition: SpnEnums.hpp:2061
static constexpr int Disabled
Definition: SpnEnums.hpp:2065
Choose what sensor source is reported via API and used by closed-loop and limit features.
Definition: SpnEnums.hpp:1551
int value
Definition: SpnEnums.hpp:1553
static constexpr int RotorSensor
Definition: SpnEnums.hpp:1555
Determines where to poll the forward limit switch.
Definition: SpnEnums.hpp:1692
static constexpr int LimitSwitchPin
Definition: SpnEnums.hpp:1696
int value
Definition: SpnEnums.hpp:1694
Determines if limit is normally-open (default) or normally-closed.
Definition: SpnEnums.hpp:1626
static constexpr int NormallyOpen
Definition: SpnEnums.hpp:1630
int value
Definition: SpnEnums.hpp:1628
Gravity Feedforward Type.
Definition: SpnEnums.hpp:1325
static constexpr int Elevator_Static
Definition: SpnEnums.hpp:1329
int value
Definition: SpnEnums.hpp:1327
Invert state of the device.
Definition: SpnEnums.hpp:1390
static constexpr int CounterClockwise_Positive
Definition: SpnEnums.hpp:1394
int value
Definition: SpnEnums.hpp:1392
The state of the motor controller bridge when output is neutral or disabled.
Definition: SpnEnums.hpp:1456
int value
Definition: SpnEnums.hpp:1458
static constexpr int Coast
Definition: SpnEnums.hpp:1460
Determines where to poll the reverse limit switch.
Definition: SpnEnums.hpp:1825
int value
Definition: SpnEnums.hpp:1827
static constexpr int LimitSwitchPin
Definition: SpnEnums.hpp:1829
Determines if limit is normally-open (default) or normally-closed.
Definition: SpnEnums.hpp:1759
static constexpr int NormallyOpen
Definition: SpnEnums.hpp:1763
int value
Definition: SpnEnums.hpp:1761
Direction of the sensor to determine positive facing the LED side of the CANcoder.
Definition: SpnEnums.hpp:179
static constexpr int CounterClockwise_Positive
Definition: SpnEnums.hpp:183
int value
Definition: SpnEnums.hpp:181
Definition: ManualEvent.hpp:12