CTRE Phoenix 6 C++ 24.3.0
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 hardware { namespace core { class CoreTalonFX; } }
23namespace configs { class SlotConfigs; }
24
25namespace configs {
26
28{
29public:
30 virtual std::string ToString() const = 0;
31 friend std::ostream &operator<<(std::ostream &str, const ParentConfiguration &v)
32 {
33 str << v.ToString();
34 return str;
35 }
36 virtual ctre::phoenix::StatusCode Deserialize(const std::string &string) = 0;
37};
38
39
40/**
41 * \brief Configs that affect the magnet sensor and how to interpret
42 * it.
43 *
44 * \details Includes sensor range, sensor direction, and the magnet
45 * offset.
46 */
48{
49public:
50 /**
51 * \brief Direction of the sensor to determine positive rotation, as
52 * seen facing the LED side of the CANcoder.
53 *
54 */
56 /**
57 * \brief This offset is added to the reported position, allowing the
58 * application to trim the zero position. When set to the default
59 * value of zero, position reports zero when magnet north pole aligns
60 * with the LED.
61 *
62 * - Minimum Value: -1
63 * - Maximum Value: 1
64 * - Default Value: 0
65 * - Units: rotations
66 */
67 double MagnetOffset = 0;
68 /**
69 * \brief The range of the absolute sensor in rotations, either [-0.5,
70 * 0.5) or [0, 1).
71 *
72 */
74
75 /**
76 * \brief Modifies this configuration's SensorDirection parameter and returns itself for
77 * method-chaining and easier to use config API.
78 *
79 * Direction of the sensor to determine positive rotation, as seen
80 * facing the LED side of the CANcoder.
81 *
82 *
83 * \param newSensorDirection Parameter to modify
84 * \returns Itself
85 */
87 {
88 SensorDirection = std::move(newSensorDirection);
89 return *this;
90 }
91 /**
92 * \brief Modifies this configuration's MagnetOffset parameter and returns itself for
93 * method-chaining and easier to use config API.
94 *
95 * This offset is added to the reported position, allowing the
96 * application to trim the zero position. When set to the default
97 * value of zero, position reports zero when magnet north pole aligns
98 * with the LED.
99 *
100 * - Minimum Value: -1
101 * - Maximum Value: 1
102 * - Default Value: 0
103 * - Units: rotations
104 *
105 * \param newMagnetOffset Parameter to modify
106 * \returns Itself
107 */
108 MagnetSensorConfigs& WithMagnetOffset(double newMagnetOffset)
109 {
110 MagnetOffset = std::move(newMagnetOffset);
111 return *this;
112 }
113 /**
114 * \brief Modifies this configuration's AbsoluteSensorRange parameter and returns itself for
115 * method-chaining and easier to use config API.
116 *
117 * The range of the absolute sensor in rotations, either [-0.5, 0.5)
118 * or [0, 1).
119 *
120 *
121 * \param newAbsoluteSensorRange Parameter to modify
122 * \returns Itself
123 */
125 {
126 AbsoluteSensorRange = std::move(newAbsoluteSensorRange);
127 return *this;
128 }
129
130
131
132 std::string ToString() const override
133 {
134 std::stringstream ss;
135 ss << "{" << std::endl;
136 ss << "Config Group: MagnetSensor" << std::endl;
137 ss << "Name: \"SensorDirection\" Value: \"" << SensorDirection << "\"" << std::endl;
138 ss << "Name: \"MagnetOffset\" Value: \"" << MagnetOffset << "rotations\"" << std::endl;
139 ss << "Name: \"AbsoluteSensorRange\" Value: \"" << AbsoluteSensorRange << "\"" << std::endl;
140 ss << "}" << std::endl;
141 return ss.str();
142 }
143
144 std::string Serialize() const override
145 {
146 std::stringstream ss;
147 char *ref;
148 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CANcoder_SensorDirection, SensorDirection.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
149 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANCoder_MagnetOffset, MagnetOffset, &ref); if (ref != nullptr) { ss << ref; free(ref); }
150 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CANcoder_AbsoluteSensorRange, AbsoluteSensorRange.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
151 return ss.str();
152 }
153
154 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
155 {
156 const char *string_c_str = to_deserialize.c_str();
157 size_t string_length = to_deserialize.length();
158 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CANcoder_SensorDirection, string_c_str, string_length, &SensorDirection.value);
159 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANCoder_MagnetOffset, string_c_str, string_length, &MagnetOffset);
160 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CANcoder_AbsoluteSensorRange, string_c_str, string_length, &AbsoluteSensorRange.value);
161 return 0;
162 }
163};
164
165
166/**
167 * \brief Configs for Pigeon 2's Mount Pose configuration.
168 *
169 * \details These configs allow the Pigeon2 to be mounted in whatever
170 * orientation that's desired and ensure the reported
171 * Yaw/Pitch/Roll is from the robot's reference.
172 */
174{
175public:
176 /**
177 * \brief The mounting calibration yaw-component
178 *
179 * - Minimum Value: -360
180 * - Maximum Value: 360
181 * - Default Value: 0
182 * - Units: deg
183 */
184 double MountPoseYaw = 0;
185 /**
186 * \brief The mounting calibration pitch-component
187 *
188 * - Minimum Value: -360
189 * - Maximum Value: 360
190 * - Default Value: 0
191 * - Units: deg
192 */
193 double MountPosePitch = 0;
194 /**
195 * \brief The mounting calibration roll-component
196 *
197 * - Minimum Value: -360
198 * - Maximum Value: 360
199 * - Default Value: 0
200 * - Units: deg
201 */
202 double MountPoseRoll = 0;
203
204 /**
205 * \brief Modifies this configuration's MountPoseYaw parameter and returns itself for
206 * method-chaining and easier to use config API.
207 *
208 * The mounting calibration yaw-component
209 *
210 * - Minimum Value: -360
211 * - Maximum Value: 360
212 * - Default Value: 0
213 * - Units: deg
214 *
215 * \param newMountPoseYaw Parameter to modify
216 * \returns Itself
217 */
218 MountPoseConfigs& WithMountPoseYaw(double newMountPoseYaw)
219 {
220 MountPoseYaw = std::move(newMountPoseYaw);
221 return *this;
222 }
223 /**
224 * \brief Modifies this configuration's MountPosePitch parameter and returns itself for
225 * method-chaining and easier to use config API.
226 *
227 * The mounting calibration pitch-component
228 *
229 * - Minimum Value: -360
230 * - Maximum Value: 360
231 * - Default Value: 0
232 * - Units: deg
233 *
234 * \param newMountPosePitch Parameter to modify
235 * \returns Itself
236 */
237 MountPoseConfigs& WithMountPosePitch(double newMountPosePitch)
238 {
239 MountPosePitch = std::move(newMountPosePitch);
240 return *this;
241 }
242 /**
243 * \brief Modifies this configuration's MountPoseRoll parameter and returns itself for
244 * method-chaining and easier to use config API.
245 *
246 * The mounting calibration roll-component
247 *
248 * - Minimum Value: -360
249 * - Maximum Value: 360
250 * - Default Value: 0
251 * - Units: deg
252 *
253 * \param newMountPoseRoll Parameter to modify
254 * \returns Itself
255 */
256 MountPoseConfigs& WithMountPoseRoll(double newMountPoseRoll)
257 {
258 MountPoseRoll = std::move(newMountPoseRoll);
259 return *this;
260 }
261
262
263
264 std::string ToString() const override
265 {
266 std::stringstream ss;
267 ss << "{" << std::endl;
268 ss << "Config Group: MountPose" << std::endl;
269 ss << "Name: \"MountPoseYaw\" Value: \"" << MountPoseYaw << "deg\"" << std::endl;
270 ss << "Name: \"MountPosePitch\" Value: \"" << MountPosePitch << "deg\"" << std::endl;
271 ss << "Name: \"MountPoseRoll\" Value: \"" << MountPoseRoll << "deg\"" << std::endl;
272 ss << "}" << std::endl;
273 return ss.str();
274 }
275
276 std::string Serialize() const override
277 {
278 std::stringstream ss;
279 char *ref;
280 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseYaw, MountPoseYaw, &ref); if (ref != nullptr) { ss << ref; free(ref); }
281 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPosePitch, MountPosePitch, &ref); if (ref != nullptr) { ss << ref; free(ref); }
282 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseRoll, MountPoseRoll, &ref); if (ref != nullptr) { ss << ref; free(ref); }
283 return ss.str();
284 }
285
286 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
287 {
288 const char *string_c_str = to_deserialize.c_str();
289 size_t string_length = to_deserialize.length();
290 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseYaw, string_c_str, string_length, &MountPoseYaw);
291 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPosePitch, string_c_str, string_length, &MountPosePitch);
292 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseRoll, string_c_str, string_length, &MountPoseRoll);
293 return 0;
294 }
295};
296
297
298/**
299 * \brief Configs to trim the Pigeon2's gyroscope.
300 *
301 * \details Pigeon2 allows the user to trim the gyroscope's
302 * sensitivity. While this isn't necessary for the Pigeon2,
303 * as it comes calibrated out-of-the-box, users can make use
304 * of this to make the Pigeon2 even more accurate for their
305 * application.
306 */
308{
309public:
310 /**
311 * \brief The gyro scalar component for the X axis
312 *
313 * - Minimum Value: -180
314 * - Maximum Value: 180
315 * - Default Value: 0
316 * - Units: deg per rotation
317 */
318 double GyroScalarX = 0;
319 /**
320 * \brief The gyro scalar component for the Y axis
321 *
322 * - Minimum Value: -180
323 * - Maximum Value: 180
324 * - Default Value: 0
325 * - Units: deg per rotation
326 */
327 double GyroScalarY = 0;
328 /**
329 * \brief The gyro scalar component for the Z axis
330 *
331 * - Minimum Value: -180
332 * - Maximum Value: 180
333 * - Default Value: 0
334 * - Units: deg per rotation
335 */
336 double GyroScalarZ = 0;
337
338 /**
339 * \brief Modifies this configuration's GyroScalarX parameter and returns itself for
340 * method-chaining and easier to use config API.
341 *
342 * The gyro scalar component for the X axis
343 *
344 * - Minimum Value: -180
345 * - Maximum Value: 180
346 * - Default Value: 0
347 * - Units: deg per rotation
348 *
349 * \param newGyroScalarX Parameter to modify
350 * \returns Itself
351 */
352 GyroTrimConfigs& WithGyroScalarX(double newGyroScalarX)
353 {
354 GyroScalarX = std::move(newGyroScalarX);
355 return *this;
356 }
357 /**
358 * \brief Modifies this configuration's GyroScalarY parameter and returns itself for
359 * method-chaining and easier to use config API.
360 *
361 * The gyro scalar component for the Y axis
362 *
363 * - Minimum Value: -180
364 * - Maximum Value: 180
365 * - Default Value: 0
366 * - Units: deg per rotation
367 *
368 * \param newGyroScalarY Parameter to modify
369 * \returns Itself
370 */
371 GyroTrimConfigs& WithGyroScalarY(double newGyroScalarY)
372 {
373 GyroScalarY = std::move(newGyroScalarY);
374 return *this;
375 }
376 /**
377 * \brief Modifies this configuration's GyroScalarZ parameter and returns itself for
378 * method-chaining and easier to use config API.
379 *
380 * The gyro scalar component for the Z axis
381 *
382 * - Minimum Value: -180
383 * - Maximum Value: 180
384 * - Default Value: 0
385 * - Units: deg per rotation
386 *
387 * \param newGyroScalarZ Parameter to modify
388 * \returns Itself
389 */
390 GyroTrimConfigs& WithGyroScalarZ(double newGyroScalarZ)
391 {
392 GyroScalarZ = std::move(newGyroScalarZ);
393 return *this;
394 }
395
396
397
398 std::string ToString() const override
399 {
400 std::stringstream ss;
401 ss << "{" << std::endl;
402 ss << "Config Group: GyroTrim" << std::endl;
403 ss << "Name: \"GyroScalarX\" Value: \"" << GyroScalarX << "deg per rotation\"" << std::endl;
404 ss << "Name: \"GyroScalarY\" Value: \"" << GyroScalarY << "deg per rotation\"" << std::endl;
405 ss << "Name: \"GyroScalarZ\" Value: \"" << GyroScalarZ << "deg per rotation\"" << std::endl;
406 ss << "}" << std::endl;
407 return ss.str();
408 }
409
410 std::string Serialize() const override
411 {
412 std::stringstream ss;
413 char *ref;
414 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarX, GyroScalarX, &ref); if (ref != nullptr) { ss << ref; free(ref); }
415 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarY, GyroScalarY, &ref); if (ref != nullptr) { ss << ref; free(ref); }
416 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarZ, GyroScalarZ, &ref); if (ref != nullptr) { ss << ref; free(ref); }
417 return ss.str();
418 }
419
420 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
421 {
422 const char *string_c_str = to_deserialize.c_str();
423 size_t string_length = to_deserialize.length();
424 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarX, string_c_str, string_length, &GyroScalarX);
425 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarY, string_c_str, string_length, &GyroScalarY);
426 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarZ, string_c_str, string_length, &GyroScalarZ);
427 return 0;
428 }
429};
430
431
432/**
433 * \brief Configs to enable/disable various features of the Pigeon2.
434 *
435 * \details These configs allow the user to enable or disable various
436 * aspects of the Pigeon2.
437 */
439{
440public:
441 /**
442 * \brief Turns on or off the magnetometer fusing for 9-axis. FRC
443 * users are not recommended to turn this on, as the magnetic
444 * influence of the robot will likely negatively affect the
445 * performance of the Pigeon2.
446 *
447 * - Default Value: False
448 */
449 bool EnableCompass = false;
450 /**
451 * \brief Disables using the temperature compensation feature
452 *
453 * - Default Value: False
454 */
456 /**
457 * \brief Disables using the no-motion calibration feature
458 *
459 * - Default Value: False
460 */
462
463 /**
464 * \brief Modifies this configuration's EnableCompass parameter and returns itself for
465 * method-chaining and easier to use config API.
466 *
467 * Turns on or off the magnetometer fusing for 9-axis. FRC users are
468 * not recommended to turn this on, as the magnetic influence of the
469 * robot will likely negatively affect the performance of the Pigeon2.
470 *
471 * - Default Value: False
472 *
473 * \param newEnableCompass Parameter to modify
474 * \returns Itself
475 */
477 {
478 EnableCompass = std::move(newEnableCompass);
479 return *this;
480 }
481 /**
482 * \brief Modifies this configuration's DisableTemperatureCompensation parameter and returns itself for
483 * method-chaining and easier to use config API.
484 *
485 * Disables using the temperature compensation feature
486 *
487 * - Default Value: False
488 *
489 * \param newDisableTemperatureCompensation Parameter to modify
490 * \returns Itself
491 */
492 Pigeon2FeaturesConfigs& WithDisableTemperatureCompensation(bool newDisableTemperatureCompensation)
493 {
494 DisableTemperatureCompensation = std::move(newDisableTemperatureCompensation);
495 return *this;
496 }
497 /**
498 * \brief Modifies this configuration's DisableNoMotionCalibration parameter and returns itself for
499 * method-chaining and easier to use config API.
500 *
501 * Disables using the no-motion calibration feature
502 *
503 * - Default Value: False
504 *
505 * \param newDisableNoMotionCalibration Parameter to modify
506 * \returns Itself
507 */
508 Pigeon2FeaturesConfigs& WithDisableNoMotionCalibration(bool newDisableNoMotionCalibration)
509 {
510 DisableNoMotionCalibration = std::move(newDisableNoMotionCalibration);
511 return *this;
512 }
513
514
515
516 std::string ToString() const override
517 {
518 std::stringstream ss;
519 ss << "{" << std::endl;
520 ss << "Config Group: Pigeon2Features" << std::endl;
521 ss << "Name: \"EnableCompass\" Value: \"" << EnableCompass << "\"" << std::endl;
522 ss << "Name: \"DisableTemperatureCompensation\" Value: \"" << DisableTemperatureCompensation << "\"" << std::endl;
523 ss << "Name: \"DisableNoMotionCalibration\" Value: \"" << DisableNoMotionCalibration << "\"" << std::endl;
524 ss << "}" << std::endl;
525 return ss.str();
526 }
527
528 std::string Serialize() const override
529 {
530 std::stringstream ss;
531 char *ref;
532 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2UseCompass, EnableCompass, &ref); if (ref != nullptr) { ss << ref; free(ref); }
533 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableTemperatureCompensation, DisableTemperatureCompensation, &ref); if (ref != nullptr) { ss << ref; free(ref); }
534 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableNoMotionCalibration, DisableNoMotionCalibration, &ref); if (ref != nullptr) { ss << ref; free(ref); }
535 return ss.str();
536 }
537
538 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
539 {
540 const char *string_c_str = to_deserialize.c_str();
541 size_t string_length = to_deserialize.length();
542 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2UseCompass, string_c_str, string_length, &EnableCompass);
543 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableTemperatureCompensation, string_c_str, string_length, &DisableTemperatureCompensation);
544 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableNoMotionCalibration, string_c_str, string_length, &DisableNoMotionCalibration);
545 return 0;
546 }
547};
548
549
550/**
551 * \brief Configs that directly affect motor output.
552 *
553 * \details Includes motor invert, neutral mode, and other features
554 * related to motor output.
555 */
557{
558public:
559 /**
560 * \brief Invert state of the device.
561 *
562 */
564 /**
565 * \brief The state of the motor controller bridge when output is
566 * neutral or disabled.
567 *
568 */
570 /**
571 * \brief Configures the output deadband duty cycle during duty cycle
572 * and voltage based control modes.
573 *
574 * - Minimum Value: 0.0
575 * - Maximum Value: 0.25
576 * - Default Value: 0
577 * - Units: fractional
578 */
580 /**
581 * \brief Maximum (forward) output during duty cycle based control
582 * modes.
583 *
584 * - Minimum Value: -1.0
585 * - Maximum Value: 1.0
586 * - Default Value: 1
587 * - Units: fractional
588 */
590 /**
591 * \brief Minimum (reverse) output during duty cycle based control
592 * modes.
593 *
594 * - Minimum Value: -1.0
595 * - Maximum Value: 1.0
596 * - Default Value: -1
597 * - Units: fractional
598 */
600
601 /**
602 * \brief Modifies this configuration's Inverted parameter and returns itself for
603 * method-chaining and easier to use config API.
604 *
605 * Invert state of the device.
606 *
607 *
608 * \param newInverted Parameter to modify
609 * \returns Itself
610 */
612 {
613 Inverted = std::move(newInverted);
614 return *this;
615 }
616 /**
617 * \brief Modifies this configuration's NeutralMode parameter and returns itself for
618 * method-chaining and easier to use config API.
619 *
620 * The state of the motor controller bridge when output is neutral or
621 * disabled.
622 *
623 *
624 * \param newNeutralMode Parameter to modify
625 * \returns Itself
626 */
628 {
629 NeutralMode = std::move(newNeutralMode);
630 return *this;
631 }
632 /**
633 * \brief Modifies this configuration's DutyCycleNeutralDeadband parameter and returns itself for
634 * method-chaining and easier to use config API.
635 *
636 * Configures the output deadband duty cycle during duty cycle and
637 * voltage based control modes.
638 *
639 * - Minimum Value: 0.0
640 * - Maximum Value: 0.25
641 * - Default Value: 0
642 * - Units: fractional
643 *
644 * \param newDutyCycleNeutralDeadband Parameter to modify
645 * \returns Itself
646 */
647 MotorOutputConfigs& WithDutyCycleNeutralDeadband(double newDutyCycleNeutralDeadband)
648 {
649 DutyCycleNeutralDeadband = std::move(newDutyCycleNeutralDeadband);
650 return *this;
651 }
652 /**
653 * \brief Modifies this configuration's PeakForwardDutyCycle parameter and returns itself for
654 * method-chaining and easier to use config API.
655 *
656 * Maximum (forward) output during duty cycle based control modes.
657 *
658 * - Minimum Value: -1.0
659 * - Maximum Value: 1.0
660 * - Default Value: 1
661 * - Units: fractional
662 *
663 * \param newPeakForwardDutyCycle Parameter to modify
664 * \returns Itself
665 */
666 MotorOutputConfigs& WithPeakForwardDutyCycle(double newPeakForwardDutyCycle)
667 {
668 PeakForwardDutyCycle = std::move(newPeakForwardDutyCycle);
669 return *this;
670 }
671 /**
672 * \brief Modifies this configuration's PeakReverseDutyCycle parameter and returns itself for
673 * method-chaining and easier to use config API.
674 *
675 * Minimum (reverse) output during duty cycle based control modes.
676 *
677 * - Minimum Value: -1.0
678 * - Maximum Value: 1.0
679 * - Default Value: -1
680 * - Units: fractional
681 *
682 * \param newPeakReverseDutyCycle Parameter to modify
683 * \returns Itself
684 */
685 MotorOutputConfigs& WithPeakReverseDutyCycle(double newPeakReverseDutyCycle)
686 {
687 PeakReverseDutyCycle = std::move(newPeakReverseDutyCycle);
688 return *this;
689 }
690
691
692
693 std::string ToString() const override
694 {
695 std::stringstream ss;
696 ss << "{" << std::endl;
697 ss << "Config Group: MotorOutput" << std::endl;
698 ss << "Name: \"Inverted\" Value: \"" << Inverted << "\"" << std::endl;
699 ss << "Name: \"NeutralMode\" Value: \"" << NeutralMode << "\"" << std::endl;
700 ss << "Name: \"DutyCycleNeutralDeadband\" Value: \"" << DutyCycleNeutralDeadband << "fractional\"" << std::endl;
701 ss << "Name: \"PeakForwardDutyCycle\" Value: \"" << PeakForwardDutyCycle << "fractional\"" << std::endl;
702 ss << "Name: \"PeakReverseDutyCycle\" Value: \"" << PeakReverseDutyCycle << "fractional\"" << std::endl;
703 ss << "}" << std::endl;
704 return ss.str();
705 }
706
707 std::string Serialize() const override
708 {
709 std::stringstream ss;
710 char *ref;
711 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_Inverted, Inverted.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
712 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_NeutralMode, NeutralMode.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
713 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleNeutralDB, DutyCycleNeutralDeadband, &ref); if (ref != nullptr) { ss << ref; free(ref); }
714 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardDC, PeakForwardDutyCycle, &ref); if (ref != nullptr) { ss << ref; free(ref); }
715 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseDC, PeakReverseDutyCycle, &ref); if (ref != nullptr) { ss << ref; free(ref); }
716 return ss.str();
717 }
718
719 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
720 {
721 const char *string_c_str = to_deserialize.c_str();
722 size_t string_length = to_deserialize.length();
723 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_Inverted, string_c_str, string_length, &Inverted.value);
724 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_NeutralMode, string_c_str, string_length, &NeutralMode.value);
725 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleNeutralDB, string_c_str, string_length, &DutyCycleNeutralDeadband);
726 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardDC, string_c_str, string_length, &PeakForwardDutyCycle);
727 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseDC, string_c_str, string_length, &PeakReverseDutyCycle);
728 return 0;
729 }
730};
731
732
733/**
734 * \brief Configs that directly affect current limiting features.
735 *
736 * \details Contains the supply/stator current limit thresholds and
737 * whether to enable them.
738 */
740{
741public:
742 /**
743 * \brief The amount of current allowed in the motor (motoring and
744 * regen current). Note this requires StatorCurrentLimitEnable to be
745 * true.
746 *
747 * This is only applicable for non-torque current control modes. For
748 * torque current control, set the PeakForwardTorqueCurrent and
749 * PeakReverseTorqueCurrent in TorqueCurrentConfigs instead.
750 *
751 * Stator current is directly proportional to torque, so this limit
752 * can be used to restrict the torque output of the motor, such as
753 * preventing wheel slip for a drivetrain. Additionally, stator
754 * current limits can prevent brownouts during acceleration; supply
755 * current will never exceed the stator current limit and is often
756 * significantly lower than stator current.
757 *
758 * A reasonable starting point for a stator current limit is 120 A,
759 * with values commonly ranging from 80-160 A. Mechanisms with a hard
760 * stop may need a smaller limit to reduce the torque applied when
761 * running into the hard stop.
762 *
763 * - Minimum Value: 0.0
764 * - Maximum Value: 800.0
765 * - Default Value: 0
766 * - Units: A
767 */
769 /**
770 * \brief Enable motor stator current limiting.
771 *
772 * - Default Value: False
773 */
775 /**
776 * \brief The amount of supply current allowed. Note this requires
777 * SupplyCurrentLimitEnable to be true. Use SupplyCurrentThreshold
778 * and SupplyTimeThreshold to allow brief periods of high-current
779 * before limiting occurs.
780 *
781 * This is only applicable for non-torque current control modes. For
782 * torque current control, set the PeakForwardTorqueCurrent and
783 * PeakReverseTorqueCurrent in TorqueCurrentConfigs instead.
784 *
785 * Supply current is the current drawn from the battery, so this limit
786 * can be used to prevent breaker trips and improve battery longevity.
787 * Additionally, in the rare case where the robot experiences
788 * brownouts despite configuring stator current limits, a supply
789 * current limit can further help avoid brownouts. However, such
790 * brownouts are most commonly caused by a bad battery or poor power
791 * wiring.
792 *
793 * A reasonable starting point for a supply current limit is 60 A with
794 * a threshold of 80 A for 0.1 seconds. Supply current limits commonly
795 * range from 20-80 A depending on the breaker used.
796 *
797 * - Minimum Value: 0.0
798 * - Maximum Value: 800.0
799 * - Default Value: 0
800 * - Units: A
801 */
803 /**
804 * \brief Enable motor supply current limiting.
805 *
806 * - Default Value: False
807 */
809 /**
810 * \brief Delay supply current limiting until current exceeds this
811 * threshold for longer than SupplyTimeThreshold. This allows current
812 * draws above SupplyCurrentLimit for a fixed period of time. This
813 * has no effect if SupplyCurrentLimit is greater than this value.
814 *
815 * - Minimum Value: 0.0
816 * - Maximum Value: 511
817 * - Default Value: 0
818 * - Units: A
819 */
821 /**
822 * \brief Allows unlimited current for a period of time before current
823 * limiting occurs. Current threshold is the maximum of
824 * SupplyCurrentThreshold and SupplyCurrentLimit.
825 *
826 * - Minimum Value: 0.0
827 * - Maximum Value: 1.275
828 * - Default Value: 0
829 * - Units: sec
830 */
832
833 /**
834 * \brief Modifies this configuration's StatorCurrentLimit parameter and returns itself for
835 * method-chaining and easier to use config API.
836 *
837 * The amount of current allowed in the motor (motoring and regen
838 * current). Note this requires StatorCurrentLimitEnable to be true.
839 *
840 * This is only applicable for non-torque current control modes. For
841 * torque current control, set the PeakForwardTorqueCurrent and
842 * PeakReverseTorqueCurrent in TorqueCurrentConfigs instead.
843 *
844 * Stator current is directly proportional to torque, so this limit
845 * can be used to restrict the torque output of the motor, such as
846 * preventing wheel slip for a drivetrain. Additionally, stator
847 * current limits can prevent brownouts during acceleration; supply
848 * current will never exceed the stator current limit and is often
849 * significantly lower than stator current.
850 *
851 * A reasonable starting point for a stator current limit is 120 A,
852 * with values commonly ranging from 80-160 A. Mechanisms with a hard
853 * stop may need a smaller limit to reduce the torque applied when
854 * running into the hard stop.
855 *
856 * - Minimum Value: 0.0
857 * - Maximum Value: 800.0
858 * - Default Value: 0
859 * - Units: A
860 *
861 * \param newStatorCurrentLimit Parameter to modify
862 * \returns Itself
863 */
864 CurrentLimitsConfigs& WithStatorCurrentLimit(double newStatorCurrentLimit)
865 {
866 StatorCurrentLimit = std::move(newStatorCurrentLimit);
867 return *this;
868 }
869 /**
870 * \brief Modifies this configuration's StatorCurrentLimitEnable parameter and returns itself for
871 * method-chaining and easier to use config API.
872 *
873 * Enable motor stator current limiting.
874 *
875 * - Default Value: False
876 *
877 * \param newStatorCurrentLimitEnable Parameter to modify
878 * \returns Itself
879 */
880 CurrentLimitsConfigs& WithStatorCurrentLimitEnable(bool newStatorCurrentLimitEnable)
881 {
882 StatorCurrentLimitEnable = std::move(newStatorCurrentLimitEnable);
883 return *this;
884 }
885 /**
886 * \brief Modifies this configuration's SupplyCurrentLimit parameter and returns itself for
887 * method-chaining and easier to use config API.
888 *
889 * The amount of supply current allowed. Note this requires
890 * SupplyCurrentLimitEnable to be true. Use SupplyCurrentThreshold
891 * and SupplyTimeThreshold to allow brief periods of high-current
892 * before limiting occurs.
893 *
894 * This is only applicable for non-torque current control modes. For
895 * torque current control, set the PeakForwardTorqueCurrent and
896 * PeakReverseTorqueCurrent in TorqueCurrentConfigs instead.
897 *
898 * Supply current is the current drawn from the battery, so this limit
899 * can be used to prevent breaker trips and improve battery longevity.
900 * Additionally, in the rare case where the robot experiences
901 * brownouts despite configuring stator current limits, a supply
902 * current limit can further help avoid brownouts. However, such
903 * brownouts are most commonly caused by a bad battery or poor power
904 * wiring.
905 *
906 * A reasonable starting point for a supply current limit is 60 A with
907 * a threshold of 80 A for 0.1 seconds. Supply current limits commonly
908 * range from 20-80 A depending on the breaker used.
909 *
910 * - Minimum Value: 0.0
911 * - Maximum Value: 800.0
912 * - Default Value: 0
913 * - Units: A
914 *
915 * \param newSupplyCurrentLimit Parameter to modify
916 * \returns Itself
917 */
918 CurrentLimitsConfigs& WithSupplyCurrentLimit(double newSupplyCurrentLimit)
919 {
920 SupplyCurrentLimit = std::move(newSupplyCurrentLimit);
921 return *this;
922 }
923 /**
924 * \brief Modifies this configuration's SupplyCurrentLimitEnable parameter and returns itself for
925 * method-chaining and easier to use config API.
926 *
927 * Enable motor supply current limiting.
928 *
929 * - Default Value: False
930 *
931 * \param newSupplyCurrentLimitEnable Parameter to modify
932 * \returns Itself
933 */
934 CurrentLimitsConfigs& WithSupplyCurrentLimitEnable(bool newSupplyCurrentLimitEnable)
935 {
936 SupplyCurrentLimitEnable = std::move(newSupplyCurrentLimitEnable);
937 return *this;
938 }
939 /**
940 * \brief Modifies this configuration's SupplyCurrentThreshold parameter and returns itself for
941 * method-chaining and easier to use config API.
942 *
943 * Delay supply current limiting until current exceeds this threshold
944 * for longer than SupplyTimeThreshold. This allows current draws
945 * above SupplyCurrentLimit for a fixed period of time. This has no
946 * effect if SupplyCurrentLimit is greater than this value.
947 *
948 * - Minimum Value: 0.0
949 * - Maximum Value: 511
950 * - Default Value: 0
951 * - Units: A
952 *
953 * \param newSupplyCurrentThreshold Parameter to modify
954 * \returns Itself
955 */
956 CurrentLimitsConfigs& WithSupplyCurrentThreshold(double newSupplyCurrentThreshold)
957 {
958 SupplyCurrentThreshold = std::move(newSupplyCurrentThreshold);
959 return *this;
960 }
961 /**
962 * \brief Modifies this configuration's SupplyTimeThreshold parameter and returns itself for
963 * method-chaining and easier to use config API.
964 *
965 * Allows unlimited current for a period of time before current
966 * limiting occurs. Current threshold is the maximum of
967 * SupplyCurrentThreshold and SupplyCurrentLimit.
968 *
969 * - Minimum Value: 0.0
970 * - Maximum Value: 1.275
971 * - Default Value: 0
972 * - Units: sec
973 *
974 * \param newSupplyTimeThreshold Parameter to modify
975 * \returns Itself
976 */
977 CurrentLimitsConfigs& WithSupplyTimeThreshold(double newSupplyTimeThreshold)
978 {
979 SupplyTimeThreshold = std::move(newSupplyTimeThreshold);
980 return *this;
981 }
982
983
984
985 std::string ToString() const override
986 {
987 std::stringstream ss;
988 ss << "{" << std::endl;
989 ss << "Config Group: CurrentLimits" << std::endl;
990 ss << "Name: \"StatorCurrentLimit\" Value: \"" << StatorCurrentLimit << "A\"" << std::endl;
991 ss << "Name: \"StatorCurrentLimitEnable\" Value: \"" << StatorCurrentLimitEnable << "\"" << std::endl;
992 ss << "Name: \"SupplyCurrentLimit\" Value: \"" << SupplyCurrentLimit << "A\"" << std::endl;
993 ss << "Name: \"SupplyCurrentLimitEnable\" Value: \"" << SupplyCurrentLimitEnable << "\"" << std::endl;
994 ss << "Name: \"SupplyCurrentThreshold\" Value: \"" << SupplyCurrentThreshold << "A\"" << std::endl;
995 ss << "Name: \"SupplyTimeThreshold\" Value: \"" << SupplyTimeThreshold << "sec\"" << std::endl;
996 ss << "}" << std::endl;
997 return ss.str();
998 }
999
1000 std::string Serialize() const override
1001 {
1002 std::stringstream ss;
1003 char *ref;
1004 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_StatorCurrentLimit, StatorCurrentLimit, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1005 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_StatorCurrLimitEn, StatorCurrentLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1006 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrentLimit, SupplyCurrentLimit, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1007 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrLimitEn, SupplyCurrentLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1008 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrThres, SupplyCurrentThreshold, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1009 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyTimeThres, SupplyTimeThreshold, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1010 return ss.str();
1011 }
1012
1013 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1014 {
1015 const char *string_c_str = to_deserialize.c_str();
1016 size_t string_length = to_deserialize.length();
1017 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_StatorCurrentLimit, string_c_str, string_length, &StatorCurrentLimit);
1018 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_StatorCurrLimitEn, string_c_str, string_length, &StatorCurrentLimitEnable);
1019 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrentLimit, string_c_str, string_length, &SupplyCurrentLimit);
1020 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrLimitEn, string_c_str, string_length, &SupplyCurrentLimitEnable);
1021 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrThres, string_c_str, string_length, &SupplyCurrentThreshold);
1022 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyTimeThres, string_c_str, string_length, &SupplyTimeThreshold);
1023 return 0;
1024 }
1025};
1026
1027
1028/**
1029 * \brief Configs that affect Voltage control types.
1030 *
1031 * \details Includes peak output voltages and other configs affecting
1032 * voltage measurements.
1033 */
1035{
1036public:
1037 /**
1038 * \brief The time constant (in seconds) of the low-pass filter for
1039 * the supply voltage.
1040 *
1041 * \details This impacts the filtering for the reported supply
1042 * voltage, and any control strategies that use the supply voltage
1043 * (such as voltage control on a motor controller).
1044 *
1045 * - Minimum Value: 0.0
1046 * - Maximum Value: 0.1
1047 * - Default Value: 0
1048 * - Units: sec
1049 */
1051 /**
1052 * \brief Maximum (forward) output during voltage based control modes.
1053 *
1054 * - Minimum Value: -16
1055 * - Maximum Value: 16
1056 * - Default Value: 16
1057 * - Units: V
1058 */
1060 /**
1061 * \brief Minimum (reverse) output during voltage based control modes.
1062 *
1063 * - Minimum Value: -16
1064 * - Maximum Value: 16
1065 * - Default Value: -16
1066 * - Units: V
1067 */
1069
1070 /**
1071 * \brief Modifies this configuration's SupplyVoltageTimeConstant parameter and returns itself for
1072 * method-chaining and easier to use config API.
1073 *
1074 * The time constant (in seconds) of the low-pass filter for the
1075 * supply voltage.
1076 *
1077 * \details This impacts the filtering for the reported supply
1078 * voltage, and any control strategies that use the supply voltage
1079 * (such as voltage control on a motor controller).
1080 *
1081 * - Minimum Value: 0.0
1082 * - Maximum Value: 0.1
1083 * - Default Value: 0
1084 * - Units: sec
1085 *
1086 * \param newSupplyVoltageTimeConstant Parameter to modify
1087 * \returns Itself
1088 */
1089 VoltageConfigs& WithSupplyVoltageTimeConstant(double newSupplyVoltageTimeConstant)
1090 {
1091 SupplyVoltageTimeConstant = std::move(newSupplyVoltageTimeConstant);
1092 return *this;
1093 }
1094 /**
1095 * \brief Modifies this configuration's PeakForwardVoltage parameter and returns itself for
1096 * method-chaining and easier to use config API.
1097 *
1098 * Maximum (forward) output during voltage based control modes.
1099 *
1100 * - Minimum Value: -16
1101 * - Maximum Value: 16
1102 * - Default Value: 16
1103 * - Units: V
1104 *
1105 * \param newPeakForwardVoltage Parameter to modify
1106 * \returns Itself
1107 */
1108 VoltageConfigs& WithPeakForwardVoltage(double newPeakForwardVoltage)
1109 {
1110 PeakForwardVoltage = std::move(newPeakForwardVoltage);
1111 return *this;
1112 }
1113 /**
1114 * \brief Modifies this configuration's PeakReverseVoltage parameter and returns itself for
1115 * method-chaining and easier to use config API.
1116 *
1117 * Minimum (reverse) output during voltage based control modes.
1118 *
1119 * - Minimum Value: -16
1120 * - Maximum Value: 16
1121 * - Default Value: -16
1122 * - Units: V
1123 *
1124 * \param newPeakReverseVoltage Parameter to modify
1125 * \returns Itself
1126 */
1127 VoltageConfigs& WithPeakReverseVoltage(double newPeakReverseVoltage)
1128 {
1129 PeakReverseVoltage = std::move(newPeakReverseVoltage);
1130 return *this;
1131 }
1132
1133
1134
1135 std::string ToString() const override
1136 {
1137 std::stringstream ss;
1138 ss << "{" << std::endl;
1139 ss << "Config Group: Voltage" << std::endl;
1140 ss << "Name: \"SupplyVoltageTimeConstant\" Value: \"" << SupplyVoltageTimeConstant << "sec\"" << std::endl;
1141 ss << "Name: \"PeakForwardVoltage\" Value: \"" << PeakForwardVoltage << "V\"" << std::endl;
1142 ss << "Name: \"PeakReverseVoltage\" Value: \"" << PeakReverseVoltage << "V\"" << std::endl;
1143 ss << "}" << std::endl;
1144 return ss.str();
1145 }
1146
1147 std::string Serialize() const override
1148 {
1149 std::stringstream ss;
1150 char *ref;
1151 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyVLowpassTau, SupplyVoltageTimeConstant, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1152 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardV, PeakForwardVoltage, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1153 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseV, PeakReverseVoltage, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1154 return ss.str();
1155 }
1156
1157 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1158 {
1159 const char *string_c_str = to_deserialize.c_str();
1160 size_t string_length = to_deserialize.length();
1161 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyVLowpassTau, string_c_str, string_length, &SupplyVoltageTimeConstant);
1162 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardV, string_c_str, string_length, &PeakForwardVoltage);
1163 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseV, string_c_str, string_length, &PeakReverseVoltage);
1164 return 0;
1165 }
1166};
1167
1168
1169/**
1170 * \brief Configs that affect Torque Current control types.
1171 *
1172 * \details Includes the maximum and minimum applied torque output and
1173 * the neutral deadband used during TorqueCurrentFOC
1174 * requests.
1175 */
1177{
1178public:
1179 /**
1180 * \brief Maximum (forward) output during torque current based control
1181 * modes.
1182 *
1183 * - Minimum Value: -800
1184 * - Maximum Value: 800
1185 * - Default Value: 800
1186 * - Units: A
1187 */
1189 /**
1190 * \brief Minimum (reverse) output during torque current based control
1191 * modes.
1192 *
1193 * - Minimum Value: -800
1194 * - Maximum Value: 800
1195 * - Default Value: -800
1196 * - Units: A
1197 */
1199 /**
1200 * \brief Configures the output deadband during torque current based
1201 * control modes.
1202 *
1203 * - Minimum Value: 0
1204 * - Maximum Value: 25
1205 * - Default Value: 0.0
1206 * - Units: A
1207 */
1209
1210 /**
1211 * \brief Modifies this configuration's PeakForwardTorqueCurrent parameter and returns itself for
1212 * method-chaining and easier to use config API.
1213 *
1214 * Maximum (forward) output during torque current based control modes.
1215 *
1216 * - Minimum Value: -800
1217 * - Maximum Value: 800
1218 * - Default Value: 800
1219 * - Units: A
1220 *
1221 * \param newPeakForwardTorqueCurrent Parameter to modify
1222 * \returns Itself
1223 */
1224 TorqueCurrentConfigs& WithPeakForwardTorqueCurrent(double newPeakForwardTorqueCurrent)
1225 {
1226 PeakForwardTorqueCurrent = std::move(newPeakForwardTorqueCurrent);
1227 return *this;
1228 }
1229 /**
1230 * \brief Modifies this configuration's PeakReverseTorqueCurrent parameter and returns itself for
1231 * method-chaining and easier to use config API.
1232 *
1233 * Minimum (reverse) output during torque current based control modes.
1234 *
1235 * - Minimum Value: -800
1236 * - Maximum Value: 800
1237 * - Default Value: -800
1238 * - Units: A
1239 *
1240 * \param newPeakReverseTorqueCurrent Parameter to modify
1241 * \returns Itself
1242 */
1243 TorqueCurrentConfigs& WithPeakReverseTorqueCurrent(double newPeakReverseTorqueCurrent)
1244 {
1245 PeakReverseTorqueCurrent = std::move(newPeakReverseTorqueCurrent);
1246 return *this;
1247 }
1248 /**
1249 * \brief Modifies this configuration's TorqueNeutralDeadband parameter and returns itself for
1250 * method-chaining and easier to use config API.
1251 *
1252 * Configures the output deadband during torque current based control
1253 * modes.
1254 *
1255 * - Minimum Value: 0
1256 * - Maximum Value: 25
1257 * - Default Value: 0.0
1258 * - Units: A
1259 *
1260 * \param newTorqueNeutralDeadband Parameter to modify
1261 * \returns Itself
1262 */
1263 TorqueCurrentConfigs& WithTorqueNeutralDeadband(double newTorqueNeutralDeadband)
1264 {
1265 TorqueNeutralDeadband = std::move(newTorqueNeutralDeadband);
1266 return *this;
1267 }
1268
1269
1270
1271 std::string ToString() const override
1272 {
1273 std::stringstream ss;
1274 ss << "{" << std::endl;
1275 ss << "Config Group: TorqueCurrent" << std::endl;
1276 ss << "Name: \"PeakForwardTorqueCurrent\" Value: \"" << PeakForwardTorqueCurrent << "A\"" << std::endl;
1277 ss << "Name: \"PeakReverseTorqueCurrent\" Value: \"" << PeakReverseTorqueCurrent << "A\"" << std::endl;
1278 ss << "Name: \"TorqueNeutralDeadband\" Value: \"" << TorqueNeutralDeadband << "A\"" << std::endl;
1279 ss << "}" << std::endl;
1280 return ss.str();
1281 }
1282
1283 std::string Serialize() const override
1284 {
1285 std::stringstream ss;
1286 char *ref;
1287 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForTorqCurr, PeakForwardTorqueCurrent, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1288 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakRevTorqCurr, PeakReverseTorqueCurrent, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1289 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueNeutralDB, TorqueNeutralDeadband, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1290 return ss.str();
1291 }
1292
1293 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1294 {
1295 const char *string_c_str = to_deserialize.c_str();
1296 size_t string_length = to_deserialize.length();
1297 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForTorqCurr, string_c_str, string_length, &PeakForwardTorqueCurrent);
1298 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakRevTorqCurr, string_c_str, string_length, &PeakReverseTorqueCurrent);
1299 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueNeutralDB, string_c_str, string_length, &TorqueNeutralDeadband);
1300 return 0;
1301 }
1302};
1303
1304
1305/**
1306 * \brief Configs that affect the feedback of this motor controller.
1307 *
1308 * \details Includes feedback sensor source, any offsets for the
1309 * feedback sensor, and various ratios to describe the
1310 * relationship between the sensor and the mechanism for
1311 * closed looping.
1312 */
1314{
1315public:
1316 /**
1317 * \brief This offset is applied to the absolute integrated rotor
1318 * sensor. This can be used to zero the rotor in applications that
1319 * are within one rotor rotation.
1320 *
1321 * - Minimum Value: -1
1322 * - Maximum Value: 1
1323 * - Default Value: 0.0
1324 * - Units: rotations
1325 */
1327 /**
1328 * \brief This is the ratio of sensor rotations to the mechanism's
1329 * output. This is equivalent to the mechanism's gear ratio if the
1330 * sensor is located on the input of a gearbox. If sensor is on the
1331 * output of a gearbox, then this is typically set to 1. Note if this
1332 * is set to zero, device will reset back to one.
1333 *
1334 * - Minimum Value: -1000
1335 * - Maximum Value: 1000
1336 * - Default Value: 1.0
1337 * - Units: scalar
1338 */
1340 /**
1341 * \brief Talon FX is capable of fusing a remote CANcoder with its
1342 * rotor sensor to produce a high-bandwidth sensor source. This
1343 * feature requires specifying the ratio between the remote sensor and
1344 * the motor rotor. Note if this is set to zero, device will reset
1345 * back to one.
1346 *
1347 * - Minimum Value: -1000
1348 * - Maximum Value: 1000
1349 * - Default Value: 1.0
1350 * - Units: scalar
1351 */
1353 /**
1354 * \brief Choose what sensor source is reported via API and used by
1355 * closed-loop and limit features. The default is RotorSensor, which
1356 * uses the internal rotor sensor in the Talon FX.
1357 *
1358 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
1359 * (this also requires setting FeedbackRemoteSensorID). Talon FX will
1360 * update its position and velocity whenever CANcoder publishes its
1361 * information on CAN bus.
1362 *
1363 * Choose FusedCANcoder (requires Phoenix Pro) and Talon FX will fuse
1364 * another CANcoder's information with the internal rotor, which
1365 * provides the best possible position and velocity for accuracy and
1366 * bandwidth (this also requires setting FeedbackRemoteSensorID).
1367 * FusedCANcoder was developed for applications such as
1368 * swerve-azimuth.
1369 *
1370 * Choose SyncCANcoder (requires Phoenix Pro) and Talon FX will
1371 * synchronize its internal rotor position against another CANcoder,
1372 * then continue to use the rotor sensor for closed loop control (this
1373 * also requires setting FeedbackRemoteSensorID). The TalonFX will
1374 * report if its internal position differs significantly from the
1375 * reported CANcoder position. SyncCANcoder was developed for
1376 * mechanisms where there is a risk of the CANcoder failing in such a
1377 * way that it reports a position that does not match the mechanism,
1378 * such as the sensor mounting assembly breaking off.
1379 *
1380 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
1381 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
1382 * also requires setting FeedbackRemoteSensorID). Talon FX will
1383 * update its position to match the selected value whenever Pigeon2
1384 * publishes its information on CAN bus. Note that the Talon FX
1385 * position will be in rotations and not degrees.
1386 *
1387 * \details Note: When the feedback source is changed to
1388 * FusedCANcoder, the Talon FX needs a period of time to fuse before
1389 * sensor-based (soft-limit, closed loop, etc.) features are used.
1390 * This period of time is determined by the update frequency of the
1391 * CANcoder's Position signal.
1392 *
1393 */
1395 /**
1396 * \brief Device ID of which remote device to use. This is not used
1397 * if the Sensor Source is the internal rotor sensor.
1398 *
1399 * - Minimum Value: 0
1400 * - Maximum Value: 62
1401 * - Default Value: 0
1402 * - Units:
1403 */
1405
1406 /**
1407 * \brief Modifies this configuration's FeedbackRotorOffset parameter and returns itself for
1408 * method-chaining and easier to use config API.
1409 *
1410 * This offset is applied to the absolute integrated rotor sensor.
1411 * This can be used to zero the rotor in applications that are within
1412 * one rotor rotation.
1413 *
1414 * - Minimum Value: -1
1415 * - Maximum Value: 1
1416 * - Default Value: 0.0
1417 * - Units: rotations
1418 *
1419 * \param newFeedbackRotorOffset Parameter to modify
1420 * \returns Itself
1421 */
1422 FeedbackConfigs& WithFeedbackRotorOffset(double newFeedbackRotorOffset)
1423 {
1424 FeedbackRotorOffset = std::move(newFeedbackRotorOffset);
1425 return *this;
1426 }
1427 /**
1428 * \brief Modifies this configuration's SensorToMechanismRatio parameter and returns itself for
1429 * method-chaining and easier to use config API.
1430 *
1431 * This is the ratio of sensor rotations to the mechanism's output.
1432 * This is equivalent to the mechanism's gear ratio if the sensor is
1433 * located on the input of a gearbox. If sensor is on the output of a
1434 * gearbox, then this is typically set to 1. Note if this is set to
1435 * zero, device will reset back to one.
1436 *
1437 * - Minimum Value: -1000
1438 * - Maximum Value: 1000
1439 * - Default Value: 1.0
1440 * - Units: scalar
1441 *
1442 * \param newSensorToMechanismRatio Parameter to modify
1443 * \returns Itself
1444 */
1445 FeedbackConfigs& WithSensorToMechanismRatio(double newSensorToMechanismRatio)
1446 {
1447 SensorToMechanismRatio = std::move(newSensorToMechanismRatio);
1448 return *this;
1449 }
1450 /**
1451 * \brief Modifies this configuration's RotorToSensorRatio parameter and returns itself for
1452 * method-chaining and easier to use config API.
1453 *
1454 * Talon FX is capable of fusing a remote CANcoder with its rotor
1455 * sensor to produce a high-bandwidth sensor source. This feature
1456 * requires specifying the ratio between the remote sensor and the
1457 * motor rotor. Note if this is set to zero, device will reset back
1458 * to one.
1459 *
1460 * - Minimum Value: -1000
1461 * - Maximum Value: 1000
1462 * - Default Value: 1.0
1463 * - Units: scalar
1464 *
1465 * \param newRotorToSensorRatio Parameter to modify
1466 * \returns Itself
1467 */
1468 FeedbackConfigs& WithRotorToSensorRatio(double newRotorToSensorRatio)
1469 {
1470 RotorToSensorRatio = std::move(newRotorToSensorRatio);
1471 return *this;
1472 }
1473 /**
1474 * \brief Modifies this configuration's FeedbackSensorSource parameter and returns itself for
1475 * method-chaining and easier to use config API.
1476 *
1477 * Choose what sensor source is reported via API and used by
1478 * closed-loop and limit features. The default is RotorSensor, which
1479 * uses the internal rotor sensor in the Talon FX.
1480 *
1481 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
1482 * (this also requires setting FeedbackRemoteSensorID). Talon FX will
1483 * update its position and velocity whenever CANcoder publishes its
1484 * information on CAN bus.
1485 *
1486 * Choose FusedCANcoder (requires Phoenix Pro) and Talon FX will fuse
1487 * another CANcoder's information with the internal rotor, which
1488 * provides the best possible position and velocity for accuracy and
1489 * bandwidth (this also requires setting FeedbackRemoteSensorID).
1490 * FusedCANcoder was developed for applications such as
1491 * swerve-azimuth.
1492 *
1493 * Choose SyncCANcoder (requires Phoenix Pro) and Talon FX will
1494 * synchronize its internal rotor position against another CANcoder,
1495 * then continue to use the rotor sensor for closed loop control (this
1496 * also requires setting FeedbackRemoteSensorID). The TalonFX will
1497 * report if its internal position differs significantly from the
1498 * reported CANcoder position. SyncCANcoder was developed for
1499 * mechanisms where there is a risk of the CANcoder failing in such a
1500 * way that it reports a position that does not match the mechanism,
1501 * such as the sensor mounting assembly breaking off.
1502 *
1503 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
1504 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
1505 * also requires setting FeedbackRemoteSensorID). Talon FX will
1506 * update its position to match the selected value whenever Pigeon2
1507 * publishes its information on CAN bus. Note that the Talon FX
1508 * position will be in rotations and not degrees.
1509 *
1510 * \details Note: When the feedback source is changed to
1511 * FusedCANcoder, the Talon FX needs a period of time to fuse before
1512 * sensor-based (soft-limit, closed loop, etc.) features are used.
1513 * This period of time is determined by the update frequency of the
1514 * CANcoder's Position signal.
1515 *
1516 *
1517 * \param newFeedbackSensorSource Parameter to modify
1518 * \returns Itself
1519 */
1521 {
1522 FeedbackSensorSource = std::move(newFeedbackSensorSource);
1523 return *this;
1524 }
1525 /**
1526 * \brief Modifies this configuration's FeedbackRemoteSensorID parameter and returns itself for
1527 * method-chaining and easier to use config API.
1528 *
1529 * Device ID of which remote device to use. This is not used if the
1530 * Sensor Source is the internal rotor sensor.
1531 *
1532 * - Minimum Value: 0
1533 * - Maximum Value: 62
1534 * - Default Value: 0
1535 * - Units:
1536 *
1537 * \param newFeedbackRemoteSensorID Parameter to modify
1538 * \returns Itself
1539 */
1540 FeedbackConfigs& WithFeedbackRemoteSensorID(int newFeedbackRemoteSensorID)
1541 {
1542 FeedbackRemoteSensorID = std::move(newFeedbackRemoteSensorID);
1543 return *this;
1544 }
1545
1546 /**
1547 * \brief Helper method to configure this feedback group to use
1548 * RemoteCANcoder by passing in the CANcoder object. When using
1549 * RemoteCANcoder, the Talon FX will use another CANcoder on
1550 * the same CAN bus. Talon FX will update its position and
1551 * velocity whenever CANcoder publishes its information on CAN
1552 * bus.
1553 *
1554 * \param device CANcoder reference to use for RemoteCANcoder
1555 * \returns Itself
1556 */
1558
1559 /**
1560 * \brief Helper method to configure this feedback group to use
1561 * FusedCANcoder by passing in the CANcoder object. When using
1562 * FusedCANcoder (requires Phoenix Pro), the Talon FX will fuse
1563 * another CANcoder's information with the internal rotor,
1564 * which provides the best possible position and velocity for
1565 * accuracy and bandwidth. FusedCANcoder was developed for
1566 * applications such as swerve-azimuth.
1567 *
1568 * \param device CANcoder reference to use for FusedCANcoder
1569 * \returns Itself
1570 */
1572
1573 /**
1574 * \brief Helper method to configure this feedback group to use
1575 * SyncCANcoder by passing in the CANcoder object. When using
1576 * SyncCANcoder (requires Phoenix Pro), the Talon FX will
1577 * synchronize its internal rotor position against another
1578 * CANcoder, then continue to use the rotor sensor for closed
1579 * loop control. The TalonFX will report if its internal
1580 * position differs significantly from the reported CANcoder
1581 * position. SyncCANcoder was developed for mechanisms where
1582 * there is a risk of the CANcoder failing in such a way that
1583 * it reports a position that does not match the mechanism,
1584 * such as the sensor mounting assembly breaking off.
1585 *
1586 * \param device CANcoder reference to use for SyncCANcoder
1587 * \returns Itself
1588 */
1590
1591
1592
1593 std::string ToString() const override
1594 {
1595 std::stringstream ss;
1596 ss << "{" << std::endl;
1597 ss << "Config Group: Feedback" << std::endl;
1598 ss << "Name: \"FeedbackRotorOffset\" Value: \"" << FeedbackRotorOffset << "rotations\"" << std::endl;
1599 ss << "Name: \"SensorToMechanismRatio\" Value: \"" << SensorToMechanismRatio << "scalar\"" << std::endl;
1600 ss << "Name: \"RotorToSensorRatio\" Value: \"" << RotorToSensorRatio << "scalar\"" << std::endl;
1601 ss << "Name: \"FeedbackSensorSource\" Value: \"" << FeedbackSensorSource << "\"" << std::endl;
1602 ss << "Name: \"FeedbackRemoteSensorID\" Value: \"" << FeedbackRemoteSensorID << "\"" << std::endl;
1603 ss << "}" << std::endl;
1604 return ss.str();
1605 }
1606
1607 std::string Serialize() const override
1608 {
1609 std::stringstream ss;
1610 char *ref;
1611 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_FeedbackRotorOffset, FeedbackRotorOffset, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1612 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SensorToMechanismRatio, SensorToMechanismRatio, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1613 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_RotorToSensorRatio, RotorToSensorRatio, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1614 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackSensorSource, FeedbackSensorSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1615 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackRemoteSensorID, FeedbackRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1616 return ss.str();
1617 }
1618
1619 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1620 {
1621 const char *string_c_str = to_deserialize.c_str();
1622 size_t string_length = to_deserialize.length();
1623 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_FeedbackRotorOffset, string_c_str, string_length, &FeedbackRotorOffset);
1624 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SensorToMechanismRatio, string_c_str, string_length, &SensorToMechanismRatio);
1625 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_RotorToSensorRatio, string_c_str, string_length, &RotorToSensorRatio);
1626 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackSensorSource, string_c_str, string_length, &FeedbackSensorSource.value);
1627 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackRemoteSensorID, string_c_str, string_length, &FeedbackRemoteSensorID);
1628 return 0;
1629 }
1630};
1631
1632
1633/**
1634 * \brief Configs related to sensors used for differential control of
1635 * a mechanism.
1636 *
1637 * \details Includes the differential sensor sources and IDs.
1638 */
1640{
1641public:
1642 /**
1643 * \brief Choose what sensor source is used for differential control
1644 * of a mechanism. The default is Disabled. All other options
1645 * require setting the DifferentialTalonFXSensorID, as the average of
1646 * this Talon FX's sensor and the remote TalonFX's sensor is used for
1647 * the differential controller's primary targets.
1648 *
1649 * Choose RemoteTalonFX_Diff to use another TalonFX on the same CAN
1650 * bus. Talon FX will update its differential position and velocity
1651 * whenever the remote TalonFX publishes its information on CAN bus.
1652 * The differential controller will use the difference between this
1653 * TalonFX's sensor and the remote Talon FX's sensor for the
1654 * differential component of the output.
1655 *
1656 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
1657 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
1658 * also requires setting DifferentialRemoteSensorID). Talon FX will
1659 * update its differential position to match the selected value
1660 * whenever Pigeon2 publishes its information on CAN bus. Note that
1661 * the Talon FX differential position will be in rotations and not
1662 * degrees.
1663 *
1664 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
1665 * (this also requires setting DifferentialRemoteSensorID). Talon FX
1666 * will update its differential position and velocity to match the
1667 * CANcoder whenever CANcoder publishes its information on CAN bus.
1668 *
1669 */
1671 /**
1672 * \brief Device ID of which remote Talon FX to use. This is used
1673 * when the Differential Sensor Source is not disabled.
1674 *
1675 * - Minimum Value: 0
1676 * - Maximum Value: 62
1677 * - Default Value: 0
1678 * - Units:
1679 */
1681 /**
1682 * \brief Device ID of which remote sensor to use on the differential
1683 * axis. This is used when the Differential Sensor Source is not
1684 * RemoteTalonFX_Diff.
1685 *
1686 * - Minimum Value: 0
1687 * - Maximum Value: 62
1688 * - Default Value: 0
1689 * - Units:
1690 */
1692
1693 /**
1694 * \brief Modifies this configuration's DifferentialSensorSource parameter and returns itself for
1695 * method-chaining and easier to use config API.
1696 *
1697 * Choose what sensor source is used for differential control of a
1698 * mechanism. The default is Disabled. All other options require
1699 * setting the DifferentialTalonFXSensorID, as the average of this
1700 * Talon FX's sensor and the remote TalonFX's sensor is used for the
1701 * differential controller's primary targets.
1702 *
1703 * Choose RemoteTalonFX_Diff to use another TalonFX on the same CAN
1704 * bus. Talon FX will update its differential position and velocity
1705 * whenever the remote TalonFX publishes its information on CAN bus.
1706 * The differential controller will use the difference between this
1707 * TalonFX's sensor and the remote Talon FX's sensor for the
1708 * differential component of the output.
1709 *
1710 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
1711 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
1712 * also requires setting DifferentialRemoteSensorID). Talon FX will
1713 * update its differential position to match the selected value
1714 * whenever Pigeon2 publishes its information on CAN bus. Note that
1715 * the Talon FX differential position will be in rotations and not
1716 * degrees.
1717 *
1718 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
1719 * (this also requires setting DifferentialRemoteSensorID). Talon FX
1720 * will update its differential position and velocity to match the
1721 * CANcoder whenever CANcoder publishes its information on CAN bus.
1722 *
1723 *
1724 * \param newDifferentialSensorSource Parameter to modify
1725 * \returns Itself
1726 */
1728 {
1729 DifferentialSensorSource = std::move(newDifferentialSensorSource);
1730 return *this;
1731 }
1732 /**
1733 * \brief Modifies this configuration's DifferentialTalonFXSensorID parameter and returns itself for
1734 * method-chaining and easier to use config API.
1735 *
1736 * Device ID of which remote Talon FX to use. This is used when the
1737 * Differential Sensor Source is not disabled.
1738 *
1739 * - Minimum Value: 0
1740 * - Maximum Value: 62
1741 * - Default Value: 0
1742 * - Units:
1743 *
1744 * \param newDifferentialTalonFXSensorID Parameter to modify
1745 * \returns Itself
1746 */
1748 {
1749 DifferentialTalonFXSensorID = std::move(newDifferentialTalonFXSensorID);
1750 return *this;
1751 }
1752 /**
1753 * \brief Modifies this configuration's DifferentialRemoteSensorID parameter and returns itself for
1754 * method-chaining and easier to use config API.
1755 *
1756 * Device ID of which remote sensor to use on the differential axis.
1757 * This is used when the Differential Sensor Source is not
1758 * RemoteTalonFX_Diff.
1759 *
1760 * - Minimum Value: 0
1761 * - Maximum Value: 62
1762 * - Default Value: 0
1763 * - Units:
1764 *
1765 * \param newDifferentialRemoteSensorID Parameter to modify
1766 * \returns Itself
1767 */
1769 {
1770 DifferentialRemoteSensorID = std::move(newDifferentialRemoteSensorID);
1771 return *this;
1772 }
1773
1774
1775
1776 std::string ToString() const override
1777 {
1778 std::stringstream ss;
1779 ss << "{" << std::endl;
1780 ss << "Config Group: DifferentialSensors" << std::endl;
1781 ss << "Name: \"DifferentialSensorSource\" Value: \"" << DifferentialSensorSource << "\"" << std::endl;
1782 ss << "Name: \"DifferentialTalonFXSensorID\" Value: \"" << DifferentialTalonFXSensorID << "\"" << std::endl;
1783 ss << "Name: \"DifferentialRemoteSensorID\" Value: \"" << DifferentialRemoteSensorID << "\"" << std::endl;
1784 ss << "}" << std::endl;
1785 return ss.str();
1786 }
1787
1788 std::string Serialize() const override
1789 {
1790 std::stringstream ss;
1791 char *ref;
1792 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialSensorSource, DifferentialSensorSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1793 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialTalonFXSensorID, DifferentialTalonFXSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1794 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialRemoteSensorID, DifferentialRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1795 return ss.str();
1796 }
1797
1798 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1799 {
1800 const char *string_c_str = to_deserialize.c_str();
1801 size_t string_length = to_deserialize.length();
1802 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialSensorSource, string_c_str, string_length, &DifferentialSensorSource.value);
1803 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialTalonFXSensorID, string_c_str, string_length, &DifferentialTalonFXSensorID);
1804 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialRemoteSensorID, string_c_str, string_length, &DifferentialRemoteSensorID);
1805 return 0;
1806 }
1807};
1808
1809
1810/**
1811 * \brief Configs related to constants used for differential control
1812 * of a mechanism.
1813 *
1814 * \details Includes the differential peak outputs.
1815 */
1817{
1818public:
1819 /**
1820 * \brief Maximum differential output during duty cycle based
1821 * differential control modes.
1822 *
1823 * - Minimum Value: 0.0
1824 * - Maximum Value: 2.0
1825 * - Default Value: 2
1826 * - Units: fractional
1827 */
1829 /**
1830 * \brief Maximum differential output during voltage based
1831 * differential control modes.
1832 *
1833 * - Minimum Value: 0.0
1834 * - Maximum Value: 32
1835 * - Default Value: 32
1836 * - Units: V
1837 */
1839 /**
1840 * \brief Maximum differential output during torque current based
1841 * differential control modes.
1842 *
1843 * - Minimum Value: 0.0
1844 * - Maximum Value: 1600
1845 * - Default Value: 1600
1846 * - Units: A
1847 */
1849
1850 /**
1851 * \brief Modifies this configuration's PeakDifferentialDutyCycle parameter and returns itself for
1852 * method-chaining and easier to use config API.
1853 *
1854 * Maximum differential output during duty cycle based differential
1855 * control modes.
1856 *
1857 * - Minimum Value: 0.0
1858 * - Maximum Value: 2.0
1859 * - Default Value: 2
1860 * - Units: fractional
1861 *
1862 * \param newPeakDifferentialDutyCycle Parameter to modify
1863 * \returns Itself
1864 */
1866 {
1867 PeakDifferentialDutyCycle = std::move(newPeakDifferentialDutyCycle);
1868 return *this;
1869 }
1870 /**
1871 * \brief Modifies this configuration's PeakDifferentialVoltage parameter and returns itself for
1872 * method-chaining and easier to use config API.
1873 *
1874 * Maximum differential output during voltage based differential
1875 * control modes.
1876 *
1877 * - Minimum Value: 0.0
1878 * - Maximum Value: 32
1879 * - Default Value: 32
1880 * - Units: V
1881 *
1882 * \param newPeakDifferentialVoltage Parameter to modify
1883 * \returns Itself
1884 */
1886 {
1887 PeakDifferentialVoltage = std::move(newPeakDifferentialVoltage);
1888 return *this;
1889 }
1890 /**
1891 * \brief Modifies this configuration's PeakDifferentialTorqueCurrent parameter and returns itself for
1892 * method-chaining and easier to use config API.
1893 *
1894 * Maximum differential output during torque current based
1895 * differential control modes.
1896 *
1897 * - Minimum Value: 0.0
1898 * - Maximum Value: 1600
1899 * - Default Value: 1600
1900 * - Units: A
1901 *
1902 * \param newPeakDifferentialTorqueCurrent Parameter to modify
1903 * \returns Itself
1904 */
1905 DifferentialConstantsConfigs& WithPeakDifferentialTorqueCurrent(double newPeakDifferentialTorqueCurrent)
1906 {
1907 PeakDifferentialTorqueCurrent = std::move(newPeakDifferentialTorqueCurrent);
1908 return *this;
1909 }
1910
1911
1912
1913 std::string ToString() const override
1914 {
1915 std::stringstream ss;
1916 ss << "{" << std::endl;
1917 ss << "Config Group: DifferentialConstants" << std::endl;
1918 ss << "Name: \"PeakDifferentialDutyCycle\" Value: \"" << PeakDifferentialDutyCycle << "fractional\"" << std::endl;
1919 ss << "Name: \"PeakDifferentialVoltage\" Value: \"" << PeakDifferentialVoltage << "V\"" << std::endl;
1920 ss << "Name: \"PeakDifferentialTorqueCurrent\" Value: \"" << PeakDifferentialTorqueCurrent << "A\"" << std::endl;
1921 ss << "}" << std::endl;
1922 return ss.str();
1923 }
1924
1925 std::string Serialize() const override
1926 {
1927 std::stringstream ss;
1928 char *ref;
1929 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffDC, PeakDifferentialDutyCycle, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1930 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffV, PeakDifferentialVoltage, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1931 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffTorqCurr, PeakDifferentialTorqueCurrent, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1932 return ss.str();
1933 }
1934
1935 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
1936 {
1937 const char *string_c_str = to_deserialize.c_str();
1938 size_t string_length = to_deserialize.length();
1939 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffDC, string_c_str, string_length, &PeakDifferentialDutyCycle);
1940 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffV, string_c_str, string_length, &PeakDifferentialVoltage);
1941 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffTorqCurr, string_c_str, string_length, &PeakDifferentialTorqueCurrent);
1942 return 0;
1943 }
1944};
1945
1946
1947/**
1948 * \brief Configs that affect the open-loop control of this motor
1949 * controller.
1950 *
1951 * \details Open-loop ramp rates for the various control types.
1952 */
1954{
1955public:
1956 /**
1957 * \brief If non-zero, this determines how much time to ramp from 0%
1958 * output to 100% during open-loop modes.
1959 *
1960 * - Minimum Value: 0
1961 * - Maximum Value: 1
1962 * - Default Value: 0
1963 * - Units: sec
1964 */
1966 /**
1967 * \brief If non-zero, this determines how much time to ramp from 0V
1968 * output to 12V during open-loop modes.
1969 *
1970 * - Minimum Value: 0
1971 * - Maximum Value: 1
1972 * - Default Value: 0
1973 * - Units: sec
1974 */
1976 /**
1977 * \brief If non-zero, this determines how much time to ramp from 0A
1978 * output to 300A during open-loop modes.
1979 *
1980 * - Minimum Value: 0
1981 * - Maximum Value: 10
1982 * - Default Value: 0
1983 * - Units: sec
1984 */
1986
1987 /**
1988 * \brief Modifies this configuration's DutyCycleOpenLoopRampPeriod parameter and returns itself for
1989 * method-chaining and easier to use config API.
1990 *
1991 * If non-zero, this determines how much time to ramp from 0% output
1992 * to 100% during open-loop modes.
1993 *
1994 * - Minimum Value: 0
1995 * - Maximum Value: 1
1996 * - Default Value: 0
1997 * - Units: sec
1998 *
1999 * \param newDutyCycleOpenLoopRampPeriod Parameter to modify
2000 * \returns Itself
2001 */
2002 OpenLoopRampsConfigs& WithDutyCycleOpenLoopRampPeriod(double newDutyCycleOpenLoopRampPeriod)
2003 {
2004 DutyCycleOpenLoopRampPeriod = std::move(newDutyCycleOpenLoopRampPeriod);
2005 return *this;
2006 }
2007 /**
2008 * \brief Modifies this configuration's VoltageOpenLoopRampPeriod parameter and returns itself for
2009 * method-chaining and easier to use config API.
2010 *
2011 * If non-zero, this determines how much time to ramp from 0V output
2012 * to 12V during open-loop modes.
2013 *
2014 * - Minimum Value: 0
2015 * - Maximum Value: 1
2016 * - Default Value: 0
2017 * - Units: sec
2018 *
2019 * \param newVoltageOpenLoopRampPeriod Parameter to modify
2020 * \returns Itself
2021 */
2022 OpenLoopRampsConfigs& WithVoltageOpenLoopRampPeriod(double newVoltageOpenLoopRampPeriod)
2023 {
2024 VoltageOpenLoopRampPeriod = std::move(newVoltageOpenLoopRampPeriod);
2025 return *this;
2026 }
2027 /**
2028 * \brief Modifies this configuration's TorqueOpenLoopRampPeriod parameter and returns itself for
2029 * method-chaining and easier to use config API.
2030 *
2031 * If non-zero, this determines how much time to ramp from 0A output
2032 * to 300A during open-loop modes.
2033 *
2034 * - Minimum Value: 0
2035 * - Maximum Value: 10
2036 * - Default Value: 0
2037 * - Units: sec
2038 *
2039 * \param newTorqueOpenLoopRampPeriod Parameter to modify
2040 * \returns Itself
2041 */
2042 OpenLoopRampsConfigs& WithTorqueOpenLoopRampPeriod(double newTorqueOpenLoopRampPeriod)
2043 {
2044 TorqueOpenLoopRampPeriod = std::move(newTorqueOpenLoopRampPeriod);
2045 return *this;
2046 }
2047
2048
2049
2050 std::string ToString() const override
2051 {
2052 std::stringstream ss;
2053 ss << "{" << std::endl;
2054 ss << "Config Group: OpenLoopRamps" << std::endl;
2055 ss << "Name: \"DutyCycleOpenLoopRampPeriod\" Value: \"" << DutyCycleOpenLoopRampPeriod << "sec\"" << std::endl;
2056 ss << "Name: \"VoltageOpenLoopRampPeriod\" Value: \"" << VoltageOpenLoopRampPeriod << "sec\"" << std::endl;
2057 ss << "Name: \"TorqueOpenLoopRampPeriod\" Value: \"" << TorqueOpenLoopRampPeriod << "sec\"" << std::endl;
2058 ss << "}" << std::endl;
2059 return ss.str();
2060 }
2061
2062 std::string Serialize() const override
2063 {
2064 std::stringstream ss;
2065 char *ref;
2066 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleOpenLoopRampPeriod, DutyCycleOpenLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2067 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageOpenLoopRampPeriod, VoltageOpenLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2068 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueOpenLoopRampPeriod, TorqueOpenLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2069 return ss.str();
2070 }
2071
2072 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
2073 {
2074 const char *string_c_str = to_deserialize.c_str();
2075 size_t string_length = to_deserialize.length();
2076 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleOpenLoopRampPeriod, string_c_str, string_length, &DutyCycleOpenLoopRampPeriod);
2077 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageOpenLoopRampPeriod, string_c_str, string_length, &VoltageOpenLoopRampPeriod);
2078 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueOpenLoopRampPeriod, string_c_str, string_length, &TorqueOpenLoopRampPeriod);
2079 return 0;
2080 }
2081};
2082
2083
2084/**
2085 * \brief Configs that affect the closed-loop control of this motor
2086 * controller.
2087 *
2088 * \details Closed-loop ramp rates for the various control types.
2089 */
2091{
2092public:
2093 /**
2094 * \brief If non-zero, this determines how much time to ramp from 0%
2095 * output to 100% during closed-loop modes.
2096 *
2097 * - Minimum Value: 0
2098 * - Maximum Value: 1
2099 * - Default Value: 0
2100 * - Units: sec
2101 */
2103 /**
2104 * \brief If non-zero, this determines how much time to ramp from 0V
2105 * output to 12V during closed-loop modes.
2106 *
2107 * - Minimum Value: 0
2108 * - Maximum Value: 1
2109 * - Default Value: 0
2110 * - Units: sec
2111 */
2113 /**
2114 * \brief If non-zero, this determines how much time to ramp from 0A
2115 * output to 300A during closed-loop modes.
2116 *
2117 * - Minimum Value: 0
2118 * - Maximum Value: 10
2119 * - Default Value: 0
2120 * - Units: sec
2121 */
2123
2124 /**
2125 * \brief Modifies this configuration's DutyCycleClosedLoopRampPeriod parameter and returns itself for
2126 * method-chaining and easier to use config API.
2127 *
2128 * If non-zero, this determines how much time to ramp from 0% output
2129 * to 100% during closed-loop modes.
2130 *
2131 * - Minimum Value: 0
2132 * - Maximum Value: 1
2133 * - Default Value: 0
2134 * - Units: sec
2135 *
2136 * \param newDutyCycleClosedLoopRampPeriod Parameter to modify
2137 * \returns Itself
2138 */
2139 ClosedLoopRampsConfigs& WithDutyCycleClosedLoopRampPeriod(double newDutyCycleClosedLoopRampPeriod)
2140 {
2141 DutyCycleClosedLoopRampPeriod = std::move(newDutyCycleClosedLoopRampPeriod);
2142 return *this;
2143 }
2144 /**
2145 * \brief Modifies this configuration's VoltageClosedLoopRampPeriod parameter and returns itself for
2146 * method-chaining and easier to use config API.
2147 *
2148 * If non-zero, this determines how much time to ramp from 0V output
2149 * to 12V during closed-loop modes.
2150 *
2151 * - Minimum Value: 0
2152 * - Maximum Value: 1
2153 * - Default Value: 0
2154 * - Units: sec
2155 *
2156 * \param newVoltageClosedLoopRampPeriod Parameter to modify
2157 * \returns Itself
2158 */
2159 ClosedLoopRampsConfigs& WithVoltageClosedLoopRampPeriod(double newVoltageClosedLoopRampPeriod)
2160 {
2161 VoltageClosedLoopRampPeriod = std::move(newVoltageClosedLoopRampPeriod);
2162 return *this;
2163 }
2164 /**
2165 * \brief Modifies this configuration's TorqueClosedLoopRampPeriod parameter and returns itself for
2166 * method-chaining and easier to use config API.
2167 *
2168 * If non-zero, this determines how much time to ramp from 0A output
2169 * to 300A during closed-loop modes.
2170 *
2171 * - Minimum Value: 0
2172 * - Maximum Value: 10
2173 * - Default Value: 0
2174 * - Units: sec
2175 *
2176 * \param newTorqueClosedLoopRampPeriod Parameter to modify
2177 * \returns Itself
2178 */
2179 ClosedLoopRampsConfigs& WithTorqueClosedLoopRampPeriod(double newTorqueClosedLoopRampPeriod)
2180 {
2181 TorqueClosedLoopRampPeriod = std::move(newTorqueClosedLoopRampPeriod);
2182 return *this;
2183 }
2184
2185
2186
2187 std::string ToString() const override
2188 {
2189 std::stringstream ss;
2190 ss << "{" << std::endl;
2191 ss << "Config Group: ClosedLoopRamps" << std::endl;
2192 ss << "Name: \"DutyCycleClosedLoopRampPeriod\" Value: \"" << DutyCycleClosedLoopRampPeriod << "sec\"" << std::endl;
2193 ss << "Name: \"VoltageClosedLoopRampPeriod\" Value: \"" << VoltageClosedLoopRampPeriod << "sec\"" << std::endl;
2194 ss << "Name: \"TorqueClosedLoopRampPeriod\" Value: \"" << TorqueClosedLoopRampPeriod << "sec\"" << std::endl;
2195 ss << "}" << std::endl;
2196 return ss.str();
2197 }
2198
2199 std::string Serialize() const override
2200 {
2201 std::stringstream ss;
2202 char *ref;
2203 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleClosedLoopRampPeriod, DutyCycleClosedLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2204 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageClosedLoopRampPeriod, VoltageClosedLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2205 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueClosedLoopRampPeriod, TorqueClosedLoopRampPeriod, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2206 return ss.str();
2207 }
2208
2209 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
2210 {
2211 const char *string_c_str = to_deserialize.c_str();
2212 size_t string_length = to_deserialize.length();
2213 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleClosedLoopRampPeriod, string_c_str, string_length, &DutyCycleClosedLoopRampPeriod);
2214 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageClosedLoopRampPeriod, string_c_str, string_length, &VoltageClosedLoopRampPeriod);
2215 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueClosedLoopRampPeriod, string_c_str, string_length, &TorqueClosedLoopRampPeriod);
2216 return 0;
2217 }
2218};
2219
2220
2221/**
2222 * \brief Configs that change how the motor controller behaves under
2223 * different limit switch states.
2224 *
2225 * \details Includes configs such as enabling limit switches,
2226 * configuring the remote sensor ID, the source, and the
2227 * position to set on limit.
2228 */
2230{
2231public:
2232 /**
2233 * \brief Determines if the forward limit switch is normally-open
2234 * (default) or normally-closed.
2235 *
2236 */
2238 /**
2239 * \brief If enabled, the position is automatically set to a specific
2240 * value, specified by ForwardLimitAutosetPositionValue, when the
2241 * forward limit switch is asserted.
2242 *
2243 * - Default Value: False
2244 */
2246 /**
2247 * \brief The value to automatically set the position to when the
2248 * forward limit switch is asserted. This has no effect if
2249 * ForwardLimitAutosetPositionEnable is false.
2250 *
2251 * - Minimum Value: -3.4e+38
2252 * - Maximum Value: 3.4e+38
2253 * - Default Value: 0
2254 * - Units: rotations
2255 */
2257 /**
2258 * \brief If enabled, motor output is set to neutral when the forward
2259 * limit switch is asserted and positive output is requested.
2260 *
2261 * - Default Value: True
2262 */
2264 /**
2265 * \brief Determines where to poll the forward limit switch. This
2266 * defaults to the forward limit switch pin on the limit switch
2267 * connector.
2268 *
2269 * Choose RemoteTalonFX to use the forward limit switch attached to
2270 * another Talon FX on the same CAN bus (this also requires setting
2271 * ForwardLimitRemoteSensorID).
2272 *
2273 * Choose RemoteCANifier to use the forward limit switch attached to
2274 * another CANifier on the same CAN bus (this also requires setting
2275 * ForwardLimitRemoteSensorID).
2276 *
2277 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
2278 * (this also requires setting ForwardLimitRemoteSensorID). The
2279 * forward limit will assert when the CANcoder magnet strength changes
2280 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
2281 *
2282 */
2284 /**
2285 * \brief Device ID of the remote device if using remote limit switch
2286 * features for the forward limit switch.
2287 *
2288 * - Minimum Value: 0
2289 * - Maximum Value: 62
2290 * - Default Value: 0
2291 * - Units:
2292 */
2294 /**
2295 * \brief Determines if the reverse limit switch is normally-open
2296 * (default) or normally-closed.
2297 *
2298 */
2300 /**
2301 * \brief If enabled, the position is automatically set to a specific
2302 * value, specified by ReverseLimitAutosetPositionValue, when the
2303 * reverse limit switch is asserted.
2304 *
2305 * - Default Value: False
2306 */
2308 /**
2309 * \brief The value to automatically set the position to when the
2310 * reverse limit switch is asserted. This has no effect if
2311 * ReverseLimitAutosetPositionEnable is false.
2312 *
2313 * - Minimum Value: -3.4e+38
2314 * - Maximum Value: 3.4e+38
2315 * - Default Value: 0
2316 * - Units: rotations
2317 */
2319 /**
2320 * \brief If enabled, motor output is set to neutral when reverse
2321 * limit switch is asseted and negative output is requested.
2322 *
2323 * - Default Value: True
2324 */
2326 /**
2327 * \brief Determines where to poll the reverse limit switch. This
2328 * defaults to the reverse limit switch pin on the limit switch
2329 * connector.
2330 *
2331 * Choose RemoteTalonFX to use the reverse limit switch attached to
2332 * another Talon FX on the same CAN bus (this also requires setting
2333 * ReverseLimitRemoteSensorID).
2334 *
2335 * Choose RemoteCANifier to use the reverse limit switch attached to
2336 * another CANifier on the same CAN bus (this also requires setting
2337 * ReverseLimitRemoteSensorID).
2338 *
2339 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
2340 * (this also requires setting ReverseLimitRemoteSensorID). The
2341 * reverse limit will assert when the CANcoder magnet strength changes
2342 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
2343 *
2344 */
2346 /**
2347 * \brief Device ID of the remote device if using remote limit switch
2348 * features for the reverse limit switch.
2349 *
2350 * - Minimum Value: 0
2351 * - Maximum Value: 62
2352 * - Default Value: 0
2353 * - Units:
2354 */
2356
2357 /**
2358 * \brief Modifies this configuration's ForwardLimitType parameter and returns itself for
2359 * method-chaining and easier to use config API.
2360 *
2361 * Determines if the forward limit switch is normally-open (default)
2362 * or normally-closed.
2363 *
2364 *
2365 * \param newForwardLimitType Parameter to modify
2366 * \returns Itself
2367 */
2369 {
2370 ForwardLimitType = std::move(newForwardLimitType);
2371 return *this;
2372 }
2373 /**
2374 * \brief Modifies this configuration's ForwardLimitAutosetPositionEnable parameter and returns itself for
2375 * method-chaining and easier to use config API.
2376 *
2377 * If enabled, the position is automatically set to a specific value,
2378 * specified by ForwardLimitAutosetPositionValue, when the forward
2379 * limit switch is asserted.
2380 *
2381 * - Default Value: False
2382 *
2383 * \param newForwardLimitAutosetPositionEnable Parameter to modify
2384 * \returns Itself
2385 */
2386 HardwareLimitSwitchConfigs& WithForwardLimitAutosetPositionEnable(bool newForwardLimitAutosetPositionEnable)
2387 {
2388 ForwardLimitAutosetPositionEnable = std::move(newForwardLimitAutosetPositionEnable);
2389 return *this;
2390 }
2391 /**
2392 * \brief Modifies this configuration's ForwardLimitAutosetPositionValue parameter and returns itself for
2393 * method-chaining and easier to use config API.
2394 *
2395 * The value to automatically set the position to when the forward
2396 * limit switch is asserted. This has no effect if
2397 * ForwardLimitAutosetPositionEnable is false.
2398 *
2399 * - Minimum Value: -3.4e+38
2400 * - Maximum Value: 3.4e+38
2401 * - Default Value: 0
2402 * - Units: rotations
2403 *
2404 * \param newForwardLimitAutosetPositionValue Parameter to modify
2405 * \returns Itself
2406 */
2407 HardwareLimitSwitchConfigs& WithForwardLimitAutosetPositionValue(double newForwardLimitAutosetPositionValue)
2408 {
2409 ForwardLimitAutosetPositionValue = std::move(newForwardLimitAutosetPositionValue);
2410 return *this;
2411 }
2412 /**
2413 * \brief Modifies this configuration's ForwardLimitEnable parameter and returns itself for
2414 * method-chaining and easier to use config API.
2415 *
2416 * If enabled, motor output is set to neutral when the forward limit
2417 * switch is asserted and positive output is requested.
2418 *
2419 * - Default Value: True
2420 *
2421 * \param newForwardLimitEnable Parameter to modify
2422 * \returns Itself
2423 */
2425 {
2426 ForwardLimitEnable = std::move(newForwardLimitEnable);
2427 return *this;
2428 }
2429 /**
2430 * \brief Modifies this configuration's ForwardLimitSource parameter and returns itself for
2431 * method-chaining and easier to use config API.
2432 *
2433 * Determines where to poll the forward limit switch. This defaults
2434 * to the forward limit switch pin on the limit switch connector.
2435 *
2436 * Choose RemoteTalonFX to use the forward limit switch attached to
2437 * another Talon FX on the same CAN bus (this also requires setting
2438 * ForwardLimitRemoteSensorID).
2439 *
2440 * Choose RemoteCANifier to use the forward limit switch attached to
2441 * another CANifier on the same CAN bus (this also requires setting
2442 * ForwardLimitRemoteSensorID).
2443 *
2444 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
2445 * (this also requires setting ForwardLimitRemoteSensorID). The
2446 * forward limit will assert when the CANcoder magnet strength changes
2447 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
2448 *
2449 *
2450 * \param newForwardLimitSource Parameter to modify
2451 * \returns Itself
2452 */
2454 {
2455 ForwardLimitSource = std::move(newForwardLimitSource);
2456 return *this;
2457 }
2458 /**
2459 * \brief Modifies this configuration's ForwardLimitRemoteSensorID parameter and returns itself for
2460 * method-chaining and easier to use config API.
2461 *
2462 * Device ID of the remote device if using remote limit switch
2463 * features for the forward limit switch.
2464 *
2465 * - Minimum Value: 0
2466 * - Maximum Value: 62
2467 * - Default Value: 0
2468 * - Units:
2469 *
2470 * \param newForwardLimitRemoteSensorID Parameter to modify
2471 * \returns Itself
2472 */
2474 {
2475 ForwardLimitRemoteSensorID = std::move(newForwardLimitRemoteSensorID);
2476 return *this;
2477 }
2478 /**
2479 * \brief Modifies this configuration's ReverseLimitType parameter and returns itself for
2480 * method-chaining and easier to use config API.
2481 *
2482 * Determines if the reverse limit switch is normally-open (default)
2483 * or normally-closed.
2484 *
2485 *
2486 * \param newReverseLimitType Parameter to modify
2487 * \returns Itself
2488 */
2490 {
2491 ReverseLimitType = std::move(newReverseLimitType);
2492 return *this;
2493 }
2494 /**
2495 * \brief Modifies this configuration's ReverseLimitAutosetPositionEnable parameter and returns itself for
2496 * method-chaining and easier to use config API.
2497 *
2498 * If enabled, the position is automatically set to a specific value,
2499 * specified by ReverseLimitAutosetPositionValue, when the reverse
2500 * limit switch is asserted.
2501 *
2502 * - Default Value: False
2503 *
2504 * \param newReverseLimitAutosetPositionEnable Parameter to modify
2505 * \returns Itself
2506 */
2507 HardwareLimitSwitchConfigs& WithReverseLimitAutosetPositionEnable(bool newReverseLimitAutosetPositionEnable)
2508 {
2509 ReverseLimitAutosetPositionEnable = std::move(newReverseLimitAutosetPositionEnable);
2510 return *this;
2511 }
2512 /**
2513 * \brief Modifies this configuration's ReverseLimitAutosetPositionValue parameter and returns itself for
2514 * method-chaining and easier to use config API.
2515 *
2516 * The value to automatically set the position to when the reverse
2517 * limit switch is asserted. This has no effect if
2518 * ReverseLimitAutosetPositionEnable is false.
2519 *
2520 * - Minimum Value: -3.4e+38
2521 * - Maximum Value: 3.4e+38
2522 * - Default Value: 0
2523 * - Units: rotations
2524 *
2525 * \param newReverseLimitAutosetPositionValue Parameter to modify
2526 * \returns Itself
2527 */
2528 HardwareLimitSwitchConfigs& WithReverseLimitAutosetPositionValue(double newReverseLimitAutosetPositionValue)
2529 {
2530 ReverseLimitAutosetPositionValue = std::move(newReverseLimitAutosetPositionValue);
2531 return *this;
2532 }
2533 /**
2534 * \brief Modifies this configuration's ReverseLimitEnable parameter and returns itself for
2535 * method-chaining and easier to use config API.
2536 *
2537 * If enabled, motor output is set to neutral when reverse limit
2538 * switch is asseted and negative output is requested.
2539 *
2540 * - Default Value: True
2541 *
2542 * \param newReverseLimitEnable Parameter to modify
2543 * \returns Itself
2544 */
2546 {
2547 ReverseLimitEnable = std::move(newReverseLimitEnable);
2548 return *this;
2549 }
2550 /**
2551 * \brief Modifies this configuration's ReverseLimitSource parameter and returns itself for
2552 * method-chaining and easier to use config API.
2553 *
2554 * Determines where to poll the reverse limit switch. This defaults
2555 * to the reverse limit switch pin on the limit switch connector.
2556 *
2557 * Choose RemoteTalonFX to use the reverse limit switch attached to
2558 * another Talon FX on the same CAN bus (this also requires setting
2559 * ReverseLimitRemoteSensorID).
2560 *
2561 * Choose RemoteCANifier to use the reverse limit switch attached to
2562 * another CANifier on the same CAN bus (this also requires setting
2563 * ReverseLimitRemoteSensorID).
2564 *
2565 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
2566 * (this also requires setting ReverseLimitRemoteSensorID). The
2567 * reverse limit will assert when the CANcoder magnet strength changes
2568 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
2569 *
2570 *
2571 * \param newReverseLimitSource Parameter to modify
2572 * \returns Itself
2573 */
2575 {
2576 ReverseLimitSource = std::move(newReverseLimitSource);
2577 return *this;
2578 }
2579 /**
2580 * \brief Modifies this configuration's ReverseLimitRemoteSensorID parameter and returns itself for
2581 * method-chaining and easier to use config API.
2582 *
2583 * Device ID of the remote device if using remote limit switch
2584 * features for the reverse limit switch.
2585 *
2586 * - Minimum Value: 0
2587 * - Maximum Value: 62
2588 * - Default Value: 0
2589 * - Units:
2590 *
2591 * \param newReverseLimitRemoteSensorID Parameter to modify
2592 * \returns Itself
2593 */
2595 {
2596 ReverseLimitRemoteSensorID = std::move(newReverseLimitRemoteSensorID);
2597 return *this;
2598 }
2599
2600 /**
2601 * \brief Helper method to configure this feedback group to use
2602 * RemoteTalonFX forward limit switch by passing in the TalonFX
2603 * object. When using RemoteTalonFX, the Talon FX will use the
2604 * forward limit switch attached to another Talon FX on the
2605 * same CAN bus.
2606 *
2607 * \param device TalonFX reference to use for RemoteTalonFX forward limit
2608 * switch
2609 * \returns Itself
2610 */
2612
2613 /**
2614 * \brief Helper method to configure this feedback group to use
2615 * RemoteCANcoder forward limit switch by passing in the
2616 * CANcoder object. When using RemoteCANcoder, the Talon FX
2617 * will use another CANcoder on the same CAN bus. The forward
2618 * limit will assert when the CANcoder magnet strength changes
2619 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
2620 *
2621 * \param device CANcoder reference to use for RemoteCANcoder forward limit
2622 * switch
2623 * \returns Itself
2624 */
2626
2627 /**
2628 * \brief Helper method to configure this feedback group to use
2629 * RemoteTalonFX reverse limit switch by passing in the TalonFX
2630 * object. When using RemoteTalonFX, the Talon FX will use the
2631 * reverse limit switch attached to another Talon FX on the
2632 * same CAN bus.
2633 *
2634 * \param device TalonFX reference to use for RemoteTalonFX reverse limit
2635 * switch
2636 * \returns Itself
2637 */
2639
2640 /**
2641 * \brief Helper method to configure this feedback group to use
2642 * RemoteCANcoder reverse limit switch by passing in the
2643 * CANcoder object. When using RemoteCANcoder, the Talon FX
2644 * will use another CANcoder on the same CAN bus. The reverse
2645 * limit will assert when the CANcoder magnet strength changes
2646 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
2647 *
2648 * \param device CANcoder reference to use for RemoteCANcoder reverse limit
2649 * switch
2650 * \returns Itself
2651 */
2653
2654
2655
2656 std::string ToString() const override
2657 {
2658 std::stringstream ss;
2659 ss << "{" << std::endl;
2660 ss << "Config Group: HardwareLimitSwitch" << std::endl;
2661 ss << "Name: \"ForwardLimitType\" Value: \"" << ForwardLimitType << "\"" << std::endl;
2662 ss << "Name: \"ForwardLimitAutosetPositionEnable\" Value: \"" << ForwardLimitAutosetPositionEnable << "\"" << std::endl;
2663 ss << "Name: \"ForwardLimitAutosetPositionValue\" Value: \"" << ForwardLimitAutosetPositionValue << "rotations\"" << std::endl;
2664 ss << "Name: \"ForwardLimitEnable\" Value: \"" << ForwardLimitEnable << "\"" << std::endl;
2665 ss << "Name: \"ForwardLimitSource\" Value: \"" << ForwardLimitSource << "\"" << std::endl;
2666 ss << "Name: \"ForwardLimitRemoteSensorID\" Value: \"" << ForwardLimitRemoteSensorID << "\"" << std::endl;
2667 ss << "Name: \"ReverseLimitType\" Value: \"" << ReverseLimitType << "\"" << std::endl;
2668 ss << "Name: \"ReverseLimitAutosetPositionEnable\" Value: \"" << ReverseLimitAutosetPositionEnable << "\"" << std::endl;
2669 ss << "Name: \"ReverseLimitAutosetPositionValue\" Value: \"" << ReverseLimitAutosetPositionValue << "rotations\"" << std::endl;
2670 ss << "Name: \"ReverseLimitEnable\" Value: \"" << ReverseLimitEnable << "\"" << std::endl;
2671 ss << "Name: \"ReverseLimitSource\" Value: \"" << ReverseLimitSource << "\"" << std::endl;
2672 ss << "Name: \"ReverseLimitRemoteSensorID\" Value: \"" << ReverseLimitRemoteSensorID << "\"" << std::endl;
2673 ss << "}" << std::endl;
2674 return ss.str();
2675 }
2676
2677 std::string Serialize() const override
2678 {
2679 std::stringstream ss;
2680 char *ref;
2681 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitType, ForwardLimitType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2682 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosEnable, ForwardLimitAutosetPositionEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2683 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosValue, ForwardLimitAutosetPositionValue, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2684 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitEnable, ForwardLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2685 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitSource, ForwardLimitSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2686 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitRemoteSensorID, ForwardLimitRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2687 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitType, ReverseLimitType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2688 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosEnable, ReverseLimitAutosetPositionEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2689 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosValue, ReverseLimitAutosetPositionValue, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2690 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitEnable, ReverseLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2691 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitSource, ReverseLimitSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2692 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitRemoteSensorID, ReverseLimitRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2693 return ss.str();
2694 }
2695
2696 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
2697 {
2698 const char *string_c_str = to_deserialize.c_str();
2699 size_t string_length = to_deserialize.length();
2700 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitType, string_c_str, string_length, &ForwardLimitType.value);
2701 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosEnable, string_c_str, string_length, &ForwardLimitAutosetPositionEnable);
2702 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosValue, string_c_str, string_length, &ForwardLimitAutosetPositionValue);
2703 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitEnable, string_c_str, string_length, &ForwardLimitEnable);
2704 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitSource, string_c_str, string_length, &ForwardLimitSource.value);
2705 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitRemoteSensorID, string_c_str, string_length, &ForwardLimitRemoteSensorID);
2706 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitType, string_c_str, string_length, &ReverseLimitType.value);
2707 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosEnable, string_c_str, string_length, &ReverseLimitAutosetPositionEnable);
2708 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosValue, string_c_str, string_length, &ReverseLimitAutosetPositionValue);
2709 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitEnable, string_c_str, string_length, &ReverseLimitEnable);
2710 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitSource, string_c_str, string_length, &ReverseLimitSource.value);
2711 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitRemoteSensorID, string_c_str, string_length, &ReverseLimitRemoteSensorID);
2712 return 0;
2713 }
2714};
2715
2716
2717/**
2718 * \brief Configs that affect audible components of the device.
2719 *
2720 * \details Includes configuration for the beep on boot.
2721 */
2723{
2724public:
2725 /**
2726 * \brief If true, the TalonFX will beep during boot-up. This is
2727 * useful for general debugging, and defaults to true. If rotor is
2728 * moving during boot-up, the beep will not occur regardless of this
2729 * setting.
2730 *
2731 * - Default Value: True
2732 */
2733 bool BeepOnBoot = true;
2734 /**
2735 * \brief If true, the TalonFX will beep during configuration API
2736 * calls if device is disabled. This is useful for general debugging,
2737 * and defaults to true. Note that if the rotor is moving, the beep
2738 * will not occur regardless of this setting.
2739 *
2740 * - Default Value: True
2741 */
2742 bool BeepOnConfig = true;
2743 /**
2744 * \brief If true, the TalonFX will allow Orchestra and MusicTone
2745 * requests during disabled state. This can be used to address corner
2746 * cases when music features are needed when disabled. This setting
2747 * defaults to false. Note that if the rotor is moving, music
2748 * features are always disabled regardless of this setting.
2749 *
2750 * - Default Value: False
2751 */
2753
2754 /**
2755 * \brief Modifies this configuration's BeepOnBoot parameter and returns itself for
2756 * method-chaining and easier to use config API.
2757 *
2758 * If true, the TalonFX will beep during boot-up. This is useful for
2759 * general debugging, and defaults to true. If rotor is moving during
2760 * boot-up, the beep will not occur regardless of this setting.
2761 *
2762 * - Default Value: True
2763 *
2764 * \param newBeepOnBoot Parameter to modify
2765 * \returns Itself
2766 */
2767 AudioConfigs& WithBeepOnBoot(bool newBeepOnBoot)
2768 {
2769 BeepOnBoot = std::move(newBeepOnBoot);
2770 return *this;
2771 }
2772 /**
2773 * \brief Modifies this configuration's BeepOnConfig parameter and returns itself for
2774 * method-chaining and easier to use config API.
2775 *
2776 * If true, the TalonFX will beep during configuration API calls if
2777 * device is disabled. This is useful for general debugging, and
2778 * defaults to true. Note that if the rotor is moving, the beep will
2779 * not occur regardless of this setting.
2780 *
2781 * - Default Value: True
2782 *
2783 * \param newBeepOnConfig Parameter to modify
2784 * \returns Itself
2785 */
2786 AudioConfigs& WithBeepOnConfig(bool newBeepOnConfig)
2787 {
2788 BeepOnConfig = std::move(newBeepOnConfig);
2789 return *this;
2790 }
2791 /**
2792 * \brief Modifies this configuration's AllowMusicDurDisable parameter and returns itself for
2793 * method-chaining and easier to use config API.
2794 *
2795 * If true, the TalonFX will allow Orchestra and MusicTone requests
2796 * during disabled state. This can be used to address corner cases
2797 * when music features are needed when disabled. This setting
2798 * defaults to false. Note that if the rotor is moving, music
2799 * features are always disabled regardless of this setting.
2800 *
2801 * - Default Value: False
2802 *
2803 * \param newAllowMusicDurDisable Parameter to modify
2804 * \returns Itself
2805 */
2806 AudioConfigs& WithAllowMusicDurDisable(bool newAllowMusicDurDisable)
2807 {
2808 AllowMusicDurDisable = std::move(newAllowMusicDurDisable);
2809 return *this;
2810 }
2811
2812
2813
2814 std::string ToString() const override
2815 {
2816 std::stringstream ss;
2817 ss << "{" << std::endl;
2818 ss << "Config Group: Audio" << std::endl;
2819 ss << "Name: \"BeepOnBoot\" Value: \"" << BeepOnBoot << "\"" << std::endl;
2820 ss << "Name: \"BeepOnConfig\" Value: \"" << BeepOnConfig << "\"" << std::endl;
2821 ss << "Name: \"AllowMusicDurDisable\" Value: \"" << AllowMusicDurDisable << "\"" << std::endl;
2822 ss << "}" << std::endl;
2823 return ss.str();
2824 }
2825
2826 std::string Serialize() const override
2827 {
2828 std::stringstream ss;
2829 char *ref;
2830 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnBoot, BeepOnBoot, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2831 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnConfig, BeepOnConfig, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2832 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_AllowMusicDurDisable, AllowMusicDurDisable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2833 return ss.str();
2834 }
2835
2836 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
2837 {
2838 const char *string_c_str = to_deserialize.c_str();
2839 size_t string_length = to_deserialize.length();
2840 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnBoot, string_c_str, string_length, &BeepOnBoot);
2841 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnConfig, string_c_str, string_length, &BeepOnConfig);
2842 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_AllowMusicDurDisable, string_c_str, string_length, &AllowMusicDurDisable);
2843 return 0;
2844 }
2845};
2846
2847
2848/**
2849 * \brief Configs that affect how software-limit switches behave.
2850 *
2851 * \details Includes enabling software-limit switches and the
2852 * threshold at which they are tripped.
2853 */
2855{
2856public:
2857 /**
2858 * \brief If enabled, the motor output is set to neutral if position
2859 * exceeds ForwardSoftLimitThreshold and forward output is requested.
2860 *
2861 * - Default Value: False
2862 */
2864 /**
2865 * \brief If enabled, the motor output is set to neutral if position
2866 * exceeds ReverseSoftLimitThreshold and reverse output is requested.
2867 *
2868 * - Default Value: False
2869 */
2871 /**
2872 * \brief Position threshold for forward soft limit features.
2873 * ForwardSoftLimitEnable must be enabled for this to take effect.
2874 *
2875 * - Minimum Value: -3.4e+38
2876 * - Maximum Value: 3.4e+38
2877 * - Default Value: 0
2878 * - Units: rotations
2879 */
2881 /**
2882 * \brief Position threshold for reverse soft limit features.
2883 * ReverseSoftLimitEnable must be enabled for this to take effect.
2884 *
2885 * - Minimum Value: -3.4e+38
2886 * - Maximum Value: 3.4e+38
2887 * - Default Value: 0
2888 * - Units: rotations
2889 */
2891
2892 /**
2893 * \brief Modifies this configuration's ForwardSoftLimitEnable parameter and returns itself for
2894 * method-chaining and easier to use config API.
2895 *
2896 * If enabled, the motor output is set to neutral if position exceeds
2897 * ForwardSoftLimitThreshold and forward output is requested.
2898 *
2899 * - Default Value: False
2900 *
2901 * \param newForwardSoftLimitEnable Parameter to modify
2902 * \returns Itself
2903 */
2905 {
2906 ForwardSoftLimitEnable = std::move(newForwardSoftLimitEnable);
2907 return *this;
2908 }
2909 /**
2910 * \brief Modifies this configuration's ReverseSoftLimitEnable parameter and returns itself for
2911 * method-chaining and easier to use config API.
2912 *
2913 * If enabled, the motor output is set to neutral if position exceeds
2914 * ReverseSoftLimitThreshold and reverse output is requested.
2915 *
2916 * - Default Value: False
2917 *
2918 * \param newReverseSoftLimitEnable Parameter to modify
2919 * \returns Itself
2920 */
2922 {
2923 ReverseSoftLimitEnable = std::move(newReverseSoftLimitEnable);
2924 return *this;
2925 }
2926 /**
2927 * \brief Modifies this configuration's ForwardSoftLimitThreshold parameter and returns itself for
2928 * method-chaining and easier to use config API.
2929 *
2930 * Position threshold for forward soft limit features.
2931 * ForwardSoftLimitEnable must be enabled for this to take effect.
2932 *
2933 * - Minimum Value: -3.4e+38
2934 * - Maximum Value: 3.4e+38
2935 * - Default Value: 0
2936 * - Units: rotations
2937 *
2938 * \param newForwardSoftLimitThreshold Parameter to modify
2939 * \returns Itself
2940 */
2941 SoftwareLimitSwitchConfigs& WithForwardSoftLimitThreshold(double newForwardSoftLimitThreshold)
2942 {
2943 ForwardSoftLimitThreshold = std::move(newForwardSoftLimitThreshold);
2944 return *this;
2945 }
2946 /**
2947 * \brief Modifies this configuration's ReverseSoftLimitThreshold parameter and returns itself for
2948 * method-chaining and easier to use config API.
2949 *
2950 * Position threshold for reverse soft limit features.
2951 * ReverseSoftLimitEnable must be enabled for this to take effect.
2952 *
2953 * - Minimum Value: -3.4e+38
2954 * - Maximum Value: 3.4e+38
2955 * - Default Value: 0
2956 * - Units: rotations
2957 *
2958 * \param newReverseSoftLimitThreshold Parameter to modify
2959 * \returns Itself
2960 */
2961 SoftwareLimitSwitchConfigs& WithReverseSoftLimitThreshold(double newReverseSoftLimitThreshold)
2962 {
2963 ReverseSoftLimitThreshold = std::move(newReverseSoftLimitThreshold);
2964 return *this;
2965 }
2966
2967
2968
2969 std::string ToString() const override
2970 {
2971 std::stringstream ss;
2972 ss << "{" << std::endl;
2973 ss << "Config Group: SoftwareLimitSwitch" << std::endl;
2974 ss << "Name: \"ForwardSoftLimitEnable\" Value: \"" << ForwardSoftLimitEnable << "\"" << std::endl;
2975 ss << "Name: \"ReverseSoftLimitEnable\" Value: \"" << ReverseSoftLimitEnable << "\"" << std::endl;
2976 ss << "Name: \"ForwardSoftLimitThreshold\" Value: \"" << ForwardSoftLimitThreshold << "rotations\"" << std::endl;
2977 ss << "Name: \"ReverseSoftLimitThreshold\" Value: \"" << ReverseSoftLimitThreshold << "rotations\"" << std::endl;
2978 ss << "}" << std::endl;
2979 return ss.str();
2980 }
2981
2982 std::string Serialize() const override
2983 {
2984 std::stringstream ss;
2985 char *ref;
2986 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitEnable, ForwardSoftLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2987 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitEnable, ReverseSoftLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2988 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitThreshold, ForwardSoftLimitThreshold, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2989 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitThreshold, ReverseSoftLimitThreshold, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2990 return ss.str();
2991 }
2992
2993 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
2994 {
2995 const char *string_c_str = to_deserialize.c_str();
2996 size_t string_length = to_deserialize.length();
2997 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitEnable, string_c_str, string_length, &ForwardSoftLimitEnable);
2998 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitEnable, string_c_str, string_length, &ReverseSoftLimitEnable);
2999 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitThreshold, string_c_str, string_length, &ForwardSoftLimitThreshold);
3000 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitThreshold, string_c_str, string_length, &ReverseSoftLimitThreshold);
3001 return 0;
3002 }
3003};
3004
3005
3006/**
3007 * \brief Configs for Motion Magic®.
3008 *
3009 * \details Includes Velocity, Acceleration, Jerk, and Expo
3010 * parameters.
3011 */
3013{
3014public:
3015 /**
3016 * \brief This is the maximum velocity Motion Magic® based control
3017 * modes are allowed to use. Motion Magic® Velocity control modes do
3018 * not use this config. When using Motion Magic® Expo control modes,
3019 * setting this to 0 will allow the profile to run to the max possible
3020 * velocity based on Expo_kV.
3021 *
3022 * - Minimum Value: 0
3023 * - Maximum Value: 9999
3024 * - Default Value: 0
3025 * - Units: rps
3026 */
3028 /**
3029 * \brief This is the target acceleration Motion Magic® based control
3030 * modes are allowed to use. Motion Magic® Expo control modes do not
3031 * use this config.
3032 *
3033 * - Minimum Value: 0
3034 * - Maximum Value: 9999
3035 * - Default Value: 0
3036 * - Units: rot per sec²
3037 */
3039 /**
3040 * \brief This is the target jerk (acceleration derivative) Motion
3041 * Magic® based control modes are allowed to use. Motion Magic® Expo
3042 * control modes do not use this config. This allows Motion Magic®
3043 * support of S-Curves. If this is set to zero, then Motion Magic®
3044 * will not apply a Jerk limit.
3045 *
3046 * - Minimum Value: 0
3047 * - Maximum Value: 9999
3048 * - Default Value: 0
3049 * - Units: rot per sec³
3050 */
3052 /**
3053 * \brief This is the target kV used only by Motion Magic® Expo
3054 * control modes, in units of V/rps. This represents the amount of
3055 * voltage necessary to hold a velocity. In terms of the Motion Magic®
3056 * Expo profile, a higher kV results in a slower maximum velocity. A
3057 * kV of 0 will be promoted to a reasonable default of 0.12.
3058 *
3059 * - Minimum Value: 0.001
3060 * - Maximum Value: 100
3061 * - Default Value: 0
3062 * - Units: V/rps
3063 */
3065 /**
3066 * \brief This is the target kA used only by Motion Magic® Expo
3067 * control modes, in units of V/rps². This represents the amount of
3068 * voltage necessary to achieve an acceleration. In terms of the
3069 * Motion Magic® Expo profile, a higher kA results in a slower
3070 * acceleration. A kA of 0 will be promoted to a reasonable default of
3071 * 0.1.
3072 *
3073 * - Minimum Value: 1e-05
3074 * - Maximum Value: 100
3075 * - Default Value: 0
3076 * - Units: V/rps²
3077 */
3079
3080 /**
3081 * \brief Modifies this configuration's MotionMagicCruiseVelocity parameter and returns itself for
3082 * method-chaining and easier to use config API.
3083 *
3084 * This is the maximum velocity Motion Magic® based control modes are
3085 * allowed to use. Motion Magic® Velocity control modes do not use
3086 * this config. When using Motion Magic® Expo control modes, setting
3087 * this to 0 will allow the profile to run to the max possible
3088 * velocity based on Expo_kV.
3089 *
3090 * - Minimum Value: 0
3091 * - Maximum Value: 9999
3092 * - Default Value: 0
3093 * - Units: rps
3094 *
3095 * \param newMotionMagicCruiseVelocity Parameter to modify
3096 * \returns Itself
3097 */
3098 MotionMagicConfigs& WithMotionMagicCruiseVelocity(double newMotionMagicCruiseVelocity)
3099 {
3100 MotionMagicCruiseVelocity = std::move(newMotionMagicCruiseVelocity);
3101 return *this;
3102 }
3103 /**
3104 * \brief Modifies this configuration's MotionMagicAcceleration parameter and returns itself for
3105 * method-chaining and easier to use config API.
3106 *
3107 * This is the target acceleration Motion Magic® based control modes
3108 * are allowed to use. Motion Magic® Expo control modes do not use
3109 * this config.
3110 *
3111 * - Minimum Value: 0
3112 * - Maximum Value: 9999
3113 * - Default Value: 0
3114 * - Units: rot per sec²
3115 *
3116 * \param newMotionMagicAcceleration Parameter to modify
3117 * \returns Itself
3118 */
3119 MotionMagicConfigs& WithMotionMagicAcceleration(double newMotionMagicAcceleration)
3120 {
3121 MotionMagicAcceleration = std::move(newMotionMagicAcceleration);
3122 return *this;
3123 }
3124 /**
3125 * \brief Modifies this configuration's MotionMagicJerk parameter and returns itself for
3126 * method-chaining and easier to use config API.
3127 *
3128 * This is the target jerk (acceleration derivative) Motion Magic®
3129 * based control modes are allowed to use. Motion Magic® Expo control
3130 * modes do not use this config. This allows Motion Magic® support of
3131 * S-Curves. If this is set to zero, then Motion Magic® will not
3132 * apply a Jerk limit.
3133 *
3134 * - Minimum Value: 0
3135 * - Maximum Value: 9999
3136 * - Default Value: 0
3137 * - Units: rot per sec³
3138 *
3139 * \param newMotionMagicJerk Parameter to modify
3140 * \returns Itself
3141 */
3142 MotionMagicConfigs& WithMotionMagicJerk(double newMotionMagicJerk)
3143 {
3144 MotionMagicJerk = std::move(newMotionMagicJerk);
3145 return *this;
3146 }
3147 /**
3148 * \brief Modifies this configuration's MotionMagicExpo_kV parameter and returns itself for
3149 * method-chaining and easier to use config API.
3150 *
3151 * This is the target kV used only by Motion Magic® Expo control
3152 * modes, in units of V/rps. This represents the amount of voltage
3153 * necessary to hold a velocity. In terms of the Motion Magic® Expo
3154 * profile, a higher kV results in a slower maximum velocity. A kV of
3155 * 0 will be promoted to a reasonable default of 0.12.
3156 *
3157 * - Minimum Value: 0.001
3158 * - Maximum Value: 100
3159 * - Default Value: 0
3160 * - Units: V/rps
3161 *
3162 * \param newMotionMagicExpo_kV Parameter to modify
3163 * \returns Itself
3164 */
3165 MotionMagicConfigs& WithMotionMagicExpo_kV(double newMotionMagicExpo_kV)
3166 {
3167 MotionMagicExpo_kV = std::move(newMotionMagicExpo_kV);
3168 return *this;
3169 }
3170 /**
3171 * \brief Modifies this configuration's MotionMagicExpo_kA parameter and returns itself for
3172 * method-chaining and easier to use config API.
3173 *
3174 * This is the target kA used only by Motion Magic® Expo control
3175 * modes, in units of V/rps². This represents the amount of voltage
3176 * necessary to achieve an acceleration. In terms of the Motion Magic®
3177 * Expo profile, a higher kA results in a slower acceleration. A kA of
3178 * 0 will be promoted to a reasonable default of 0.1.
3179 *
3180 * - Minimum Value: 1e-05
3181 * - Maximum Value: 100
3182 * - Default Value: 0
3183 * - Units: V/rps²
3184 *
3185 * \param newMotionMagicExpo_kA Parameter to modify
3186 * \returns Itself
3187 */
3188 MotionMagicConfigs& WithMotionMagicExpo_kA(double newMotionMagicExpo_kA)
3189 {
3190 MotionMagicExpo_kA = std::move(newMotionMagicExpo_kA);
3191 return *this;
3192 }
3193
3194
3195
3196 std::string ToString() const override
3197 {
3198 std::stringstream ss;
3199 ss << "{" << std::endl;
3200 ss << "Config Group: MotionMagic" << std::endl;
3201 ss << "Name: \"MotionMagicCruiseVelocity\" Value: \"" << MotionMagicCruiseVelocity << "rps\"" << std::endl;
3202 ss << "Name: \"MotionMagicAcceleration\" Value: \"" << MotionMagicAcceleration << "rot per sec²\"" << std::endl;
3203 ss << "Name: \"MotionMagicJerk\" Value: \"" << MotionMagicJerk << "rot per sec³\"" << std::endl;
3204 ss << "Name: \"MotionMagicExpo_kV\" Value: \"" << MotionMagicExpo_kV << "V/rps\"" << std::endl;
3205 ss << "Name: \"MotionMagicExpo_kA\" Value: \"" << MotionMagicExpo_kA << "V/rps²\"" << std::endl;
3206 ss << "}" << std::endl;
3207 return ss.str();
3208 }
3209
3210 std::string Serialize() const override
3211 {
3212 std::stringstream ss;
3213 char *ref;
3214 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicCruiseVelocity, MotionMagicCruiseVelocity, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3215 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicAcceleration, MotionMagicAcceleration, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3216 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicJerk, MotionMagicJerk, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3217 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicExpo_kV, MotionMagicExpo_kV, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3218 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicExpo_kA, MotionMagicExpo_kA, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3219 return ss.str();
3220 }
3221
3222 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
3223 {
3224 const char *string_c_str = to_deserialize.c_str();
3225 size_t string_length = to_deserialize.length();
3226 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicCruiseVelocity, string_c_str, string_length, &MotionMagicCruiseVelocity);
3227 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicAcceleration, string_c_str, string_length, &MotionMagicAcceleration);
3228 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicJerk, string_c_str, string_length, &MotionMagicJerk);
3229 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicExpo_kV, string_c_str, string_length, &MotionMagicExpo_kV);
3230 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicExpo_kA, string_c_str, string_length, &MotionMagicExpo_kA);
3231 return 0;
3232 }
3233};
3234
3235
3236/**
3237 * \brief Custom Params.
3238 *
3239 * \details Custom paramaters that have no real impact on controller.
3240 */
3242{
3243public:
3244 /**
3245 * \brief Custom parameter 0. This is provided to allow
3246 * end-applications to store persistent information in the device.
3247 *
3248 * - Minimum Value: -32768
3249 * - Maximum Value: 32767
3250 * - Default Value: 0
3251 * - Units:
3252 */
3254 /**
3255 * \brief Custom parameter 1. This is provided to allow
3256 * end-applications to store persistent information in the device.
3257 *
3258 * - Minimum Value: -32768
3259 * - Maximum Value: 32767
3260 * - Default Value: 0
3261 * - Units:
3262 */
3264
3265 /**
3266 * \brief Modifies this configuration's CustomParam0 parameter and returns itself for
3267 * method-chaining and easier to use config API.
3268 *
3269 * Custom parameter 0. This is provided to allow end-applications to
3270 * store persistent information in the device.
3271 *
3272 * - Minimum Value: -32768
3273 * - Maximum Value: 32767
3274 * - Default Value: 0
3275 * - Units:
3276 *
3277 * \param newCustomParam0 Parameter to modify
3278 * \returns Itself
3279 */
3281 {
3282 CustomParam0 = std::move(newCustomParam0);
3283 return *this;
3284 }
3285 /**
3286 * \brief Modifies this configuration's CustomParam1 parameter and returns itself for
3287 * method-chaining and easier to use config API.
3288 *
3289 * Custom parameter 1. This is provided to allow end-applications to
3290 * store persistent information in the device.
3291 *
3292 * - Minimum Value: -32768
3293 * - Maximum Value: 32767
3294 * - Default Value: 0
3295 * - Units:
3296 *
3297 * \param newCustomParam1 Parameter to modify
3298 * \returns Itself
3299 */
3301 {
3302 CustomParam1 = std::move(newCustomParam1);
3303 return *this;
3304 }
3305
3306
3307
3308 std::string ToString() const override
3309 {
3310 std::stringstream ss;
3311 ss << "{" << std::endl;
3312 ss << "Config Group: CustomParams" << std::endl;
3313 ss << "Name: \"CustomParam0\" Value: \"" << CustomParam0 << "\"" << std::endl;
3314 ss << "Name: \"CustomParam1\" Value: \"" << CustomParam1 << "\"" << std::endl;
3315 ss << "}" << std::endl;
3316 return ss.str();
3317 }
3318
3319 std::string Serialize() const override
3320 {
3321 std::stringstream ss;
3322 char *ref;
3323 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CustomParam0, CustomParam0, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3324 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CustomParam1, CustomParam1, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3325 return ss.str();
3326 }
3327
3328 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
3329 {
3330 const char *string_c_str = to_deserialize.c_str();
3331 size_t string_length = to_deserialize.length();
3332 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CustomParam0, string_c_str, string_length, &CustomParam0);
3333 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CustomParam1, string_c_str, string_length, &CustomParam1);
3334 return 0;
3335 }
3336};
3337
3338
3339/**
3340 * \brief Configs that affect general behavior during closed-looping.
3341 *
3342 * \details Includes Continuous Wrap features.
3343 */
3345{
3346public:
3347 /**
3348 * \brief Wrap position error within [-0.5,+0.5) mechanism rotations.
3349 * Typically used for continuous position closed-loops like swerve
3350 * azimuth.
3351 *
3352 * \details This uses the mechanism rotation value. If there is a gear
3353 * ratio between the sensor and the mechanism, make sure to apply a
3354 * SensorToMechanismRatio so the closed loop operates on the full
3355 * rotation.
3356 *
3357 * - Default Value: False
3358 */
3359 bool ContinuousWrap = false;
3360
3361
3362
3363
3364 std::string ToString() const override
3365 {
3366 std::stringstream ss;
3367 ss << "{" << std::endl;
3368 ss << "Config Group: ClosedLoopGeneral" << std::endl;
3369 ss << "Name: \"ContinuousWrap\" Value: \"" << ContinuousWrap << "\"" << std::endl;
3370 ss << "}" << std::endl;
3371 return ss.str();
3372 }
3373
3374 std::string Serialize() const override
3375 {
3376 std::stringstream ss;
3377 char *ref;
3378 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ContinuousWrap, ContinuousWrap, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3379 return ss.str();
3380 }
3381
3382 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
3383 {
3384 const char *string_c_str = to_deserialize.c_str();
3385 size_t string_length = to_deserialize.length();
3386 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ContinuousWrap, string_c_str, string_length, &ContinuousWrap);
3387 return 0;
3388 }
3389};
3390
3391
3392/**
3393 * \brief Gains for the specified slot.
3394 *
3395 * \details If this slot is selected, these gains are used in closed
3396 * loop control requests.
3397 */
3399{
3400public:
3401 /**
3402 * \brief Proportional Gain
3403 *
3404 * \details The units for this gain is dependent on the control mode.
3405 * Since this gain is multiplied by error in the input, the units
3406 * should be defined as units of output per unit of input error. For
3407 * example, when controlling velocity using a duty cycle closed loop,
3408 * the units for the proportional gain will be duty cycle per rps of
3409 * error, or 1/rps.
3410 *
3411 * - Minimum Value: 0
3412 * - Maximum Value: 3.4e+38
3413 * - Default Value: 0
3414 * - Units:
3415 */
3416 double kP = 0;
3417 /**
3418 * \brief Integral Gain
3419 *
3420 * \details The units for this gain is dependent on the control mode.
3421 * Since this gain is multiplied by error in the input integrated over
3422 * time (in units of seconds), the units should be defined as units of
3423 * output per unit of integrated input error. For example, when
3424 * controlling velocity using a duty cycle closed loop, integrating
3425 * velocity over time results in rps * s = rotations. Therefore, the
3426 * units for the integral gain will be duty cycle per rotation of
3427 * accumulated error, or 1/rot.
3428 *
3429 * - Minimum Value: 0
3430 * - Maximum Value: 3.4e+38
3431 * - Default Value: 0
3432 * - Units:
3433 */
3434 double kI = 0;
3435 /**
3436 * \brief Derivative Gain
3437 *
3438 * \details The units for this gain is dependent on the control mode.
3439 * Since this gain is multiplied by the derivative of error in the
3440 * input with respect to time (in units of seconds), the units should
3441 * be defined as units of output per unit of the differentiated input
3442 * error. For example, when controlling velocity using a duty cycle
3443 * closed loop, the derivative of velocity with respect to time is
3444 * rps/s, which is acceleration. Therefore, the units for the
3445 * derivative gain will be duty cycle per unit of acceleration error,
3446 * or 1/(rps/s).
3447 *
3448 * - Minimum Value: 0
3449 * - Maximum Value: 3.4e+38
3450 * - Default Value: 0
3451 * - Units:
3452 */
3453 double kD = 0;
3454 /**
3455 * \brief Static Feedforward Gain
3456 *
3457 * \details This is added to the closed loop output. The unit for this
3458 * constant is dependent on the control mode, typically fractional
3459 * duty cycle, voltage, or torque current.
3460 *
3461 * The sign is typically determined by reference velocity when using
3462 * position, velocity, and Motion Magic® closed loop modes. However,
3463 * when using position closed loop with zero velocity reference (no
3464 * motion profiling), the application can instead use the position
3465 * closed loop error by setting the Static Feedforward Sign
3466 * configuration parameter. When doing so, we recommend the minimal
3467 * amount of kS, otherwise the motor output may dither when closed
3468 * loop error is near zero.
3469 *
3470 * - Minimum Value: -512
3471 * - Maximum Value: 511
3472 * - Default Value: 0
3473 * - Units:
3474 */
3475 double kS = 0;
3476 /**
3477 * \brief Velocity Feedforward Gain
3478 *
3479 * \details The units for this gain is dependent on the control mode.
3480 * Since this gain is multiplied by the requested velocity, the units
3481 * should be defined as units of output per unit of requested input
3482 * velocity. For example, when controlling velocity using a duty cycle
3483 * closed loop, the units for the velocity feedfoward gain will be
3484 * duty cycle per requested rps, or 1/rps.
3485 *
3486 * - Minimum Value: 0
3487 * - Maximum Value: 3.4e+38
3488 * - Default Value: 0
3489 * - Units:
3490 */
3491 double kV = 0;
3492 /**
3493 * \brief Acceleration Feedforward Gain
3494 *
3495 * \details The units for this gain is dependent on the control mode.
3496 * Since this gain is multiplied by the requested acceleration, the
3497 * units should be defined as units of output per unit of requested
3498 * input acceleration. For example, when controlling velocity using a
3499 * duty cycle closed loop, the units for the acceleration feedfoward
3500 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
3501 *
3502 * - Minimum Value: 0
3503 * - Maximum Value: 3.4e+38
3504 * - Default Value: 0
3505 * - Units:
3506 */
3507 double kA = 0;
3508 /**
3509 * \brief Gravity Feedforward/Feedback Gain
3510 *
3511 * \details This is added to the closed loop output. The sign is
3512 * determined by GravityType. The unit for this constant is dependent
3513 * on the control mode, typically fractional duty cycle, voltage, or
3514 * torque current.
3515 *
3516 * - Minimum Value: -512
3517 * - Maximum Value: 511
3518 * - Default Value: 0
3519 * - Units:
3520 */
3521 double kG = 0;
3522 /**
3523 * \brief Gravity Feedforward/Feedback Type
3524 *
3525 * \details This determines the type of the gravity
3526 * feedforward/feedback.
3527 *
3528 * Choose Elevator_Static for systems where the gravity feedforward is
3529 * constant, such as an elevator. The gravity feedforward output will
3530 * always have the same sign.
3531 *
3532 * Choose Arm_Cosine for systems where the gravity feedback is
3533 * dependent on the angular position of the mechanism, such as an arm.
3534 * The gravity feedback output will vary depending on the mechanism
3535 * angular position. Note that the sensor offset and ratios must be
3536 * configured so that the sensor reports a position of 0 when the
3537 * mechanism is horizonal (parallel to the ground), and the reported
3538 * sensor position is 1:1 with the mechanism.
3539 *
3540 */
3542 /**
3543 * \brief Static Feedforward Sign during position closed loop
3544 *
3545 * \details This determines the sign of the applied kS during position
3546 * closed-loop modes. The default behavior uses the velocity reference
3547 * sign. This works well with velocity closed loop, Motion Magic®
3548 * controls, and position closed loop when velocity reference is
3549 * specified (motion profiling).
3550 *
3551 * However, when using position closed loop with zero velocity
3552 * reference (no motion profiling), the application may want to apply
3553 * static feedforward based on the closed loop error sign instead.
3554 * When doing so, we recommend the minimal amount of kS, otherwise the
3555 * motor output may dither when closed loop error is near zero.
3556 *
3557 */
3559
3560 /**
3561 * \brief Modifies this configuration's kP parameter and returns itself for
3562 * method-chaining and easier to use config API.
3563 *
3564 * Proportional Gain
3565 *
3566 * \details The units for this gain is dependent on the control mode.
3567 * Since this gain is multiplied by error in the input, the units
3568 * should be defined as units of output per unit of input error. For
3569 * example, when controlling velocity using a duty cycle closed loop,
3570 * the units for the proportional gain will be duty cycle per rps of
3571 * error, or 1/rps.
3572 *
3573 * - Minimum Value: 0
3574 * - Maximum Value: 3.4e+38
3575 * - Default Value: 0
3576 * - Units:
3577 *
3578 * \param newKP Parameter to modify
3579 * \returns Itself
3580 */
3581 Slot0Configs& WithKP(double newKP)
3582 {
3583 kP = std::move(newKP);
3584 return *this;
3585 }
3586 /**
3587 * \brief Modifies this configuration's kI parameter and returns itself for
3588 * method-chaining and easier to use config API.
3589 *
3590 * Integral Gain
3591 *
3592 * \details The units for this gain is dependent on the control mode.
3593 * Since this gain is multiplied by error in the input integrated over
3594 * time (in units of seconds), the units should be defined as units of
3595 * output per unit of integrated input error. For example, when
3596 * controlling velocity using a duty cycle closed loop, integrating
3597 * velocity over time results in rps * s = rotations. Therefore, the
3598 * units for the integral gain will be duty cycle per rotation of
3599 * accumulated error, or 1/rot.
3600 *
3601 * - Minimum Value: 0
3602 * - Maximum Value: 3.4e+38
3603 * - Default Value: 0
3604 * - Units:
3605 *
3606 * \param newKI Parameter to modify
3607 * \returns Itself
3608 */
3609 Slot0Configs& WithKI(double newKI)
3610 {
3611 kI = std::move(newKI);
3612 return *this;
3613 }
3614 /**
3615 * \brief Modifies this configuration's kD parameter and returns itself for
3616 * method-chaining and easier to use config API.
3617 *
3618 * Derivative Gain
3619 *
3620 * \details The units for this gain is dependent on the control mode.
3621 * Since this gain is multiplied by the derivative of error in the
3622 * input with respect to time (in units of seconds), the units should
3623 * be defined as units of output per unit of the differentiated input
3624 * error. For example, when controlling velocity using a duty cycle
3625 * closed loop, the derivative of velocity with respect to time is
3626 * rps/s, which is acceleration. Therefore, the units for the
3627 * derivative gain will be duty cycle per unit of acceleration error,
3628 * or 1/(rps/s).
3629 *
3630 * - Minimum Value: 0
3631 * - Maximum Value: 3.4e+38
3632 * - Default Value: 0
3633 * - Units:
3634 *
3635 * \param newKD Parameter to modify
3636 * \returns Itself
3637 */
3638 Slot0Configs& WithKD(double newKD)
3639 {
3640 kD = std::move(newKD);
3641 return *this;
3642 }
3643 /**
3644 * \brief Modifies this configuration's kS parameter and returns itself for
3645 * method-chaining and easier to use config API.
3646 *
3647 * Static Feedforward Gain
3648 *
3649 * \details This is added to the closed loop output. The unit for this
3650 * constant is dependent on the control mode, typically fractional
3651 * duty cycle, voltage, or torque current.
3652 *
3653 * The sign is typically determined by reference velocity when using
3654 * position, velocity, and Motion Magic® closed loop modes. However,
3655 * when using position closed loop with zero velocity reference (no
3656 * motion profiling), the application can instead use the position
3657 * closed loop error by setting the Static Feedforward Sign
3658 * configuration parameter. When doing so, we recommend the minimal
3659 * amount of kS, otherwise the motor output may dither when closed
3660 * loop error is near zero.
3661 *
3662 * - Minimum Value: -512
3663 * - Maximum Value: 511
3664 * - Default Value: 0
3665 * - Units:
3666 *
3667 * \param newKS Parameter to modify
3668 * \returns Itself
3669 */
3670 Slot0Configs& WithKS(double newKS)
3671 {
3672 kS = std::move(newKS);
3673 return *this;
3674 }
3675 /**
3676 * \brief Modifies this configuration's kV parameter and returns itself for
3677 * method-chaining and easier to use config API.
3678 *
3679 * Velocity Feedforward Gain
3680 *
3681 * \details The units for this gain is dependent on the control mode.
3682 * Since this gain is multiplied by the requested velocity, the units
3683 * should be defined as units of output per unit of requested input
3684 * velocity. For example, when controlling velocity using a duty cycle
3685 * closed loop, the units for the velocity feedfoward gain will be
3686 * duty cycle per requested rps, or 1/rps.
3687 *
3688 * - Minimum Value: 0
3689 * - Maximum Value: 3.4e+38
3690 * - Default Value: 0
3691 * - Units:
3692 *
3693 * \param newKV Parameter to modify
3694 * \returns Itself
3695 */
3696 Slot0Configs& WithKV(double newKV)
3697 {
3698 kV = std::move(newKV);
3699 return *this;
3700 }
3701 /**
3702 * \brief Modifies this configuration's kA parameter and returns itself for
3703 * method-chaining and easier to use config API.
3704 *
3705 * Acceleration Feedforward Gain
3706 *
3707 * \details The units for this gain is dependent on the control mode.
3708 * Since this gain is multiplied by the requested acceleration, the
3709 * units should be defined as units of output per unit of requested
3710 * input acceleration. For example, when controlling velocity using a
3711 * duty cycle closed loop, the units for the acceleration feedfoward
3712 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
3713 *
3714 * - Minimum Value: 0
3715 * - Maximum Value: 3.4e+38
3716 * - Default Value: 0
3717 * - Units:
3718 *
3719 * \param newKA Parameter to modify
3720 * \returns Itself
3721 */
3722 Slot0Configs& WithKA(double newKA)
3723 {
3724 kA = std::move(newKA);
3725 return *this;
3726 }
3727 /**
3728 * \brief Modifies this configuration's kG parameter and returns itself for
3729 * method-chaining and easier to use config API.
3730 *
3731 * Gravity Feedforward/Feedback Gain
3732 *
3733 * \details This is added to the closed loop output. The sign is
3734 * determined by GravityType. The unit for this constant is dependent
3735 * on the control mode, typically fractional duty cycle, voltage, or
3736 * torque current.
3737 *
3738 * - Minimum Value: -512
3739 * - Maximum Value: 511
3740 * - Default Value: 0
3741 * - Units:
3742 *
3743 * \param newKG Parameter to modify
3744 * \returns Itself
3745 */
3746 Slot0Configs& WithKG(double newKG)
3747 {
3748 kG = std::move(newKG);
3749 return *this;
3750 }
3751 /**
3752 * \brief Modifies this configuration's GravityType parameter and returns itself for
3753 * method-chaining and easier to use config API.
3754 *
3755 * Gravity Feedforward/Feedback Type
3756 *
3757 * \details This determines the type of the gravity
3758 * feedforward/feedback.
3759 *
3760 * Choose Elevator_Static for systems where the gravity feedforward is
3761 * constant, such as an elevator. The gravity feedforward output will
3762 * always have the same sign.
3763 *
3764 * Choose Arm_Cosine for systems where the gravity feedback is
3765 * dependent on the angular position of the mechanism, such as an arm.
3766 * The gravity feedback output will vary depending on the mechanism
3767 * angular position. Note that the sensor offset and ratios must be
3768 * configured so that the sensor reports a position of 0 when the
3769 * mechanism is horizonal (parallel to the ground), and the reported
3770 * sensor position is 1:1 with the mechanism.
3771 *
3772 *
3773 * \param newGravityType Parameter to modify
3774 * \returns Itself
3775 */
3777 {
3778 GravityType = std::move(newGravityType);
3779 return *this;
3780 }
3781 /**
3782 * \brief Modifies this configuration's StaticFeedforwardSign parameter and returns itself for
3783 * method-chaining and easier to use config API.
3784 *
3785 * Static Feedforward Sign during position closed loop
3786 *
3787 * \details This determines the sign of the applied kS during position
3788 * closed-loop modes. The default behavior uses the velocity reference
3789 * sign. This works well with velocity closed loop, Motion Magic®
3790 * controls, and position closed loop when velocity reference is
3791 * specified (motion profiling).
3792 *
3793 * However, when using position closed loop with zero velocity
3794 * reference (no motion profiling), the application may want to apply
3795 * static feedforward based on the closed loop error sign instead.
3796 * When doing so, we recommend the minimal amount of kS, otherwise the
3797 * motor output may dither when closed loop error is near zero.
3798 *
3799 *
3800 * \param newStaticFeedforwardSign Parameter to modify
3801 * \returns Itself
3802 */
3804 {
3805 StaticFeedforwardSign = std::move(newStaticFeedforwardSign);
3806 return *this;
3807 }
3808
3809 static Slot0Configs From(const SlotConfigs& value);
3810
3811 std::string ToString() const override
3812 {
3813 std::stringstream ss;
3814 ss << "{" << std::endl;
3815 ss << "Config Group: Slot0" << std::endl;
3816 ss << "Name: \"kP\" Value: \"" << kP << "\"" << std::endl;
3817 ss << "Name: \"kI\" Value: \"" << kI << "\"" << std::endl;
3818 ss << "Name: \"kD\" Value: \"" << kD << "\"" << std::endl;
3819 ss << "Name: \"kS\" Value: \"" << kS << "\"" << std::endl;
3820 ss << "Name: \"kV\" Value: \"" << kV << "\"" << std::endl;
3821 ss << "Name: \"kA\" Value: \"" << kA << "\"" << std::endl;
3822 ss << "Name: \"kG\" Value: \"" << kG << "\"" << std::endl;
3823 ss << "Name: \"GravityType\" Value: \"" << GravityType << "\"" << std::endl;
3824 ss << "Name: \"StaticFeedforwardSign\" Value: \"" << StaticFeedforwardSign << "\"" << std::endl;
3825 ss << "}" << std::endl;
3826 return ss.str();
3827 }
3828
3829 std::string Serialize() const override
3830 {
3831 std::stringstream ss;
3832 char *ref;
3833 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kP, kP, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3834 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kI, kI, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3835 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kD, kD, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3836 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kS, kS, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3837 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kV, kV, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3838 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kA, kA, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3839 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kG, kG, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3840 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot0_kG_Type, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3841 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot0_kS_Sign, StaticFeedforwardSign.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3842 return ss.str();
3843 }
3844
3845 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
3846 {
3847 const char *string_c_str = to_deserialize.c_str();
3848 size_t string_length = to_deserialize.length();
3849 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kP, string_c_str, string_length, &kP);
3850 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kI, string_c_str, string_length, &kI);
3851 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kD, string_c_str, string_length, &kD);
3852 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kS, string_c_str, string_length, &kS);
3853 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kV, string_c_str, string_length, &kV);
3854 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kA, string_c_str, string_length, &kA);
3855 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kG, string_c_str, string_length, &kG);
3856 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot0_kG_Type, string_c_str, string_length, &GravityType.value);
3857 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot0_kS_Sign, string_c_str, string_length, &StaticFeedforwardSign.value);
3858 return 0;
3859 }
3860};
3861
3862
3863/**
3864 * \brief Gains for the specified slot.
3865 *
3866 * \details If this slot is selected, these gains are used in closed
3867 * loop control requests.
3868 */
3870{
3871public:
3872 /**
3873 * \brief Proportional Gain
3874 *
3875 * \details The units for this gain is dependent on the control mode.
3876 * Since this gain is multiplied by error in the input, the units
3877 * should be defined as units of output per unit of input error. For
3878 * example, when controlling velocity using a duty cycle closed loop,
3879 * the units for the proportional gain will be duty cycle per rps, or
3880 * 1/rps.
3881 *
3882 * - Minimum Value: 0
3883 * - Maximum Value: 3.4e+38
3884 * - Default Value: 0
3885 * - Units:
3886 */
3887 double kP = 0;
3888 /**
3889 * \brief Integral Gain
3890 *
3891 * \details The units for this gain is dependent on the control mode.
3892 * Since this gain is multiplied by error in the input integrated over
3893 * time (in units of seconds), the units should be defined as units of
3894 * output per unit of integrated input error. For example, when
3895 * controlling velocity using a duty cycle closed loop, integrating
3896 * velocity over time results in rps * s = rotations. Therefore, the
3897 * units for the integral gain will be duty cycle per rotation of
3898 * accumulated error, or 1/rot.
3899 *
3900 * - Minimum Value: 0
3901 * - Maximum Value: 3.4e+38
3902 * - Default Value: 0
3903 * - Units:
3904 */
3905 double kI = 0;
3906 /**
3907 * \brief Derivative Gain
3908 *
3909 * \details The units for this gain is dependent on the control mode.
3910 * Since this gain is multiplied by the derivative of error in the
3911 * input with respect to time (in units of seconds), the units should
3912 * be defined as units of output per unit of the differentiated input
3913 * error. For example, when controlling velocity using a duty cycle
3914 * closed loop, the derivative of velocity with respect to time is
3915 * rps/s, which is acceleration. Therefore, the units for the
3916 * derivative gain will be duty cycle per unit of acceleration error,
3917 * or 1/(rps/s).
3918 *
3919 * - Minimum Value: 0
3920 * - Maximum Value: 3.4e+38
3921 * - Default Value: 0
3922 * - Units:
3923 */
3924 double kD = 0;
3925 /**
3926 * \brief Static Feedforward Gain
3927 *
3928 * \details This is added to the closed loop output. The unit for this
3929 * constant is dependent on the control mode, typically fractional
3930 * duty cycle, voltage, or torque current.
3931 *
3932 * The sign is typically determined by reference velocity when using
3933 * position, velocity, and Motion Magic® closed loop modes. However,
3934 * when using position closed loop with zero velocity reference (no
3935 * motion profiling), the application can instead use the position
3936 * closed loop error by setting the Static Feedforward Sign
3937 * configuration parameter. When doing so, we recommend the minimal
3938 * amount of kS, otherwise the motor output may dither when closed
3939 * loop error is near zero.
3940 *
3941 * - Minimum Value: -512
3942 * - Maximum Value: 511
3943 * - Default Value: 0
3944 * - Units:
3945 */
3946 double kS = 0;
3947 /**
3948 * \brief Velocity Feedforward Gain
3949 *
3950 * \details The units for this gain is dependent on the control mode.
3951 * Since this gain is multiplied by the requested velocity, the units
3952 * should be defined as units of output per unit of requested input
3953 * velocity. For example, when controlling velocity using a duty cycle
3954 * closed loop, the units for the velocity feedfoward gain will be
3955 * duty cycle per requested rps, or 1/rps.
3956 *
3957 * - Minimum Value: 0
3958 * - Maximum Value: 3.4e+38
3959 * - Default Value: 0
3960 * - Units:
3961 */
3962 double kV = 0;
3963 /**
3964 * \brief Acceleration Feedforward Gain
3965 *
3966 * \details The units for this gain is dependent on the control mode.
3967 * Since this gain is multiplied by the requested acceleration, the
3968 * units should be defined as units of output per unit of requested
3969 * input acceleration. For example, when controlling velocity using a
3970 * duty cycle closed loop, the units for the acceleration feedfoward
3971 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
3972 *
3973 * - Minimum Value: 0
3974 * - Maximum Value: 3.4e+38
3975 * - Default Value: 0
3976 * - Units:
3977 */
3978 double kA = 0;
3979 /**
3980 * \brief Gravity Feedforward/Feedback Gain
3981 *
3982 * \details This is added to the closed loop output. The sign is
3983 * determined by GravityType. The unit for this constant is dependent
3984 * on the control mode, typically fractional duty cycle, voltage, or
3985 * torque current.
3986 *
3987 * - Minimum Value: -512
3988 * - Maximum Value: 511
3989 * - Default Value: 0
3990 * - Units:
3991 */
3992 double kG = 0;
3993 /**
3994 * \brief Gravity Feedforward/Feedback Type
3995 *
3996 * \details This determines the type of the gravity
3997 * feedforward/feedback.
3998 *
3999 * Choose Elevator_Static for systems where the gravity feedforward is
4000 * constant, such as an elevator. The gravity feedforward output will
4001 * always be positive.
4002 *
4003 * Choose Arm_Cosine for systems where the gravity feedback is
4004 * dependent on the angular position of the mechanism, such as an arm.
4005 * The gravity feedback output will vary depending on the mechanism
4006 * angular position. Note that the sensor offset and ratios must be
4007 * configured so that the sensor position is 0 when the mechanism is
4008 * horizonal, and one rotation of the mechanism corresponds to one
4009 * rotation of the sensor position.
4010 *
4011 */
4013 /**
4014 * \brief Static Feedforward Sign during position closed loop
4015 *
4016 * \details This determines the sign of the applied kS during position
4017 * closed-loop modes. The default behavior uses the velocity reference
4018 * sign. This works well with velocity closed loop, Motion Magic®
4019 * controls, and position closed loop when velocity reference is
4020 * specified (motion profiling).
4021 *
4022 * However, when using position closed loop with zero velocity
4023 * reference (no motion profiling), the application may want to apply
4024 * static feedforward based on the closed loop error sign instead.
4025 * When doing so, we recommend the minimal amount of kS, otherwise the
4026 * motor output may dither when closed loop error is near zero.
4027 *
4028 */
4030
4031 /**
4032 * \brief Modifies this configuration's kP parameter and returns itself for
4033 * method-chaining and easier to use config API.
4034 *
4035 * Proportional Gain
4036 *
4037 * \details The units for this gain is dependent on the control mode.
4038 * Since this gain is multiplied by error in the input, the units
4039 * should be defined as units of output per unit of input error. For
4040 * example, when controlling velocity using a duty cycle closed loop,
4041 * the units for the proportional gain will be duty cycle per rps, or
4042 * 1/rps.
4043 *
4044 * - Minimum Value: 0
4045 * - Maximum Value: 3.4e+38
4046 * - Default Value: 0
4047 * - Units:
4048 *
4049 * \param newKP Parameter to modify
4050 * \returns Itself
4051 */
4052 Slot1Configs& WithKP(double newKP)
4053 {
4054 kP = std::move(newKP);
4055 return *this;
4056 }
4057 /**
4058 * \brief Modifies this configuration's kI parameter and returns itself for
4059 * method-chaining and easier to use config API.
4060 *
4061 * Integral Gain
4062 *
4063 * \details The units for this gain is dependent on the control mode.
4064 * Since this gain is multiplied by error in the input integrated over
4065 * time (in units of seconds), the units should be defined as units of
4066 * output per unit of integrated input error. For example, when
4067 * controlling velocity using a duty cycle closed loop, integrating
4068 * velocity over time results in rps * s = rotations. Therefore, the
4069 * units for the integral gain will be duty cycle per rotation of
4070 * accumulated error, or 1/rot.
4071 *
4072 * - Minimum Value: 0
4073 * - Maximum Value: 3.4e+38
4074 * - Default Value: 0
4075 * - Units:
4076 *
4077 * \param newKI Parameter to modify
4078 * \returns Itself
4079 */
4080 Slot1Configs& WithKI(double newKI)
4081 {
4082 kI = std::move(newKI);
4083 return *this;
4084 }
4085 /**
4086 * \brief Modifies this configuration's kD parameter and returns itself for
4087 * method-chaining and easier to use config API.
4088 *
4089 * Derivative Gain
4090 *
4091 * \details The units for this gain is dependent on the control mode.
4092 * Since this gain is multiplied by the derivative of error in the
4093 * input with respect to time (in units of seconds), the units should
4094 * be defined as units of output per unit of the differentiated input
4095 * error. For example, when controlling velocity using a duty cycle
4096 * closed loop, the derivative of velocity with respect to time is
4097 * rps/s, which is acceleration. Therefore, the units for the
4098 * derivative gain will be duty cycle per unit of acceleration error,
4099 * or 1/(rps/s).
4100 *
4101 * - Minimum Value: 0
4102 * - Maximum Value: 3.4e+38
4103 * - Default Value: 0
4104 * - Units:
4105 *
4106 * \param newKD Parameter to modify
4107 * \returns Itself
4108 */
4109 Slot1Configs& WithKD(double newKD)
4110 {
4111 kD = std::move(newKD);
4112 return *this;
4113 }
4114 /**
4115 * \brief Modifies this configuration's kS parameter and returns itself for
4116 * method-chaining and easier to use config API.
4117 *
4118 * Static Feedforward Gain
4119 *
4120 * \details This is added to the closed loop output. The unit for this
4121 * constant is dependent on the control mode, typically fractional
4122 * duty cycle, voltage, or torque current.
4123 *
4124 * The sign is typically determined by reference velocity when using
4125 * position, velocity, and Motion Magic® closed loop modes. However,
4126 * when using position closed loop with zero velocity reference (no
4127 * motion profiling), the application can instead use the position
4128 * closed loop error by setting the Static Feedforward Sign
4129 * configuration parameter. When doing so, we recommend the minimal
4130 * amount of kS, otherwise the motor output may dither when closed
4131 * loop error is near zero.
4132 *
4133 * - Minimum Value: -512
4134 * - Maximum Value: 511
4135 * - Default Value: 0
4136 * - Units:
4137 *
4138 * \param newKS Parameter to modify
4139 * \returns Itself
4140 */
4141 Slot1Configs& WithKS(double newKS)
4142 {
4143 kS = std::move(newKS);
4144 return *this;
4145 }
4146 /**
4147 * \brief Modifies this configuration's kV parameter and returns itself for
4148 * method-chaining and easier to use config API.
4149 *
4150 * Velocity Feedforward Gain
4151 *
4152 * \details The units for this gain is dependent on the control mode.
4153 * Since this gain is multiplied by the requested velocity, the units
4154 * should be defined as units of output per unit of requested input
4155 * velocity. For example, when controlling velocity using a duty cycle
4156 * closed loop, the units for the velocity feedfoward gain will be
4157 * duty cycle per requested rps, or 1/rps.
4158 *
4159 * - Minimum Value: 0
4160 * - Maximum Value: 3.4e+38
4161 * - Default Value: 0
4162 * - Units:
4163 *
4164 * \param newKV Parameter to modify
4165 * \returns Itself
4166 */
4167 Slot1Configs& WithKV(double newKV)
4168 {
4169 kV = std::move(newKV);
4170 return *this;
4171 }
4172 /**
4173 * \brief Modifies this configuration's kA parameter and returns itself for
4174 * method-chaining and easier to use config API.
4175 *
4176 * Acceleration Feedforward Gain
4177 *
4178 * \details The units for this gain is dependent on the control mode.
4179 * Since this gain is multiplied by the requested acceleration, the
4180 * units should be defined as units of output per unit of requested
4181 * input acceleration. For example, when controlling velocity using a
4182 * duty cycle closed loop, the units for the acceleration feedfoward
4183 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
4184 *
4185 * - Minimum Value: 0
4186 * - Maximum Value: 3.4e+38
4187 * - Default Value: 0
4188 * - Units:
4189 *
4190 * \param newKA Parameter to modify
4191 * \returns Itself
4192 */
4193 Slot1Configs& WithKA(double newKA)
4194 {
4195 kA = std::move(newKA);
4196 return *this;
4197 }
4198 /**
4199 * \brief Modifies this configuration's kG parameter and returns itself for
4200 * method-chaining and easier to use config API.
4201 *
4202 * Gravity Feedforward/Feedback Gain
4203 *
4204 * \details This is added to the closed loop output. The sign is
4205 * determined by GravityType. The unit for this constant is dependent
4206 * on the control mode, typically fractional duty cycle, voltage, or
4207 * torque current.
4208 *
4209 * - Minimum Value: -512
4210 * - Maximum Value: 511
4211 * - Default Value: 0
4212 * - Units:
4213 *
4214 * \param newKG Parameter to modify
4215 * \returns Itself
4216 */
4217 Slot1Configs& WithKG(double newKG)
4218 {
4219 kG = std::move(newKG);
4220 return *this;
4221 }
4222 /**
4223 * \brief Modifies this configuration's GravityType parameter and returns itself for
4224 * method-chaining and easier to use config API.
4225 *
4226 * Gravity Feedforward/Feedback Type
4227 *
4228 * \details This determines the type of the gravity
4229 * feedforward/feedback.
4230 *
4231 * Choose Elevator_Static for systems where the gravity feedforward is
4232 * constant, such as an elevator. The gravity feedforward output will
4233 * always be positive.
4234 *
4235 * Choose Arm_Cosine for systems where the gravity feedback is
4236 * dependent on the angular position of the mechanism, such as an arm.
4237 * The gravity feedback output will vary depending on the mechanism
4238 * angular position. Note that the sensor offset and ratios must be
4239 * configured so that the sensor position is 0 when the mechanism is
4240 * horizonal, and one rotation of the mechanism corresponds to one
4241 * rotation of the sensor position.
4242 *
4243 *
4244 * \param newGravityType Parameter to modify
4245 * \returns Itself
4246 */
4248 {
4249 GravityType = std::move(newGravityType);
4250 return *this;
4251 }
4252 /**
4253 * \brief Modifies this configuration's StaticFeedforwardSign parameter and returns itself for
4254 * method-chaining and easier to use config API.
4255 *
4256 * Static Feedforward Sign during position closed loop
4257 *
4258 * \details This determines the sign of the applied kS during position
4259 * closed-loop modes. The default behavior uses the velocity reference
4260 * sign. This works well with velocity closed loop, Motion Magic®
4261 * controls, and position closed loop when velocity reference is
4262 * specified (motion profiling).
4263 *
4264 * However, when using position closed loop with zero velocity
4265 * reference (no motion profiling), the application may want to apply
4266 * static feedforward based on the closed loop error sign instead.
4267 * When doing so, we recommend the minimal amount of kS, otherwise the
4268 * motor output may dither when closed loop error is near zero.
4269 *
4270 *
4271 * \param newStaticFeedforwardSign Parameter to modify
4272 * \returns Itself
4273 */
4275 {
4276 StaticFeedforwardSign = std::move(newStaticFeedforwardSign);
4277 return *this;
4278 }
4279
4280 static Slot1Configs From(const SlotConfigs& value);
4281
4282 std::string ToString() const override
4283 {
4284 std::stringstream ss;
4285 ss << "{" << std::endl;
4286 ss << "Config Group: Slot1" << std::endl;
4287 ss << "Name: \"kP\" Value: \"" << kP << "\"" << std::endl;
4288 ss << "Name: \"kI\" Value: \"" << kI << "\"" << std::endl;
4289 ss << "Name: \"kD\" Value: \"" << kD << "\"" << std::endl;
4290 ss << "Name: \"kS\" Value: \"" << kS << "\"" << std::endl;
4291 ss << "Name: \"kV\" Value: \"" << kV << "\"" << std::endl;
4292 ss << "Name: \"kA\" Value: \"" << kA << "\"" << std::endl;
4293 ss << "Name: \"kG\" Value: \"" << kG << "\"" << std::endl;
4294 ss << "Name: \"GravityType\" Value: \"" << GravityType << "\"" << std::endl;
4295 ss << "Name: \"StaticFeedforwardSign\" Value: \"" << StaticFeedforwardSign << "\"" << std::endl;
4296 ss << "}" << std::endl;
4297 return ss.str();
4298 }
4299
4300 std::string Serialize() const override
4301 {
4302 std::stringstream ss;
4303 char *ref;
4304 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kP, kP, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4305 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kI, kI, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4306 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kD, kD, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4307 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kS, kS, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4308 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kV, kV, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4309 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kA, kA, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4310 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kG, kG, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4311 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot1_kG_Type, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4312 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot1_kS_Sign, StaticFeedforwardSign.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4313 return ss.str();
4314 }
4315
4316 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
4317 {
4318 const char *string_c_str = to_deserialize.c_str();
4319 size_t string_length = to_deserialize.length();
4320 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kP, string_c_str, string_length, &kP);
4321 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kI, string_c_str, string_length, &kI);
4322 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kD, string_c_str, string_length, &kD);
4323 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kS, string_c_str, string_length, &kS);
4324 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kV, string_c_str, string_length, &kV);
4325 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kA, string_c_str, string_length, &kA);
4326 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kG, string_c_str, string_length, &kG);
4327 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot1_kG_Type, string_c_str, string_length, &GravityType.value);
4328 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot1_kS_Sign, string_c_str, string_length, &StaticFeedforwardSign.value);
4329 return 0;
4330 }
4331};
4332
4333
4334/**
4335 * \brief Gains for the specified slot.
4336 *
4337 * \details If this slot is selected, these gains are used in closed
4338 * loop control requests.
4339 */
4341{
4342public:
4343 /**
4344 * \brief Proportional Gain
4345 *
4346 * \details The units for this gain is dependent on the control mode.
4347 * Since this gain is multiplied by error in the input, the units
4348 * should be defined as units of output per unit of input error. For
4349 * example, when controlling velocity using a duty cycle closed loop,
4350 * the units for the proportional gain will be duty cycle per rps, or
4351 * 1/rps.
4352 *
4353 * - Minimum Value: 0
4354 * - Maximum Value: 3.4e+38
4355 * - Default Value: 0
4356 * - Units:
4357 */
4358 double kP = 0;
4359 /**
4360 * \brief Integral Gain
4361 *
4362 * \details The units for this gain is dependent on the control mode.
4363 * Since this gain is multiplied by error in the input integrated over
4364 * time (in units of seconds), the units should be defined as units of
4365 * output per unit of integrated input error. For example, when
4366 * controlling velocity using a duty cycle closed loop, integrating
4367 * velocity over time results in rps * s = rotations. Therefore, the
4368 * units for the integral gain will be duty cycle per rotation of
4369 * accumulated error, or 1/rot.
4370 *
4371 * - Minimum Value: 0
4372 * - Maximum Value: 3.4e+38
4373 * - Default Value: 0
4374 * - Units:
4375 */
4376 double kI = 0;
4377 /**
4378 * \brief Derivative Gain
4379 *
4380 * \details The units for this gain is dependent on the control mode.
4381 * Since this gain is multiplied by the derivative of error in the
4382 * input with respect to time (in units of seconds), the units should
4383 * be defined as units of output per unit of the differentiated input
4384 * error. For example, when controlling velocity using a duty cycle
4385 * closed loop, the derivative of velocity with respect to time is
4386 * rps/s, which is acceleration. Therefore, the units for the
4387 * derivative gain will be duty cycle per unit of acceleration error,
4388 * or 1/(rps/s).
4389 *
4390 * - Minimum Value: 0
4391 * - Maximum Value: 3.4e+38
4392 * - Default Value: 0
4393 * - Units:
4394 */
4395 double kD = 0;
4396 /**
4397 * \brief Static Feedforward Gain
4398 *
4399 * \details This is added to the closed loop output. The unit for this
4400 * constant is dependent on the control mode, typically fractional
4401 * duty cycle, voltage, or torque current.
4402 *
4403 * The sign is typically determined by reference velocity when using
4404 * position, velocity, and Motion Magic® closed loop modes. However,
4405 * when using position closed loop with zero velocity reference (no
4406 * motion profiling), the application can instead use the position
4407 * closed loop error by setting the Static Feedforward Sign
4408 * configuration parameter. When doing so, we recommend the minimal
4409 * amount of kS, otherwise the motor output may dither when closed
4410 * loop error is near zero.
4411 *
4412 * - Minimum Value: -512
4413 * - Maximum Value: 511
4414 * - Default Value: 0
4415 * - Units:
4416 */
4417 double kS = 0;
4418 /**
4419 * \brief Velocity Feedforward Gain
4420 *
4421 * \details The units for this gain is dependent on the control mode.
4422 * Since this gain is multiplied by the requested velocity, the units
4423 * should be defined as units of output per unit of requested input
4424 * velocity. For example, when controlling velocity using a duty cycle
4425 * closed loop, the units for the velocity feedfoward gain will be
4426 * duty cycle per requested rps, or 1/rps.
4427 *
4428 * - Minimum Value: 0
4429 * - Maximum Value: 3.4e+38
4430 * - Default Value: 0
4431 * - Units:
4432 */
4433 double kV = 0;
4434 /**
4435 * \brief Acceleration Feedforward Gain
4436 *
4437 * \details The units for this gain is dependent on the control mode.
4438 * Since this gain is multiplied by the requested acceleration, the
4439 * units should be defined as units of output per unit of requested
4440 * input acceleration. For example, when controlling velocity using a
4441 * duty cycle closed loop, the units for the acceleration feedfoward
4442 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
4443 *
4444 * - Minimum Value: 0
4445 * - Maximum Value: 3.4e+38
4446 * - Default Value: 0
4447 * - Units:
4448 */
4449 double kA = 0;
4450 /**
4451 * \brief Gravity Feedforward/Feedback Gain
4452 *
4453 * \details This is added to the closed loop output. The sign is
4454 * determined by GravityType. The unit for this constant is dependent
4455 * on the control mode, typically fractional duty cycle, voltage, or
4456 * torque current.
4457 *
4458 * - Minimum Value: -512
4459 * - Maximum Value: 511
4460 * - Default Value: 0
4461 * - Units:
4462 */
4463 double kG = 0;
4464 /**
4465 * \brief Gravity Feedforward/Feedback Type
4466 *
4467 * \details This determines the type of the gravity
4468 * feedforward/feedback.
4469 *
4470 * Choose Elevator_Static for systems where the gravity feedforward is
4471 * constant, such as an elevator. The gravity feedforward output will
4472 * always be positive.
4473 *
4474 * Choose Arm_Cosine for systems where the gravity feedback is
4475 * dependent on the angular position of the mechanism, such as an arm.
4476 * The gravity feedback output will vary depending on the mechanism
4477 * angular position. Note that the sensor offset and ratios must be
4478 * configured so that the sensor position is 0 when the mechanism is
4479 * horizonal, and one rotation of the mechanism corresponds to one
4480 * rotation of the sensor position.
4481 *
4482 */
4484 /**
4485 * \brief Static Feedforward Sign during position closed loop
4486 *
4487 * \details This determines the sign of the applied kS during position
4488 * closed-loop modes. The default behavior uses the velocity reference
4489 * sign. This works well with velocity closed loop, Motion Magic®
4490 * controls, and position closed loop when velocity reference is
4491 * specified (motion profiling).
4492 *
4493 * However, when using position closed loop with zero velocity
4494 * reference (no motion profiling), the application may want to apply
4495 * static feedforward based on the closed loop error sign instead.
4496 * When doing so, we recommend the minimal amount of kS, otherwise the
4497 * motor output may dither when closed loop error is near zero.
4498 *
4499 */
4501
4502 /**
4503 * \brief Modifies this configuration's kP parameter and returns itself for
4504 * method-chaining and easier to use config API.
4505 *
4506 * Proportional Gain
4507 *
4508 * \details The units for this gain is dependent on the control mode.
4509 * Since this gain is multiplied by error in the input, the units
4510 * should be defined as units of output per unit of input error. For
4511 * example, when controlling velocity using a duty cycle closed loop,
4512 * the units for the proportional gain will be duty cycle per rps, or
4513 * 1/rps.
4514 *
4515 * - Minimum Value: 0
4516 * - Maximum Value: 3.4e+38
4517 * - Default Value: 0
4518 * - Units:
4519 *
4520 * \param newKP Parameter to modify
4521 * \returns Itself
4522 */
4523 Slot2Configs& WithKP(double newKP)
4524 {
4525 kP = std::move(newKP);
4526 return *this;
4527 }
4528 /**
4529 * \brief Modifies this configuration's kI parameter and returns itself for
4530 * method-chaining and easier to use config API.
4531 *
4532 * Integral Gain
4533 *
4534 * \details The units for this gain is dependent on the control mode.
4535 * Since this gain is multiplied by error in the input integrated over
4536 * time (in units of seconds), the units should be defined as units of
4537 * output per unit of integrated input error. For example, when
4538 * controlling velocity using a duty cycle closed loop, integrating
4539 * velocity over time results in rps * s = rotations. Therefore, the
4540 * units for the integral gain will be duty cycle per rotation of
4541 * accumulated error, or 1/rot.
4542 *
4543 * - Minimum Value: 0
4544 * - Maximum Value: 3.4e+38
4545 * - Default Value: 0
4546 * - Units:
4547 *
4548 * \param newKI Parameter to modify
4549 * \returns Itself
4550 */
4551 Slot2Configs& WithKI(double newKI)
4552 {
4553 kI = std::move(newKI);
4554 return *this;
4555 }
4556 /**
4557 * \brief Modifies this configuration's kD parameter and returns itself for
4558 * method-chaining and easier to use config API.
4559 *
4560 * Derivative Gain
4561 *
4562 * \details The units for this gain is dependent on the control mode.
4563 * Since this gain is multiplied by the derivative of error in the
4564 * input with respect to time (in units of seconds), the units should
4565 * be defined as units of output per unit of the differentiated input
4566 * error. For example, when controlling velocity using a duty cycle
4567 * closed loop, the derivative of velocity with respect to time is
4568 * rps/s, which is acceleration. Therefore, the units for the
4569 * derivative gain will be duty cycle per unit of acceleration error,
4570 * or 1/(rps/s).
4571 *
4572 * - Minimum Value: 0
4573 * - Maximum Value: 3.4e+38
4574 * - Default Value: 0
4575 * - Units:
4576 *
4577 * \param newKD Parameter to modify
4578 * \returns Itself
4579 */
4580 Slot2Configs& WithKD(double newKD)
4581 {
4582 kD = std::move(newKD);
4583 return *this;
4584 }
4585 /**
4586 * \brief Modifies this configuration's kS parameter and returns itself for
4587 * method-chaining and easier to use config API.
4588 *
4589 * Static Feedforward Gain
4590 *
4591 * \details This is added to the closed loop output. The unit for this
4592 * constant is dependent on the control mode, typically fractional
4593 * duty cycle, voltage, or torque current.
4594 *
4595 * The sign is typically determined by reference velocity when using
4596 * position, velocity, and Motion Magic® closed loop modes. However,
4597 * when using position closed loop with zero velocity reference (no
4598 * motion profiling), the application can instead use the position
4599 * closed loop error by setting the Static Feedforward Sign
4600 * configuration parameter. When doing so, we recommend the minimal
4601 * amount of kS, otherwise the motor output may dither when closed
4602 * loop error is near zero.
4603 *
4604 * - Minimum Value: -512
4605 * - Maximum Value: 511
4606 * - Default Value: 0
4607 * - Units:
4608 *
4609 * \param newKS Parameter to modify
4610 * \returns Itself
4611 */
4612 Slot2Configs& WithKS(double newKS)
4613 {
4614 kS = std::move(newKS);
4615 return *this;
4616 }
4617 /**
4618 * \brief Modifies this configuration's kV parameter and returns itself for
4619 * method-chaining and easier to use config API.
4620 *
4621 * Velocity Feedforward Gain
4622 *
4623 * \details The units for this gain is dependent on the control mode.
4624 * Since this gain is multiplied by the requested velocity, the units
4625 * should be defined as units of output per unit of requested input
4626 * velocity. For example, when controlling velocity using a duty cycle
4627 * closed loop, the units for the velocity feedfoward gain will be
4628 * duty cycle per requested rps, or 1/rps.
4629 *
4630 * - Minimum Value: 0
4631 * - Maximum Value: 3.4e+38
4632 * - Default Value: 0
4633 * - Units:
4634 *
4635 * \param newKV Parameter to modify
4636 * \returns Itself
4637 */
4638 Slot2Configs& WithKV(double newKV)
4639 {
4640 kV = std::move(newKV);
4641 return *this;
4642 }
4643 /**
4644 * \brief Modifies this configuration's kA parameter and returns itself for
4645 * method-chaining and easier to use config API.
4646 *
4647 * Acceleration Feedforward Gain
4648 *
4649 * \details The units for this gain is dependent on the control mode.
4650 * Since this gain is multiplied by the requested acceleration, the
4651 * units should be defined as units of output per unit of requested
4652 * input acceleration. For example, when controlling velocity using a
4653 * duty cycle closed loop, the units for the acceleration feedfoward
4654 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
4655 *
4656 * - Minimum Value: 0
4657 * - Maximum Value: 3.4e+38
4658 * - Default Value: 0
4659 * - Units:
4660 *
4661 * \param newKA Parameter to modify
4662 * \returns Itself
4663 */
4664 Slot2Configs& WithKA(double newKA)
4665 {
4666 kA = std::move(newKA);
4667 return *this;
4668 }
4669 /**
4670 * \brief Modifies this configuration's kG parameter and returns itself for
4671 * method-chaining and easier to use config API.
4672 *
4673 * Gravity Feedforward/Feedback Gain
4674 *
4675 * \details This is added to the closed loop output. The sign is
4676 * determined by GravityType. The unit for this constant is dependent
4677 * on the control mode, typically fractional duty cycle, voltage, or
4678 * torque current.
4679 *
4680 * - Minimum Value: -512
4681 * - Maximum Value: 511
4682 * - Default Value: 0
4683 * - Units:
4684 *
4685 * \param newKG Parameter to modify
4686 * \returns Itself
4687 */
4688 Slot2Configs& WithKG(double newKG)
4689 {
4690 kG = std::move(newKG);
4691 return *this;
4692 }
4693 /**
4694 * \brief Modifies this configuration's GravityType parameter and returns itself for
4695 * method-chaining and easier to use config API.
4696 *
4697 * Gravity Feedforward/Feedback Type
4698 *
4699 * \details This determines the type of the gravity
4700 * feedforward/feedback.
4701 *
4702 * Choose Elevator_Static for systems where the gravity feedforward is
4703 * constant, such as an elevator. The gravity feedforward output will
4704 * always be positive.
4705 *
4706 * Choose Arm_Cosine for systems where the gravity feedback is
4707 * dependent on the angular position of the mechanism, such as an arm.
4708 * The gravity feedback output will vary depending on the mechanism
4709 * angular position. Note that the sensor offset and ratios must be
4710 * configured so that the sensor position is 0 when the mechanism is
4711 * horizonal, and one rotation of the mechanism corresponds to one
4712 * rotation of the sensor position.
4713 *
4714 *
4715 * \param newGravityType Parameter to modify
4716 * \returns Itself
4717 */
4719 {
4720 GravityType = std::move(newGravityType);
4721 return *this;
4722 }
4723 /**
4724 * \brief Modifies this configuration's StaticFeedforwardSign parameter and returns itself for
4725 * method-chaining and easier to use config API.
4726 *
4727 * Static Feedforward Sign during position closed loop
4728 *
4729 * \details This determines the sign of the applied kS during position
4730 * closed-loop modes. The default behavior uses the velocity reference
4731 * sign. This works well with velocity closed loop, Motion Magic®
4732 * controls, and position closed loop when velocity reference is
4733 * specified (motion profiling).
4734 *
4735 * However, when using position closed loop with zero velocity
4736 * reference (no motion profiling), the application may want to apply
4737 * static feedforward based on the closed loop error sign instead.
4738 * When doing so, we recommend the minimal amount of kS, otherwise the
4739 * motor output may dither when closed loop error is near zero.
4740 *
4741 *
4742 * \param newStaticFeedforwardSign Parameter to modify
4743 * \returns Itself
4744 */
4746 {
4747 StaticFeedforwardSign = std::move(newStaticFeedforwardSign);
4748 return *this;
4749 }
4750
4751 static Slot2Configs From(const SlotConfigs& value);
4752
4753 std::string ToString() const override
4754 {
4755 std::stringstream ss;
4756 ss << "{" << std::endl;
4757 ss << "Config Group: Slot2" << std::endl;
4758 ss << "Name: \"kP\" Value: \"" << kP << "\"" << std::endl;
4759 ss << "Name: \"kI\" Value: \"" << kI << "\"" << std::endl;
4760 ss << "Name: \"kD\" Value: \"" << kD << "\"" << std::endl;
4761 ss << "Name: \"kS\" Value: \"" << kS << "\"" << std::endl;
4762 ss << "Name: \"kV\" Value: \"" << kV << "\"" << std::endl;
4763 ss << "Name: \"kA\" Value: \"" << kA << "\"" << std::endl;
4764 ss << "Name: \"kG\" Value: \"" << kG << "\"" << std::endl;
4765 ss << "Name: \"GravityType\" Value: \"" << GravityType << "\"" << std::endl;
4766 ss << "Name: \"StaticFeedforwardSign\" Value: \"" << StaticFeedforwardSign << "\"" << std::endl;
4767 ss << "}" << std::endl;
4768 return ss.str();
4769 }
4770
4771 std::string Serialize() const override
4772 {
4773 std::stringstream ss;
4774 char *ref;
4775 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kP, kP, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4776 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kI, kI, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4777 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kD, kD, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4778 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kS, kS, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4779 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kV, kV, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4780 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kA, kA, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4781 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kG, kG, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4782 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot2_kG_Type, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4783 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot2_kS_Sign, StaticFeedforwardSign.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4784 return ss.str();
4785 }
4786
4787 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize) override
4788 {
4789 const char *string_c_str = to_deserialize.c_str();
4790 size_t string_length = to_deserialize.length();
4791 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kP, string_c_str, string_length, &kP);
4792 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kI, string_c_str, string_length, &kI);
4793 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kD, string_c_str, string_length, &kD);
4794 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kS, string_c_str, string_length, &kS);
4795 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kV, string_c_str, string_length, &kV);
4796 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kA, string_c_str, string_length, &kA);
4797 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kG, string_c_str, string_length, &kG);
4798 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot2_kG_Type, string_c_str, string_length, &GravityType.value);
4799 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot2_kS_Sign, string_c_str, string_length, &StaticFeedforwardSign.value);
4800 return 0;
4801 }
4802};
4803
4804/**
4805 * \brief Gains for the specified slot.
4806 *
4807 * \details If this slot is selected, these gains are used in closed
4808 * loop control requests.
4809 */
4811{
4812 struct SlotSpns
4813 {
4814 int kPSpn;
4815 int kISpn;
4816 int kDSpn;
4817 int kSSpn;
4818 int kVSpn;
4819 int kASpn;
4820 int kGSpn;
4821 int GravityTypeSpn;
4822 int StaticFeedforwardSignSpn;
4823 };
4824
4825 std::map<int, SlotSpns> genericMap{
4826 {0, SlotSpns{
4827 ctre::phoenix6::spns::SpnValue::Slot0_kP,
4828 ctre::phoenix6::spns::SpnValue::Slot0_kI,
4829 ctre::phoenix6::spns::SpnValue::Slot0_kD,
4830 ctre::phoenix6::spns::SpnValue::Slot0_kS,
4831 ctre::phoenix6::spns::SpnValue::Slot0_kV,
4832 ctre::phoenix6::spns::SpnValue::Slot0_kA,
4833 ctre::phoenix6::spns::SpnValue::Slot0_kG,
4834 ctre::phoenix6::spns::SpnValue::Slot0_kG_Type,
4835 ctre::phoenix6::spns::SpnValue::Slot0_kS_Sign,
4836 }},
4837
4838 {1, SlotSpns{
4839 ctre::phoenix6::spns::SpnValue::Slot1_kP,
4840 ctre::phoenix6::spns::SpnValue::Slot1_kI,
4841 ctre::phoenix6::spns::SpnValue::Slot1_kD,
4842 ctre::phoenix6::spns::SpnValue::Slot1_kS,
4843 ctre::phoenix6::spns::SpnValue::Slot1_kV,
4844 ctre::phoenix6::spns::SpnValue::Slot1_kA,
4845 ctre::phoenix6::spns::SpnValue::Slot1_kG,
4846 ctre::phoenix6::spns::SpnValue::Slot1_kG_Type,
4847 ctre::phoenix6::spns::SpnValue::Slot1_kS_Sign,
4848 }},
4849
4850 {2, SlotSpns{
4851 ctre::phoenix6::spns::SpnValue::Slot2_kP,
4852 ctre::phoenix6::spns::SpnValue::Slot2_kI,
4853 ctre::phoenix6::spns::SpnValue::Slot2_kD,
4854 ctre::phoenix6::spns::SpnValue::Slot2_kS,
4855 ctre::phoenix6::spns::SpnValue::Slot2_kV,
4856 ctre::phoenix6::spns::SpnValue::Slot2_kA,
4857 ctre::phoenix6::spns::SpnValue::Slot2_kG,
4858 ctre::phoenix6::spns::SpnValue::Slot2_kG_Type,
4859 ctre::phoenix6::spns::SpnValue::Slot2_kS_Sign,
4860 }},
4861
4862 };
4863
4864public:
4865 /**
4866 * \brief Proportional Gain
4867 *
4868 * \details The units for this gain is dependent on the control mode.
4869 * Since this gain is multiplied by error in the input, the units
4870 * should be defined as units of output per unit of input error. For
4871 * example, when controlling velocity using a duty cycle closed loop,
4872 * the units for the proportional gain will be duty cycle per rps of
4873 * error, or 1/rps.
4874 *
4875 * - Minimum Value: 0
4876 * - Maximum Value: 3.4e+38
4877 * - Default Value: 0
4878 * - Units:
4879 */
4880 double kP = 0;
4881 /**
4882 * \brief Integral Gain
4883 *
4884 * \details The units for this gain is dependent on the control mode.
4885 * Since this gain is multiplied by error in the input integrated over
4886 * time (in units of seconds), the units should be defined as units of
4887 * output per unit of integrated input error. For example, when
4888 * controlling velocity using a duty cycle closed loop, integrating
4889 * velocity over time results in rps * s = rotations. Therefore, the
4890 * units for the integral gain will be duty cycle per rotation of
4891 * accumulated error, or 1/rot.
4892 *
4893 * - Minimum Value: 0
4894 * - Maximum Value: 3.4e+38
4895 * - Default Value: 0
4896 * - Units:
4897 */
4898 double kI = 0;
4899 /**
4900 * \brief Derivative Gain
4901 *
4902 * \details The units for this gain is dependent on the control mode.
4903 * Since this gain is multiplied by the derivative of error in the
4904 * input with respect to time (in units of seconds), the units should
4905 * be defined as units of output per unit of the differentiated input
4906 * error. For example, when controlling velocity using a duty cycle
4907 * closed loop, the derivative of velocity with respect to time is
4908 * rps/s, which is acceleration. Therefore, the units for the
4909 * derivative gain will be duty cycle per unit of acceleration error,
4910 * or 1/(rps/s).
4911 *
4912 * - Minimum Value: 0
4913 * - Maximum Value: 3.4e+38
4914 * - Default Value: 0
4915 * - Units:
4916 */
4917 double kD = 0;
4918 /**
4919 * \brief Static Feedforward Gain
4920 *
4921 * \details This is added to the closed loop output. The unit for this
4922 * constant is dependent on the control mode, typically fractional
4923 * duty cycle, voltage, or torque current.
4924 *
4925 * The sign is typically determined by reference velocity when using
4926 * position, velocity, and Motion Magic® closed loop modes. However,
4927 * when using position closed loop with zero velocity reference (no
4928 * motion profiling), the application can instead use the position
4929 * closed loop error by setting the Static Feedforward Sign
4930 * configuration parameter. When doing so, we recommend the minimal
4931 * amount of kS, otherwise the motor output may dither when closed
4932 * loop error is near zero.
4933 *
4934 * - Minimum Value: -512
4935 * - Maximum Value: 511
4936 * - Default Value: 0
4937 * - Units:
4938 */
4939 double kS = 0;
4940 /**
4941 * \brief Velocity Feedforward Gain
4942 *
4943 * \details The units for this gain is dependent on the control mode.
4944 * Since this gain is multiplied by the requested velocity, the units
4945 * should be defined as units of output per unit of requested input
4946 * velocity. For example, when controlling velocity using a duty cycle
4947 * closed loop, the units for the velocity feedfoward gain will be
4948 * duty cycle per requested rps, or 1/rps.
4949 *
4950 * - Minimum Value: 0
4951 * - Maximum Value: 3.4e+38
4952 * - Default Value: 0
4953 * - Units:
4954 */
4955 double kV = 0;
4956 /**
4957 * \brief Acceleration Feedforward Gain
4958 *
4959 * \details The units for this gain is dependent on the control mode.
4960 * Since this gain is multiplied by the requested acceleration, the
4961 * units should be defined as units of output per unit of requested
4962 * input acceleration. For example, when controlling velocity using a
4963 * duty cycle closed loop, the units for the acceleration feedfoward
4964 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
4965 *
4966 * - Minimum Value: 0
4967 * - Maximum Value: 3.4e+38
4968 * - Default Value: 0
4969 * - Units:
4970 */
4971 double kA = 0;
4972 /**
4973 * \brief Gravity Feedforward/Feedback Gain
4974 *
4975 * \details This is added to the closed loop output. The sign is
4976 * determined by GravityType. The unit for this constant is dependent
4977 * on the control mode, typically fractional duty cycle, voltage, or
4978 * torque current.
4979 *
4980 * - Minimum Value: -512
4981 * - Maximum Value: 511
4982 * - Default Value: 0
4983 * - Units:
4984 */
4985 double kG = 0;
4986 /**
4987 * \brief Gravity Feedforward/Feedback Type
4988 *
4989 * \details This determines the type of the gravity
4990 * feedforward/feedback.
4991 *
4992 * Choose Elevator_Static for systems where the gravity feedforward is
4993 * constant, such as an elevator. The gravity feedforward output will
4994 * always have the same sign.
4995 *
4996 * Choose Arm_Cosine for systems where the gravity feedback is
4997 * dependent on the angular position of the mechanism, such as an arm.
4998 * The gravity feedback output will vary depending on the mechanism
4999 * angular position. Note that the sensor offset and ratios must be
5000 * configured so that the sensor reports a position of 0 when the
5001 * mechanism is horizonal (parallel to the ground), and the reported
5002 * sensor position is 1:1 with the mechanism.
5003 *
5004 */
5006 /**
5007 * \brief Static Feedforward Sign during position closed loop
5008 *
5009 * \details This determines the sign of the applied kS during position
5010 * closed-loop modes. The default behavior uses the velocity reference
5011 * sign. This works well with velocity closed loop, Motion Magic®
5012 * controls, and position closed loop when velocity reference is
5013 * specified (motion profiling).
5014 *
5015 * However, when using position closed loop with zero velocity
5016 * reference (no motion profiling), the application may want to apply
5017 * static feedforward based on the closed loop error sign instead.
5018 * When doing so, we recommend the minimal amount of kS, otherwise the
5019 * motor output may dither when closed loop error is near zero.
5020 *
5021 */
5023
5024 /**
5025 * \brief Modifies this configuration's kP parameter and returns itself for
5026 * method-chaining and easier to use config API.
5027 *
5028 * Proportional Gain
5029 *
5030 * \details The units for this gain is dependent on the control mode.
5031 * Since this gain is multiplied by error in the input, the units
5032 * should be defined as units of output per unit of input error. For
5033 * example, when controlling velocity using a duty cycle closed loop,
5034 * the units for the proportional gain will be duty cycle per rps of
5035 * error, or 1/rps.
5036 *
5037 * - Minimum Value: 0
5038 * - Maximum Value: 3.4e+38
5039 * - Default Value: 0
5040 * - Units:
5041 *
5042 * \param newKP Parameter to modify
5043 * \returns Itself
5044 */
5045 SlotConfigs& WithKP(double newKP)
5046 {
5047 kP = std::move(newKP);
5048 return *this;
5049 }
5050 /**
5051 * \brief Modifies this configuration's kI parameter and returns itself for
5052 * method-chaining and easier to use config API.
5053 *
5054 * Integral Gain
5055 *
5056 * \details The units for this gain is dependent on the control mode.
5057 * Since this gain is multiplied by error in the input integrated over
5058 * time (in units of seconds), the units should be defined as units of
5059 * output per unit of integrated input error. For example, when
5060 * controlling velocity using a duty cycle closed loop, integrating
5061 * velocity over time results in rps * s = rotations. Therefore, the
5062 * units for the integral gain will be duty cycle per rotation of
5063 * accumulated error, or 1/rot.
5064 *
5065 * - Minimum Value: 0
5066 * - Maximum Value: 3.4e+38
5067 * - Default Value: 0
5068 * - Units:
5069 *
5070 * \param newKI Parameter to modify
5071 * \returns Itself
5072 */
5073 SlotConfigs& WithKI(double newKI)
5074 {
5075 kI = std::move(newKI);
5076 return *this;
5077 }
5078 /**
5079 * \brief Modifies this configuration's kD parameter and returns itself for
5080 * method-chaining and easier to use config API.
5081 *
5082 * Derivative Gain
5083 *
5084 * \details The units for this gain is dependent on the control mode.
5085 * Since this gain is multiplied by the derivative of error in the
5086 * input with respect to time (in units of seconds), the units should
5087 * be defined as units of output per unit of the differentiated input
5088 * error. For example, when controlling velocity using a duty cycle
5089 * closed loop, the derivative of velocity with respect to time is
5090 * rps/s, which is acceleration. Therefore, the units for the
5091 * derivative gain will be duty cycle per unit of acceleration error,
5092 * or 1/(rps/s).
5093 *
5094 * - Minimum Value: 0
5095 * - Maximum Value: 3.4e+38
5096 * - Default Value: 0
5097 * - Units:
5098 *
5099 * \param newKD Parameter to modify
5100 * \returns Itself
5101 */
5102 SlotConfigs& WithKD(double newKD)
5103 {
5104 kD = std::move(newKD);
5105 return *this;
5106 }
5107 /**
5108 * \brief Modifies this configuration's kS parameter and returns itself for
5109 * method-chaining and easier to use config API.
5110 *
5111 * Static Feedforward Gain
5112 *
5113 * \details This is added to the closed loop output. The unit for this
5114 * constant is dependent on the control mode, typically fractional
5115 * duty cycle, voltage, or torque current.
5116 *
5117 * The sign is typically determined by reference velocity when using
5118 * position, velocity, and Motion Magic® closed loop modes. However,
5119 * when using position closed loop with zero velocity reference (no
5120 * motion profiling), the application can instead use the position
5121 * closed loop error by setting the Static Feedforward Sign
5122 * configuration parameter. When doing so, we recommend the minimal
5123 * amount of kS, otherwise the motor output may dither when closed
5124 * loop error is near zero.
5125 *
5126 * - Minimum Value: -512
5127 * - Maximum Value: 511
5128 * - Default Value: 0
5129 * - Units:
5130 *
5131 * \param newKS Parameter to modify
5132 * \returns Itself
5133 */
5134 SlotConfigs& WithKS(double newKS)
5135 {
5136 kS = std::move(newKS);
5137 return *this;
5138 }
5139 /**
5140 * \brief Modifies this configuration's kV parameter and returns itself for
5141 * method-chaining and easier to use config API.
5142 *
5143 * Velocity Feedforward Gain
5144 *
5145 * \details The units for this gain is dependent on the control mode.
5146 * Since this gain is multiplied by the requested velocity, the units
5147 * should be defined as units of output per unit of requested input
5148 * velocity. For example, when controlling velocity using a duty cycle
5149 * closed loop, the units for the velocity feedfoward gain will be
5150 * duty cycle per requested rps, or 1/rps.
5151 *
5152 * - Minimum Value: 0
5153 * - Maximum Value: 3.4e+38
5154 * - Default Value: 0
5155 * - Units:
5156 *
5157 * \param newKV Parameter to modify
5158 * \returns Itself
5159 */
5160 SlotConfigs& WithKV(double newKV)
5161 {
5162 kV = std::move(newKV);
5163 return *this;
5164 }
5165 /**
5166 * \brief Modifies this configuration's kA parameter and returns itself for
5167 * method-chaining and easier to use config API.
5168 *
5169 * Acceleration Feedforward Gain
5170 *
5171 * \details The units for this gain is dependent on the control mode.
5172 * Since this gain is multiplied by the requested acceleration, the
5173 * units should be defined as units of output per unit of requested
5174 * input acceleration. For example, when controlling velocity using a
5175 * duty cycle closed loop, the units for the acceleration feedfoward
5176 * gain will be duty cycle per requested rps/s, or 1/(rps/s).
5177 *
5178 * - Minimum Value: 0
5179 * - Maximum Value: 3.4e+38
5180 * - Default Value: 0
5181 * - Units:
5182 *
5183 * \param newKA Parameter to modify
5184 * \returns Itself
5185 */
5186 SlotConfigs& WithKA(double newKA)
5187 {
5188 kA = std::move(newKA);
5189 return *this;
5190 }
5191 /**
5192 * \brief Modifies this configuration's kG parameter and returns itself for
5193 * method-chaining and easier to use config API.
5194 *
5195 * Gravity Feedforward/Feedback Gain
5196 *
5197 * \details This is added to the closed loop output. The sign is
5198 * determined by GravityType. The unit for this constant is dependent
5199 * on the control mode, typically fractional duty cycle, voltage, or
5200 * torque current.
5201 *
5202 * - Minimum Value: -512
5203 * - Maximum Value: 511
5204 * - Default Value: 0
5205 * - Units:
5206 *
5207 * \param newKG Parameter to modify
5208 * \returns Itself
5209 */
5210 SlotConfigs& WithKG(double newKG)
5211 {
5212 kG = std::move(newKG);
5213 return *this;
5214 }
5215 /**
5216 * \brief Modifies this configuration's GravityType parameter and returns itself for
5217 * method-chaining and easier to use config API.
5218 *
5219 * Gravity Feedforward/Feedback Type
5220 *
5221 * \details This determines the type of the gravity
5222 * feedforward/feedback.
5223 *
5224 * Choose Elevator_Static for systems where the gravity feedforward is
5225 * constant, such as an elevator. The gravity feedforward output will
5226 * always have the same sign.
5227 *
5228 * Choose Arm_Cosine for systems where the gravity feedback is
5229 * dependent on the angular position of the mechanism, such as an arm.
5230 * The gravity feedback output will vary depending on the mechanism
5231 * angular position. Note that the sensor offset and ratios must be
5232 * configured so that the sensor reports a position of 0 when the
5233 * mechanism is horizonal (parallel to the ground), and the reported
5234 * sensor position is 1:1 with the mechanism.
5235 *
5236 *
5237 * \param newGravityType Parameter to modify
5238 * \returns Itself
5239 */
5241 {
5242 GravityType = std::move(newGravityType);
5243 return *this;
5244 }
5245 /**
5246 * \brief Modifies this configuration's StaticFeedforwardSign parameter and returns itself for
5247 * method-chaining and easier to use config API.
5248 *
5249 * Static Feedforward Sign during position closed loop
5250 *
5251 * \details This determines the sign of the applied kS during position
5252 * closed-loop modes. The default behavior uses the velocity reference
5253 * sign. This works well with velocity closed loop, Motion Magic®
5254 * controls, and position closed loop when velocity reference is
5255 * specified (motion profiling).
5256 *
5257 * However, when using position closed loop with zero velocity
5258 * reference (no motion profiling), the application may want to apply
5259 * static feedforward based on the closed loop error sign instead.
5260 * When doing so, we recommend the minimal amount of kS, otherwise the
5261 * motor output may dither when closed loop error is near zero.
5262 *
5263 *
5264 * \param newStaticFeedforwardSign Parameter to modify
5265 * \returns Itself
5266 */
5268 {
5269 StaticFeedforwardSign = std::move(newStaticFeedforwardSign);
5270 return *this;
5271 }
5272
5273
5274 /**
5275 * \brief Chooses which slot these configs are for.
5276 */
5277 int SlotNumber = 0;
5278
5279 static SlotConfigs From(const Slot0Configs& value);
5280 static SlotConfigs From(const Slot1Configs& value);
5281 static SlotConfigs From(const Slot2Configs& value);
5282
5283 std::string ToString() const
5284 {
5285 std::stringstream ss;
5286 ss << "{" << std::endl;
5287 ss << "Config Group: Slot" << std::endl;
5288 ss << "Name: \"kP\" Value: \"" << kP << "\"" << std::endl;
5289 ss << "Name: \"kI\" Value: \"" << kI << "\"" << std::endl;
5290 ss << "Name: \"kD\" Value: \"" << kD << "\"" << std::endl;
5291 ss << "Name: \"kS\" Value: \"" << kS << "\"" << std::endl;
5292 ss << "Name: \"kV\" Value: \"" << kV << "\"" << std::endl;
5293 ss << "Name: \"kA\" Value: \"" << kA << "\"" << std::endl;
5294 ss << "Name: \"kG\" Value: \"" << kG << "\"" << std::endl;
5295 ss << "Name: \"GravityType\" Value: \"" << GravityType << "\"" << std::endl;
5296 ss << "Name: \"StaticFeedforwardSign\" Value: \"" << StaticFeedforwardSign << "\"" << std::endl;
5297 ss << "}" << std::endl;
5298 return ss.str();
5299 }
5300
5301 std::string Serialize() const
5302 {
5303 std::stringstream ss;
5304 SlotSpns currentSpns = genericMap.at(SlotNumber);
5305 char *ref;
5306 c_ctre_phoenix6_serialize_double(currentSpns.kPSpn, kP, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5307 c_ctre_phoenix6_serialize_double(currentSpns.kISpn, kI, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5308 c_ctre_phoenix6_serialize_double(currentSpns.kDSpn, kD, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5309 c_ctre_phoenix6_serialize_double(currentSpns.kSSpn, kS, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5310 c_ctre_phoenix6_serialize_double(currentSpns.kVSpn, kV, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5311 c_ctre_phoenix6_serialize_double(currentSpns.kASpn, kA, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5312 c_ctre_phoenix6_serialize_double(currentSpns.kGSpn, kG, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5313 c_ctre_phoenix6_serialize_int(currentSpns.GravityTypeSpn, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5314 c_ctre_phoenix6_serialize_int(currentSpns.StaticFeedforwardSignSpn, StaticFeedforwardSign.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5315 return ss.str();
5316 }
5317
5318 ctre::phoenix::StatusCode Deserialize(const std::string& to_deserialize)
5319 {
5320 const char *string_c_str = to_deserialize.c_str();
5321 size_t string_length = to_deserialize.length();
5322 SlotSpns currentSpns = genericMap.at(SlotNumber);
5323 c_ctre_phoenix6_deserialize_double(currentSpns.kPSpn, string_c_str, string_length, &kP);
5324 c_ctre_phoenix6_deserialize_double(currentSpns.kISpn, string_c_str, string_length, &kI);
5325 c_ctre_phoenix6_deserialize_double(currentSpns.kDSpn, string_c_str, string_length, &kD);
5326 c_ctre_phoenix6_deserialize_double(currentSpns.kSSpn, string_c_str, string_length, &kS);
5327 c_ctre_phoenix6_deserialize_double(currentSpns.kVSpn, string_c_str, string_length, &kV);
5328 c_ctre_phoenix6_deserialize_double(currentSpns.kASpn, string_c_str, string_length, &kA);
5329 c_ctre_phoenix6_deserialize_double(currentSpns.kGSpn, string_c_str, string_length, &kG);
5330 c_ctre_phoenix6_deserialize_int(currentSpns.GravityTypeSpn, string_c_str, string_length, &GravityType.value);
5331 c_ctre_phoenix6_deserialize_int(currentSpns.StaticFeedforwardSignSpn, string_c_str, string_length, &StaticFeedforwardSign.value);
5332 return 0;
5333 }
5334};
5335
5336
5337}
5338}
5339}
ii that the Software will be uninterrupted or error free
Definition: CTRE_LICENSE.txt:226
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:2723
AudioConfigs & WithBeepOnBoot(bool newBeepOnBoot)
Modifies this configuration's BeepOnBoot parameter and returns itself for method-chaining and easier ...
Definition: Configs.hpp:2767
bool BeepOnConfig
If true, the TalonFX will beep during configuration API calls if device is disabled.
Definition: Configs.hpp:2742
bool AllowMusicDurDisable
If true, the TalonFX will allow Orchestra and MusicTone requests during disabled state.
Definition: Configs.hpp:2752
std::string Serialize() const override
Definition: Configs.hpp:2826
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:2836
std::string ToString() const override
Definition: Configs.hpp:2814
AudioConfigs & WithAllowMusicDurDisable(bool newAllowMusicDurDisable)
Modifies this configuration's AllowMusicDurDisable parameter and returns itself for method-chaining a...
Definition: Configs.hpp:2806
AudioConfigs & WithBeepOnConfig(bool newBeepOnConfig)
Modifies this configuration's BeepOnConfig parameter and returns itself for method-chaining and easie...
Definition: Configs.hpp:2786
bool BeepOnBoot
If true, the TalonFX will beep during boot-up.
Definition: Configs.hpp:2733
Configs that affect general behavior during closed-looping.
Definition: Configs.hpp:3345
bool ContinuousWrap
Wrap position error within [-0.5,+0.5) mechanism rotations.
Definition: Configs.hpp:3359
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:3382
std::string ToString() const override
Definition: Configs.hpp:3364
std::string Serialize() const override
Definition: Configs.hpp:3374
Configs that affect the closed-loop control of this motor controller.
Definition: Configs.hpp:2091
double TorqueClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0A output to 300A during closed-loop modes.
Definition: Configs.hpp:2122
std::string Serialize() const override
Definition: Configs.hpp:2199
double VoltageClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0V output to 12V during closed-loop modes.
Definition: Configs.hpp:2112
ClosedLoopRampsConfigs & WithDutyCycleClosedLoopRampPeriod(double newDutyCycleClosedLoopRampPeriod)
Modifies this configuration's DutyCycleClosedLoopRampPeriod parameter and returns itself for method-c...
Definition: Configs.hpp:2139
ClosedLoopRampsConfigs & WithTorqueClosedLoopRampPeriod(double newTorqueClosedLoopRampPeriod)
Modifies this configuration's TorqueClosedLoopRampPeriod parameter and returns itself for method-chai...
Definition: Configs.hpp:2179
double DutyCycleClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0% output to 100% during closed-loop modes.
Definition: Configs.hpp:2102
ClosedLoopRampsConfigs & WithVoltageClosedLoopRampPeriod(double newVoltageClosedLoopRampPeriod)
Modifies this configuration's VoltageClosedLoopRampPeriod parameter and returns itself for method-cha...
Definition: Configs.hpp:2159
std::string ToString() const override
Definition: Configs.hpp:2187
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:2209
Configs that directly affect current limiting features.
Definition: Configs.hpp:740
bool StatorCurrentLimitEnable
Enable motor stator current limiting.
Definition: Configs.hpp:774
double StatorCurrentLimit
The amount of current allowed in the motor (motoring and regen current).
Definition: Configs.hpp:768
double SupplyCurrentLimit
The amount of supply current allowed.
Definition: Configs.hpp:802
CurrentLimitsConfigs & WithSupplyCurrentThreshold(double newSupplyCurrentThreshold)
Modifies this configuration's SupplyCurrentThreshold parameter and returns itself for method-chaining...
Definition: Configs.hpp:956
CurrentLimitsConfigs & WithSupplyCurrentLimit(double newSupplyCurrentLimit)
Modifies this configuration's SupplyCurrentLimit parameter and returns itself for method-chaining and...
Definition: Configs.hpp:918
double SupplyCurrentThreshold
Delay supply current limiting until current exceeds this threshold for longer than SupplyTimeThreshol...
Definition: Configs.hpp:820
std::string Serialize() const override
Definition: Configs.hpp:1000
CurrentLimitsConfigs & WithSupplyCurrentLimitEnable(bool newSupplyCurrentLimitEnable)
Modifies this configuration's SupplyCurrentLimitEnable parameter and returns itself for method-chaini...
Definition: Configs.hpp:934
CurrentLimitsConfigs & WithStatorCurrentLimit(double newStatorCurrentLimit)
Modifies this configuration's StatorCurrentLimit parameter and returns itself for method-chaining and...
Definition: Configs.hpp:864
double SupplyTimeThreshold
Allows unlimited current for a period of time before current limiting occurs.
Definition: Configs.hpp:831
CurrentLimitsConfigs & WithSupplyTimeThreshold(double newSupplyTimeThreshold)
Modifies this configuration's SupplyTimeThreshold parameter and returns itself for method-chaining an...
Definition: Configs.hpp:977
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1013
CurrentLimitsConfigs & WithStatorCurrentLimitEnable(bool newStatorCurrentLimitEnable)
Modifies this configuration's StatorCurrentLimitEnable parameter and returns itself for method-chaini...
Definition: Configs.hpp:880
std::string ToString() const override
Definition: Configs.hpp:985
bool SupplyCurrentLimitEnable
Enable motor supply current limiting.
Definition: Configs.hpp:808
Custom Params.
Definition: Configs.hpp:3242
CustomParamsConfigs & WithCustomParam1(int newCustomParam1)
Modifies this configuration's CustomParam1 parameter and returns itself for method-chaining and easie...
Definition: Configs.hpp:3300
std::string ToString() const override
Definition: Configs.hpp:3308
int CustomParam0
Custom parameter 0.
Definition: Configs.hpp:3253
std::string Serialize() const override
Definition: Configs.hpp:3319
int CustomParam1
Custom parameter 1.
Definition: Configs.hpp:3263
CustomParamsConfigs & WithCustomParam0(int newCustomParam0)
Modifies this configuration's CustomParam0 parameter and returns itself for method-chaining and easie...
Definition: Configs.hpp:3280
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:3328
Configs related to constants used for differential control of a mechanism.
Definition: Configs.hpp:1817
std::string Serialize() const override
Definition: Configs.hpp:1925
std::string ToString() const override
Definition: Configs.hpp:1913
double PeakDifferentialDutyCycle
Maximum differential output during duty cycle based differential control modes.
Definition: Configs.hpp:1828
double PeakDifferentialTorqueCurrent
Maximum differential output during torque current based differential control modes.
Definition: Configs.hpp:1848
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1935
DifferentialConstantsConfigs & WithPeakDifferentialDutyCycle(double newPeakDifferentialDutyCycle)
Modifies this configuration's PeakDifferentialDutyCycle parameter and returns itself for method-chain...
Definition: Configs.hpp:1865
DifferentialConstantsConfigs & WithPeakDifferentialTorqueCurrent(double newPeakDifferentialTorqueCurrent)
Modifies this configuration's PeakDifferentialTorqueCurrent parameter and returns itself for method-c...
Definition: Configs.hpp:1905
double PeakDifferentialVoltage
Maximum differential output during voltage based differential control modes.
Definition: Configs.hpp:1838
DifferentialConstantsConfigs & WithPeakDifferentialVoltage(double newPeakDifferentialVoltage)
Modifies this configuration's PeakDifferentialVoltage parameter and returns itself for method-chainin...
Definition: Configs.hpp:1885
Configs related to sensors used for differential control of a mechanism.
Definition: Configs.hpp:1640
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1798
DifferentialSensorsConfigs & WithDifferentialTalonFXSensorID(int newDifferentialTalonFXSensorID)
Modifies this configuration's DifferentialTalonFXSensorID parameter and returns itself for method-cha...
Definition: Configs.hpp:1747
std::string Serialize() const override
Definition: Configs.hpp:1788
DifferentialSensorsConfigs & WithDifferentialRemoteSensorID(int newDifferentialRemoteSensorID)
Modifies this configuration's DifferentialRemoteSensorID parameter and returns itself for method-chai...
Definition: Configs.hpp:1768
DifferentialSensorsConfigs & WithDifferentialSensorSource(signals::DifferentialSensorSourceValue newDifferentialSensorSource)
Modifies this configuration's DifferentialSensorSource parameter and returns itself for method-chaini...
Definition: Configs.hpp:1727
std::string ToString() const override
Definition: Configs.hpp:1776
signals::DifferentialSensorSourceValue DifferentialSensorSource
Choose what sensor source is used for differential control of a mechanism.
Definition: Configs.hpp:1670
int DifferentialRemoteSensorID
Device ID of which remote sensor to use on the differential axis.
Definition: Configs.hpp:1691
int DifferentialTalonFXSensorID
Device ID of which remote Talon FX to use.
Definition: Configs.hpp:1680
Configs that affect the feedback of this motor controller.
Definition: Configs.hpp:1314
FeedbackConfigs & WithSensorToMechanismRatio(double newSensorToMechanismRatio)
Modifies this configuration's SensorToMechanismRatio parameter and returns itself for method-chaining...
Definition: Configs.hpp:1445
std::string ToString() const override
Definition: Configs.hpp:1593
FeedbackConfigs & WithFeedbackSensorSource(signals::FeedbackSensorSourceValue newFeedbackSensorSource)
Modifies this configuration's FeedbackSensorSource parameter and returns itself for method-chaining a...
Definition: Configs.hpp:1520
double FeedbackRotorOffset
This offset is applied to the absolute integrated rotor sensor.
Definition: Configs.hpp:1326
signals::FeedbackSensorSourceValue FeedbackSensorSource
Choose what sensor source is reported via API and used by closed-loop and limit features.
Definition: Configs.hpp:1394
FeedbackConfigs & WithRemoteCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use RemoteCANcoder by passing in the CANcoder objec...
double SensorToMechanismRatio
This is the ratio of sensor rotations to the mechanism's output.
Definition: Configs.hpp:1339
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1619
FeedbackConfigs & WithSyncCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use SyncCANcoder by passing in the CANcoder object.
std::string Serialize() const override
Definition: Configs.hpp:1607
double RotorToSensorRatio
Talon FX is capable of fusing a remote CANcoder with its rotor sensor to produce a high-bandwidth sen...
Definition: Configs.hpp:1352
FeedbackConfigs & WithFeedbackRotorOffset(double newFeedbackRotorOffset)
Modifies this configuration's FeedbackRotorOffset parameter and returns itself for method-chaining an...
Definition: Configs.hpp:1422
FeedbackConfigs & WithFeedbackRemoteSensorID(int newFeedbackRemoteSensorID)
Modifies this configuration's FeedbackRemoteSensorID parameter and returns itself for method-chaining...
Definition: Configs.hpp:1540
FeedbackConfigs & WithRotorToSensorRatio(double newRotorToSensorRatio)
Modifies this configuration's RotorToSensorRatio parameter and returns itself for method-chaining and...
Definition: Configs.hpp:1468
int FeedbackRemoteSensorID
Device ID of which remote device to use.
Definition: Configs.hpp:1404
FeedbackConfigs & WithFusedCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use FusedCANcoder by passing in the CANcoder object...
Configs to trim the Pigeon2's gyroscope.
Definition: Configs.hpp:308
GyroTrimConfigs & WithGyroScalarZ(double newGyroScalarZ)
Modifies this configuration's GyroScalarZ parameter and returns itself for method-chaining and easier...
Definition: Configs.hpp:390
std::string Serialize() const override
Definition: Configs.hpp:410
std::string ToString() const override
Definition: Configs.hpp:398
double GyroScalarX
The gyro scalar component for the X axis.
Definition: Configs.hpp:318
GyroTrimConfigs & WithGyroScalarY(double newGyroScalarY)
Modifies this configuration's GyroScalarY parameter and returns itself for method-chaining and easier...
Definition: Configs.hpp:371
GyroTrimConfigs & WithGyroScalarX(double newGyroScalarX)
Modifies this configuration's GyroScalarX parameter and returns itself for method-chaining and easier...
Definition: Configs.hpp:352
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:420
double GyroScalarZ
The gyro scalar component for the Z axis.
Definition: Configs.hpp:336
double GyroScalarY
The gyro scalar component for the Y axis.
Definition: Configs.hpp:327
Configs that change how the motor controller behaves under different limit switch states.
Definition: Configs.hpp:2230
HardwareLimitSwitchConfigs & WithReverseLimitRemoteTalonFX(const hardware::core::CoreTalonFX &device)
Helper method to configure this feedback group to use RemoteTalonFX reverse limit switch by passing i...
std::string ToString() const override
Definition: Configs.hpp:2656
signals::ForwardLimitTypeValue ForwardLimitType
Determines if the forward limit switch is normally-open (default) or normally-closed.
Definition: Configs.hpp:2237
HardwareLimitSwitchConfigs & WithForwardLimitRemoteSensorID(int newForwardLimitRemoteSensorID)
Modifies this configuration's ForwardLimitRemoteSensorID parameter and returns itself for method-chai...
Definition: Configs.hpp:2473
signals::ForwardLimitSourceValue ForwardLimitSource
Determines where to poll the forward limit switch.
Definition: Configs.hpp:2283
HardwareLimitSwitchConfigs & WithReverseLimitSource(signals::ReverseLimitSourceValue newReverseLimitSource)
Modifies this configuration's ReverseLimitSource parameter and returns itself for method-chaining and...
Definition: Configs.hpp:2574
bool ForwardLimitEnable
If enabled, motor output is set to neutral when the forward limit switch is asserted and positive out...
Definition: Configs.hpp:2263
HardwareLimitSwitchConfigs & WithReverseLimitRemoteSensorID(int newReverseLimitRemoteSensorID)
Modifies this configuration's ReverseLimitRemoteSensorID parameter and returns itself for method-chai...
Definition: Configs.hpp:2594
bool ReverseLimitAutosetPositionEnable
If enabled, the position is automatically set to a specific value, specified by ReverseLimitAutosetPo...
Definition: Configs.hpp:2307
bool ForwardLimitAutosetPositionEnable
If enabled, the position is automatically set to a specific value, specified by ForwardLimitAutosetPo...
Definition: Configs.hpp:2245
signals::ReverseLimitTypeValue ReverseLimitType
Determines if the reverse limit switch is normally-open (default) or normally-closed.
Definition: Configs.hpp:2299
HardwareLimitSwitchConfigs & WithForwardLimitSource(signals::ForwardLimitSourceValue newForwardLimitSource)
Modifies this configuration's ForwardLimitSource parameter and returns itself for method-chaining and...
Definition: Configs.hpp:2453
double ReverseLimitAutosetPositionValue
The value to automatically set the position to when the reverse limit switch is asserted.
Definition: Configs.hpp:2318
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:2696
HardwareLimitSwitchConfigs & WithReverseLimitRemoteCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use RemoteCANcoder reverse limit switch by passing ...
int ForwardLimitRemoteSensorID
Device ID of the remote device if using remote limit switch features for the forward limit switch.
Definition: Configs.hpp:2293
double ForwardLimitAutosetPositionValue
The value to automatically set the position to when the forward limit switch is asserted.
Definition: Configs.hpp:2256
signals::ReverseLimitSourceValue ReverseLimitSource
Determines where to poll the reverse limit switch.
Definition: Configs.hpp:2345
HardwareLimitSwitchConfigs & WithForwardLimitRemoteTalonFX(const hardware::core::CoreTalonFX &device)
Helper method to configure this feedback group to use RemoteTalonFX forward limit switch by passing i...
HardwareLimitSwitchConfigs & WithForwardLimitAutosetPositionEnable(bool newForwardLimitAutosetPositionEnable)
Modifies this configuration's ForwardLimitAutosetPositionEnable parameter and returns itself for meth...
Definition: Configs.hpp:2386
HardwareLimitSwitchConfigs & WithReverseLimitEnable(bool newReverseLimitEnable)
Modifies this configuration's ReverseLimitEnable parameter and returns itself for method-chaining and...
Definition: Configs.hpp:2545
std::string Serialize() const override
Definition: Configs.hpp:2677
HardwareLimitSwitchConfigs & WithReverseLimitType(signals::ReverseLimitTypeValue newReverseLimitType)
Modifies this configuration's ReverseLimitType parameter and returns itself for method-chaining and e...
Definition: Configs.hpp:2489
HardwareLimitSwitchConfigs & WithReverseLimitAutosetPositionEnable(bool newReverseLimitAutosetPositionEnable)
Modifies this configuration's ReverseLimitAutosetPositionEnable parameter and returns itself for meth...
Definition: Configs.hpp:2507
HardwareLimitSwitchConfigs & WithForwardLimitEnable(bool newForwardLimitEnable)
Modifies this configuration's ForwardLimitEnable parameter and returns itself for method-chaining and...
Definition: Configs.hpp:2424
HardwareLimitSwitchConfigs & WithForwardLimitAutosetPositionValue(double newForwardLimitAutosetPositionValue)
Modifies this configuration's ForwardLimitAutosetPositionValue parameter and returns itself for metho...
Definition: Configs.hpp:2407
HardwareLimitSwitchConfigs & WithReverseLimitAutosetPositionValue(double newReverseLimitAutosetPositionValue)
Modifies this configuration's ReverseLimitAutosetPositionValue parameter and returns itself for metho...
Definition: Configs.hpp:2528
HardwareLimitSwitchConfigs & WithForwardLimitRemoteCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use RemoteCANcoder forward limit switch by passing ...
bool ReverseLimitEnable
If enabled, motor output is set to neutral when reverse limit switch is asseted and negative output i...
Definition: Configs.hpp:2325
int ReverseLimitRemoteSensorID
Device ID of the remote device if using remote limit switch features for the reverse limit switch.
Definition: Configs.hpp:2355
HardwareLimitSwitchConfigs & WithForwardLimitType(signals::ForwardLimitTypeValue newForwardLimitType)
Modifies this configuration's ForwardLimitType parameter and returns itself for method-chaining and e...
Definition: Configs.hpp:2368
Configs that affect the magnet sensor and how to interpret it.
Definition: Configs.hpp:48
std::string Serialize() const override
Definition: Configs.hpp:144
signals::AbsoluteSensorRangeValue AbsoluteSensorRange
The range of the absolute sensor in rotations, either [-0.5, 0.5) or [0, 1).
Definition: Configs.hpp:73
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:154
MagnetSensorConfigs & WithMagnetOffset(double newMagnetOffset)
Modifies this configuration's MagnetOffset parameter and returns itself for method-chaining and easie...
Definition: Configs.hpp:108
double MagnetOffset
This offset is added to the reported position, allowing the application to trim the zero position.
Definition: Configs.hpp:67
MagnetSensorConfigs & WithSensorDirection(signals::SensorDirectionValue newSensorDirection)
Modifies this configuration's SensorDirection parameter and returns itself for method-chaining and ea...
Definition: Configs.hpp:86
std::string ToString() const override
Definition: Configs.hpp:132
signals::SensorDirectionValue SensorDirection
Direction of the sensor to determine positive rotation, as seen facing the LED side of the CANcoder.
Definition: Configs.hpp:55
MagnetSensorConfigs & WithAbsoluteSensorRange(signals::AbsoluteSensorRangeValue newAbsoluteSensorRange)
Modifies this configuration's AbsoluteSensorRange parameter and returns itself for method-chaining an...
Definition: Configs.hpp:124
Configs for Motion Magic®.
Definition: Configs.hpp:3013
double MotionMagicCruiseVelocity
This is the maximum velocity Motion Magic® based control modes are allowed to use.
Definition: Configs.hpp:3027
MotionMagicConfigs & WithMotionMagicJerk(double newMotionMagicJerk)
Modifies this configuration's MotionMagicJerk parameter and returns itself for method-chaining and ea...
Definition: Configs.hpp:3142
MotionMagicConfigs & WithMotionMagicAcceleration(double newMotionMagicAcceleration)
Modifies this configuration's MotionMagicAcceleration parameter and returns itself for method-chainin...
Definition: Configs.hpp:3119
MotionMagicConfigs & WithMotionMagicCruiseVelocity(double newMotionMagicCruiseVelocity)
Modifies this configuration's MotionMagicCruiseVelocity parameter and returns itself for method-chain...
Definition: Configs.hpp:3098
std::string Serialize() const override
Definition: Configs.hpp:3210
double MotionMagicJerk
This is the target jerk (acceleration derivative) Motion Magic® based control modes are allowed to us...
Definition: Configs.hpp:3051
double MotionMagicExpo_kV
This is the target kV used only by Motion Magic® Expo control modes, in units of V/rps.
Definition: Configs.hpp:3064
double MotionMagicAcceleration
This is the target acceleration Motion Magic® based control modes are allowed to use.
Definition: Configs.hpp:3038
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:3222
double MotionMagicExpo_kA
This is the target kA used only by Motion Magic® Expo control modes, in units of V/rps².
Definition: Configs.hpp:3078
MotionMagicConfigs & WithMotionMagicExpo_kV(double newMotionMagicExpo_kV)
Modifies this configuration's MotionMagicExpo_kV parameter and returns itself for method-chaining and...
Definition: Configs.hpp:3165
std::string ToString() const override
Definition: Configs.hpp:3196
MotionMagicConfigs & WithMotionMagicExpo_kA(double newMotionMagicExpo_kA)
Modifies this configuration's MotionMagicExpo_kA parameter and returns itself for method-chaining and...
Definition: Configs.hpp:3188
Configs that directly affect motor output.
Definition: Configs.hpp:557
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:719
MotorOutputConfigs & WithNeutralMode(signals::NeutralModeValue newNeutralMode)
Modifies this configuration's NeutralMode parameter and returns itself for method-chaining and easier...
Definition: Configs.hpp:627
MotorOutputConfigs & WithPeakForwardDutyCycle(double newPeakForwardDutyCycle)
Modifies this configuration's PeakForwardDutyCycle parameter and returns itself for method-chaining a...
Definition: Configs.hpp:666
double PeakForwardDutyCycle
Maximum (forward) output during duty cycle based control modes.
Definition: Configs.hpp:589
double DutyCycleNeutralDeadband
Configures the output deadband duty cycle during duty cycle and voltage based control modes.
Definition: Configs.hpp:579
signals::NeutralModeValue NeutralMode
The state of the motor controller bridge when output is neutral or disabled.
Definition: Configs.hpp:569
MotorOutputConfigs & WithDutyCycleNeutralDeadband(double newDutyCycleNeutralDeadband)
Modifies this configuration's DutyCycleNeutralDeadband parameter and returns itself for method-chaini...
Definition: Configs.hpp:647
MotorOutputConfigs & WithPeakReverseDutyCycle(double newPeakReverseDutyCycle)
Modifies this configuration's PeakReverseDutyCycle parameter and returns itself for method-chaining a...
Definition: Configs.hpp:685
double PeakReverseDutyCycle
Minimum (reverse) output during duty cycle based control modes.
Definition: Configs.hpp:599
MotorOutputConfigs & WithInverted(signals::InvertedValue newInverted)
Modifies this configuration's Inverted parameter and returns itself for method-chaining and easier to...
Definition: Configs.hpp:611
std::string ToString() const override
Definition: Configs.hpp:693
signals::InvertedValue Inverted
Invert state of the device.
Definition: Configs.hpp:563
std::string Serialize() const override
Definition: Configs.hpp:707
Configs for Pigeon 2's Mount Pose configuration.
Definition: Configs.hpp:174
MountPoseConfigs & WithMountPoseRoll(double newMountPoseRoll)
Modifies this configuration's MountPoseRoll parameter and returns itself for method-chaining and easi...
Definition: Configs.hpp:256
double MountPoseYaw
The mounting calibration yaw-component.
Definition: Configs.hpp:184
double MountPosePitch
The mounting calibration pitch-component.
Definition: Configs.hpp:193
MountPoseConfigs & WithMountPosePitch(double newMountPosePitch)
Modifies this configuration's MountPosePitch parameter and returns itself for method-chaining and eas...
Definition: Configs.hpp:237
std::string ToString() const override
Definition: Configs.hpp:264
MountPoseConfigs & WithMountPoseYaw(double newMountPoseYaw)
Modifies this configuration's MountPoseYaw parameter and returns itself for method-chaining and easie...
Definition: Configs.hpp:218
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:286
double MountPoseRoll
The mounting calibration roll-component.
Definition: Configs.hpp:202
std::string Serialize() const override
Definition: Configs.hpp:276
Configs that affect the open-loop control of this motor controller.
Definition: Configs.hpp:1954
OpenLoopRampsConfigs & WithTorqueOpenLoopRampPeriod(double newTorqueOpenLoopRampPeriod)
Modifies this configuration's TorqueOpenLoopRampPeriod parameter and returns itself for method-chaini...
Definition: Configs.hpp:2042
std::string Serialize() const override
Definition: Configs.hpp:2062
OpenLoopRampsConfigs & WithDutyCycleOpenLoopRampPeriod(double newDutyCycleOpenLoopRampPeriod)
Modifies this configuration's DutyCycleOpenLoopRampPeriod parameter and returns itself for method-cha...
Definition: Configs.hpp:2002
double DutyCycleOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0% output to 100% during open-loop modes.
Definition: Configs.hpp:1965
OpenLoopRampsConfigs & WithVoltageOpenLoopRampPeriod(double newVoltageOpenLoopRampPeriod)
Modifies this configuration's VoltageOpenLoopRampPeriod parameter and returns itself for method-chain...
Definition: Configs.hpp:2022
std::string ToString() const override
Definition: Configs.hpp:2050
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:2072
double VoltageOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0V output to 12V during open-loop modes.
Definition: Configs.hpp:1975
double TorqueOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0A output to 300A during open-loop modes.
Definition: Configs.hpp:1985
friend std::ostream & operator<<(std::ostream &str, const ParentConfiguration &v)
Definition: Configs.hpp:31
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:439
bool DisableTemperatureCompensation
Disables using the temperature compensation feature.
Definition: Configs.hpp:455
std::string ToString() const override
Definition: Configs.hpp:516
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:538
Pigeon2FeaturesConfigs & WithDisableNoMotionCalibration(bool newDisableNoMotionCalibration)
Modifies this configuration's DisableNoMotionCalibration parameter and returns itself for method-chai...
Definition: Configs.hpp:508
std::string Serialize() const override
Definition: Configs.hpp:528
bool DisableNoMotionCalibration
Disables using the no-motion calibration feature.
Definition: Configs.hpp:461
Pigeon2FeaturesConfigs & WithEnableCompass(bool newEnableCompass)
Modifies this configuration's EnableCompass parameter and returns itself for method-chaining and easi...
Definition: Configs.hpp:476
bool EnableCompass
Turns on or off the magnetometer fusing for 9-axis.
Definition: Configs.hpp:449
Pigeon2FeaturesConfigs & WithDisableTemperatureCompensation(bool newDisableTemperatureCompensation)
Modifies this configuration's DisableTemperatureCompensation parameter and returns itself for method-...
Definition: Configs.hpp:492
Gains for the specified slot.
Definition: Configs.hpp:3399
Slot0Configs & WithKP(double newKP)
Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:3581
static Slot0Configs From(const SlotConfigs &value)
Slot0Configs & WithKV(double newKV)
Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:3696
signals::StaticFeedforwardSignValue StaticFeedforwardSign
Static Feedforward Sign during position closed loop.
Definition: Configs.hpp:3558
Slot0Configs & WithKD(double newKD)
Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:3638
std::string ToString() const override
Definition: Configs.hpp:3811
signals::GravityTypeValue GravityType
Gravity Feedforward/Feedback Type.
Definition: Configs.hpp:3541
Slot0Configs & WithGravityType(signals::GravityTypeValue newGravityType)
Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier...
Definition: Configs.hpp:3776
double kD
Derivative Gain.
Definition: Configs.hpp:3453
double kG
Gravity Feedforward/Feedback Gain.
Definition: Configs.hpp:3521
double kV
Velocity Feedforward Gain.
Definition: Configs.hpp:3491
double kI
Integral Gain.
Definition: Configs.hpp:3434
Slot0Configs & WithStaticFeedforwardSign(signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining ...
Definition: Configs.hpp:3803
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:3845
Slot0Configs & WithKI(double newKI)
Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:3609
double kA
Acceleration Feedforward Gain.
Definition: Configs.hpp:3507
double kP
Proportional Gain.
Definition: Configs.hpp:3416
Slot0Configs & WithKG(double newKG)
Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:3746
std::string Serialize() const override
Definition: Configs.hpp:3829
Slot0Configs & WithKS(double newKS)
Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:3670
Slot0Configs & WithKA(double newKA)
Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:3722
double kS
Static Feedforward Gain.
Definition: Configs.hpp:3475
Gains for the specified slot.
Definition: Configs.hpp:3870
Slot1Configs & WithKS(double newKS)
Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4141
Slot1Configs & WithKI(double newKI)
Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4080
std::string Serialize() const override
Definition: Configs.hpp:4300
static Slot1Configs From(const SlotConfigs &value)
double kD
Derivative Gain.
Definition: Configs.hpp:3924
double kI
Integral Gain.
Definition: Configs.hpp:3905
double kS
Static Feedforward Gain.
Definition: Configs.hpp:3946
signals::StaticFeedforwardSignValue StaticFeedforwardSign
Static Feedforward Sign during position closed loop.
Definition: Configs.hpp:4029
Slot1Configs & WithGravityType(signals::GravityTypeValue newGravityType)
Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier...
Definition: Configs.hpp:4247
double kA
Acceleration Feedforward Gain.
Definition: Configs.hpp:3978
Slot1Configs & WithKV(double newKV)
Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4167
double kG
Gravity Feedforward/Feedback Gain.
Definition: Configs.hpp:3992
std::string ToString() const override
Definition: Configs.hpp:4282
Slot1Configs & WithKD(double newKD)
Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4109
double kP
Proportional Gain.
Definition: Configs.hpp:3887
signals::GravityTypeValue GravityType
Gravity Feedforward/Feedback Type.
Definition: Configs.hpp:4012
Slot1Configs & WithKG(double newKG)
Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4217
Slot1Configs & WithKP(double newKP)
Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4052
Slot1Configs & WithKA(double newKA)
Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4193
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:4316
Slot1Configs & WithStaticFeedforwardSign(signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining ...
Definition: Configs.hpp:4274
double kV
Velocity Feedforward Gain.
Definition: Configs.hpp:3962
Gains for the specified slot.
Definition: Configs.hpp:4341
double kV
Velocity Feedforward Gain.
Definition: Configs.hpp:4433
std::string Serialize() const override
Definition: Configs.hpp:4771
Slot2Configs & WithKV(double newKV)
Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4638
signals::GravityTypeValue GravityType
Gravity Feedforward/Feedback Type.
Definition: Configs.hpp:4483
double kP
Proportional Gain.
Definition: Configs.hpp:4358
Slot2Configs & WithKD(double newKD)
Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4580
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:4787
double kI
Integral Gain.
Definition: Configs.hpp:4376
Slot2Configs & WithKI(double newKI)
Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4551
double kA
Acceleration Feedforward Gain.
Definition: Configs.hpp:4449
Slot2Configs & WithKA(double newKA)
Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4664
Slot2Configs & WithStaticFeedforwardSign(signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining ...
Definition: Configs.hpp:4745
double kG
Gravity Feedforward/Feedback Gain.
Definition: Configs.hpp:4463
Slot2Configs & WithKP(double newKP)
Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4523
double kS
Static Feedforward Gain.
Definition: Configs.hpp:4417
static Slot2Configs From(const SlotConfigs &value)
Slot2Configs & WithGravityType(signals::GravityTypeValue newGravityType)
Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier...
Definition: Configs.hpp:4718
Slot2Configs & WithKG(double newKG)
Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4688
signals::StaticFeedforwardSignValue StaticFeedforwardSign
Static Feedforward Sign during position closed loop.
Definition: Configs.hpp:4500
std::string ToString() const override
Definition: Configs.hpp:4753
Slot2Configs & WithKS(double newKS)
Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:4612
double kD
Derivative Gain.
Definition: Configs.hpp:4395
Gains for the specified slot.
Definition: Configs.hpp:4811
static SlotConfigs From(const Slot2Configs &value)
std::string ToString() const
Definition: Configs.hpp:5283
double kP
Proportional Gain.
Definition: Configs.hpp:4880
static SlotConfigs From(const Slot1Configs &value)
SlotConfigs & WithKA(double newKA)
Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:5186
SlotConfigs & WithGravityType(signals::GravityTypeValue newGravityType)
Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier...
Definition: Configs.hpp:5240
SlotConfigs & WithKD(double newKD)
Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:5102
double kG
Gravity Feedforward/Feedback Gain.
Definition: Configs.hpp:4985
double kI
Integral Gain.
Definition: Configs.hpp:4898
SlotConfigs & WithKV(double newKV)
Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:5160
double kA
Acceleration Feedforward Gain.
Definition: Configs.hpp:4971
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize)
Definition: Configs.hpp:5318
signals::StaticFeedforwardSignValue StaticFeedforwardSign
Static Feedforward Sign during position closed loop.
Definition: Configs.hpp:5022
SlotConfigs & WithKP(double newKP)
Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:5045
double kD
Derivative Gain.
Definition: Configs.hpp:4917
SlotConfigs & WithKG(double newKG)
Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:5210
int SlotNumber
Chooses which slot these configs are for.
Definition: Configs.hpp:5277
double kV
Velocity Feedforward Gain.
Definition: Configs.hpp:4955
SlotConfigs & WithKS(double newKS)
Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:5134
std::string Serialize() const
Definition: Configs.hpp:5301
static SlotConfigs From(const Slot0Configs &value)
signals::GravityTypeValue GravityType
Gravity Feedforward/Feedback Type.
Definition: Configs.hpp:5005
SlotConfigs & WithKI(double newKI)
Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use c...
Definition: Configs.hpp:5073
SlotConfigs & WithStaticFeedforwardSign(signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining ...
Definition: Configs.hpp:5267
double kS
Static Feedforward Gain.
Definition: Configs.hpp:4939
Configs that affect how software-limit switches behave.
Definition: Configs.hpp:2855
double ForwardSoftLimitThreshold
Position threshold for forward soft limit features.
Definition: Configs.hpp:2880
std::string ToString() const override
Definition: Configs.hpp:2969
double ReverseSoftLimitThreshold
Position threshold for reverse soft limit features.
Definition: Configs.hpp:2890
SoftwareLimitSwitchConfigs & WithForwardSoftLimitEnable(bool newForwardSoftLimitEnable)
Modifies this configuration's ForwardSoftLimitEnable parameter and returns itself for method-chaining...
Definition: Configs.hpp:2904
SoftwareLimitSwitchConfigs & WithForwardSoftLimitThreshold(double newForwardSoftLimitThreshold)
Modifies this configuration's ForwardSoftLimitThreshold parameter and returns itself for method-chain...
Definition: Configs.hpp:2941
SoftwareLimitSwitchConfigs & WithReverseSoftLimitEnable(bool newReverseSoftLimitEnable)
Modifies this configuration's ReverseSoftLimitEnable parameter and returns itself for method-chaining...
Definition: Configs.hpp:2921
std::string Serialize() const override
Definition: Configs.hpp:2982
SoftwareLimitSwitchConfigs & WithReverseSoftLimitThreshold(double newReverseSoftLimitThreshold)
Modifies this configuration's ReverseSoftLimitThreshold parameter and returns itself for method-chain...
Definition: Configs.hpp:2961
bool ReverseSoftLimitEnable
If enabled, the motor output is set to neutral if position exceeds ReverseSoftLimitThreshold and reve...
Definition: Configs.hpp:2870
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:2993
bool ForwardSoftLimitEnable
If enabled, the motor output is set to neutral if position exceeds ForwardSoftLimitThreshold and forw...
Definition: Configs.hpp:2863
Configs that affect Torque Current control types.
Definition: Configs.hpp:1177
std::string ToString() const override
Definition: Configs.hpp:1271
double TorqueNeutralDeadband
Configures the output deadband during torque current based control modes.
Definition: Configs.hpp:1208
TorqueCurrentConfigs & WithTorqueNeutralDeadband(double newTorqueNeutralDeadband)
Modifies this configuration's TorqueNeutralDeadband parameter and returns itself for method-chaining ...
Definition: Configs.hpp:1263
double PeakForwardTorqueCurrent
Maximum (forward) output during torque current based control modes.
Definition: Configs.hpp:1188
TorqueCurrentConfigs & WithPeakForwardTorqueCurrent(double newPeakForwardTorqueCurrent)
Modifies this configuration's PeakForwardTorqueCurrent parameter and returns itself for method-chaini...
Definition: Configs.hpp:1224
TorqueCurrentConfigs & WithPeakReverseTorqueCurrent(double newPeakReverseTorqueCurrent)
Modifies this configuration's PeakReverseTorqueCurrent parameter and returns itself for method-chaini...
Definition: Configs.hpp:1243
std::string Serialize() const override
Definition: Configs.hpp:1283
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1293
double PeakReverseTorqueCurrent
Minimum (reverse) output during torque current based control modes.
Definition: Configs.hpp:1198
Configs that affect Voltage control types.
Definition: Configs.hpp:1035
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:1157
double PeakReverseVoltage
Minimum (reverse) output during voltage based control modes.
Definition: Configs.hpp:1068
std::string Serialize() const override
Definition: Configs.hpp:1147
std::string ToString() const override
Definition: Configs.hpp:1135
double PeakForwardVoltage
Maximum (forward) output during voltage based control modes.
Definition: Configs.hpp:1059
VoltageConfigs & WithPeakForwardVoltage(double newPeakForwardVoltage)
Modifies this configuration's PeakForwardVoltage parameter and returns itself for method-chaining and...
Definition: Configs.hpp:1108
VoltageConfigs & WithSupplyVoltageTimeConstant(double newSupplyVoltageTimeConstant)
Modifies this configuration's SupplyVoltageTimeConstant parameter and returns itself for method-chain...
Definition: Configs.hpp:1089
double SupplyVoltageTimeConstant
The time constant (in seconds) of the low-pass filter for the supply voltage.
Definition: Configs.hpp:1050
VoltageConfigs & WithPeakReverseVoltage(double newPeakReverseVoltage)
Modifies this configuration's PeakReverseVoltage parameter and returns itself for method-chaining and...
Definition: Configs.hpp:1127
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CoreCANcoder.hpp:504
Class description for the Talon FX integrated motor controller.
Definition: CoreTalonFX.hpp:2734
The range of the absolute sensor in rotations, either [-0.5, 0.5) or [0, 1).
Definition: SpnEnums.hpp:750
static constexpr int Signed_PlusMinusHalf
Definition: SpnEnums.hpp:755
Choose what sensor source is used for differential control of a mechanism.
Definition: SpnEnums.hpp:2190
static constexpr int Disabled
Definition: SpnEnums.hpp:2194
Choose what sensor source is reported via API and used by closed-loop and limit features.
Definition: SpnEnums.hpp:1638
int value
Definition: SpnEnums.hpp:1640
static constexpr int RotorSensor
Definition: SpnEnums.hpp:1642
Determines where to poll the forward limit switch.
Definition: SpnEnums.hpp:1793
static constexpr int LimitSwitchPin
Definition: SpnEnums.hpp:1797
int value
Definition: SpnEnums.hpp:1795
Determines if the forward limit switch is normally-open (default) or normally-closed.
Definition: SpnEnums.hpp:1714
static constexpr int NormallyOpen
Definition: SpnEnums.hpp:1718
int value
Definition: SpnEnums.hpp:1716
Gravity Feedforward/Feedback Type.
Definition: SpnEnums.hpp:1406
static constexpr int Elevator_Static
Definition: SpnEnums.hpp:1410
int value
Definition: SpnEnums.hpp:1408
Invert state of the device.
Definition: SpnEnums.hpp:1471
static constexpr int CounterClockwise_Positive
Definition: SpnEnums.hpp:1475
int value
Definition: SpnEnums.hpp:1473
The state of the motor controller bridge when output is neutral or disabled.
Definition: SpnEnums.hpp:1537
int value
Definition: SpnEnums.hpp:1539
static constexpr int Coast
Definition: SpnEnums.hpp:1541
Determines where to poll the reverse limit switch.
Definition: SpnEnums.hpp:1944
int value
Definition: SpnEnums.hpp:1946
static constexpr int LimitSwitchPin
Definition: SpnEnums.hpp:1948
Determines if the reverse limit switch is normally-open (default) or normally-closed.
Definition: SpnEnums.hpp:1865
static constexpr int NormallyOpen
Definition: SpnEnums.hpp:1869
int value
Definition: SpnEnums.hpp:1867
Direction of the sensor to determine positive rotation, as seen facing the LED side of the CANcoder.
Definition: SpnEnums.hpp:246
static constexpr int CounterClockwise_Positive
Definition: SpnEnums.hpp:250
int value
Definition: SpnEnums.hpp:248
Static Feedforward Sign during position closed loop.
Definition: SpnEnums.hpp:2275
static constexpr int UseVelocitySign
Definition: SpnEnums.hpp:2279
Definition: string_util.hpp:15