CTRE Phoenix 6 C++ 25.4.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 "ctre/unit/pid_ff.h"
15#include <units/angle.h>
16#include <units/angular_acceleration.h>
17#include <units/angular_jerk.h>
18#include <units/angular_velocity.h>
19#include <units/current.h>
20#include <units/dimensionless.h>
21#include <units/frequency.h>
22#include <units/length.h>
23#include <units/voltage.h>
24#include <sstream>
25#include <map>
26#include <string>
27
28namespace ctre {
29namespace phoenix6 {
30
31namespace hardware { namespace core { class CoreCANcoder; } }
32namespace hardware { namespace core { class CoreCANdi; } }
33namespace hardware { namespace core { class CoreTalonFX; } }
34namespace hardware { namespace core { class CoreCANrange; } }
35namespace configs { class SlotConfigs; }
36
37namespace configs {
38
40{
41public:
42 virtual std::string ToString() const = 0;
43 friend std::ostream &operator<<(std::ostream &str, const ParentConfiguration &v)
44 {
45 str << v.ToString();
46 return str;
47 }
48 virtual ctre::phoenix::StatusCode Deserialize(const std::string &string) = 0;
49};
50
51
52/**
53 * \brief Configs that affect the magnet sensor and how to interpret
54 * it.
55 *
56 * \details Includes sensor direction, the sensor discontinuity point,
57 * and the magnet offset.
58 */
60{
61public:
62 constexpr MagnetSensorConfigs() = default;
63
64 /**
65 * \brief Direction of the sensor to determine positive rotation, as
66 * seen facing the LED side of the CANcoder.
67 *
68 */
70 /**
71 * \brief This offset is added to the reported position, allowing the
72 * application to trim the zero position. When set to the default
73 * value of zero, position reports zero when magnet north pole aligns
74 * with the LED.
75 *
76 * - Minimum Value: -1
77 * - Maximum Value: 1
78 * - Default Value: 0
79 * - Units: rotations
80 */
81 units::angle::turn_t MagnetOffset = 0_tr;
82 /**
83 * \brief The positive discontinuity point of the absolute sensor in
84 * rotations. This determines the point at which the absolute sensor
85 * wraps around, keeping the absolute position (after offset) in the
86 * range [x-1, x).
87 *
88 * - Setting this to 1 makes the absolute position unsigned [0, 1)
89 * - Setting this to 0.5 makes the absolute position signed [-0.5,
90 * 0.5)
91 * - Setting this to 0 makes the absolute position always negative
92 * [-1, 0)
93 *
94 * Many rotational mechanisms such as arms have a region of motion
95 * that is unreachable. This should be set to the center of that
96 * region of motion, in non-negative rotations. This affects the
97 * position of the device at bootup.
98 *
99 * \details For example, consider an arm which can travel from -0.2 to
100 * 0.6 rotations with a little leeway, where 0 is horizontally
101 * forward. Since -0.2 rotations has the same absolute position as 0.8
102 * rotations, we can say that the arm typically does not travel in the
103 * range (0.6, 0.8) rotations. As a result, the discontinuity point
104 * would be the center of that range, which is 0.7 rotations. This
105 * results in an absolute sensor range of [-0.3, 0.7) rotations.
106 *
107 * Given a total range of motion less than 1 rotation, users can
108 * calculate the discontinuity point using mean(lowerLimit,
109 * upperLimit) + 0.5. If that results in a value outside the range [0,
110 * 1], either cap the value to [0, 1], or add/subtract 1.0 rotation
111 * from your lower and upper limits of motion.
112 *
113 * On a Talon motor controller, this is only supported when using the
114 * PulseWidth sensor source.
115 *
116 * - Minimum Value: 0.0
117 * - Maximum Value: 1.0
118 * - Default Value: 0.5
119 * - Units: rotations
120 */
121 units::angle::turn_t AbsoluteSensorDiscontinuityPoint = 0.5_tr;
122
123 /**
124 * \brief Modifies this configuration's SensorDirection parameter and returns itself for
125 * method-chaining and easier to use config API.
126 *
127 * Direction of the sensor to determine positive rotation, as seen
128 * facing the LED side of the CANcoder.
129 *
130 *
131 * \param newSensorDirection Parameter to modify
132 * \returns Itself
133 */
135 {
136 SensorDirection = std::move(newSensorDirection);
137 return *this;
138 }
139
140 /**
141 * \brief Modifies this configuration's MagnetOffset parameter and returns itself for
142 * method-chaining and easier to use config API.
143 *
144 * This offset is added to the reported position, allowing the
145 * application to trim the zero position. When set to the default
146 * value of zero, position reports zero when magnet north pole aligns
147 * with the LED.
148 *
149 * - Minimum Value: -1
150 * - Maximum Value: 1
151 * - Default Value: 0
152 * - Units: rotations
153 *
154 * \param newMagnetOffset Parameter to modify
155 * \returns Itself
156 */
157 constexpr MagnetSensorConfigs &WithMagnetOffset(units::angle::turn_t newMagnetOffset)
158 {
159 MagnetOffset = std::move(newMagnetOffset);
160 return *this;
161 }
162
163 /**
164 * \brief Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for
165 * method-chaining and easier to use config API.
166 *
167 * The positive discontinuity point of the absolute sensor in
168 * rotations. This determines the point at which the absolute sensor
169 * wraps around, keeping the absolute position (after offset) in the
170 * range [x-1, x).
171 *
172 * - Setting this to 1 makes the absolute position unsigned [0, 1)
173 * - Setting this to 0.5 makes the absolute position signed [-0.5,
174 * 0.5)
175 * - Setting this to 0 makes the absolute position always negative
176 * [-1, 0)
177 *
178 * Many rotational mechanisms such as arms have a region of motion
179 * that is unreachable. This should be set to the center of that
180 * region of motion, in non-negative rotations. This affects the
181 * position of the device at bootup.
182 *
183 * \details For example, consider an arm which can travel from -0.2 to
184 * 0.6 rotations with a little leeway, where 0 is horizontally
185 * forward. Since -0.2 rotations has the same absolute position as 0.8
186 * rotations, we can say that the arm typically does not travel in the
187 * range (0.6, 0.8) rotations. As a result, the discontinuity point
188 * would be the center of that range, which is 0.7 rotations. This
189 * results in an absolute sensor range of [-0.3, 0.7) rotations.
190 *
191 * Given a total range of motion less than 1 rotation, users can
192 * calculate the discontinuity point using mean(lowerLimit,
193 * upperLimit) + 0.5. If that results in a value outside the range [0,
194 * 1], either cap the value to [0, 1], or add/subtract 1.0 rotation
195 * from your lower and upper limits of motion.
196 *
197 * On a Talon motor controller, this is only supported when using the
198 * PulseWidth sensor source.
199 *
200 * - Minimum Value: 0.0
201 * - Maximum Value: 1.0
202 * - Default Value: 0.5
203 * - Units: rotations
204 *
205 * \param newAbsoluteSensorDiscontinuityPoint Parameter to modify
206 * \returns Itself
207 */
208 constexpr MagnetSensorConfigs &WithAbsoluteSensorDiscontinuityPoint(units::angle::turn_t newAbsoluteSensorDiscontinuityPoint)
209 {
210 AbsoluteSensorDiscontinuityPoint = std::move(newAbsoluteSensorDiscontinuityPoint);
211 return *this;
212 }
213
214
215
216 std::string ToString() const override
217 {
218 std::stringstream ss;
219 ss << "Config Group: MagnetSensor" << std::endl;
220 ss << " SensorDirection: " << SensorDirection << std::endl;
221 ss << " MagnetOffset: " << MagnetOffset.to<double>() << " rotations" << std::endl;
222 ss << " AbsoluteSensorDiscontinuityPoint: " << AbsoluteSensorDiscontinuityPoint.to<double>() << " rotations" << std::endl;
223 return ss.str();
224 }
225
226 std::string Serialize() const override
227 {
228 std::stringstream ss;
229 char *ref;
230 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CANcoder_SensorDirection, SensorDirection.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
231 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANCoder_MagnetOffset, MagnetOffset.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
232 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_AbsoluteSensorDiscontinuityPoint, AbsoluteSensorDiscontinuityPoint.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
233 return ss.str();
234 }
235
236 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
237 {
238 const char *string_c_str = to_deserialize.c_str();
239 size_t string_length = to_deserialize.length();
240 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CANcoder_SensorDirection, string_c_str, string_length, &SensorDirection.value);
241 double MagnetOffsetVal = MagnetOffset.to<double>();
242 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANCoder_MagnetOffset, string_c_str, string_length, &MagnetOffsetVal);
243 MagnetOffset = units::angle::turn_t{MagnetOffsetVal};
244 double AbsoluteSensorDiscontinuityPointVal = AbsoluteSensorDiscontinuityPoint.to<double>();
245 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_AbsoluteSensorDiscontinuityPoint, string_c_str, string_length, &AbsoluteSensorDiscontinuityPointVal);
246 AbsoluteSensorDiscontinuityPoint = units::angle::turn_t{AbsoluteSensorDiscontinuityPointVal};
247 return 0;
248 }
249};
250
251
252/**
253 * \brief Configs for Pigeon 2's Mount Pose configuration.
254 *
255 * \details These configs allow the Pigeon2 to be mounted in whatever
256 * orientation that's desired and ensure the reported
257 * Yaw/Pitch/Roll is from the robot's reference.
258 */
260{
261public:
262 constexpr MountPoseConfigs() = default;
263
264 /**
265 * \brief The mounting calibration yaw-component.
266 *
267 * - Minimum Value: -360
268 * - Maximum Value: 360
269 * - Default Value: 0
270 * - Units: deg
271 */
272 units::angle::degree_t MountPoseYaw = 0_deg;
273 /**
274 * \brief The mounting calibration pitch-component.
275 *
276 * - Minimum Value: -360
277 * - Maximum Value: 360
278 * - Default Value: 0
279 * - Units: deg
280 */
281 units::angle::degree_t MountPosePitch = 0_deg;
282 /**
283 * \brief The mounting calibration roll-component.
284 *
285 * - Minimum Value: -360
286 * - Maximum Value: 360
287 * - Default Value: 0
288 * - Units: deg
289 */
290 units::angle::degree_t MountPoseRoll = 0_deg;
291
292 /**
293 * \brief Modifies this configuration's MountPoseYaw parameter and returns itself for
294 * method-chaining and easier to use config API.
295 *
296 * The mounting calibration yaw-component.
297 *
298 * - Minimum Value: -360
299 * - Maximum Value: 360
300 * - Default Value: 0
301 * - Units: deg
302 *
303 * \param newMountPoseYaw Parameter to modify
304 * \returns Itself
305 */
306 constexpr MountPoseConfigs &WithMountPoseYaw(units::angle::degree_t newMountPoseYaw)
307 {
308 MountPoseYaw = std::move(newMountPoseYaw);
309 return *this;
310 }
311
312 /**
313 * \brief Modifies this configuration's MountPosePitch parameter and returns itself for
314 * method-chaining and easier to use config API.
315 *
316 * The mounting calibration pitch-component.
317 *
318 * - Minimum Value: -360
319 * - Maximum Value: 360
320 * - Default Value: 0
321 * - Units: deg
322 *
323 * \param newMountPosePitch Parameter to modify
324 * \returns Itself
325 */
326 constexpr MountPoseConfigs &WithMountPosePitch(units::angle::degree_t newMountPosePitch)
327 {
328 MountPosePitch = std::move(newMountPosePitch);
329 return *this;
330 }
331
332 /**
333 * \brief Modifies this configuration's MountPoseRoll parameter and returns itself for
334 * method-chaining and easier to use config API.
335 *
336 * The mounting calibration roll-component.
337 *
338 * - Minimum Value: -360
339 * - Maximum Value: 360
340 * - Default Value: 0
341 * - Units: deg
342 *
343 * \param newMountPoseRoll Parameter to modify
344 * \returns Itself
345 */
346 constexpr MountPoseConfigs &WithMountPoseRoll(units::angle::degree_t newMountPoseRoll)
347 {
348 MountPoseRoll = std::move(newMountPoseRoll);
349 return *this;
350 }
351
352
353
354 std::string ToString() const override
355 {
356 std::stringstream ss;
357 ss << "Config Group: MountPose" << std::endl;
358 ss << " MountPoseYaw: " << MountPoseYaw.to<double>() << " deg" << std::endl;
359 ss << " MountPosePitch: " << MountPosePitch.to<double>() << " deg" << std::endl;
360 ss << " MountPoseRoll: " << MountPoseRoll.to<double>() << " deg" << std::endl;
361 return ss.str();
362 }
363
364 std::string Serialize() const override
365 {
366 std::stringstream ss;
367 char *ref;
368 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseYaw, MountPoseYaw.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
369 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPosePitch, MountPosePitch.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
370 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseRoll, MountPoseRoll.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
371 return ss.str();
372 }
373
374 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
375 {
376 const char *string_c_str = to_deserialize.c_str();
377 size_t string_length = to_deserialize.length();
378 double MountPoseYawVal = MountPoseYaw.to<double>();
379 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseYaw, string_c_str, string_length, &MountPoseYawVal);
380 MountPoseYaw = units::angle::degree_t{MountPoseYawVal};
381 double MountPosePitchVal = MountPosePitch.to<double>();
382 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPosePitch, string_c_str, string_length, &MountPosePitchVal);
383 MountPosePitch = units::angle::degree_t{MountPosePitchVal};
384 double MountPoseRollVal = MountPoseRoll.to<double>();
385 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2MountPoseRoll, string_c_str, string_length, &MountPoseRollVal);
386 MountPoseRoll = units::angle::degree_t{MountPoseRollVal};
387 return 0;
388 }
389};
390
391
392/**
393 * \brief Configs to trim the Pigeon2's gyroscope.
394 *
395 * \details Pigeon2 allows the user to trim the gyroscope's
396 * sensitivity. While this isn't necessary for the Pigeon2,
397 * as it comes calibrated out-of-the-box, users can make use
398 * of this to make the Pigeon2 even more accurate for their
399 * application.
400 */
402{
403public:
404 constexpr GyroTrimConfigs() = default;
405
406 /**
407 * \brief The gyro scalar component for the X axis.
408 *
409 * - Minimum Value: -180
410 * - Maximum Value: 180
411 * - Default Value: 0
412 * - Units: deg per rotation
413 */
414 units::dimensionless::scalar_t GyroScalarX = 0;
415 /**
416 * \brief The gyro scalar component for the Y axis.
417 *
418 * - Minimum Value: -180
419 * - Maximum Value: 180
420 * - Default Value: 0
421 * - Units: deg per rotation
422 */
423 units::dimensionless::scalar_t GyroScalarY = 0;
424 /**
425 * \brief The gyro scalar component for the Z axis.
426 *
427 * - Minimum Value: -180
428 * - Maximum Value: 180
429 * - Default Value: 0
430 * - Units: deg per rotation
431 */
432 units::dimensionless::scalar_t GyroScalarZ = 0;
433
434 /**
435 * \brief Modifies this configuration's GyroScalarX parameter and returns itself for
436 * method-chaining and easier to use config API.
437 *
438 * The gyro scalar component for the X axis.
439 *
440 * - Minimum Value: -180
441 * - Maximum Value: 180
442 * - Default Value: 0
443 * - Units: deg per rotation
444 *
445 * \param newGyroScalarX Parameter to modify
446 * \returns Itself
447 */
448 constexpr GyroTrimConfigs &WithGyroScalarX(units::dimensionless::scalar_t newGyroScalarX)
449 {
450 GyroScalarX = std::move(newGyroScalarX);
451 return *this;
452 }
453
454 /**
455 * \brief Modifies this configuration's GyroScalarY parameter and returns itself for
456 * method-chaining and easier to use config API.
457 *
458 * The gyro scalar component for the Y axis.
459 *
460 * - Minimum Value: -180
461 * - Maximum Value: 180
462 * - Default Value: 0
463 * - Units: deg per rotation
464 *
465 * \param newGyroScalarY Parameter to modify
466 * \returns Itself
467 */
468 constexpr GyroTrimConfigs &WithGyroScalarY(units::dimensionless::scalar_t newGyroScalarY)
469 {
470 GyroScalarY = std::move(newGyroScalarY);
471 return *this;
472 }
473
474 /**
475 * \brief Modifies this configuration's GyroScalarZ parameter and returns itself for
476 * method-chaining and easier to use config API.
477 *
478 * The gyro scalar component for the Z axis.
479 *
480 * - Minimum Value: -180
481 * - Maximum Value: 180
482 * - Default Value: 0
483 * - Units: deg per rotation
484 *
485 * \param newGyroScalarZ Parameter to modify
486 * \returns Itself
487 */
488 constexpr GyroTrimConfigs &WithGyroScalarZ(units::dimensionless::scalar_t newGyroScalarZ)
489 {
490 GyroScalarZ = std::move(newGyroScalarZ);
491 return *this;
492 }
493
494
495
496 std::string ToString() const override
497 {
498 std::stringstream ss;
499 ss << "Config Group: GyroTrim" << std::endl;
500 ss << " GyroScalarX: " << GyroScalarX.to<double>() << " deg per rotation" << std::endl;
501 ss << " GyroScalarY: " << GyroScalarY.to<double>() << " deg per rotation" << std::endl;
502 ss << " GyroScalarZ: " << GyroScalarZ.to<double>() << " deg per rotation" << std::endl;
503 return ss.str();
504 }
505
506 std::string Serialize() const override
507 {
508 std::stringstream ss;
509 char *ref;
510 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarX, GyroScalarX.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
511 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarY, GyroScalarY.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
512 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarZ, GyroScalarZ.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
513 return ss.str();
514 }
515
516 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
517 {
518 const char *string_c_str = to_deserialize.c_str();
519 size_t string_length = to_deserialize.length();
520 double GyroScalarXVal = GyroScalarX.to<double>();
521 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarX, string_c_str, string_length, &GyroScalarXVal);
522 GyroScalarX = units::dimensionless::scalar_t{GyroScalarXVal};
523 double GyroScalarYVal = GyroScalarY.to<double>();
524 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarY, string_c_str, string_length, &GyroScalarYVal);
525 GyroScalarY = units::dimensionless::scalar_t{GyroScalarYVal};
526 double GyroScalarZVal = GyroScalarZ.to<double>();
527 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Pigeon2GyroScalarZ, string_c_str, string_length, &GyroScalarZVal);
528 GyroScalarZ = units::dimensionless::scalar_t{GyroScalarZVal};
529 return 0;
530 }
531};
532
533
534/**
535 * \brief Configs to enable/disable various features of the Pigeon2.
536 *
537 * \details These configs allow the user to enable or disable various
538 * aspects of the Pigeon2.
539 */
541{
542public:
543 constexpr Pigeon2FeaturesConfigs() = default;
544
545 /**
546 * \brief Turns on or off the magnetometer fusing for 9-axis. FRC
547 * users are not recommended to turn this on, as the magnetic
548 * influence of the robot will likely negatively affect the
549 * performance of the Pigeon2.
550 *
551 * - Default Value: False
552 */
553 bool EnableCompass = false;
554 /**
555 * \brief Disables using the temperature compensation feature.
556 *
557 * - Default Value: False
558 */
560 /**
561 * \brief Disables using the no-motion calibration feature.
562 *
563 * - Default Value: False
564 */
566
567 /**
568 * \brief Modifies this configuration's EnableCompass parameter and returns itself for
569 * method-chaining and easier to use config API.
570 *
571 * Turns on or off the magnetometer fusing for 9-axis. FRC users are
572 * not recommended to turn this on, as the magnetic influence of the
573 * robot will likely negatively affect the performance of the Pigeon2.
574 *
575 * - Default Value: False
576 *
577 * \param newEnableCompass Parameter to modify
578 * \returns Itself
579 */
580 constexpr Pigeon2FeaturesConfigs &WithEnableCompass(bool newEnableCompass)
581 {
582 EnableCompass = std::move(newEnableCompass);
583 return *this;
584 }
585
586 /**
587 * \brief Modifies this configuration's DisableTemperatureCompensation parameter and returns itself for
588 * method-chaining and easier to use config API.
589 *
590 * Disables using the temperature compensation feature.
591 *
592 * - Default Value: False
593 *
594 * \param newDisableTemperatureCompensation Parameter to modify
595 * \returns Itself
596 */
597 constexpr Pigeon2FeaturesConfigs &WithDisableTemperatureCompensation(bool newDisableTemperatureCompensation)
598 {
599 DisableTemperatureCompensation = std::move(newDisableTemperatureCompensation);
600 return *this;
601 }
602
603 /**
604 * \brief Modifies this configuration's DisableNoMotionCalibration parameter and returns itself for
605 * method-chaining and easier to use config API.
606 *
607 * Disables using the no-motion calibration feature.
608 *
609 * - Default Value: False
610 *
611 * \param newDisableNoMotionCalibration Parameter to modify
612 * \returns Itself
613 */
614 constexpr Pigeon2FeaturesConfigs &WithDisableNoMotionCalibration(bool newDisableNoMotionCalibration)
615 {
616 DisableNoMotionCalibration = std::move(newDisableNoMotionCalibration);
617 return *this;
618 }
619
620
621
622 std::string ToString() const override
623 {
624 std::stringstream ss;
625 ss << "Config Group: Pigeon2Features" << std::endl;
626 ss << " EnableCompass: " << EnableCompass << std::endl;
627 ss << " DisableTemperatureCompensation: " << DisableTemperatureCompensation << std::endl;
628 ss << " DisableNoMotionCalibration: " << DisableNoMotionCalibration << std::endl;
629 return ss.str();
630 }
631
632 std::string Serialize() const override
633 {
634 std::stringstream ss;
635 char *ref;
636 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2UseCompass, EnableCompass, &ref); if (ref != nullptr) { ss << ref; free(ref); }
637 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableTemperatureCompensation, DisableTemperatureCompensation, &ref); if (ref != nullptr) { ss << ref; free(ref); }
638 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableNoMotionCalibration, DisableNoMotionCalibration, &ref); if (ref != nullptr) { ss << ref; free(ref); }
639 return ss.str();
640 }
641
642 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
643 {
644 const char *string_c_str = to_deserialize.c_str();
645 size_t string_length = to_deserialize.length();
646 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2UseCompass, string_c_str, string_length, &EnableCompass);
647 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableTemperatureCompensation, string_c_str, string_length, &DisableTemperatureCompensation);
648 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Pigeon2DisableNoMotionCalibration, string_c_str, string_length, &DisableNoMotionCalibration);
649 return 0;
650 }
651};
652
653
654/**
655 * \brief Configs that directly affect motor output.
656 *
657 * \details Includes motor invert, neutral mode, and other features
658 * related to motor output.
659 */
661{
662public:
663 constexpr MotorOutputConfigs() = default;
664
665 /**
666 * \brief Invert state of the device as seen from the front of the
667 * motor.
668 *
669 */
671 /**
672 * \brief The state of the motor controller bridge when output is
673 * neutral or disabled.
674 *
675 */
677 /**
678 * \brief Configures the output deadband duty cycle during duty cycle
679 * and voltage based control modes.
680 *
681 * - Minimum Value: 0.0
682 * - Maximum Value: 0.25
683 * - Default Value: 0
684 * - Units: fractional
685 */
686 units::dimensionless::scalar_t DutyCycleNeutralDeadband = 0;
687 /**
688 * \brief Maximum (forward) output during duty cycle based control
689 * modes.
690 *
691 * - Minimum Value: -1.0
692 * - Maximum Value: 1.0
693 * - Default Value: 1
694 * - Units: fractional
695 */
696 units::dimensionless::scalar_t PeakForwardDutyCycle = 1;
697 /**
698 * \brief Minimum (reverse) output during duty cycle based control
699 * modes.
700 *
701 * - Minimum Value: -1.0
702 * - Maximum Value: 1.0
703 * - Default Value: -1
704 * - Units: fractional
705 */
706 units::dimensionless::scalar_t PeakReverseDutyCycle = -1;
707 /**
708 * \brief When a control request UseTimesync is enabled, this
709 * determines the time-sychronized frequency at which control requests
710 * are applied.
711 *
712 * \details The application of the control request will be delayed
713 * until the next timesync boundary at the frequency defined by this
714 * config. When set to 0 Hz, timesync will never be used for control
715 * requests, regardless of the value of UseTimesync.
716 *
717 * - Minimum Value: 50
718 * - Maximum Value: 500
719 * - Default Value: 0
720 * - Units: Hz
721 */
722 units::frequency::hertz_t ControlTimesyncFreqHz = 0_Hz;
723
724 /**
725 * \brief Modifies this configuration's Inverted parameter and returns itself for
726 * method-chaining and easier to use config API.
727 *
728 * Invert state of the device as seen from the front of the motor.
729 *
730 *
731 * \param newInverted Parameter to modify
732 * \returns Itself
733 */
735 {
736 Inverted = std::move(newInverted);
737 return *this;
738 }
739
740 /**
741 * \brief Modifies this configuration's NeutralMode parameter and returns itself for
742 * method-chaining and easier to use config API.
743 *
744 * The state of the motor controller bridge when output is neutral or
745 * disabled.
746 *
747 *
748 * \param newNeutralMode Parameter to modify
749 * \returns Itself
750 */
752 {
753 NeutralMode = std::move(newNeutralMode);
754 return *this;
755 }
756
757 /**
758 * \brief Modifies this configuration's DutyCycleNeutralDeadband parameter and returns itself for
759 * method-chaining and easier to use config API.
760 *
761 * Configures the output deadband duty cycle during duty cycle and
762 * voltage based control modes.
763 *
764 * - Minimum Value: 0.0
765 * - Maximum Value: 0.25
766 * - Default Value: 0
767 * - Units: fractional
768 *
769 * \param newDutyCycleNeutralDeadband Parameter to modify
770 * \returns Itself
771 */
772 constexpr MotorOutputConfigs &WithDutyCycleNeutralDeadband(units::dimensionless::scalar_t newDutyCycleNeutralDeadband)
773 {
774 DutyCycleNeutralDeadband = std::move(newDutyCycleNeutralDeadband);
775 return *this;
776 }
777
778 /**
779 * \brief Modifies this configuration's PeakForwardDutyCycle parameter and returns itself for
780 * method-chaining and easier to use config API.
781 *
782 * Maximum (forward) output during duty cycle based control modes.
783 *
784 * - Minimum Value: -1.0
785 * - Maximum Value: 1.0
786 * - Default Value: 1
787 * - Units: fractional
788 *
789 * \param newPeakForwardDutyCycle Parameter to modify
790 * \returns Itself
791 */
792 constexpr MotorOutputConfigs &WithPeakForwardDutyCycle(units::dimensionless::scalar_t newPeakForwardDutyCycle)
793 {
794 PeakForwardDutyCycle = std::move(newPeakForwardDutyCycle);
795 return *this;
796 }
797
798 /**
799 * \brief Modifies this configuration's PeakReverseDutyCycle parameter and returns itself for
800 * method-chaining and easier to use config API.
801 *
802 * Minimum (reverse) output during duty cycle based control modes.
803 *
804 * - Minimum Value: -1.0
805 * - Maximum Value: 1.0
806 * - Default Value: -1
807 * - Units: fractional
808 *
809 * \param newPeakReverseDutyCycle Parameter to modify
810 * \returns Itself
811 */
812 constexpr MotorOutputConfigs &WithPeakReverseDutyCycle(units::dimensionless::scalar_t newPeakReverseDutyCycle)
813 {
814 PeakReverseDutyCycle = std::move(newPeakReverseDutyCycle);
815 return *this;
816 }
817
818 /**
819 * \brief Modifies this configuration's ControlTimesyncFreqHz parameter and returns itself for
820 * method-chaining and easier to use config API.
821 *
822 * When a control request UseTimesync is enabled, this determines the
823 * time-sychronized frequency at which control requests are applied.
824 *
825 * \details The application of the control request will be delayed
826 * until the next timesync boundary at the frequency defined by this
827 * config. When set to 0 Hz, timesync will never be used for control
828 * requests, regardless of the value of UseTimesync.
829 *
830 * - Minimum Value: 50
831 * - Maximum Value: 500
832 * - Default Value: 0
833 * - Units: Hz
834 *
835 * \param newControlTimesyncFreqHz Parameter to modify
836 * \returns Itself
837 */
838 constexpr MotorOutputConfigs &WithControlTimesyncFreqHz(units::frequency::hertz_t newControlTimesyncFreqHz)
839 {
840 ControlTimesyncFreqHz = std::move(newControlTimesyncFreqHz);
841 return *this;
842 }
843
844
845
846 std::string ToString() const override
847 {
848 std::stringstream ss;
849 ss << "Config Group: MotorOutput" << std::endl;
850 ss << " Inverted: " << Inverted << std::endl;
851 ss << " NeutralMode: " << NeutralMode << std::endl;
852 ss << " DutyCycleNeutralDeadband: " << DutyCycleNeutralDeadband.to<double>() << " fractional" << std::endl;
853 ss << " PeakForwardDutyCycle: " << PeakForwardDutyCycle.to<double>() << " fractional" << std::endl;
854 ss << " PeakReverseDutyCycle: " << PeakReverseDutyCycle.to<double>() << " fractional" << std::endl;
855 ss << " ControlTimesyncFreqHz: " << ControlTimesyncFreqHz.to<double>() << " Hz" << std::endl;
856 return ss.str();
857 }
858
859 std::string Serialize() const override
860 {
861 std::stringstream ss;
862 char *ref;
863 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_Inverted, Inverted.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
864 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_NeutralMode, NeutralMode.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
865 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleNeutralDB, DutyCycleNeutralDeadband.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
866 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardDC, PeakForwardDutyCycle.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
867 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseDC, PeakReverseDutyCycle.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
868 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ControlTimesyncFreq, ControlTimesyncFreqHz.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
869 return ss.str();
870 }
871
872 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
873 {
874 const char *string_c_str = to_deserialize.c_str();
875 size_t string_length = to_deserialize.length();
876 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_Inverted, string_c_str, string_length, &Inverted.value);
877 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_NeutralMode, string_c_str, string_length, &NeutralMode.value);
878 double DutyCycleNeutralDeadbandVal = DutyCycleNeutralDeadband.to<double>();
879 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleNeutralDB, string_c_str, string_length, &DutyCycleNeutralDeadbandVal);
880 DutyCycleNeutralDeadband = units::dimensionless::scalar_t{DutyCycleNeutralDeadbandVal};
881 double PeakForwardDutyCycleVal = PeakForwardDutyCycle.to<double>();
882 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardDC, string_c_str, string_length, &PeakForwardDutyCycleVal);
883 PeakForwardDutyCycle = units::dimensionless::scalar_t{PeakForwardDutyCycleVal};
884 double PeakReverseDutyCycleVal = PeakReverseDutyCycle.to<double>();
885 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseDC, string_c_str, string_length, &PeakReverseDutyCycleVal);
886 PeakReverseDutyCycle = units::dimensionless::scalar_t{PeakReverseDutyCycleVal};
887 double ControlTimesyncFreqHzVal = ControlTimesyncFreqHz.to<double>();
888 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ControlTimesyncFreq, string_c_str, string_length, &ControlTimesyncFreqHzVal);
889 ControlTimesyncFreqHz = units::frequency::hertz_t{ControlTimesyncFreqHzVal};
890 return 0;
891 }
892};
893
894
895/**
896 * \brief Configs that directly affect current limiting features.
897 *
898 * \details Contains the supply/stator current limit thresholds and
899 * whether to enable them.
900 */
902{
903public:
904 constexpr CurrentLimitsConfigs() = default;
905
906 /**
907 * \brief The amount of current allowed in the motor (motoring and
908 * regen current). Note this requires StatorCurrentLimitEnable to be
909 * true.
910 *
911 * For torque current control, this is applied in addition to the
912 * PeakForwardTorqueCurrent and PeakReverseTorqueCurrent in
913 * TorqueCurrentConfigs.
914 *
915 * Stator current is directly proportional to torque, so this limit
916 * can be used to restrict the torque output of the motor, such as
917 * preventing wheel slip for a drivetrain. Additionally, stator
918 * current limits can prevent brownouts during acceleration; supply
919 * current will never exceed the stator current limit and is often
920 * significantly lower than stator current.
921 *
922 * A reasonable starting point for a stator current limit is 120 A,
923 * with values commonly ranging from 80-160 A. Mechanisms with a hard
924 * stop may need a smaller limit to reduce the torque applied when
925 * running into the hard stop.
926 *
927 * - Minimum Value: 0.0
928 * - Maximum Value: 800.0
929 * - Default Value: 120
930 * - Units: A
931 */
932 units::current::ampere_t StatorCurrentLimit = 120_A;
933 /**
934 * \brief Enable motor stator current limiting.
935 *
936 * - Default Value: True
937 */
939 /**
940 * \brief The absolute maximum amount of supply current allowed. Note
941 * this requires SupplyCurrentLimitEnable to be true. Use
942 * SupplyCurrentLowerLimit and SupplyCurrentLowerTime to reduce the
943 * supply current limit after the time threshold is exceeded.
944 *
945 * Supply current is the current drawn from the battery, so this limit
946 * can be used to prevent breaker trips and improve battery longevity.
947 * Additionally, in scenarios where the robot experiences brownouts
948 * despite configuring stator current limits, a supply current limit
949 * can further help avoid brownouts. However, it is important to note
950 * that such brownouts may be caused by a bad battery or poor power
951 * wiring.
952 *
953 * A reasonable starting point for a supply current limit is 70 A with
954 * a lower limit of 40 A after 1.0 second. Supply current limits
955 * commonly range from 20-80 A depending on the breaker used.
956 *
957 * - Minimum Value: 0.0
958 * - Maximum Value: 800.0
959 * - Default Value: 70
960 * - Units: A
961 */
962 units::current::ampere_t SupplyCurrentLimit = 70_A;
963 /**
964 * \brief Enable motor supply current limiting.
965 *
966 * - Default Value: True
967 */
969 /**
970 * \brief The amount of supply current allowed after the regular
971 * SupplyCurrentLimit is active for longer than
972 * SupplyCurrentLowerTime. This allows higher current draws for a
973 * fixed period of time before reducing the current limit to protect
974 * breakers. This has no effect if SupplyCurrentLimit is lower than
975 * this value or SupplyCurrentLowerTime is 0.
976 *
977 * - Minimum Value: 0.0
978 * - Maximum Value: 500
979 * - Default Value: 40
980 * - Units: A
981 */
982 units::current::ampere_t SupplyCurrentLowerLimit = 40_A;
983 /**
984 * \brief Reduces supply current to the SupplyCurrentLowerLimit after
985 * limiting to SupplyCurrentLimit for this period of time. If this is
986 * set to 0, SupplyCurrentLowerLimit will be ignored.
987 *
988 * - Minimum Value: 0.0
989 * - Maximum Value: 2.5
990 * - Default Value: 1.0
991 * - Units: seconds
992 */
993 units::time::second_t SupplyCurrentLowerTime = 1.0_s;
994
995 /**
996 * \brief Modifies this configuration's StatorCurrentLimit parameter and returns itself for
997 * method-chaining and easier to use config API.
998 *
999 * The amount of current allowed in the motor (motoring and regen
1000 * current). Note this requires StatorCurrentLimitEnable to be true.
1001 *
1002 * For torque current control, this is applied in addition to the
1003 * PeakForwardTorqueCurrent and PeakReverseTorqueCurrent in
1004 * TorqueCurrentConfigs.
1005 *
1006 * Stator current is directly proportional to torque, so this limit
1007 * can be used to restrict the torque output of the motor, such as
1008 * preventing wheel slip for a drivetrain. Additionally, stator
1009 * current limits can prevent brownouts during acceleration; supply
1010 * current will never exceed the stator current limit and is often
1011 * significantly lower than stator current.
1012 *
1013 * A reasonable starting point for a stator current limit is 120 A,
1014 * with values commonly ranging from 80-160 A. Mechanisms with a hard
1015 * stop may need a smaller limit to reduce the torque applied when
1016 * running into the hard stop.
1017 *
1018 * - Minimum Value: 0.0
1019 * - Maximum Value: 800.0
1020 * - Default Value: 120
1021 * - Units: A
1022 *
1023 * \param newStatorCurrentLimit Parameter to modify
1024 * \returns Itself
1025 */
1026 constexpr CurrentLimitsConfigs &WithStatorCurrentLimit(units::current::ampere_t newStatorCurrentLimit)
1027 {
1028 StatorCurrentLimit = std::move(newStatorCurrentLimit);
1029 return *this;
1030 }
1031
1032 /**
1033 * \brief Modifies this configuration's StatorCurrentLimitEnable parameter and returns itself for
1034 * method-chaining and easier to use config API.
1035 *
1036 * Enable motor stator current limiting.
1037 *
1038 * - Default Value: True
1039 *
1040 * \param newStatorCurrentLimitEnable Parameter to modify
1041 * \returns Itself
1042 */
1043 constexpr CurrentLimitsConfigs &WithStatorCurrentLimitEnable(bool newStatorCurrentLimitEnable)
1044 {
1045 StatorCurrentLimitEnable = std::move(newStatorCurrentLimitEnable);
1046 return *this;
1047 }
1048
1049 /**
1050 * \brief Modifies this configuration's SupplyCurrentLimit parameter and returns itself for
1051 * method-chaining and easier to use config API.
1052 *
1053 * The absolute maximum amount of supply current allowed. Note this
1054 * requires SupplyCurrentLimitEnable to be true. Use
1055 * SupplyCurrentLowerLimit and SupplyCurrentLowerTime to reduce the
1056 * supply current limit after the time threshold is exceeded.
1057 *
1058 * Supply current is the current drawn from the battery, so this limit
1059 * can be used to prevent breaker trips and improve battery longevity.
1060 * Additionally, in scenarios where the robot experiences brownouts
1061 * despite configuring stator current limits, a supply current limit
1062 * can further help avoid brownouts. However, it is important to note
1063 * that such brownouts may be caused by a bad battery or poor power
1064 * wiring.
1065 *
1066 * A reasonable starting point for a supply current limit is 70 A with
1067 * a lower limit of 40 A after 1.0 second. Supply current limits
1068 * commonly range from 20-80 A depending on the breaker used.
1069 *
1070 * - Minimum Value: 0.0
1071 * - Maximum Value: 800.0
1072 * - Default Value: 70
1073 * - Units: A
1074 *
1075 * \param newSupplyCurrentLimit Parameter to modify
1076 * \returns Itself
1077 */
1078 constexpr CurrentLimitsConfigs &WithSupplyCurrentLimit(units::current::ampere_t newSupplyCurrentLimit)
1079 {
1080 SupplyCurrentLimit = std::move(newSupplyCurrentLimit);
1081 return *this;
1082 }
1083
1084 /**
1085 * \brief Modifies this configuration's SupplyCurrentLimitEnable parameter and returns itself for
1086 * method-chaining and easier to use config API.
1087 *
1088 * Enable motor supply current limiting.
1089 *
1090 * - Default Value: True
1091 *
1092 * \param newSupplyCurrentLimitEnable Parameter to modify
1093 * \returns Itself
1094 */
1095 constexpr CurrentLimitsConfigs &WithSupplyCurrentLimitEnable(bool newSupplyCurrentLimitEnable)
1096 {
1097 SupplyCurrentLimitEnable = std::move(newSupplyCurrentLimitEnable);
1098 return *this;
1099 }
1100
1101 /**
1102 * \brief Modifies this configuration's SupplyCurrentLowerLimit parameter and returns itself for
1103 * method-chaining and easier to use config API.
1104 *
1105 * The amount of supply current allowed after the regular
1106 * SupplyCurrentLimit is active for longer than
1107 * SupplyCurrentLowerTime. This allows higher current draws for a
1108 * fixed period of time before reducing the current limit to protect
1109 * breakers. This has no effect if SupplyCurrentLimit is lower than
1110 * this value or SupplyCurrentLowerTime is 0.
1111 *
1112 * - Minimum Value: 0.0
1113 * - Maximum Value: 500
1114 * - Default Value: 40
1115 * - Units: A
1116 *
1117 * \param newSupplyCurrentLowerLimit Parameter to modify
1118 * \returns Itself
1119 */
1120 constexpr CurrentLimitsConfigs &WithSupplyCurrentLowerLimit(units::current::ampere_t newSupplyCurrentLowerLimit)
1121 {
1122 SupplyCurrentLowerLimit = std::move(newSupplyCurrentLowerLimit);
1123 return *this;
1124 }
1125
1126 /**
1127 * \brief Modifies this configuration's SupplyCurrentLowerTime parameter and returns itself for
1128 * method-chaining and easier to use config API.
1129 *
1130 * Reduces supply current to the SupplyCurrentLowerLimit after
1131 * limiting to SupplyCurrentLimit for this period of time. If this is
1132 * set to 0, SupplyCurrentLowerLimit will be ignored.
1133 *
1134 * - Minimum Value: 0.0
1135 * - Maximum Value: 2.5
1136 * - Default Value: 1.0
1137 * - Units: seconds
1138 *
1139 * \param newSupplyCurrentLowerTime Parameter to modify
1140 * \returns Itself
1141 */
1142 constexpr CurrentLimitsConfigs &WithSupplyCurrentLowerTime(units::time::second_t newSupplyCurrentLowerTime)
1143 {
1144 SupplyCurrentLowerTime = std::move(newSupplyCurrentLowerTime);
1145 return *this;
1146 }
1147
1148
1149
1150 std::string ToString() const override
1151 {
1152 std::stringstream ss;
1153 ss << "Config Group: CurrentLimits" << std::endl;
1154 ss << " StatorCurrentLimit: " << StatorCurrentLimit.to<double>() << " A" << std::endl;
1155 ss << " StatorCurrentLimitEnable: " << StatorCurrentLimitEnable << std::endl;
1156 ss << " SupplyCurrentLimit: " << SupplyCurrentLimit.to<double>() << " A" << std::endl;
1157 ss << " SupplyCurrentLimitEnable: " << SupplyCurrentLimitEnable << std::endl;
1158 ss << " SupplyCurrentLowerLimit: " << SupplyCurrentLowerLimit.to<double>() << " A" << std::endl;
1159 ss << " SupplyCurrentLowerTime: " << SupplyCurrentLowerTime.to<double>() << " seconds" << std::endl;
1160 return ss.str();
1161 }
1162
1163 std::string Serialize() const override
1164 {
1165 std::stringstream ss;
1166 char *ref;
1167 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_StatorCurrentLimit, StatorCurrentLimit.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1168 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_StatorCurrLimitEn, StatorCurrentLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1169 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrentLimit, SupplyCurrentLimit.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1170 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrLimitEn, SupplyCurrentLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1171 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrentLowerLimit, SupplyCurrentLowerLimit.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1172 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrentLowerTime, SupplyCurrentLowerTime.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1173 return ss.str();
1174 }
1175
1176 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
1177 {
1178 const char *string_c_str = to_deserialize.c_str();
1179 size_t string_length = to_deserialize.length();
1180 double StatorCurrentLimitVal = StatorCurrentLimit.to<double>();
1181 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_StatorCurrentLimit, string_c_str, string_length, &StatorCurrentLimitVal);
1182 StatorCurrentLimit = units::current::ampere_t{StatorCurrentLimitVal};
1183 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_StatorCurrLimitEn, string_c_str, string_length, &StatorCurrentLimitEnable);
1184 double SupplyCurrentLimitVal = SupplyCurrentLimit.to<double>();
1185 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrentLimit, string_c_str, string_length, &SupplyCurrentLimitVal);
1186 SupplyCurrentLimit = units::current::ampere_t{SupplyCurrentLimitVal};
1187 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrLimitEn, string_c_str, string_length, &SupplyCurrentLimitEnable);
1188 double SupplyCurrentLowerLimitVal = SupplyCurrentLowerLimit.to<double>();
1189 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrentLowerLimit, string_c_str, string_length, &SupplyCurrentLowerLimitVal);
1190 SupplyCurrentLowerLimit = units::current::ampere_t{SupplyCurrentLowerLimitVal};
1191 double SupplyCurrentLowerTimeVal = SupplyCurrentLowerTime.to<double>();
1192 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyCurrentLowerTime, string_c_str, string_length, &SupplyCurrentLowerTimeVal);
1193 SupplyCurrentLowerTime = units::time::second_t{SupplyCurrentLowerTimeVal};
1194 return 0;
1195 }
1196};
1197
1198
1199/**
1200 * \brief Configs that affect Voltage control types.
1201 *
1202 * \details Includes peak output voltages and other configs affecting
1203 * voltage measurements.
1204 */
1206{
1207public:
1208 constexpr VoltageConfigs() = default;
1209
1210 /**
1211 * \brief The time constant (in seconds) of the low-pass filter for
1212 * the supply voltage.
1213 *
1214 * \details This impacts the filtering for the reported supply
1215 * voltage, and any control strategies that use the supply voltage
1216 * (such as voltage control on a motor controller).
1217 *
1218 * - Minimum Value: 0.0
1219 * - Maximum Value: 0.1
1220 * - Default Value: 0
1221 * - Units: seconds
1222 */
1223 units::time::second_t SupplyVoltageTimeConstant = 0_s;
1224 /**
1225 * \brief Maximum (forward) output during voltage based control modes.
1226 *
1227 * - Minimum Value: -16
1228 * - Maximum Value: 16
1229 * - Default Value: 16
1230 * - Units: V
1231 */
1232 units::voltage::volt_t PeakForwardVoltage = 16_V;
1233 /**
1234 * \brief Minimum (reverse) output during voltage based control modes.
1235 *
1236 * - Minimum Value: -16
1237 * - Maximum Value: 16
1238 * - Default Value: -16
1239 * - Units: V
1240 */
1241 units::voltage::volt_t PeakReverseVoltage = -16_V;
1242
1243 /**
1244 * \brief Modifies this configuration's SupplyVoltageTimeConstant parameter and returns itself for
1245 * method-chaining and easier to use config API.
1246 *
1247 * The time constant (in seconds) of the low-pass filter for the
1248 * supply voltage.
1249 *
1250 * \details This impacts the filtering for the reported supply
1251 * voltage, and any control strategies that use the supply voltage
1252 * (such as voltage control on a motor controller).
1253 *
1254 * - Minimum Value: 0.0
1255 * - Maximum Value: 0.1
1256 * - Default Value: 0
1257 * - Units: seconds
1258 *
1259 * \param newSupplyVoltageTimeConstant Parameter to modify
1260 * \returns Itself
1261 */
1262 constexpr VoltageConfigs &WithSupplyVoltageTimeConstant(units::time::second_t newSupplyVoltageTimeConstant)
1263 {
1264 SupplyVoltageTimeConstant = std::move(newSupplyVoltageTimeConstant);
1265 return *this;
1266 }
1267
1268 /**
1269 * \brief Modifies this configuration's PeakForwardVoltage parameter and returns itself for
1270 * method-chaining and easier to use config API.
1271 *
1272 * Maximum (forward) output during voltage based control modes.
1273 *
1274 * - Minimum Value: -16
1275 * - Maximum Value: 16
1276 * - Default Value: 16
1277 * - Units: V
1278 *
1279 * \param newPeakForwardVoltage Parameter to modify
1280 * \returns Itself
1281 */
1282 constexpr VoltageConfigs &WithPeakForwardVoltage(units::voltage::volt_t newPeakForwardVoltage)
1283 {
1284 PeakForwardVoltage = std::move(newPeakForwardVoltage);
1285 return *this;
1286 }
1287
1288 /**
1289 * \brief Modifies this configuration's PeakReverseVoltage parameter and returns itself for
1290 * method-chaining and easier to use config API.
1291 *
1292 * Minimum (reverse) output during voltage based control modes.
1293 *
1294 * - Minimum Value: -16
1295 * - Maximum Value: 16
1296 * - Default Value: -16
1297 * - Units: V
1298 *
1299 * \param newPeakReverseVoltage Parameter to modify
1300 * \returns Itself
1301 */
1302 constexpr VoltageConfigs &WithPeakReverseVoltage(units::voltage::volt_t newPeakReverseVoltage)
1303 {
1304 PeakReverseVoltage = std::move(newPeakReverseVoltage);
1305 return *this;
1306 }
1307
1308
1309
1310 std::string ToString() const override
1311 {
1312 std::stringstream ss;
1313 ss << "Config Group: Voltage" << std::endl;
1314 ss << " SupplyVoltageTimeConstant: " << SupplyVoltageTimeConstant.to<double>() << " seconds" << std::endl;
1315 ss << " PeakForwardVoltage: " << PeakForwardVoltage.to<double>() << " V" << std::endl;
1316 ss << " PeakReverseVoltage: " << PeakReverseVoltage.to<double>() << " V" << std::endl;
1317 return ss.str();
1318 }
1319
1320 std::string Serialize() const override
1321 {
1322 std::stringstream ss;
1323 char *ref;
1324 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyVLowpassTau, SupplyVoltageTimeConstant.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1325 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardV, PeakForwardVoltage.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1326 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseV, PeakReverseVoltage.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1327 return ss.str();
1328 }
1329
1330 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
1331 {
1332 const char *string_c_str = to_deserialize.c_str();
1333 size_t string_length = to_deserialize.length();
1334 double SupplyVoltageTimeConstantVal = SupplyVoltageTimeConstant.to<double>();
1335 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SupplyVLowpassTau, string_c_str, string_length, &SupplyVoltageTimeConstantVal);
1336 SupplyVoltageTimeConstant = units::time::second_t{SupplyVoltageTimeConstantVal};
1337 double PeakForwardVoltageVal = PeakForwardVoltage.to<double>();
1338 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForwardV, string_c_str, string_length, &PeakForwardVoltageVal);
1339 PeakForwardVoltage = units::voltage::volt_t{PeakForwardVoltageVal};
1340 double PeakReverseVoltageVal = PeakReverseVoltage.to<double>();
1341 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakReverseV, string_c_str, string_length, &PeakReverseVoltageVal);
1342 PeakReverseVoltage = units::voltage::volt_t{PeakReverseVoltageVal};
1343 return 0;
1344 }
1345};
1346
1347
1348/**
1349 * \brief Configs that affect Torque Current control types.
1350 *
1351 * \details Includes the maximum and minimum applied torque output and
1352 * the neutral deadband used during TorqueCurrentFOC
1353 * requests.
1354 */
1356{
1357public:
1358 constexpr TorqueCurrentConfigs() = default;
1359
1360 /**
1361 * \brief Maximum (forward) output during torque current based control
1362 * modes.
1363 *
1364 * - Minimum Value: -800
1365 * - Maximum Value: 800
1366 * - Default Value: 800
1367 * - Units: A
1368 */
1369 units::current::ampere_t PeakForwardTorqueCurrent = 800_A;
1370 /**
1371 * \brief Minimum (reverse) output during torque current based control
1372 * modes.
1373 *
1374 * - Minimum Value: -800
1375 * - Maximum Value: 800
1376 * - Default Value: -800
1377 * - Units: A
1378 */
1379 units::current::ampere_t PeakReverseTorqueCurrent = -800_A;
1380 /**
1381 * \brief Configures the output deadband during torque current based
1382 * control modes.
1383 *
1384 * - Minimum Value: 0
1385 * - Maximum Value: 25
1386 * - Default Value: 0.0
1387 * - Units: A
1388 */
1389 units::current::ampere_t TorqueNeutralDeadband = 0.0_A;
1390
1391 /**
1392 * \brief Modifies this configuration's PeakForwardTorqueCurrent parameter and returns itself for
1393 * method-chaining and easier to use config API.
1394 *
1395 * Maximum (forward) output during torque current based control modes.
1396 *
1397 * - Minimum Value: -800
1398 * - Maximum Value: 800
1399 * - Default Value: 800
1400 * - Units: A
1401 *
1402 * \param newPeakForwardTorqueCurrent Parameter to modify
1403 * \returns Itself
1404 */
1405 constexpr TorqueCurrentConfigs &WithPeakForwardTorqueCurrent(units::current::ampere_t newPeakForwardTorqueCurrent)
1406 {
1407 PeakForwardTorqueCurrent = std::move(newPeakForwardTorqueCurrent);
1408 return *this;
1409 }
1410
1411 /**
1412 * \brief Modifies this configuration's PeakReverseTorqueCurrent parameter and returns itself for
1413 * method-chaining and easier to use config API.
1414 *
1415 * Minimum (reverse) output during torque current based control modes.
1416 *
1417 * - Minimum Value: -800
1418 * - Maximum Value: 800
1419 * - Default Value: -800
1420 * - Units: A
1421 *
1422 * \param newPeakReverseTorqueCurrent Parameter to modify
1423 * \returns Itself
1424 */
1425 constexpr TorqueCurrentConfigs &WithPeakReverseTorqueCurrent(units::current::ampere_t newPeakReverseTorqueCurrent)
1426 {
1427 PeakReverseTorqueCurrent = std::move(newPeakReverseTorqueCurrent);
1428 return *this;
1429 }
1430
1431 /**
1432 * \brief Modifies this configuration's TorqueNeutralDeadband parameter and returns itself for
1433 * method-chaining and easier to use config API.
1434 *
1435 * Configures the output deadband during torque current based control
1436 * modes.
1437 *
1438 * - Minimum Value: 0
1439 * - Maximum Value: 25
1440 * - Default Value: 0.0
1441 * - Units: A
1442 *
1443 * \param newTorqueNeutralDeadband Parameter to modify
1444 * \returns Itself
1445 */
1446 constexpr TorqueCurrentConfigs &WithTorqueNeutralDeadband(units::current::ampere_t newTorqueNeutralDeadband)
1447 {
1448 TorqueNeutralDeadband = std::move(newTorqueNeutralDeadband);
1449 return *this;
1450 }
1451
1452
1453
1454 std::string ToString() const override
1455 {
1456 std::stringstream ss;
1457 ss << "Config Group: TorqueCurrent" << std::endl;
1458 ss << " PeakForwardTorqueCurrent: " << PeakForwardTorqueCurrent.to<double>() << " A" << std::endl;
1459 ss << " PeakReverseTorqueCurrent: " << PeakReverseTorqueCurrent.to<double>() << " A" << std::endl;
1460 ss << " TorqueNeutralDeadband: " << TorqueNeutralDeadband.to<double>() << " A" << std::endl;
1461 return ss.str();
1462 }
1463
1464 std::string Serialize() const override
1465 {
1466 std::stringstream ss;
1467 char *ref;
1468 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForTorqCurr, PeakForwardTorqueCurrent.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1469 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakRevTorqCurr, PeakReverseTorqueCurrent.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1470 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueNeutralDB, TorqueNeutralDeadband.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1471 return ss.str();
1472 }
1473
1474 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
1475 {
1476 const char *string_c_str = to_deserialize.c_str();
1477 size_t string_length = to_deserialize.length();
1478 double PeakForwardTorqueCurrentVal = PeakForwardTorqueCurrent.to<double>();
1479 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakForTorqCurr, string_c_str, string_length, &PeakForwardTorqueCurrentVal);
1480 PeakForwardTorqueCurrent = units::current::ampere_t{PeakForwardTorqueCurrentVal};
1481 double PeakReverseTorqueCurrentVal = PeakReverseTorqueCurrent.to<double>();
1482 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakRevTorqCurr, string_c_str, string_length, &PeakReverseTorqueCurrentVal);
1483 PeakReverseTorqueCurrent = units::current::ampere_t{PeakReverseTorqueCurrentVal};
1484 double TorqueNeutralDeadbandVal = TorqueNeutralDeadband.to<double>();
1485 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueNeutralDB, string_c_str, string_length, &TorqueNeutralDeadbandVal);
1486 TorqueNeutralDeadband = units::current::ampere_t{TorqueNeutralDeadbandVal};
1487 return 0;
1488 }
1489};
1490
1491
1492/**
1493 * \brief Configs that affect the feedback of this motor controller.
1494 *
1495 * \details Includes feedback sensor source, any offsets for the
1496 * feedback sensor, and various ratios to describe the
1497 * relationship between the sensor and the mechanism for
1498 * closed looping.
1499 */
1501{
1502public:
1503 constexpr FeedbackConfigs() = default;
1504
1505 /**
1506 * \brief The offset applied to the absolute integrated rotor sensor.
1507 * This can be used to zero the rotor in applications that are within
1508 * one rotor rotation.
1509 *
1510 * - Minimum Value: -1
1511 * - Maximum Value: 1
1512 * - Default Value: 0.0
1513 * - Units: rotations
1514 */
1515 units::angle::turn_t FeedbackRotorOffset = 0.0_tr;
1516 /**
1517 * \brief The ratio of sensor rotations to the mechanism's output,
1518 * where a ratio greater than 1 is a reduction.
1519 *
1520 * This is equivalent to the mechanism's gear ratio if the sensor is
1521 * located on the input of a gearbox. If sensor is on the output of a
1522 * gearbox, then this is typically set to 1.
1523 *
1524 * We recommend against using this config to perform onboard unit
1525 * conversions. Instead, unit conversions should be performed in
1526 * robot code using the units library.
1527 *
1528 * If this is set to zero, the device will reset back to one.
1529 *
1530 * - Minimum Value: -1000
1531 * - Maximum Value: 1000
1532 * - Default Value: 1.0
1533 * - Units: scalar
1534 */
1535 units::dimensionless::scalar_t SensorToMechanismRatio = 1.0;
1536 /**
1537 * \brief The ratio of motor rotor rotations to remote sensor
1538 * rotations, where a ratio greater than 1 is a reduction.
1539 *
1540 * The Talon FX is capable of fusing a remote CANcoder with its rotor
1541 * sensor to produce a high-bandwidth sensor source. This feature
1542 * requires specifying the ratio between the motor rotor and the
1543 * remote sensor.
1544 *
1545 * If this is set to zero, the device will reset back to one.
1546 *
1547 * - Minimum Value: -1000
1548 * - Maximum Value: 1000
1549 * - Default Value: 1.0
1550 * - Units: scalar
1551 */
1552 units::dimensionless::scalar_t RotorToSensorRatio = 1.0;
1553 /**
1554 * \brief Choose what sensor source is reported via API and used by
1555 * closed-loop and limit features. The default is RotorSensor, which
1556 * uses the internal rotor sensor in the Talon.
1557 *
1558 * Choose Remote* to use another sensor on the same CAN bus (this also
1559 * requires setting FeedbackRemoteSensorID). Talon will update its
1560 * position and velocity whenever the remote sensor publishes its
1561 * information on CAN bus, and the Talon internal rotor will not be
1562 * used.
1563 *
1564 * Choose Fused* (requires Phoenix Pro) and Talon will fuse another
1565 * sensor's information with the internal rotor, which provides the
1566 * best possible position and velocity for accuracy and bandwidth
1567 * (this also requires setting FeedbackRemoteSensorID). This was
1568 * developed for applications such as swerve-azimuth.
1569 *
1570 * Choose Sync* (requires Phoenix Pro) and Talon will synchronize its
1571 * internal rotor position against another sensor, then continue to
1572 * use the rotor sensor for closed loop control (this also requires
1573 * setting FeedbackRemoteSensorID). The Talon will report if its
1574 * internal position differs significantly from the reported remote
1575 * sensor position. This was developed for mechanisms where there is
1576 * a risk of the sensor failing in such a way that it reports a
1577 * position that does not match the mechanism, such as the sensor
1578 * mounting assembly breaking off.
1579 *
1580 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
1581 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
1582 * also requires setting FeedbackRemoteSensorID). Talon will update
1583 * its position to match the selected value whenever Pigeon2 publishes
1584 * its information on CAN bus. Note that the Talon position will be in
1585 * rotations and not degrees.
1586 *
1587 * \details Note: When the feedback source is changed to Fused* or
1588 * Sync*, the Talon needs a period of time to fuse before sensor-based
1589 * (soft-limit, closed loop, etc.) features are used. This period of
1590 * time is determined by the update frequency of the remote sensor's
1591 * Position signal.
1592 *
1593 */
1595 /**
1596 * \brief Device ID of which remote device to use. This is not used
1597 * if the Sensor Source is the internal rotor sensor.
1598 *
1599 * - Minimum Value: 0
1600 * - Maximum Value: 62
1601 * - Default Value: 0
1602 * - Units:
1603 */
1605 /**
1606 * \brief The configurable time constant of the Kalman velocity
1607 * filter. The velocity Kalman filter will adjust to act as a low-pass
1608 * with this value as its time constant.
1609 *
1610 * \details If the user is aiming for an expected cutoff frequency,
1611 * the frequency is calculated as 1 / (2 * π * τ) with τ being the
1612 * time constant.
1613 *
1614 * - Minimum Value: 0
1615 * - Maximum Value: 1
1616 * - Default Value: 0
1617 * - Units: seconds
1618 */
1619 units::time::second_t VelocityFilterTimeConstant = 0_s;
1620
1621 /**
1622 * \brief Modifies this configuration's FeedbackRotorOffset parameter and returns itself for
1623 * method-chaining and easier to use config API.
1624 *
1625 * The offset applied to the absolute integrated rotor sensor. This
1626 * can be used to zero the rotor in applications that are within one
1627 * rotor rotation.
1628 *
1629 * - Minimum Value: -1
1630 * - Maximum Value: 1
1631 * - Default Value: 0.0
1632 * - Units: rotations
1633 *
1634 * \param newFeedbackRotorOffset Parameter to modify
1635 * \returns Itself
1636 */
1637 constexpr FeedbackConfigs &WithFeedbackRotorOffset(units::angle::turn_t newFeedbackRotorOffset)
1638 {
1639 FeedbackRotorOffset = std::move(newFeedbackRotorOffset);
1640 return *this;
1641 }
1642
1643 /**
1644 * \brief Modifies this configuration's SensorToMechanismRatio parameter and returns itself for
1645 * method-chaining and easier to use config API.
1646 *
1647 * The ratio of sensor rotations to the mechanism's output, where a
1648 * ratio greater than 1 is a reduction.
1649 *
1650 * This is equivalent to the mechanism's gear ratio if the sensor is
1651 * located on the input of a gearbox. If sensor is on the output of a
1652 * gearbox, then this is typically set to 1.
1653 *
1654 * We recommend against using this config to perform onboard unit
1655 * conversions. Instead, unit conversions should be performed in
1656 * robot code using the units library.
1657 *
1658 * If this is set to zero, the device will reset back to one.
1659 *
1660 * - Minimum Value: -1000
1661 * - Maximum Value: 1000
1662 * - Default Value: 1.0
1663 * - Units: scalar
1664 *
1665 * \param newSensorToMechanismRatio Parameter to modify
1666 * \returns Itself
1667 */
1668 constexpr FeedbackConfigs &WithSensorToMechanismRatio(units::dimensionless::scalar_t newSensorToMechanismRatio)
1669 {
1670 SensorToMechanismRatio = std::move(newSensorToMechanismRatio);
1671 return *this;
1672 }
1673
1674 /**
1675 * \brief Modifies this configuration's RotorToSensorRatio parameter and returns itself for
1676 * method-chaining and easier to use config API.
1677 *
1678 * The ratio of motor rotor rotations to remote sensor rotations,
1679 * where a ratio greater than 1 is a reduction.
1680 *
1681 * The Talon FX is capable of fusing a remote CANcoder with its rotor
1682 * sensor to produce a high-bandwidth sensor source. This feature
1683 * requires specifying the ratio between the motor rotor and the
1684 * remote sensor.
1685 *
1686 * If this is set to zero, the device will reset back to one.
1687 *
1688 * - Minimum Value: -1000
1689 * - Maximum Value: 1000
1690 * - Default Value: 1.0
1691 * - Units: scalar
1692 *
1693 * \param newRotorToSensorRatio Parameter to modify
1694 * \returns Itself
1695 */
1696 constexpr FeedbackConfigs &WithRotorToSensorRatio(units::dimensionless::scalar_t newRotorToSensorRatio)
1697 {
1698 RotorToSensorRatio = std::move(newRotorToSensorRatio);
1699 return *this;
1700 }
1701
1702 /**
1703 * \brief Modifies this configuration's FeedbackSensorSource parameter and returns itself for
1704 * method-chaining and easier to use config API.
1705 *
1706 * Choose what sensor source is reported via API and used by
1707 * closed-loop and limit features. The default is RotorSensor, which
1708 * uses the internal rotor sensor in the Talon.
1709 *
1710 * Choose Remote* to use another sensor on the same CAN bus (this also
1711 * requires setting FeedbackRemoteSensorID). Talon will update its
1712 * position and velocity whenever the remote sensor publishes its
1713 * information on CAN bus, and the Talon internal rotor will not be
1714 * used.
1715 *
1716 * Choose Fused* (requires Phoenix Pro) and Talon will fuse another
1717 * sensor's information with the internal rotor, which provides the
1718 * best possible position and velocity for accuracy and bandwidth
1719 * (this also requires setting FeedbackRemoteSensorID). This was
1720 * developed for applications such as swerve-azimuth.
1721 *
1722 * Choose Sync* (requires Phoenix Pro) and Talon will synchronize its
1723 * internal rotor position against another sensor, then continue to
1724 * use the rotor sensor for closed loop control (this also requires
1725 * setting FeedbackRemoteSensorID). The Talon will report if its
1726 * internal position differs significantly from the reported remote
1727 * sensor position. This was developed for mechanisms where there is
1728 * a risk of the sensor failing in such a way that it reports a
1729 * position that does not match the mechanism, such as the sensor
1730 * mounting assembly breaking off.
1731 *
1732 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
1733 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
1734 * also requires setting FeedbackRemoteSensorID). Talon will update
1735 * its position to match the selected value whenever Pigeon2 publishes
1736 * its information on CAN bus. Note that the Talon position will be in
1737 * rotations and not degrees.
1738 *
1739 * \details Note: When the feedback source is changed to Fused* or
1740 * Sync*, the Talon needs a period of time to fuse before sensor-based
1741 * (soft-limit, closed loop, etc.) features are used. This period of
1742 * time is determined by the update frequency of the remote sensor's
1743 * Position signal.
1744 *
1745 *
1746 * \param newFeedbackSensorSource Parameter to modify
1747 * \returns Itself
1748 */
1750 {
1751 FeedbackSensorSource = std::move(newFeedbackSensorSource);
1752 return *this;
1753 }
1754
1755 /**
1756 * \brief Modifies this configuration's FeedbackRemoteSensorID parameter and returns itself for
1757 * method-chaining and easier to use config API.
1758 *
1759 * Device ID of which remote device to use. This is not used if the
1760 * Sensor Source is the internal rotor sensor.
1761 *
1762 * - Minimum Value: 0
1763 * - Maximum Value: 62
1764 * - Default Value: 0
1765 * - Units:
1766 *
1767 * \param newFeedbackRemoteSensorID Parameter to modify
1768 * \returns Itself
1769 */
1770 constexpr FeedbackConfigs &WithFeedbackRemoteSensorID(int newFeedbackRemoteSensorID)
1771 {
1772 FeedbackRemoteSensorID = std::move(newFeedbackRemoteSensorID);
1773 return *this;
1774 }
1775
1776 /**
1777 * \brief Modifies this configuration's VelocityFilterTimeConstant parameter and returns itself for
1778 * method-chaining and easier to use config API.
1779 *
1780 * The configurable time constant of the Kalman velocity filter. The
1781 * velocity Kalman filter will adjust to act as a low-pass with this
1782 * value as its time constant.
1783 *
1784 * \details If the user is aiming for an expected cutoff frequency,
1785 * the frequency is calculated as 1 / (2 * π * τ) with τ being the
1786 * time constant.
1787 *
1788 * - Minimum Value: 0
1789 * - Maximum Value: 1
1790 * - Default Value: 0
1791 * - Units: seconds
1792 *
1793 * \param newVelocityFilterTimeConstant Parameter to modify
1794 * \returns Itself
1795 */
1796 constexpr FeedbackConfigs &WithVelocityFilterTimeConstant(units::time::second_t newVelocityFilterTimeConstant)
1797 {
1798 VelocityFilterTimeConstant = std::move(newVelocityFilterTimeConstant);
1799 return *this;
1800 }
1801
1802 /**
1803 * \brief Helper method to configure this feedback group to use
1804 * RemoteCANcoder by passing in the CANcoder object.
1805 *
1806 * When using RemoteCANcoder, the Talon will use another
1807 * CANcoder on the same CAN bus. The Talon will update its
1808 * position and velocity whenever CANcoder publishes its
1809 * information on CAN bus, and the Talon internal rotor will
1810 * not be used.
1811 *
1812 * \param device CANcoder reference to use for RemoteCANcoder
1813 * \returns Itself
1814 */
1816
1817 /**
1818 * \brief Helper method to configure this feedback group to use
1819 * FusedCANcoder by passing in the CANcoder object.
1820 *
1821 * When using FusedCANcoder (requires Phoenix Pro), the Talon
1822 * will fuse another CANcoder's information with the internal
1823 * rotor, which provides the best possible position and
1824 * velocity for accuracy and bandwidth. FusedCANcoder was
1825 * developed for applications such as swerve-azimuth.
1826 *
1827 * \param device CANcoder reference to use for FusedCANcoder
1828 * \returns Itself
1829 */
1831
1832 /**
1833 * \brief Helper method to configure this feedback group to use
1834 * SyncCANcoder by passing in the CANcoder object.
1835 *
1836 * When using SyncCANcoder (requires Phoenix Pro), the Talon
1837 * will synchronize its internal rotor position against another
1838 * CANcoder, then continue to use the rotor sensor for closed
1839 * loop control. The Talon will report if its internal position
1840 * differs significantly from the reported CANcoder position.
1841 * SyncCANcoder was developed for mechanisms where there is a
1842 * risk of the CANcoder failing in such a way that it reports a
1843 * position that does not match the mechanism, such as the
1844 * sensor mounting assembly breaking off.
1845 *
1846 * \param device CANcoder reference to use for SyncCANcoder
1847 * \returns Itself
1848 */
1850
1851 /**
1852 * \brief Helper method to configure this feedback group to use
1853 * RemoteCANdi PWM 1 by passing in the CANdi object.
1854 *
1855 * \param device CANdi reference to use for RemoteCANdi
1856 * \returns Itself
1857 */
1859
1860 /**
1861 * \brief Helper method to configure this feedback group to use
1862 * RemoteCANdi PWM 2 by passing in the CANdi object.
1863 *
1864 * \param device CANdi reference to use for RemoteCANdi
1865 * \returns Itself
1866 */
1868
1869 /**
1870 * \brief Helper method to configure this feedback group to use
1871 * RemoteCANdi Quadrature by passing in the CANdi object.
1872 *
1873 * \param device CANdi reference to use for RemoteCANdi
1874 * \returns Itself
1875 */
1877
1878 /**
1879 * \brief Helper method to configure this feedback group to use
1880 * FusedCANdi PWM 1 by passing in the CANdi object.
1881 *
1882 * When using FusedCANdi (requires Phoenix Pro), the Talon will
1883 * fuse another CANdi™ branded device's information with the
1884 * internal rotor, which provides the best possible position
1885 * and velocity for accuracy and bandwidth.
1886 *
1887 * \param device CANdi reference to use for FusedCANdi
1888 * \returns Itself
1889 */
1891
1892 /**
1893 * \brief Helper method to configure this feedback group to use
1894 * FusedCANdi PWM 2 by passing in the CANdi object.
1895 *
1896 * When using FusedCANdi (requires Phoenix Pro), the Talon will
1897 * fuse another CANdi™ branded device's information with the
1898 * internal rotor, which provides the best possible position
1899 * and velocity for accuracy and bandwidth.
1900 *
1901 * \param device CANdi reference to use for FusedCANdi
1902 * \returns Itself
1903 */
1905
1906 /**
1907 * \brief Helper method to configure this feedback group to use
1908 * FusedCANdi Quadrature by passing in the CANdi object.
1909 *
1910 * When using FusedCANdi (requires Phoenix Pro), the Talon will
1911 * fuse another CANdi™ branded device's information with the
1912 * internal rotor, which provides the best possible position
1913 * and velocity for accuracy and bandwidth.
1914 *
1915 * \param device CANdi reference to use for FusedCANdi
1916 * \returns Itself
1917 */
1919
1920 /**
1921 * \brief Helper method to configure this feedback group to use
1922 * SyncCANdi PWM 1 by passing in the CANdi object.
1923 *
1924 * When using SyncCANdi (requires Phoenix Pro), the Talon will
1925 * synchronize its internal rotor position against another
1926 * CANdi™ branded device, then continue to use the rotor sensor
1927 * for closed loop control. The Talon will report if its
1928 * internal position differs significantly from the reported
1929 * CANdi™ branded device's position. SyncCANdi was developed
1930 * for mechanisms where there is a risk of the CANdi™ branded
1931 * device failing in such a way that it reports a position that
1932 * does not match the mechanism, such as the sensor mounting
1933 * assembly breaking off.
1934 *
1935 * \param device CANdi reference to use for SyncCANdi
1936 * \returns Itself
1937 */
1939
1940 /**
1941 * \brief Helper method to configure this feedback group to use
1942 * SyncCANdi PWM 2 by passing in the CANdi object.
1943 *
1944 * When using SyncCANdi (requires Phoenix Pro), the Talon will
1945 * synchronize its internal rotor position against another
1946 * CANdi™ branded device, then continue to use the rotor sensor
1947 * for closed loop control. The Talon will report if its
1948 * internal position differs significantly from the reported
1949 * CANdi™ branded device's position. SyncCANdi was developed
1950 * for mechanisms where there is a risk of the CANdi™ branded
1951 * device failing in such a way that it reports a position that
1952 * does not match the mechanism, such as the sensor mounting
1953 * assembly breaking off.
1954 *
1955 * \param device CANdi reference to use for SyncCANdi
1956 * \returns Itself
1957 */
1959
1960
1961
1962 std::string ToString() const override
1963 {
1964 std::stringstream ss;
1965 ss << "Config Group: Feedback" << std::endl;
1966 ss << " FeedbackRotorOffset: " << FeedbackRotorOffset.to<double>() << " rotations" << std::endl;
1967 ss << " SensorToMechanismRatio: " << SensorToMechanismRatio.to<double>() << " scalar" << std::endl;
1968 ss << " RotorToSensorRatio: " << RotorToSensorRatio.to<double>() << " scalar" << std::endl;
1969 ss << " FeedbackSensorSource: " << FeedbackSensorSource << std::endl;
1970 ss << " FeedbackRemoteSensorID: " << FeedbackRemoteSensorID << std::endl;
1971 ss << " VelocityFilterTimeConstant: " << VelocityFilterTimeConstant.to<double>() << " seconds" << std::endl;
1972 return ss.str();
1973 }
1974
1975 std::string Serialize() const override
1976 {
1977 std::stringstream ss;
1978 char *ref;
1979 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_FeedbackRotorOffset, FeedbackRotorOffset.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1980 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SensorToMechanismRatio, SensorToMechanismRatio.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1981 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_RotorToSensorRatio, RotorToSensorRatio.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1982 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackSensorSource, FeedbackSensorSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1983 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackRemoteSensorID, FeedbackRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
1984 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_VelocityFilterTimeConstant, VelocityFilterTimeConstant.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
1985 return ss.str();
1986 }
1987
1988 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
1989 {
1990 const char *string_c_str = to_deserialize.c_str();
1991 size_t string_length = to_deserialize.length();
1992 double FeedbackRotorOffsetVal = FeedbackRotorOffset.to<double>();
1993 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_FeedbackRotorOffset, string_c_str, string_length, &FeedbackRotorOffsetVal);
1994 FeedbackRotorOffset = units::angle::turn_t{FeedbackRotorOffsetVal};
1995 double SensorToMechanismRatioVal = SensorToMechanismRatio.to<double>();
1996 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SensorToMechanismRatio, string_c_str, string_length, &SensorToMechanismRatioVal);
1997 SensorToMechanismRatio = units::dimensionless::scalar_t{SensorToMechanismRatioVal};
1998 double RotorToSensorRatioVal = RotorToSensorRatio.to<double>();
1999 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_RotorToSensorRatio, string_c_str, string_length, &RotorToSensorRatioVal);
2000 RotorToSensorRatio = units::dimensionless::scalar_t{RotorToSensorRatioVal};
2001 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackSensorSource, string_c_str, string_length, &FeedbackSensorSource.value);
2002 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackRemoteSensorID, string_c_str, string_length, &FeedbackRemoteSensorID);
2003 double VelocityFilterTimeConstantVal = VelocityFilterTimeConstant.to<double>();
2004 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_VelocityFilterTimeConstant, string_c_str, string_length, &VelocityFilterTimeConstantVal);
2005 VelocityFilterTimeConstant = units::time::second_t{VelocityFilterTimeConstantVal};
2006 return 0;
2007 }
2008};
2009
2010
2011/**
2012 * \brief Configs that affect the external feedback sensor of this
2013 * motor controller.
2014 *
2015 * \details Includes feedback sensor source, offsets and sensor phase
2016 * for the feedback sensor, and various ratios to describe
2017 * the relationship between the sensor and the mechanism for
2018 * closed looping.
2019 */
2021{
2022public:
2023 constexpr ExternalFeedbackConfigs() = default;
2024
2025 /**
2026 * \brief The ratio of sensor rotations to the mechanism's output,
2027 * where a ratio greater than 1 is a reduction.
2028 *
2029 * This is equivalent to the mechanism's gear ratio if the sensor is
2030 * located on the input of a gearbox. If sensor is on the output of a
2031 * gearbox, then this is typically set to 1.
2032 *
2033 * We recommend against using this config to perform onboard unit
2034 * conversions. Instead, unit conversions should be performed in
2035 * robot code using the units library.
2036 *
2037 * If this is set to zero, the device will reset back to one.
2038 *
2039 * - Minimum Value: -1000
2040 * - Maximum Value: 1000
2041 * - Default Value: 1.0
2042 * - Units: scalar
2043 */
2044 units::dimensionless::scalar_t SensorToMechanismRatio = 1.0;
2045 /**
2046 * \brief The ratio of motor rotor rotations to remote sensor
2047 * rotations, where a ratio greater than 1 is a reduction.
2048 *
2049 * The Talon FX is capable of fusing a remote CANcoder with its rotor
2050 * sensor to produce a high-bandwidth sensor source. This feature
2051 * requires specifying the ratio between the motor rotor and the
2052 * remote sensor.
2053 *
2054 * If this is set to zero, the device will reset back to one.
2055 *
2056 * - Minimum Value: -1000
2057 * - Maximum Value: 1000
2058 * - Default Value: 1.0
2059 * - Units: scalar
2060 */
2061 units::dimensionless::scalar_t RotorToSensorRatio = 1.0;
2062 /**
2063 * \brief Device ID of which remote device to use. This is not used
2064 * if the Sensor Source is the internal rotor sensor.
2065 *
2066 * - Minimum Value: 0
2067 * - Maximum Value: 62
2068 * - Default Value: 0
2069 * - Units:
2070 */
2072 /**
2073 * \brief The configurable time constant of the Kalman velocity
2074 * filter. The velocity Kalman filter will adjust to act as a low-pass
2075 * with this value as its time constant.
2076 *
2077 * \details If the user is aiming for an expected cutoff frequency,
2078 * the frequency is calculated as 1 / (2 * π * τ) with τ being the
2079 * time constant.
2080 *
2081 * - Minimum Value: 0
2082 * - Maximum Value: 1
2083 * - Default Value: 0
2084 * - Units: seconds
2085 */
2086 units::time::second_t VelocityFilterTimeConstant = 0_s;
2087 /**
2088 * \brief The offset applied to any absolute sensor connected to the
2089 * Talon data port. This is only supported when using the PulseWidth
2090 * sensor source.
2091 *
2092 * This can be used to zero the sensor position in applications where
2093 * the sensor is 1:1 with the mechanism.
2094 *
2095 * - Minimum Value: -1
2096 * - Maximum Value: 1
2097 * - Default Value: 0.0
2098 * - Units: rotations
2099 */
2100 units::angle::turn_t AbsoluteSensorOffset = 0.0_tr;
2101 /**
2102 * \brief Choose what sensor source is reported via API and used by
2103 * closed-loop and limit features. The default is Commutation, which
2104 * uses the external sensor used for motor commutation.
2105 *
2106 * Choose Remote* to use another sensor on the same CAN bus (this also
2107 * requires setting FeedbackRemoteSensorID). Talon will update its
2108 * position and velocity whenever the remote sensor publishes its
2109 * information on CAN bus, and the Talon commutation sensor will not
2110 * be used.
2111 *
2112 * Choose Fused* (requires Phoenix Pro) and Talon will fuse another
2113 * sensor's information with the commutation sensor, which provides
2114 * the best possible position and velocity for accuracy and bandwidth
2115 * (this also requires setting FeedbackRemoteSensorID). This was
2116 * developed for applications such as swerve-azimuth.
2117 *
2118 * Choose Sync* (requires Phoenix Pro) and Talon will synchronize its
2119 * commutation sensor position against another sensor, then continue
2120 * to use the rotor sensor for closed loop control (this also requires
2121 * setting FeedbackRemoteSensorID). The Talon will report if its
2122 * internal position differs significantly from the reported remote
2123 * sensor position. This was developed for mechanisms where there is
2124 * a risk of the sensor failing in such a way that it reports a
2125 * position that does not match the mechanism, such as the sensor
2126 * mounting assembly breaking off.
2127 *
2128 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
2129 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
2130 * also requires setting FeedbackRemoteSensorID). Talon will update
2131 * its position to match the selected value whenever Pigeon2 publishes
2132 * its information on CAN bus. Note that the Talon position will be in
2133 * rotations and not degrees.
2134 *
2135 * Choose Quadrature to use a quadrature encoder directly attached to
2136 * the Talon data port. This provides velocity and relative position
2137 * measurements.
2138 *
2139 * Choose PulseWidth to use a pulse-width encoder directly attached to
2140 * the Talon data port. This provides velocity and absolute position
2141 * measurements.
2142 *
2143 * \details Note: When the feedback source is changed to Fused* or
2144 * Sync*, the Talon needs a period of time to fuse before sensor-based
2145 * (soft-limit, closed loop, etc.) features are used. This period of
2146 * time is determined by the update frequency of the remote sensor's
2147 * Position signal.
2148 *
2149 */
2151 /**
2152 * \brief The relationship between the motor controlled by a Talon and
2153 * the external sensor connected to the data port. This does not
2154 * affect the commutation sensor or remote sensors.
2155 *
2156 * To determine the sensor phase, set this config to Aligned and drive
2157 * the motor with positive output. If the reported sensor velocity is
2158 * positive, then the phase is Aligned. If the reported sensor
2159 * velocity is negative, then the phase is Opposed.
2160 *
2161 * The sensor direction is automatically inverted along with motor
2162 * invert, so the sensor phase does not need to be changed when motor
2163 * invert changes.
2164 *
2165 */
2167 /**
2168 * \brief The number of quadrature edges in one rotation for the
2169 * quadrature sensor connected to the Talon data port.
2170 *
2171 * This is the total number of transitions from high-to-low or
2172 * low-to-high across both channels per rotation of the sensor. This
2173 * is also equivalent to the Counts Per Revolution when using 4x
2174 * decoding.
2175 *
2176 * For example, the SRX Mag Encoder has 4096 edges per rotation, and a
2177 * US Digital 1024 CPR (Cycles Per Revolution) quadrature encoder has
2178 * 4096 edges per rotation.
2179 *
2180 * \details On the Talon FXS, this can be at most 2,000,000,000 / Peak
2181 * RPM.
2182 *
2183 * - Minimum Value: 1
2184 * - Maximum Value: 1000000
2185 * - Default Value: 4096
2186 * - Units:
2187 */
2189 /**
2190 * \brief The positive discontinuity point of the absolute sensor in
2191 * rotations. This determines the point at which the absolute sensor
2192 * wraps around, keeping the absolute position (after offset) in the
2193 * range [x-1, x).
2194 *
2195 * - Setting this to 1 makes the absolute position unsigned [0, 1)
2196 * - Setting this to 0.5 makes the absolute position signed [-0.5,
2197 * 0.5)
2198 * - Setting this to 0 makes the absolute position always negative
2199 * [-1, 0)
2200 *
2201 * Many rotational mechanisms such as arms have a region of motion
2202 * that is unreachable. This should be set to the center of that
2203 * region of motion, in non-negative rotations. This affects the
2204 * position of the device at bootup.
2205 *
2206 * \details For example, consider an arm which can travel from -0.2 to
2207 * 0.6 rotations with a little leeway, where 0 is horizontally
2208 * forward. Since -0.2 rotations has the same absolute position as 0.8
2209 * rotations, we can say that the arm typically does not travel in the
2210 * range (0.6, 0.8) rotations. As a result, the discontinuity point
2211 * would be the center of that range, which is 0.7 rotations. This
2212 * results in an absolute sensor range of [-0.3, 0.7) rotations.
2213 *
2214 * Given a total range of motion less than 1 rotation, users can
2215 * calculate the discontinuity point using mean(lowerLimit,
2216 * upperLimit) + 0.5. If that results in a value outside the range [0,
2217 * 1], either cap the value to [0, 1], or add/subtract 1.0 rotation
2218 * from your lower and upper limits of motion.
2219 *
2220 * On a Talon motor controller, this is only supported when using the
2221 * PulseWidth sensor source.
2222 *
2223 * - Minimum Value: 0.0
2224 * - Maximum Value: 1.0
2225 * - Default Value: 0.5
2226 * - Units: rotations
2227 */
2228 units::angle::turn_t AbsoluteSensorDiscontinuityPoint = 0.5_tr;
2229
2230 /**
2231 * \brief Modifies this configuration's SensorToMechanismRatio parameter and returns itself for
2232 * method-chaining and easier to use config API.
2233 *
2234 * The ratio of sensor rotations to the mechanism's output, where a
2235 * ratio greater than 1 is a reduction.
2236 *
2237 * This is equivalent to the mechanism's gear ratio if the sensor is
2238 * located on the input of a gearbox. If sensor is on the output of a
2239 * gearbox, then this is typically set to 1.
2240 *
2241 * We recommend against using this config to perform onboard unit
2242 * conversions. Instead, unit conversions should be performed in
2243 * robot code using the units library.
2244 *
2245 * If this is set to zero, the device will reset back to one.
2246 *
2247 * - Minimum Value: -1000
2248 * - Maximum Value: 1000
2249 * - Default Value: 1.0
2250 * - Units: scalar
2251 *
2252 * \param newSensorToMechanismRatio Parameter to modify
2253 * \returns Itself
2254 */
2255 constexpr ExternalFeedbackConfigs &WithSensorToMechanismRatio(units::dimensionless::scalar_t newSensorToMechanismRatio)
2256 {
2257 SensorToMechanismRatio = std::move(newSensorToMechanismRatio);
2258 return *this;
2259 }
2260
2261 /**
2262 * \brief Modifies this configuration's RotorToSensorRatio parameter and returns itself for
2263 * method-chaining and easier to use config API.
2264 *
2265 * The ratio of motor rotor rotations to remote sensor rotations,
2266 * where a ratio greater than 1 is a reduction.
2267 *
2268 * The Talon FX is capable of fusing a remote CANcoder with its rotor
2269 * sensor to produce a high-bandwidth sensor source. This feature
2270 * requires specifying the ratio between the motor rotor and the
2271 * remote sensor.
2272 *
2273 * If this is set to zero, the device will reset back to one.
2274 *
2275 * - Minimum Value: -1000
2276 * - Maximum Value: 1000
2277 * - Default Value: 1.0
2278 * - Units: scalar
2279 *
2280 * \param newRotorToSensorRatio Parameter to modify
2281 * \returns Itself
2282 */
2283 constexpr ExternalFeedbackConfigs &WithRotorToSensorRatio(units::dimensionless::scalar_t newRotorToSensorRatio)
2284 {
2285 RotorToSensorRatio = std::move(newRotorToSensorRatio);
2286 return *this;
2287 }
2288
2289 /**
2290 * \brief Modifies this configuration's FeedbackRemoteSensorID parameter and returns itself for
2291 * method-chaining and easier to use config API.
2292 *
2293 * Device ID of which remote device to use. This is not used if the
2294 * Sensor Source is the internal rotor sensor.
2295 *
2296 * - Minimum Value: 0
2297 * - Maximum Value: 62
2298 * - Default Value: 0
2299 * - Units:
2300 *
2301 * \param newFeedbackRemoteSensorID Parameter to modify
2302 * \returns Itself
2303 */
2304 constexpr ExternalFeedbackConfigs &WithFeedbackRemoteSensorID(int newFeedbackRemoteSensorID)
2305 {
2306 FeedbackRemoteSensorID = std::move(newFeedbackRemoteSensorID);
2307 return *this;
2308 }
2309
2310 /**
2311 * \brief Modifies this configuration's VelocityFilterTimeConstant parameter and returns itself for
2312 * method-chaining and easier to use config API.
2313 *
2314 * The configurable time constant of the Kalman velocity filter. The
2315 * velocity Kalman filter will adjust to act as a low-pass with this
2316 * value as its time constant.
2317 *
2318 * \details If the user is aiming for an expected cutoff frequency,
2319 * the frequency is calculated as 1 / (2 * π * τ) with τ being the
2320 * time constant.
2321 *
2322 * - Minimum Value: 0
2323 * - Maximum Value: 1
2324 * - Default Value: 0
2325 * - Units: seconds
2326 *
2327 * \param newVelocityFilterTimeConstant Parameter to modify
2328 * \returns Itself
2329 */
2330 constexpr ExternalFeedbackConfigs &WithVelocityFilterTimeConstant(units::time::second_t newVelocityFilterTimeConstant)
2331 {
2332 VelocityFilterTimeConstant = std::move(newVelocityFilterTimeConstant);
2333 return *this;
2334 }
2335
2336 /**
2337 * \brief Modifies this configuration's AbsoluteSensorOffset parameter and returns itself for
2338 * method-chaining and easier to use config API.
2339 *
2340 * The offset applied to any absolute sensor connected to the Talon
2341 * data port. This is only supported when using the PulseWidth sensor
2342 * source.
2343 *
2344 * This can be used to zero the sensor position in applications where
2345 * the sensor is 1:1 with the mechanism.
2346 *
2347 * - Minimum Value: -1
2348 * - Maximum Value: 1
2349 * - Default Value: 0.0
2350 * - Units: rotations
2351 *
2352 * \param newAbsoluteSensorOffset Parameter to modify
2353 * \returns Itself
2354 */
2355 constexpr ExternalFeedbackConfigs &WithAbsoluteSensorOffset(units::angle::turn_t newAbsoluteSensorOffset)
2356 {
2357 AbsoluteSensorOffset = std::move(newAbsoluteSensorOffset);
2358 return *this;
2359 }
2360
2361 /**
2362 * \brief Modifies this configuration's ExternalFeedbackSensorSource parameter and returns itself for
2363 * method-chaining and easier to use config API.
2364 *
2365 * Choose what sensor source is reported via API and used by
2366 * closed-loop and limit features. The default is Commutation, which
2367 * uses the external sensor used for motor commutation.
2368 *
2369 * Choose Remote* to use another sensor on the same CAN bus (this also
2370 * requires setting FeedbackRemoteSensorID). Talon will update its
2371 * position and velocity whenever the remote sensor publishes its
2372 * information on CAN bus, and the Talon commutation sensor will not
2373 * be used.
2374 *
2375 * Choose Fused* (requires Phoenix Pro) and Talon will fuse another
2376 * sensor's information with the commutation sensor, which provides
2377 * the best possible position and velocity for accuracy and bandwidth
2378 * (this also requires setting FeedbackRemoteSensorID). This was
2379 * developed for applications such as swerve-azimuth.
2380 *
2381 * Choose Sync* (requires Phoenix Pro) and Talon will synchronize its
2382 * commutation sensor position against another sensor, then continue
2383 * to use the rotor sensor for closed loop control (this also requires
2384 * setting FeedbackRemoteSensorID). The Talon will report if its
2385 * internal position differs significantly from the reported remote
2386 * sensor position. This was developed for mechanisms where there is
2387 * a risk of the sensor failing in such a way that it reports a
2388 * position that does not match the mechanism, such as the sensor
2389 * mounting assembly breaking off.
2390 *
2391 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
2392 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
2393 * also requires setting FeedbackRemoteSensorID). Talon will update
2394 * its position to match the selected value whenever Pigeon2 publishes
2395 * its information on CAN bus. Note that the Talon position will be in
2396 * rotations and not degrees.
2397 *
2398 * Choose Quadrature to use a quadrature encoder directly attached to
2399 * the Talon data port. This provides velocity and relative position
2400 * measurements.
2401 *
2402 * Choose PulseWidth to use a pulse-width encoder directly attached to
2403 * the Talon data port. This provides velocity and absolute position
2404 * measurements.
2405 *
2406 * \details Note: When the feedback source is changed to Fused* or
2407 * Sync*, the Talon needs a period of time to fuse before sensor-based
2408 * (soft-limit, closed loop, etc.) features are used. This period of
2409 * time is determined by the update frequency of the remote sensor's
2410 * Position signal.
2411 *
2412 *
2413 * \param newExternalFeedbackSensorSource Parameter to modify
2414 * \returns Itself
2415 */
2417 {
2418 ExternalFeedbackSensorSource = std::move(newExternalFeedbackSensorSource);
2419 return *this;
2420 }
2421
2422 /**
2423 * \brief Modifies this configuration's SensorPhase parameter and returns itself for
2424 * method-chaining and easier to use config API.
2425 *
2426 * The relationship between the motor controlled by a Talon and the
2427 * external sensor connected to the data port. This does not affect
2428 * the commutation sensor or remote sensors.
2429 *
2430 * To determine the sensor phase, set this config to Aligned and drive
2431 * the motor with positive output. If the reported sensor velocity is
2432 * positive, then the phase is Aligned. If the reported sensor
2433 * velocity is negative, then the phase is Opposed.
2434 *
2435 * The sensor direction is automatically inverted along with motor
2436 * invert, so the sensor phase does not need to be changed when motor
2437 * invert changes.
2438 *
2439 *
2440 * \param newSensorPhase Parameter to modify
2441 * \returns Itself
2442 */
2444 {
2445 SensorPhase = std::move(newSensorPhase);
2446 return *this;
2447 }
2448
2449 /**
2450 * \brief Modifies this configuration's QuadratureEdgesPerRotation parameter and returns itself for
2451 * method-chaining and easier to use config API.
2452 *
2453 * The number of quadrature edges in one rotation for the quadrature
2454 * sensor connected to the Talon data port.
2455 *
2456 * This is the total number of transitions from high-to-low or
2457 * low-to-high across both channels per rotation of the sensor. This
2458 * is also equivalent to the Counts Per Revolution when using 4x
2459 * decoding.
2460 *
2461 * For example, the SRX Mag Encoder has 4096 edges per rotation, and a
2462 * US Digital 1024 CPR (Cycles Per Revolution) quadrature encoder has
2463 * 4096 edges per rotation.
2464 *
2465 * \details On the Talon FXS, this can be at most 2,000,000,000 / Peak
2466 * RPM.
2467 *
2468 * - Minimum Value: 1
2469 * - Maximum Value: 1000000
2470 * - Default Value: 4096
2471 * - Units:
2472 *
2473 * \param newQuadratureEdgesPerRotation Parameter to modify
2474 * \returns Itself
2475 */
2476 constexpr ExternalFeedbackConfigs &WithQuadratureEdgesPerRotation(int newQuadratureEdgesPerRotation)
2477 {
2478 QuadratureEdgesPerRotation = std::move(newQuadratureEdgesPerRotation);
2479 return *this;
2480 }
2481
2482 /**
2483 * \brief Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for
2484 * method-chaining and easier to use config API.
2485 *
2486 * The positive discontinuity point of the absolute sensor in
2487 * rotations. This determines the point at which the absolute sensor
2488 * wraps around, keeping the absolute position (after offset) in the
2489 * range [x-1, x).
2490 *
2491 * - Setting this to 1 makes the absolute position unsigned [0, 1)
2492 * - Setting this to 0.5 makes the absolute position signed [-0.5,
2493 * 0.5)
2494 * - Setting this to 0 makes the absolute position always negative
2495 * [-1, 0)
2496 *
2497 * Many rotational mechanisms such as arms have a region of motion
2498 * that is unreachable. This should be set to the center of that
2499 * region of motion, in non-negative rotations. This affects the
2500 * position of the device at bootup.
2501 *
2502 * \details For example, consider an arm which can travel from -0.2 to
2503 * 0.6 rotations with a little leeway, where 0 is horizontally
2504 * forward. Since -0.2 rotations has the same absolute position as 0.8
2505 * rotations, we can say that the arm typically does not travel in the
2506 * range (0.6, 0.8) rotations. As a result, the discontinuity point
2507 * would be the center of that range, which is 0.7 rotations. This
2508 * results in an absolute sensor range of [-0.3, 0.7) rotations.
2509 *
2510 * Given a total range of motion less than 1 rotation, users can
2511 * calculate the discontinuity point using mean(lowerLimit,
2512 * upperLimit) + 0.5. If that results in a value outside the range [0,
2513 * 1], either cap the value to [0, 1], or add/subtract 1.0 rotation
2514 * from your lower and upper limits of motion.
2515 *
2516 * On a Talon motor controller, this is only supported when using the
2517 * PulseWidth sensor source.
2518 *
2519 * - Minimum Value: 0.0
2520 * - Maximum Value: 1.0
2521 * - Default Value: 0.5
2522 * - Units: rotations
2523 *
2524 * \param newAbsoluteSensorDiscontinuityPoint Parameter to modify
2525 * \returns Itself
2526 */
2527 constexpr ExternalFeedbackConfigs &WithAbsoluteSensorDiscontinuityPoint(units::angle::turn_t newAbsoluteSensorDiscontinuityPoint)
2528 {
2529 AbsoluteSensorDiscontinuityPoint = std::move(newAbsoluteSensorDiscontinuityPoint);
2530 return *this;
2531 }
2532
2533 /**
2534 * \brief Helper method to configure this feedback group to use
2535 * RemoteCANcoder by passing in the CANcoder object.
2536 *
2537 * When using RemoteCANcoder, the Talon will use another
2538 * CANcoder on the same CAN bus. The Talon will update its
2539 * position and velocity whenever CANcoder publishes its
2540 * information on CAN bus, and the Talon commutation sensor
2541 * will not be used.
2542 *
2543 * \param device CANcoder reference to use for RemoteCANcoder
2544 * \returns Itself
2545 */
2547
2548 /**
2549 * \brief Helper method to configure this feedback group to use
2550 * FusedCANcoder by passing in the CANcoder object.
2551 *
2552 * When using FusedCANcoder (requires Phoenix Pro), the Talon
2553 * will fuse another CANcoder's information with the
2554 * commutation sensor, which provides the best possible
2555 * position and velocity for accuracy and bandwidth.
2556 * FusedCANcoder was developed for applications such as
2557 * swerve-azimuth.
2558 *
2559 * \param device CANcoder reference to use for FusedCANcoder
2560 * \returns Itself
2561 */
2563
2564 /**
2565 * \brief Helper method to configure this feedback group to use
2566 * SyncCANcoder by passing in the CANcoder object.
2567 *
2568 * When using SyncCANcoder (requires Phoenix Pro), the Talon
2569 * will synchronize its commutation sensor position against
2570 * another CANcoder, then continue to use the rotor sensor for
2571 * closed loop control. The Talon will report if its internal
2572 * position differs significantly from the reported CANcoder
2573 * position. SyncCANcoder was developed for mechanisms where
2574 * there is a risk of the CANcoder failing in such a way that
2575 * it reports a position that does not match the mechanism,
2576 * such as the sensor mounting assembly breaking off.
2577 *
2578 * \param device CANcoder reference to use for SyncCANcoder
2579 * \returns Itself
2580 */
2582
2583 /**
2584 * \brief Helper method to configure this feedback group to use
2585 * RemoteCANdi PWM 1 by passing in the CANdi object.
2586 *
2587 * \param device CANdi reference to use for RemoteCANdi
2588 * \returns Itself
2589 */
2591
2592 /**
2593 * \brief Helper method to configure this feedback group to use
2594 * RemoteCANdi PWM 2 by passing in the CANdi object.
2595 *
2596 * \param device CANdi reference to use for RemoteCANdi
2597 * \returns Itself
2598 */
2600
2601 /**
2602 * \brief Helper method to configure this feedback group to use
2603 * RemoteCANdi Quadrature by passing in the CANdi object.
2604 *
2605 * \param device CANdi reference to use for RemoteCANdi
2606 * \returns Itself
2607 */
2609
2610 /**
2611 * \brief Helper method to configure this feedback group to use
2612 * FusedCANdi PWM 1 by passing in the CANdi object.
2613 *
2614 * When using FusedCANdi (requires Phoenix Pro), the Talon will
2615 * fuse another CANdi™ branded device's information with the
2616 * internal rotor, which provides the best possible position
2617 * and velocity for accuracy and bandwidth.
2618 *
2619 * \param device CANdi reference to use for FusedCANdi
2620 * \returns Itself
2621 */
2623
2624 /**
2625 * \brief Helper method to configure this feedback group to use
2626 * FusedCANdi PWM 2 by passing in the CANdi object.
2627 *
2628 * When using FusedCANdi (requires Phoenix Pro), the Talon will
2629 * fuse another CANdi™ branded device's information with the
2630 * internal rotor, which provides the best possible position
2631 * and velocity for accuracy and bandwidth.
2632 *
2633 * \param device CANdi reference to use for FusedCANdi
2634 * \returns Itself
2635 */
2637
2638 /**
2639 * \brief Helper method to configure this feedback group to use
2640 * FusedCANdi Quadrature by passing in the CANdi object.
2641 *
2642 * When using FusedCANdi (requires Phoenix Pro), the Talon will
2643 * fuse another CANdi™ branded device's information with the
2644 * internal rotor, which provides the best possible position
2645 * and velocity for accuracy and bandwidth.
2646 *
2647 * \param device CANdi reference to use for FusedCANdi
2648 * \returns Itself
2649 */
2651
2652 /**
2653 * \brief Helper method to configure this feedback group to use
2654 * SyncCANdi PWM 1 by passing in the CANdi object.
2655 *
2656 * When using SyncCANdi (requires Phoenix Pro), the Talon will
2657 * synchronize its internal rotor position against another
2658 * CANdi™ branded device, then continue to use the rotor sensor
2659 * for closed loop control. The Talon will report if its
2660 * internal position differs significantly from the reported
2661 * CANdi™ branded device's position. SyncCANdi was developed
2662 * for mechanisms where there is a risk of the CANdi™ branded
2663 * device failing in such a way that it reports a position that
2664 * does not match the mechanism, such as the sensor mounting
2665 * assembly breaking off.
2666 *
2667 * \param device CANdi reference to use for SyncCANdi
2668 * \returns Itself
2669 */
2671
2672 /**
2673 * \brief Helper method to configure this feedback group to use
2674 * SyncCANdi PWM 2 by passing in the CANdi object.
2675 *
2676 * When using SyncCANdi (requires Phoenix Pro), the Talon will
2677 * synchronize its internal rotor position against another
2678 * CANdi™ branded device, then continue to use the rotor sensor
2679 * for closed loop control. The Talon will report if its
2680 * internal position differs significantly from the reported
2681 * CANdi™ branded device's position. SyncCANdi was developed
2682 * for mechanisms where there is a risk of the CANdi™ branded
2683 * device failing in such a way that it reports a position that
2684 * does not match the mechanism, such as the sensor mounting
2685 * assembly breaking off.
2686 *
2687 * \param device CANdi reference to use for SyncCANdi
2688 * \returns Itself
2689 */
2691
2692
2693
2694 std::string ToString() const override
2695 {
2696 std::stringstream ss;
2697 ss << "Config Group: ExternalFeedback" << std::endl;
2698 ss << " SensorToMechanismRatio: " << SensorToMechanismRatio.to<double>() << " scalar" << std::endl;
2699 ss << " RotorToSensorRatio: " << RotorToSensorRatio.to<double>() << " scalar" << std::endl;
2700 ss << " FeedbackRemoteSensorID: " << FeedbackRemoteSensorID << std::endl;
2701 ss << " VelocityFilterTimeConstant: " << VelocityFilterTimeConstant.to<double>() << " seconds" << std::endl;
2702 ss << " AbsoluteSensorOffset: " << AbsoluteSensorOffset.to<double>() << " rotations" << std::endl;
2703 ss << " ExternalFeedbackSensorSource: " << ExternalFeedbackSensorSource << std::endl;
2704 ss << " SensorPhase: " << SensorPhase << std::endl;
2705 ss << " QuadratureEdgesPerRotation: " << QuadratureEdgesPerRotation << std::endl;
2706 ss << " AbsoluteSensorDiscontinuityPoint: " << AbsoluteSensorDiscontinuityPoint.to<double>() << " rotations" << std::endl;
2707 return ss.str();
2708 }
2709
2710 std::string Serialize() const override
2711 {
2712 std::stringstream ss;
2713 char *ref;
2714 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_SensorToMechanismRatio, SensorToMechanismRatio.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
2715 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_RotorToSensorRatio, RotorToSensorRatio.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
2716 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackRemoteSensorID, FeedbackRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2717 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_VelocityFilterTimeConstant, VelocityFilterTimeConstant.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
2718 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_AbsoluteSensorOffset, AbsoluteSensorOffset.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
2719 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ExternalFeedbackSensorSource, ExternalFeedbackSensorSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2720 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_SensorPhase, SensorPhase.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2721 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_QuadratureEdgesPerRotation, QuadratureEdgesPerRotation, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2722 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_AbsoluteSensorDiscontinuityPoint, AbsoluteSensorDiscontinuityPoint.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
2723 return ss.str();
2724 }
2725
2726 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
2727 {
2728 const char *string_c_str = to_deserialize.c_str();
2729 size_t string_length = to_deserialize.length();
2730 double SensorToMechanismRatioVal = SensorToMechanismRatio.to<double>();
2731 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_SensorToMechanismRatio, string_c_str, string_length, &SensorToMechanismRatioVal);
2732 SensorToMechanismRatio = units::dimensionless::scalar_t{SensorToMechanismRatioVal};
2733 double RotorToSensorRatioVal = RotorToSensorRatio.to<double>();
2734 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_RotorToSensorRatio, string_c_str, string_length, &RotorToSensorRatioVal);
2735 RotorToSensorRatio = units::dimensionless::scalar_t{RotorToSensorRatioVal};
2736 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_FeedbackRemoteSensorID, string_c_str, string_length, &FeedbackRemoteSensorID);
2737 double VelocityFilterTimeConstantVal = VelocityFilterTimeConstant.to<double>();
2738 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_VelocityFilterTimeConstant, string_c_str, string_length, &VelocityFilterTimeConstantVal);
2739 VelocityFilterTimeConstant = units::time::second_t{VelocityFilterTimeConstantVal};
2740 double AbsoluteSensorOffsetVal = AbsoluteSensorOffset.to<double>();
2741 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_AbsoluteSensorOffset, string_c_str, string_length, &AbsoluteSensorOffsetVal);
2742 AbsoluteSensorOffset = units::angle::turn_t{AbsoluteSensorOffsetVal};
2743 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ExternalFeedbackSensorSource, string_c_str, string_length, &ExternalFeedbackSensorSource.value);
2744 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_SensorPhase, string_c_str, string_length, &SensorPhase.value);
2745 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_QuadratureEdgesPerRotation, string_c_str, string_length, &QuadratureEdgesPerRotation);
2746 double AbsoluteSensorDiscontinuityPointVal = AbsoluteSensorDiscontinuityPoint.to<double>();
2747 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_AbsoluteSensorDiscontinuityPoint, string_c_str, string_length, &AbsoluteSensorDiscontinuityPointVal);
2748 AbsoluteSensorDiscontinuityPoint = units::angle::turn_t{AbsoluteSensorDiscontinuityPointVal};
2749 return 0;
2750 }
2751};
2752
2753
2754/**
2755 * \brief Configs related to sensors used for differential control of
2756 * a mechanism.
2757 *
2758 * \details Includes the differential sensor sources and IDs.
2759 */
2761{
2762public:
2763 constexpr DifferentialSensorsConfigs() = default;
2764
2765 /**
2766 * \brief Choose what sensor source is used for differential control
2767 * of a mechanism. The default is Disabled. All other options
2768 * require setting the DifferentialTalonFXSensorID, as the average of
2769 * this Talon FX's sensor and the remote TalonFX's sensor is used for
2770 * the differential controller's primary targets.
2771 *
2772 * Choose RemoteTalonFX_Diff to use another TalonFX on the same CAN
2773 * bus. Talon FX will update its differential position and velocity
2774 * whenever the remote TalonFX publishes its information on CAN bus.
2775 * The differential controller will use the difference between this
2776 * TalonFX's sensor and the remote Talon FX's sensor for the
2777 * differential component of the output.
2778 *
2779 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
2780 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
2781 * also requires setting DifferentialRemoteSensorID). Talon FX will
2782 * update its differential position to match the selected value
2783 * whenever Pigeon2 publishes its information on CAN bus. Note that
2784 * the Talon FX differential position will be in rotations and not
2785 * degrees.
2786 *
2787 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
2788 * (this also requires setting DifferentialRemoteSensorID). Talon FX
2789 * will update its differential position and velocity to match the
2790 * CANcoder whenever CANcoder publishes its information on CAN bus.
2791 *
2792 */
2794 /**
2795 * \brief Device ID of which remote Talon FX to use. This is used
2796 * when the Differential Sensor Source is not disabled.
2797 *
2798 * - Minimum Value: 0
2799 * - Maximum Value: 62
2800 * - Default Value: 0
2801 * - Units:
2802 */
2804 /**
2805 * \brief Device ID of which remote sensor to use on the differential
2806 * axis. This is used when the Differential Sensor Source is not
2807 * RemoteTalonFX_Diff.
2808 *
2809 * - Minimum Value: 0
2810 * - Maximum Value: 62
2811 * - Default Value: 0
2812 * - Units:
2813 */
2815
2816 /**
2817 * \brief Modifies this configuration's DifferentialSensorSource parameter and returns itself for
2818 * method-chaining and easier to use config API.
2819 *
2820 * Choose what sensor source is used for differential control of a
2821 * mechanism. The default is Disabled. All other options require
2822 * setting the DifferentialTalonFXSensorID, as the average of this
2823 * Talon FX's sensor and the remote TalonFX's sensor is used for the
2824 * differential controller's primary targets.
2825 *
2826 * Choose RemoteTalonFX_Diff to use another TalonFX on the same CAN
2827 * bus. Talon FX will update its differential position and velocity
2828 * whenever the remote TalonFX publishes its information on CAN bus.
2829 * The differential controller will use the difference between this
2830 * TalonFX's sensor and the remote Talon FX's sensor for the
2831 * differential component of the output.
2832 *
2833 * Choose RemotePigeon2_Yaw, RemotePigeon2_Pitch, and
2834 * RemotePigeon2_Roll to use another Pigeon2 on the same CAN bus (this
2835 * also requires setting DifferentialRemoteSensorID). Talon FX will
2836 * update its differential position to match the selected value
2837 * whenever Pigeon2 publishes its information on CAN bus. Note that
2838 * the Talon FX differential position will be in rotations and not
2839 * degrees.
2840 *
2841 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
2842 * (this also requires setting DifferentialRemoteSensorID). Talon FX
2843 * will update its differential position and velocity to match the
2844 * CANcoder whenever CANcoder publishes its information on CAN bus.
2845 *
2846 *
2847 * \param newDifferentialSensorSource Parameter to modify
2848 * \returns Itself
2849 */
2851 {
2852 DifferentialSensorSource = std::move(newDifferentialSensorSource);
2853 return *this;
2854 }
2855
2856 /**
2857 * \brief Modifies this configuration's DifferentialTalonFXSensorID parameter and returns itself for
2858 * method-chaining and easier to use config API.
2859 *
2860 * Device ID of which remote Talon FX to use. This is used when the
2861 * Differential Sensor Source is not disabled.
2862 *
2863 * - Minimum Value: 0
2864 * - Maximum Value: 62
2865 * - Default Value: 0
2866 * - Units:
2867 *
2868 * \param newDifferentialTalonFXSensorID Parameter to modify
2869 * \returns Itself
2870 */
2871 constexpr DifferentialSensorsConfigs &WithDifferentialTalonFXSensorID(int newDifferentialTalonFXSensorID)
2872 {
2873 DifferentialTalonFXSensorID = std::move(newDifferentialTalonFXSensorID);
2874 return *this;
2875 }
2876
2877 /**
2878 * \brief Modifies this configuration's DifferentialRemoteSensorID parameter and returns itself for
2879 * method-chaining and easier to use config API.
2880 *
2881 * Device ID of which remote sensor to use on the differential axis.
2882 * This is used when the Differential Sensor Source is not
2883 * RemoteTalonFX_Diff.
2884 *
2885 * - Minimum Value: 0
2886 * - Maximum Value: 62
2887 * - Default Value: 0
2888 * - Units:
2889 *
2890 * \param newDifferentialRemoteSensorID Parameter to modify
2891 * \returns Itself
2892 */
2893 constexpr DifferentialSensorsConfigs &WithDifferentialRemoteSensorID(int newDifferentialRemoteSensorID)
2894 {
2895 DifferentialRemoteSensorID = std::move(newDifferentialRemoteSensorID);
2896 return *this;
2897 }
2898
2899
2900
2901 std::string ToString() const override
2902 {
2903 std::stringstream ss;
2904 ss << "Config Group: DifferentialSensors" << std::endl;
2905 ss << " DifferentialSensorSource: " << DifferentialSensorSource << std::endl;
2906 ss << " DifferentialTalonFXSensorID: " << DifferentialTalonFXSensorID << std::endl;
2907 ss << " DifferentialRemoteSensorID: " << DifferentialRemoteSensorID << std::endl;
2908 return ss.str();
2909 }
2910
2911 std::string Serialize() const override
2912 {
2913 std::stringstream ss;
2914 char *ref;
2915 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialSensorSource, DifferentialSensorSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2916 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialTalonFXSensorID, DifferentialTalonFXSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2917 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialRemoteSensorID, DifferentialRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
2918 return ss.str();
2919 }
2920
2921 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
2922 {
2923 const char *string_c_str = to_deserialize.c_str();
2924 size_t string_length = to_deserialize.length();
2925 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialSensorSource, string_c_str, string_length, &DifferentialSensorSource.value);
2926 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialTalonFXSensorID, string_c_str, string_length, &DifferentialTalonFXSensorID);
2927 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_DifferentialRemoteSensorID, string_c_str, string_length, &DifferentialRemoteSensorID);
2928 return 0;
2929 }
2930};
2931
2932
2933/**
2934 * \brief Configs related to constants used for differential control
2935 * of a mechanism.
2936 *
2937 * \details Includes the differential peak outputs.
2938 */
2940{
2941public:
2942 constexpr DifferentialConstantsConfigs() = default;
2943
2944 /**
2945 * \brief Maximum differential output during duty cycle based
2946 * differential control modes.
2947 *
2948 * - Minimum Value: 0.0
2949 * - Maximum Value: 2.0
2950 * - Default Value: 2
2951 * - Units: fractional
2952 */
2953 units::dimensionless::scalar_t PeakDifferentialDutyCycle = 2;
2954 /**
2955 * \brief Maximum differential output during voltage based
2956 * differential control modes.
2957 *
2958 * - Minimum Value: 0.0
2959 * - Maximum Value: 32
2960 * - Default Value: 32
2961 * - Units: V
2962 */
2963 units::voltage::volt_t PeakDifferentialVoltage = 32_V;
2964 /**
2965 * \brief Maximum differential output during torque current based
2966 * differential control modes.
2967 *
2968 * - Minimum Value: 0.0
2969 * - Maximum Value: 1600
2970 * - Default Value: 1600
2971 * - Units: A
2972 */
2973 units::current::ampere_t PeakDifferentialTorqueCurrent = 1600_A;
2974
2975 /**
2976 * \brief Modifies this configuration's PeakDifferentialDutyCycle parameter and returns itself for
2977 * method-chaining and easier to use config API.
2978 *
2979 * Maximum differential output during duty cycle based differential
2980 * control modes.
2981 *
2982 * - Minimum Value: 0.0
2983 * - Maximum Value: 2.0
2984 * - Default Value: 2
2985 * - Units: fractional
2986 *
2987 * \param newPeakDifferentialDutyCycle Parameter to modify
2988 * \returns Itself
2989 */
2990 constexpr DifferentialConstantsConfigs &WithPeakDifferentialDutyCycle(units::dimensionless::scalar_t newPeakDifferentialDutyCycle)
2991 {
2992 PeakDifferentialDutyCycle = std::move(newPeakDifferentialDutyCycle);
2993 return *this;
2994 }
2995
2996 /**
2997 * \brief Modifies this configuration's PeakDifferentialVoltage parameter and returns itself for
2998 * method-chaining and easier to use config API.
2999 *
3000 * Maximum differential output during voltage based differential
3001 * control modes.
3002 *
3003 * - Minimum Value: 0.0
3004 * - Maximum Value: 32
3005 * - Default Value: 32
3006 * - Units: V
3007 *
3008 * \param newPeakDifferentialVoltage Parameter to modify
3009 * \returns Itself
3010 */
3011 constexpr DifferentialConstantsConfigs &WithPeakDifferentialVoltage(units::voltage::volt_t newPeakDifferentialVoltage)
3012 {
3013 PeakDifferentialVoltage = std::move(newPeakDifferentialVoltage);
3014 return *this;
3015 }
3016
3017 /**
3018 * \brief Modifies this configuration's PeakDifferentialTorqueCurrent parameter and returns itself for
3019 * method-chaining and easier to use config API.
3020 *
3021 * Maximum differential output during torque current based
3022 * differential control modes.
3023 *
3024 * - Minimum Value: 0.0
3025 * - Maximum Value: 1600
3026 * - Default Value: 1600
3027 * - Units: A
3028 *
3029 * \param newPeakDifferentialTorqueCurrent Parameter to modify
3030 * \returns Itself
3031 */
3032 constexpr DifferentialConstantsConfigs &WithPeakDifferentialTorqueCurrent(units::current::ampere_t newPeakDifferentialTorqueCurrent)
3033 {
3034 PeakDifferentialTorqueCurrent = std::move(newPeakDifferentialTorqueCurrent);
3035 return *this;
3036 }
3037
3038
3039
3040 std::string ToString() const override
3041 {
3042 std::stringstream ss;
3043 ss << "Config Group: DifferentialConstants" << std::endl;
3044 ss << " PeakDifferentialDutyCycle: " << PeakDifferentialDutyCycle.to<double>() << " fractional" << std::endl;
3045 ss << " PeakDifferentialVoltage: " << PeakDifferentialVoltage.to<double>() << " V" << std::endl;
3046 ss << " PeakDifferentialTorqueCurrent: " << PeakDifferentialTorqueCurrent.to<double>() << " A" << std::endl;
3047 return ss.str();
3048 }
3049
3050 std::string Serialize() const override
3051 {
3052 std::stringstream ss;
3053 char *ref;
3054 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffDC, PeakDifferentialDutyCycle.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3055 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffV, PeakDifferentialVoltage.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3056 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffTorqCurr, PeakDifferentialTorqueCurrent.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3057 return ss.str();
3058 }
3059
3060 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
3061 {
3062 const char *string_c_str = to_deserialize.c_str();
3063 size_t string_length = to_deserialize.length();
3064 double PeakDifferentialDutyCycleVal = PeakDifferentialDutyCycle.to<double>();
3065 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffDC, string_c_str, string_length, &PeakDifferentialDutyCycleVal);
3066 PeakDifferentialDutyCycle = units::dimensionless::scalar_t{PeakDifferentialDutyCycleVal};
3067 double PeakDifferentialVoltageVal = PeakDifferentialVoltage.to<double>();
3068 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffV, string_c_str, string_length, &PeakDifferentialVoltageVal);
3069 PeakDifferentialVoltage = units::voltage::volt_t{PeakDifferentialVoltageVal};
3070 double PeakDifferentialTorqueCurrentVal = PeakDifferentialTorqueCurrent.to<double>();
3071 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PeakDiffTorqCurr, string_c_str, string_length, &PeakDifferentialTorqueCurrentVal);
3072 PeakDifferentialTorqueCurrent = units::current::ampere_t{PeakDifferentialTorqueCurrentVal};
3073 return 0;
3074 }
3075};
3076
3077
3078/**
3079 * \brief Configs that affect the open-loop control of this motor
3080 * controller.
3081 *
3082 * \details Open-loop ramp rates for the various control types.
3083 */
3085{
3086public:
3087 constexpr OpenLoopRampsConfigs() = default;
3088
3089 /**
3090 * \brief If non-zero, this determines how much time to ramp from 0%
3091 * output to 100% during the open-loop DutyCycleOut control mode.
3092 *
3093 * This provides an easy way to limit the acceleration of the motor.
3094 * However, the acceleration and current draw of the motor can be
3095 * better restricted using current limits instead of a ramp rate.
3096 *
3097 * - Minimum Value: 0
3098 * - Maximum Value: 1
3099 * - Default Value: 0
3100 * - Units: seconds
3101 */
3102 units::time::second_t DutyCycleOpenLoopRampPeriod = 0_s;
3103 /**
3104 * \brief If non-zero, this determines how much time to ramp from 0V
3105 * output to 12V during the open-loop VoltageOut control mode.
3106 *
3107 * This provides an easy way to limit the acceleration of the motor.
3108 * However, the acceleration and current draw of the motor can be
3109 * better restricted using current limits instead of a ramp rate.
3110 *
3111 * - Minimum Value: 0
3112 * - Maximum Value: 1
3113 * - Default Value: 0
3114 * - Units: seconds
3115 */
3116 units::time::second_t VoltageOpenLoopRampPeriod = 0_s;
3117 /**
3118 * \brief If non-zero, this determines how much time to ramp from 0A
3119 * output to 300A during the open-loop TorqueCurrent control mode.
3120 *
3121 * Since TorqueCurrent is directly proportional to acceleration, this
3122 * ramp limits jerk instead of acceleration.
3123 *
3124 * - Minimum Value: 0
3125 * - Maximum Value: 10
3126 * - Default Value: 0
3127 * - Units: seconds
3128 */
3129 units::time::second_t TorqueOpenLoopRampPeriod = 0_s;
3130
3131 /**
3132 * \brief Modifies this configuration's DutyCycleOpenLoopRampPeriod parameter and returns itself for
3133 * method-chaining and easier to use config API.
3134 *
3135 * If non-zero, this determines how much time to ramp from 0% output
3136 * to 100% during the open-loop DutyCycleOut control mode.
3137 *
3138 * This provides an easy way to limit the acceleration of the motor.
3139 * However, the acceleration and current draw of the motor can be
3140 * better restricted using current limits instead of a ramp rate.
3141 *
3142 * - Minimum Value: 0
3143 * - Maximum Value: 1
3144 * - Default Value: 0
3145 * - Units: seconds
3146 *
3147 * \param newDutyCycleOpenLoopRampPeriod Parameter to modify
3148 * \returns Itself
3149 */
3150 constexpr OpenLoopRampsConfigs &WithDutyCycleOpenLoopRampPeriod(units::time::second_t newDutyCycleOpenLoopRampPeriod)
3151 {
3152 DutyCycleOpenLoopRampPeriod = std::move(newDutyCycleOpenLoopRampPeriod);
3153 return *this;
3154 }
3155
3156 /**
3157 * \brief Modifies this configuration's VoltageOpenLoopRampPeriod parameter and returns itself for
3158 * method-chaining and easier to use config API.
3159 *
3160 * If non-zero, this determines how much time to ramp from 0V output
3161 * to 12V during the open-loop VoltageOut control mode.
3162 *
3163 * This provides an easy way to limit the acceleration of the motor.
3164 * However, the acceleration and current draw of the motor can be
3165 * better restricted using current limits instead of a ramp rate.
3166 *
3167 * - Minimum Value: 0
3168 * - Maximum Value: 1
3169 * - Default Value: 0
3170 * - Units: seconds
3171 *
3172 * \param newVoltageOpenLoopRampPeriod Parameter to modify
3173 * \returns Itself
3174 */
3175 constexpr OpenLoopRampsConfigs &WithVoltageOpenLoopRampPeriod(units::time::second_t newVoltageOpenLoopRampPeriod)
3176 {
3177 VoltageOpenLoopRampPeriod = std::move(newVoltageOpenLoopRampPeriod);
3178 return *this;
3179 }
3180
3181 /**
3182 * \brief Modifies this configuration's TorqueOpenLoopRampPeriod parameter and returns itself for
3183 * method-chaining and easier to use config API.
3184 *
3185 * If non-zero, this determines how much time to ramp from 0A output
3186 * to 300A during the open-loop TorqueCurrent control mode.
3187 *
3188 * Since TorqueCurrent is directly proportional to acceleration, this
3189 * ramp limits jerk instead of acceleration.
3190 *
3191 * - Minimum Value: 0
3192 * - Maximum Value: 10
3193 * - Default Value: 0
3194 * - Units: seconds
3195 *
3196 * \param newTorqueOpenLoopRampPeriod Parameter to modify
3197 * \returns Itself
3198 */
3199 constexpr OpenLoopRampsConfigs &WithTorqueOpenLoopRampPeriod(units::time::second_t newTorqueOpenLoopRampPeriod)
3200 {
3201 TorqueOpenLoopRampPeriod = std::move(newTorqueOpenLoopRampPeriod);
3202 return *this;
3203 }
3204
3205
3206
3207 std::string ToString() const override
3208 {
3209 std::stringstream ss;
3210 ss << "Config Group: OpenLoopRamps" << std::endl;
3211 ss << " DutyCycleOpenLoopRampPeriod: " << DutyCycleOpenLoopRampPeriod.to<double>() << " seconds" << std::endl;
3212 ss << " VoltageOpenLoopRampPeriod: " << VoltageOpenLoopRampPeriod.to<double>() << " seconds" << std::endl;
3213 ss << " TorqueOpenLoopRampPeriod: " << TorqueOpenLoopRampPeriod.to<double>() << " seconds" << std::endl;
3214 return ss.str();
3215 }
3216
3217 std::string Serialize() const override
3218 {
3219 std::stringstream ss;
3220 char *ref;
3221 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleOpenLoopRampPeriod, DutyCycleOpenLoopRampPeriod.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3222 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageOpenLoopRampPeriod, VoltageOpenLoopRampPeriod.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3223 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueOpenLoopRampPeriod, TorqueOpenLoopRampPeriod.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3224 return ss.str();
3225 }
3226
3227 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
3228 {
3229 const char *string_c_str = to_deserialize.c_str();
3230 size_t string_length = to_deserialize.length();
3231 double DutyCycleOpenLoopRampPeriodVal = DutyCycleOpenLoopRampPeriod.to<double>();
3232 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleOpenLoopRampPeriod, string_c_str, string_length, &DutyCycleOpenLoopRampPeriodVal);
3233 DutyCycleOpenLoopRampPeriod = units::time::second_t{DutyCycleOpenLoopRampPeriodVal};
3234 double VoltageOpenLoopRampPeriodVal = VoltageOpenLoopRampPeriod.to<double>();
3235 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageOpenLoopRampPeriod, string_c_str, string_length, &VoltageOpenLoopRampPeriodVal);
3236 VoltageOpenLoopRampPeriod = units::time::second_t{VoltageOpenLoopRampPeriodVal};
3237 double TorqueOpenLoopRampPeriodVal = TorqueOpenLoopRampPeriod.to<double>();
3238 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueOpenLoopRampPeriod, string_c_str, string_length, &TorqueOpenLoopRampPeriodVal);
3239 TorqueOpenLoopRampPeriod = units::time::second_t{TorqueOpenLoopRampPeriodVal};
3240 return 0;
3241 }
3242};
3243
3244
3245/**
3246 * \brief Configs that affect the closed-loop control of this motor
3247 * controller.
3248 *
3249 * \details Closed-loop ramp rates for the various control types.
3250 */
3252{
3253public:
3254 constexpr ClosedLoopRampsConfigs() = default;
3255
3256 /**
3257 * \brief If non-zero, this determines how much time to ramp from 0%
3258 * output to 100% during the closed-loop DutyCycle control modes.
3259 *
3260 * If the goal is to limit acceleration, it is more useful to ramp the
3261 * closed-loop setpoint instead of the output. This can be achieved
3262 * using Motion Magic® controls.
3263 *
3264 * The acceleration and current draw of the motor can also be better
3265 * restricted using current limits instead of a ramp rate.
3266 *
3267 * - Minimum Value: 0
3268 * - Maximum Value: 1
3269 * - Default Value: 0
3270 * - Units: seconds
3271 */
3272 units::time::second_t DutyCycleClosedLoopRampPeriod = 0_s;
3273 /**
3274 * \brief If non-zero, this determines how much time to ramp from 0V
3275 * output to 12V during the closed-loop Voltage control modes.
3276 *
3277 * If the goal is to limit acceleration, it is more useful to ramp the
3278 * closed-loop setpoint instead of the output. This can be achieved
3279 * using Motion Magic® controls.
3280 *
3281 * The acceleration and current draw of the motor can also be better
3282 * restricted using current limits instead of a ramp rate.
3283 *
3284 * - Minimum Value: 0
3285 * - Maximum Value: 1
3286 * - Default Value: 0
3287 * - Units: seconds
3288 */
3289 units::time::second_t VoltageClosedLoopRampPeriod = 0_s;
3290 /**
3291 * \brief If non-zero, this determines how much time to ramp from 0A
3292 * output to 300A during the closed-loop TorqueCurrent control modes.
3293 *
3294 * Since TorqueCurrent is directly proportional to acceleration, this
3295 * ramp limits jerk instead of acceleration.
3296 *
3297 * If the goal is to limit acceleration or jerk, it is more useful to
3298 * ramp the closed-loop setpoint instead of the output. This can be
3299 * achieved using Motion Magic® controls.
3300 *
3301 * The acceleration and current draw of the motor can also be better
3302 * restricted using current limits instead of a ramp rate.
3303 *
3304 * - Minimum Value: 0
3305 * - Maximum Value: 10
3306 * - Default Value: 0
3307 * - Units: seconds
3308 */
3309 units::time::second_t TorqueClosedLoopRampPeriod = 0_s;
3310
3311 /**
3312 * \brief Modifies this configuration's DutyCycleClosedLoopRampPeriod parameter and returns itself for
3313 * method-chaining and easier to use config API.
3314 *
3315 * If non-zero, this determines how much time to ramp from 0% output
3316 * to 100% during the closed-loop DutyCycle control modes.
3317 *
3318 * If the goal is to limit acceleration, it is more useful to ramp the
3319 * closed-loop setpoint instead of the output. This can be achieved
3320 * using Motion Magic® controls.
3321 *
3322 * The acceleration and current draw of the motor can also be better
3323 * restricted using current limits instead of a ramp rate.
3324 *
3325 * - Minimum Value: 0
3326 * - Maximum Value: 1
3327 * - Default Value: 0
3328 * - Units: seconds
3329 *
3330 * \param newDutyCycleClosedLoopRampPeriod Parameter to modify
3331 * \returns Itself
3332 */
3333 constexpr ClosedLoopRampsConfigs &WithDutyCycleClosedLoopRampPeriod(units::time::second_t newDutyCycleClosedLoopRampPeriod)
3334 {
3335 DutyCycleClosedLoopRampPeriod = std::move(newDutyCycleClosedLoopRampPeriod);
3336 return *this;
3337 }
3338
3339 /**
3340 * \brief Modifies this configuration's VoltageClosedLoopRampPeriod parameter and returns itself for
3341 * method-chaining and easier to use config API.
3342 *
3343 * If non-zero, this determines how much time to ramp from 0V output
3344 * to 12V during the closed-loop Voltage control modes.
3345 *
3346 * If the goal is to limit acceleration, it is more useful to ramp the
3347 * closed-loop setpoint instead of the output. This can be achieved
3348 * using Motion Magic® controls.
3349 *
3350 * The acceleration and current draw of the motor can also be better
3351 * restricted using current limits instead of a ramp rate.
3352 *
3353 * - Minimum Value: 0
3354 * - Maximum Value: 1
3355 * - Default Value: 0
3356 * - Units: seconds
3357 *
3358 * \param newVoltageClosedLoopRampPeriod Parameter to modify
3359 * \returns Itself
3360 */
3361 constexpr ClosedLoopRampsConfigs &WithVoltageClosedLoopRampPeriod(units::time::second_t newVoltageClosedLoopRampPeriod)
3362 {
3363 VoltageClosedLoopRampPeriod = std::move(newVoltageClosedLoopRampPeriod);
3364 return *this;
3365 }
3366
3367 /**
3368 * \brief Modifies this configuration's TorqueClosedLoopRampPeriod parameter and returns itself for
3369 * method-chaining and easier to use config API.
3370 *
3371 * If non-zero, this determines how much time to ramp from 0A output
3372 * to 300A during the closed-loop TorqueCurrent control modes.
3373 *
3374 * Since TorqueCurrent is directly proportional to acceleration, this
3375 * ramp limits jerk instead of acceleration.
3376 *
3377 * If the goal is to limit acceleration or jerk, it is more useful to
3378 * ramp the closed-loop setpoint instead of the output. This can be
3379 * achieved using Motion Magic® controls.
3380 *
3381 * The acceleration and current draw of the motor can also be better
3382 * restricted using current limits instead of a ramp rate.
3383 *
3384 * - Minimum Value: 0
3385 * - Maximum Value: 10
3386 * - Default Value: 0
3387 * - Units: seconds
3388 *
3389 * \param newTorqueClosedLoopRampPeriod Parameter to modify
3390 * \returns Itself
3391 */
3392 constexpr ClosedLoopRampsConfigs &WithTorqueClosedLoopRampPeriod(units::time::second_t newTorqueClosedLoopRampPeriod)
3393 {
3394 TorqueClosedLoopRampPeriod = std::move(newTorqueClosedLoopRampPeriod);
3395 return *this;
3396 }
3397
3398
3399
3400 std::string ToString() const override
3401 {
3402 std::stringstream ss;
3403 ss << "Config Group: ClosedLoopRamps" << std::endl;
3404 ss << " DutyCycleClosedLoopRampPeriod: " << DutyCycleClosedLoopRampPeriod.to<double>() << " seconds" << std::endl;
3405 ss << " VoltageClosedLoopRampPeriod: " << VoltageClosedLoopRampPeriod.to<double>() << " seconds" << std::endl;
3406 ss << " TorqueClosedLoopRampPeriod: " << TorqueClosedLoopRampPeriod.to<double>() << " seconds" << std::endl;
3407 return ss.str();
3408 }
3409
3410 std::string Serialize() const override
3411 {
3412 std::stringstream ss;
3413 char *ref;
3414 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleClosedLoopRampPeriod, DutyCycleClosedLoopRampPeriod.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3415 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageClosedLoopRampPeriod, VoltageClosedLoopRampPeriod.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3416 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueClosedLoopRampPeriod, TorqueClosedLoopRampPeriod.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3417 return ss.str();
3418 }
3419
3420 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
3421 {
3422 const char *string_c_str = to_deserialize.c_str();
3423 size_t string_length = to_deserialize.length();
3424 double DutyCycleClosedLoopRampPeriodVal = DutyCycleClosedLoopRampPeriod.to<double>();
3425 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_DutyCycleClosedLoopRampPeriod, string_c_str, string_length, &DutyCycleClosedLoopRampPeriodVal);
3426 DutyCycleClosedLoopRampPeriod = units::time::second_t{DutyCycleClosedLoopRampPeriodVal};
3427 double VoltageClosedLoopRampPeriodVal = VoltageClosedLoopRampPeriod.to<double>();
3428 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_VoltageClosedLoopRampPeriod, string_c_str, string_length, &VoltageClosedLoopRampPeriodVal);
3429 VoltageClosedLoopRampPeriod = units::time::second_t{VoltageClosedLoopRampPeriodVal};
3430 double TorqueClosedLoopRampPeriodVal = TorqueClosedLoopRampPeriod.to<double>();
3431 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_TorqueClosedLoopRampPeriod, string_c_str, string_length, &TorqueClosedLoopRampPeriodVal);
3432 TorqueClosedLoopRampPeriod = units::time::second_t{TorqueClosedLoopRampPeriodVal};
3433 return 0;
3434 }
3435};
3436
3437
3438/**
3439 * \brief Configs that change how the motor controller behaves under
3440 * different limit switch states.
3441 *
3442 * \details Includes configs such as enabling limit switches,
3443 * configuring the remote sensor ID, the source, and the
3444 * position to set on limit.
3445 */
3447{
3448public:
3449 constexpr HardwareLimitSwitchConfigs() = default;
3450
3451 /**
3452 * \brief Determines if the forward limit switch is normally-open
3453 * (default) or normally-closed.
3454 *
3455 */
3457 /**
3458 * \brief If enabled, the position is automatically set to a specific
3459 * value, specified by ForwardLimitAutosetPositionValue, when the
3460 * forward limit switch is asserted.
3461 *
3462 * - Default Value: False
3463 */
3465 /**
3466 * \brief The value to automatically set the position to when the
3467 * forward limit switch is asserted. This has no effect if
3468 * ForwardLimitAutosetPositionEnable is false.
3469 *
3470 * - Minimum Value: -3.4e+38
3471 * - Maximum Value: 3.4e+38
3472 * - Default Value: 0
3473 * - Units: rotations
3474 */
3475 units::angle::turn_t ForwardLimitAutosetPositionValue = 0_tr;
3476 /**
3477 * \brief If enabled, motor output is set to neutral when the forward
3478 * limit switch is asserted and positive output is requested.
3479 *
3480 * - Default Value: True
3481 */
3483 /**
3484 * \brief Determines where to poll the forward limit switch. This
3485 * defaults to the forward limit switch pin on the limit switch
3486 * connector.
3487 *
3488 * Choose RemoteTalonFX to use the forward limit switch attached to
3489 * another Talon FX on the same CAN bus (this also requires setting
3490 * ForwardLimitRemoteSensorID).
3491 *
3492 * Choose RemoteCANifier to use the forward limit switch attached to
3493 * another CANifier on the same CAN bus (this also requires setting
3494 * ForwardLimitRemoteSensorID).
3495 *
3496 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
3497 * (this also requires setting ForwardLimitRemoteSensorID). The
3498 * forward limit will assert when the CANcoder magnet strength changes
3499 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
3500 *
3501 */
3503 /**
3504 * \brief Device ID of the remote device if using remote limit switch
3505 * features for the forward limit switch.
3506 *
3507 * - Minimum Value: 0
3508 * - Maximum Value: 62
3509 * - Default Value: 0
3510 * - Units:
3511 */
3513 /**
3514 * \brief Determines if the reverse limit switch is normally-open
3515 * (default) or normally-closed.
3516 *
3517 */
3519 /**
3520 * \brief If enabled, the position is automatically set to a specific
3521 * value, specified by ReverseLimitAutosetPositionValue, when the
3522 * reverse limit switch is asserted.
3523 *
3524 * - Default Value: False
3525 */
3527 /**
3528 * \brief The value to automatically set the position to when the
3529 * reverse limit switch is asserted. This has no effect if
3530 * ReverseLimitAutosetPositionEnable is false.
3531 *
3532 * - Minimum Value: -3.4e+38
3533 * - Maximum Value: 3.4e+38
3534 * - Default Value: 0
3535 * - Units: rotations
3536 */
3537 units::angle::turn_t ReverseLimitAutosetPositionValue = 0_tr;
3538 /**
3539 * \brief If enabled, motor output is set to neutral when reverse
3540 * limit switch is asseted and negative output is requested.
3541 *
3542 * - Default Value: True
3543 */
3545 /**
3546 * \brief Determines where to poll the reverse limit switch. This
3547 * defaults to the reverse limit switch pin on the limit switch
3548 * connector.
3549 *
3550 * Choose RemoteTalonFX to use the reverse limit switch attached to
3551 * another Talon FX on the same CAN bus (this also requires setting
3552 * ReverseLimitRemoteSensorID).
3553 *
3554 * Choose RemoteCANifier to use the reverse limit switch attached to
3555 * another CANifier on the same CAN bus (this also requires setting
3556 * ReverseLimitRemoteSensorID).
3557 *
3558 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
3559 * (this also requires setting ReverseLimitRemoteSensorID). The
3560 * reverse limit will assert when the CANcoder magnet strength changes
3561 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
3562 *
3563 */
3565 /**
3566 * \brief Device ID of the remote device if using remote limit switch
3567 * features for the reverse limit switch.
3568 *
3569 * - Minimum Value: 0
3570 * - Maximum Value: 62
3571 * - Default Value: 0
3572 * - Units:
3573 */
3575
3576 /**
3577 * \brief Modifies this configuration's ForwardLimitType parameter and returns itself for
3578 * method-chaining and easier to use config API.
3579 *
3580 * Determines if the forward limit switch is normally-open (default)
3581 * or normally-closed.
3582 *
3583 *
3584 * \param newForwardLimitType Parameter to modify
3585 * \returns Itself
3586 */
3588 {
3589 ForwardLimitType = std::move(newForwardLimitType);
3590 return *this;
3591 }
3592
3593 /**
3594 * \brief Modifies this configuration's ForwardLimitAutosetPositionEnable parameter and returns itself for
3595 * method-chaining and easier to use config API.
3596 *
3597 * If enabled, the position is automatically set to a specific value,
3598 * specified by ForwardLimitAutosetPositionValue, when the forward
3599 * limit switch is asserted.
3600 *
3601 * - Default Value: False
3602 *
3603 * \param newForwardLimitAutosetPositionEnable Parameter to modify
3604 * \returns Itself
3605 */
3606 constexpr HardwareLimitSwitchConfigs &WithForwardLimitAutosetPositionEnable(bool newForwardLimitAutosetPositionEnable)
3607 {
3608 ForwardLimitAutosetPositionEnable = std::move(newForwardLimitAutosetPositionEnable);
3609 return *this;
3610 }
3611
3612 /**
3613 * \brief Modifies this configuration's ForwardLimitAutosetPositionValue parameter and returns itself for
3614 * method-chaining and easier to use config API.
3615 *
3616 * The value to automatically set the position to when the forward
3617 * limit switch is asserted. This has no effect if
3618 * ForwardLimitAutosetPositionEnable is false.
3619 *
3620 * - Minimum Value: -3.4e+38
3621 * - Maximum Value: 3.4e+38
3622 * - Default Value: 0
3623 * - Units: rotations
3624 *
3625 * \param newForwardLimitAutosetPositionValue Parameter to modify
3626 * \returns Itself
3627 */
3628 constexpr HardwareLimitSwitchConfigs &WithForwardLimitAutosetPositionValue(units::angle::turn_t newForwardLimitAutosetPositionValue)
3629 {
3630 ForwardLimitAutosetPositionValue = std::move(newForwardLimitAutosetPositionValue);
3631 return *this;
3632 }
3633
3634 /**
3635 * \brief Modifies this configuration's ForwardLimitEnable parameter and returns itself for
3636 * method-chaining and easier to use config API.
3637 *
3638 * If enabled, motor output is set to neutral when the forward limit
3639 * switch is asserted and positive output is requested.
3640 *
3641 * - Default Value: True
3642 *
3643 * \param newForwardLimitEnable Parameter to modify
3644 * \returns Itself
3645 */
3646 constexpr HardwareLimitSwitchConfigs &WithForwardLimitEnable(bool newForwardLimitEnable)
3647 {
3648 ForwardLimitEnable = std::move(newForwardLimitEnable);
3649 return *this;
3650 }
3651
3652 /**
3653 * \brief Modifies this configuration's ForwardLimitSource parameter and returns itself for
3654 * method-chaining and easier to use config API.
3655 *
3656 * Determines where to poll the forward limit switch. This defaults
3657 * to the forward limit switch pin on the limit switch connector.
3658 *
3659 * Choose RemoteTalonFX to use the forward limit switch attached to
3660 * another Talon FX on the same CAN bus (this also requires setting
3661 * ForwardLimitRemoteSensorID).
3662 *
3663 * Choose RemoteCANifier to use the forward limit switch attached to
3664 * another CANifier on the same CAN bus (this also requires setting
3665 * ForwardLimitRemoteSensorID).
3666 *
3667 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
3668 * (this also requires setting ForwardLimitRemoteSensorID). The
3669 * forward limit will assert when the CANcoder magnet strength changes
3670 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
3671 *
3672 *
3673 * \param newForwardLimitSource Parameter to modify
3674 * \returns Itself
3675 */
3677 {
3678 ForwardLimitSource = std::move(newForwardLimitSource);
3679 return *this;
3680 }
3681
3682 /**
3683 * \brief Modifies this configuration's ForwardLimitRemoteSensorID parameter and returns itself for
3684 * method-chaining and easier to use config API.
3685 *
3686 * Device ID of the remote device if using remote limit switch
3687 * features for the forward limit switch.
3688 *
3689 * - Minimum Value: 0
3690 * - Maximum Value: 62
3691 * - Default Value: 0
3692 * - Units:
3693 *
3694 * \param newForwardLimitRemoteSensorID Parameter to modify
3695 * \returns Itself
3696 */
3697 constexpr HardwareLimitSwitchConfigs &WithForwardLimitRemoteSensorID(int newForwardLimitRemoteSensorID)
3698 {
3699 ForwardLimitRemoteSensorID = std::move(newForwardLimitRemoteSensorID);
3700 return *this;
3701 }
3702
3703 /**
3704 * \brief Modifies this configuration's ReverseLimitType parameter and returns itself for
3705 * method-chaining and easier to use config API.
3706 *
3707 * Determines if the reverse limit switch is normally-open (default)
3708 * or normally-closed.
3709 *
3710 *
3711 * \param newReverseLimitType Parameter to modify
3712 * \returns Itself
3713 */
3715 {
3716 ReverseLimitType = std::move(newReverseLimitType);
3717 return *this;
3718 }
3719
3720 /**
3721 * \brief Modifies this configuration's ReverseLimitAutosetPositionEnable parameter and returns itself for
3722 * method-chaining and easier to use config API.
3723 *
3724 * If enabled, the position is automatically set to a specific value,
3725 * specified by ReverseLimitAutosetPositionValue, when the reverse
3726 * limit switch is asserted.
3727 *
3728 * - Default Value: False
3729 *
3730 * \param newReverseLimitAutosetPositionEnable Parameter to modify
3731 * \returns Itself
3732 */
3733 constexpr HardwareLimitSwitchConfigs &WithReverseLimitAutosetPositionEnable(bool newReverseLimitAutosetPositionEnable)
3734 {
3735 ReverseLimitAutosetPositionEnable = std::move(newReverseLimitAutosetPositionEnable);
3736 return *this;
3737 }
3738
3739 /**
3740 * \brief Modifies this configuration's ReverseLimitAutosetPositionValue parameter and returns itself for
3741 * method-chaining and easier to use config API.
3742 *
3743 * The value to automatically set the position to when the reverse
3744 * limit switch is asserted. This has no effect if
3745 * ReverseLimitAutosetPositionEnable is false.
3746 *
3747 * - Minimum Value: -3.4e+38
3748 * - Maximum Value: 3.4e+38
3749 * - Default Value: 0
3750 * - Units: rotations
3751 *
3752 * \param newReverseLimitAutosetPositionValue Parameter to modify
3753 * \returns Itself
3754 */
3755 constexpr HardwareLimitSwitchConfigs &WithReverseLimitAutosetPositionValue(units::angle::turn_t newReverseLimitAutosetPositionValue)
3756 {
3757 ReverseLimitAutosetPositionValue = std::move(newReverseLimitAutosetPositionValue);
3758 return *this;
3759 }
3760
3761 /**
3762 * \brief Modifies this configuration's ReverseLimitEnable parameter and returns itself for
3763 * method-chaining and easier to use config API.
3764 *
3765 * If enabled, motor output is set to neutral when reverse limit
3766 * switch is asseted and negative output is requested.
3767 *
3768 * - Default Value: True
3769 *
3770 * \param newReverseLimitEnable Parameter to modify
3771 * \returns Itself
3772 */
3773 constexpr HardwareLimitSwitchConfigs &WithReverseLimitEnable(bool newReverseLimitEnable)
3774 {
3775 ReverseLimitEnable = std::move(newReverseLimitEnable);
3776 return *this;
3777 }
3778
3779 /**
3780 * \brief Modifies this configuration's ReverseLimitSource parameter and returns itself for
3781 * method-chaining and easier to use config API.
3782 *
3783 * Determines where to poll the reverse limit switch. This defaults
3784 * to the reverse limit switch pin on the limit switch connector.
3785 *
3786 * Choose RemoteTalonFX to use the reverse limit switch attached to
3787 * another Talon FX on the same CAN bus (this also requires setting
3788 * ReverseLimitRemoteSensorID).
3789 *
3790 * Choose RemoteCANifier to use the reverse limit switch attached to
3791 * another CANifier on the same CAN bus (this also requires setting
3792 * ReverseLimitRemoteSensorID).
3793 *
3794 * Choose RemoteCANcoder to use another CANcoder on the same CAN bus
3795 * (this also requires setting ReverseLimitRemoteSensorID). The
3796 * reverse limit will assert when the CANcoder magnet strength changes
3797 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
3798 *
3799 *
3800 * \param newReverseLimitSource Parameter to modify
3801 * \returns Itself
3802 */
3804 {
3805 ReverseLimitSource = std::move(newReverseLimitSource);
3806 return *this;
3807 }
3808
3809 /**
3810 * \brief Modifies this configuration's ReverseLimitRemoteSensorID parameter and returns itself for
3811 * method-chaining and easier to use config API.
3812 *
3813 * Device ID of the remote device if using remote limit switch
3814 * features for the reverse limit switch.
3815 *
3816 * - Minimum Value: 0
3817 * - Maximum Value: 62
3818 * - Default Value: 0
3819 * - Units:
3820 *
3821 * \param newReverseLimitRemoteSensorID Parameter to modify
3822 * \returns Itself
3823 */
3824 constexpr HardwareLimitSwitchConfigs &WithReverseLimitRemoteSensorID(int newReverseLimitRemoteSensorID)
3825 {
3826 ReverseLimitRemoteSensorID = std::move(newReverseLimitRemoteSensorID);
3827 return *this;
3828 }
3829
3830 /**
3831 * \brief Helper method to configure this feedback group to use
3832 * RemoteTalonFX forward limit switch by passing in the TalonFX
3833 * object. When using RemoteTalonFX, the Talon FX will use the
3834 * forward limit switch attached to another Talon FX on the
3835 * same CAN bus.
3836 *
3837 * \param device TalonFX reference to use for RemoteTalonFX forward limit switch
3838 * \returns Itself
3839 */
3841
3842 /**
3843 * \brief Helper method to configure this feedback group to use
3844 * RemoteCANcoder forward limit switch by passing in the
3845 * CANcoder object. When using RemoteCANcoder, the Talon FX
3846 * will use another CANcoder on the same CAN bus. The forward
3847 * limit will assert when the CANcoder magnet strength changes
3848 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
3849 *
3850 * \param device CANcoder reference to use for RemoteCANcoder forward limit switch
3851 * \returns Itself
3852 */
3854
3855 /**
3856 * \brief Helper method to configure this feedback group to use the
3857 * RemoteCANrange by passing in the CANrange object. The
3858 * forward limit will assert when the CANrange proximity detect
3859 * is tripped.
3860 *
3861 * \param device CANrange reference to use for RemoteCANrange forward limit switch
3862 * \returns Itself
3863 */
3865
3866 /**
3867 * \brief Helper method to configure this feedback group to use
3868 * RemoteCANdi forward limit switch on Signal 1 Input (S1IN) by
3869 * passing in the CANdi object. The forward limit will assert
3870 * when the CANdi™ branded device's Signal 1 Input (S1IN) pin
3871 * matches the configured closed state.
3872 *
3873 * \param device CANdi reference to use for RemoteCANdi forward limit switch
3874 * \returns Itself
3875 */
3877
3878 /**
3879 * \brief Helper method to configure this feedback group to use
3880 * RemoteCANdi forward limit switch on Signal 2 Input (S2IN) by
3881 * passing in the CANdi object. The forward limit will assert
3882 * when the CANdi™ branded device's Signal 2 Input (S2IN) pin
3883 * matches the configured closed state.
3884 *
3885 * \param device CANdi reference to use for RemoteCANdi forward limit switch
3886 * \returns Itself
3887 */
3889
3890 /**
3891 * \brief Helper method to configure this feedback group to use
3892 * RemoteTalonFX reverse limit switch by passing in the TalonFX
3893 * object. When using RemoteTalonFX, the Talon FX will use the
3894 * reverse limit switch attached to another Talon FX on the
3895 * same CAN bus.
3896 *
3897 * \param device TalonFX reference to use for RemoteTalonFX reverse limit switch
3898 * \returns Itself
3899 */
3901
3902 /**
3903 * \brief Helper method to configure this feedback group to use
3904 * RemoteCANcoder reverse limit switch by passing in the
3905 * CANcoder object. When using RemoteCANcoder, the Talon FX
3906 * will use another CANcoder on the same CAN bus. The reverse
3907 * limit will assert when the CANcoder magnet strength changes
3908 * from BAD (red) to ADEQUATE (orange) or GOOD (green).
3909 *
3910 * \param device CANcoder reference to use for RemoteCANcoder reverse limit switch
3911 * \returns Itself
3912 */
3914
3915 /**
3916 * \brief Helper method to configure this feedback group to use the
3917 * RemoteCANrange by passing in the CANrange object. The
3918 * reverse limit will assert when the CANrange proximity detect
3919 * is tripped.
3920 *
3921 * \param device CANrange reference to use for RemoteCANrange reverse limit switch
3922 * \returns Itself
3923 */
3925
3926 /**
3927 * \brief Helper method to configure this feedback group to use
3928 * RemoteCANdi reverse limit switch on Signal 1 Input (S1IN) by
3929 * passing in the CANdi object. The reverse limit will assert
3930 * when the CANdi™ branded device's Signal 1 Input (S1IN) pin
3931 * matches the configured closed state.
3932 *
3933 * \param device CANdi reference to use for RemoteCANdi reverse limit switch
3934 * \returns Itself
3935 */
3937
3938 /**
3939 * \brief Helper method to configure this feedback group to use
3940 * RemoteCANdi reverse limit switch on Signal 2 Input (S2IN) by
3941 * passing in the CANdi object. The reverse limit will assert
3942 * when the CANdi™ branded device's Signal 2 Input (S2IN) pin
3943 * matches the configured closed state.
3944 *
3945 * \param device CANdi reference to use for RemoteCANdi reverse limit switch
3946 * \returns Itself
3947 */
3949
3950
3951
3952 std::string ToString() const override
3953 {
3954 std::stringstream ss;
3955 ss << "Config Group: HardwareLimitSwitch" << std::endl;
3956 ss << " ForwardLimitType: " << ForwardLimitType << std::endl;
3957 ss << " ForwardLimitAutosetPositionEnable: " << ForwardLimitAutosetPositionEnable << std::endl;
3958 ss << " ForwardLimitAutosetPositionValue: " << ForwardLimitAutosetPositionValue.to<double>() << " rotations" << std::endl;
3959 ss << " ForwardLimitEnable: " << ForwardLimitEnable << std::endl;
3960 ss << " ForwardLimitSource: " << ForwardLimitSource << std::endl;
3961 ss << " ForwardLimitRemoteSensorID: " << ForwardLimitRemoteSensorID << std::endl;
3962 ss << " ReverseLimitType: " << ReverseLimitType << std::endl;
3963 ss << " ReverseLimitAutosetPositionEnable: " << ReverseLimitAutosetPositionEnable << std::endl;
3964 ss << " ReverseLimitAutosetPositionValue: " << ReverseLimitAutosetPositionValue.to<double>() << " rotations" << std::endl;
3965 ss << " ReverseLimitEnable: " << ReverseLimitEnable << std::endl;
3966 ss << " ReverseLimitSource: " << ReverseLimitSource << std::endl;
3967 ss << " ReverseLimitRemoteSensorID: " << ReverseLimitRemoteSensorID << std::endl;
3968 return ss.str();
3969 }
3970
3971 std::string Serialize() const override
3972 {
3973 std::stringstream ss;
3974 char *ref;
3975 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitType, ForwardLimitType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3976 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosEnable, ForwardLimitAutosetPositionEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3977 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosValue, ForwardLimitAutosetPositionValue.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3978 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitEnable, ForwardLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3979 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitSource, ForwardLimitSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3980 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitRemoteSensorID, ForwardLimitRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3981 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitType, ReverseLimitType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3982 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosEnable, ReverseLimitAutosetPositionEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3983 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosValue, ReverseLimitAutosetPositionValue.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
3984 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitEnable, ReverseLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3985 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitSource, ReverseLimitSource.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3986 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitRemoteSensorID, ReverseLimitRemoteSensorID, &ref); if (ref != nullptr) { ss << ref; free(ref); }
3987 return ss.str();
3988 }
3989
3990 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
3991 {
3992 const char *string_c_str = to_deserialize.c_str();
3993 size_t string_length = to_deserialize.length();
3994 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitType, string_c_str, string_length, &ForwardLimitType.value);
3995 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosEnable, string_c_str, string_length, &ForwardLimitAutosetPositionEnable);
3996 double ForwardLimitAutosetPositionValueVal = ForwardLimitAutosetPositionValue.to<double>();
3997 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitAutosetPosValue, string_c_str, string_length, &ForwardLimitAutosetPositionValueVal);
3998 ForwardLimitAutosetPositionValue = units::angle::turn_t{ForwardLimitAutosetPositionValueVal};
3999 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitEnable, string_c_str, string_length, &ForwardLimitEnable);
4000 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitSource, string_c_str, string_length, &ForwardLimitSource.value);
4001 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ForwardLimitRemoteSensorID, string_c_str, string_length, &ForwardLimitRemoteSensorID);
4002 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitType, string_c_str, string_length, &ReverseLimitType.value);
4003 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosEnable, string_c_str, string_length, &ReverseLimitAutosetPositionEnable);
4004 double ReverseLimitAutosetPositionValueVal = ReverseLimitAutosetPositionValue.to<double>();
4005 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitAutosetPosValue, string_c_str, string_length, &ReverseLimitAutosetPositionValueVal);
4006 ReverseLimitAutosetPositionValue = units::angle::turn_t{ReverseLimitAutosetPositionValueVal};
4007 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitEnable, string_c_str, string_length, &ReverseLimitEnable);
4008 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitSource, string_c_str, string_length, &ReverseLimitSource.value);
4009 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_ReverseLimitRemoteSensorID, string_c_str, string_length, &ReverseLimitRemoteSensorID);
4010 return 0;
4011 }
4012};
4013
4014
4015/**
4016 * \brief Configs that affect audible components of the device.
4017 *
4018 * \details Includes configuration for the beep on boot.
4019 */
4021{
4022public:
4023 constexpr AudioConfigs() = default;
4024
4025 /**
4026 * \brief If true, the TalonFX will beep during boot-up. This is
4027 * useful for general debugging, and defaults to true. If rotor is
4028 * moving during boot-up, the beep will not occur regardless of this
4029 * setting.
4030 *
4031 * - Default Value: True
4032 */
4033 bool BeepOnBoot = true;
4034 /**
4035 * \brief If true, the TalonFX will beep during configuration API
4036 * calls if device is disabled. This is useful for general debugging,
4037 * and defaults to true. Note that if the rotor is moving, the beep
4038 * will not occur regardless of this setting.
4039 *
4040 * - Default Value: True
4041 */
4042 bool BeepOnConfig = true;
4043 /**
4044 * \brief If true, the TalonFX will allow Orchestra and MusicTone
4045 * requests during disabled state. This can be used to address corner
4046 * cases when music features are needed when disabled. This setting
4047 * defaults to false. Note that if the rotor is moving, music
4048 * features are always disabled regardless of this setting.
4049 *
4050 * - Default Value: False
4051 */
4053
4054 /**
4055 * \brief Modifies this configuration's BeepOnBoot parameter and returns itself for
4056 * method-chaining and easier to use config API.
4057 *
4058 * If true, the TalonFX will beep during boot-up. This is useful for
4059 * general debugging, and defaults to true. If rotor is moving during
4060 * boot-up, the beep will not occur regardless of this setting.
4061 *
4062 * - Default Value: True
4063 *
4064 * \param newBeepOnBoot Parameter to modify
4065 * \returns Itself
4066 */
4067 constexpr AudioConfigs &WithBeepOnBoot(bool newBeepOnBoot)
4068 {
4069 BeepOnBoot = std::move(newBeepOnBoot);
4070 return *this;
4071 }
4072
4073 /**
4074 * \brief Modifies this configuration's BeepOnConfig parameter and returns itself for
4075 * method-chaining and easier to use config API.
4076 *
4077 * If true, the TalonFX will beep during configuration API calls if
4078 * device is disabled. This is useful for general debugging, and
4079 * defaults to true. Note that if the rotor is moving, the beep will
4080 * not occur regardless of this setting.
4081 *
4082 * - Default Value: True
4083 *
4084 * \param newBeepOnConfig Parameter to modify
4085 * \returns Itself
4086 */
4087 constexpr AudioConfigs &WithBeepOnConfig(bool newBeepOnConfig)
4088 {
4089 BeepOnConfig = std::move(newBeepOnConfig);
4090 return *this;
4091 }
4092
4093 /**
4094 * \brief Modifies this configuration's AllowMusicDurDisable parameter and returns itself for
4095 * method-chaining and easier to use config API.
4096 *
4097 * If true, the TalonFX will allow Orchestra and MusicTone requests
4098 * during disabled state. This can be used to address corner cases
4099 * when music features are needed when disabled. This setting
4100 * defaults to false. Note that if the rotor is moving, music
4101 * features are always disabled regardless of this setting.
4102 *
4103 * - Default Value: False
4104 *
4105 * \param newAllowMusicDurDisable Parameter to modify
4106 * \returns Itself
4107 */
4108 constexpr AudioConfigs &WithAllowMusicDurDisable(bool newAllowMusicDurDisable)
4109 {
4110 AllowMusicDurDisable = std::move(newAllowMusicDurDisable);
4111 return *this;
4112 }
4113
4114
4115
4116 std::string ToString() const override
4117 {
4118 std::stringstream ss;
4119 ss << "Config Group: Audio" << std::endl;
4120 ss << " BeepOnBoot: " << BeepOnBoot << std::endl;
4121 ss << " BeepOnConfig: " << BeepOnConfig << std::endl;
4122 ss << " AllowMusicDurDisable: " << AllowMusicDurDisable << std::endl;
4123 return ss.str();
4124 }
4125
4126 std::string Serialize() const override
4127 {
4128 std::stringstream ss;
4129 char *ref;
4130 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnBoot, BeepOnBoot, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4131 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnConfig, BeepOnConfig, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4132 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_AllowMusicDurDisable, AllowMusicDurDisable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4133 return ss.str();
4134 }
4135
4136 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
4137 {
4138 const char *string_c_str = to_deserialize.c_str();
4139 size_t string_length = to_deserialize.length();
4140 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnBoot, string_c_str, string_length, &BeepOnBoot);
4141 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_BeepOnConfig, string_c_str, string_length, &BeepOnConfig);
4142 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_AllowMusicDurDisable, string_c_str, string_length, &AllowMusicDurDisable);
4143 return 0;
4144 }
4145};
4146
4147
4148/**
4149 * \brief Configs that affect how software-limit switches behave.
4150 *
4151 * \details Includes enabling software-limit switches and the
4152 * threshold at which they are tripped.
4153 */
4155{
4156public:
4157 constexpr SoftwareLimitSwitchConfigs() = default;
4158
4159 /**
4160 * \brief If enabled, the motor output is set to neutral if position
4161 * exceeds ForwardSoftLimitThreshold and forward output is requested.
4162 *
4163 * - Default Value: False
4164 */
4166 /**
4167 * \brief If enabled, the motor output is set to neutral if position
4168 * exceeds ReverseSoftLimitThreshold and reverse output is requested.
4169 *
4170 * - Default Value: False
4171 */
4173 /**
4174 * \brief Position threshold for forward soft limit features.
4175 * ForwardSoftLimitEnable must be enabled for this to take effect.
4176 *
4177 * - Minimum Value: -3.4e+38
4178 * - Maximum Value: 3.4e+38
4179 * - Default Value: 0
4180 * - Units: rotations
4181 */
4182 units::angle::turn_t ForwardSoftLimitThreshold = 0_tr;
4183 /**
4184 * \brief Position threshold for reverse soft limit features.
4185 * ReverseSoftLimitEnable must be enabled for this to take effect.
4186 *
4187 * - Minimum Value: -3.4e+38
4188 * - Maximum Value: 3.4e+38
4189 * - Default Value: 0
4190 * - Units: rotations
4191 */
4192 units::angle::turn_t ReverseSoftLimitThreshold = 0_tr;
4193
4194 /**
4195 * \brief Modifies this configuration's ForwardSoftLimitEnable parameter and returns itself for
4196 * method-chaining and easier to use config API.
4197 *
4198 * If enabled, the motor output is set to neutral if position exceeds
4199 * ForwardSoftLimitThreshold and forward output is requested.
4200 *
4201 * - Default Value: False
4202 *
4203 * \param newForwardSoftLimitEnable Parameter to modify
4204 * \returns Itself
4205 */
4206 constexpr SoftwareLimitSwitchConfigs &WithForwardSoftLimitEnable(bool newForwardSoftLimitEnable)
4207 {
4208 ForwardSoftLimitEnable = std::move(newForwardSoftLimitEnable);
4209 return *this;
4210 }
4211
4212 /**
4213 * \brief Modifies this configuration's ReverseSoftLimitEnable parameter and returns itself for
4214 * method-chaining and easier to use config API.
4215 *
4216 * If enabled, the motor output is set to neutral if position exceeds
4217 * ReverseSoftLimitThreshold and reverse output is requested.
4218 *
4219 * - Default Value: False
4220 *
4221 * \param newReverseSoftLimitEnable Parameter to modify
4222 * \returns Itself
4223 */
4224 constexpr SoftwareLimitSwitchConfigs &WithReverseSoftLimitEnable(bool newReverseSoftLimitEnable)
4225 {
4226 ReverseSoftLimitEnable = std::move(newReverseSoftLimitEnable);
4227 return *this;
4228 }
4229
4230 /**
4231 * \brief Modifies this configuration's ForwardSoftLimitThreshold parameter and returns itself for
4232 * method-chaining and easier to use config API.
4233 *
4234 * Position threshold for forward soft limit features.
4235 * ForwardSoftLimitEnable must be enabled for this to take effect.
4236 *
4237 * - Minimum Value: -3.4e+38
4238 * - Maximum Value: 3.4e+38
4239 * - Default Value: 0
4240 * - Units: rotations
4241 *
4242 * \param newForwardSoftLimitThreshold Parameter to modify
4243 * \returns Itself
4244 */
4245 constexpr SoftwareLimitSwitchConfigs &WithForwardSoftLimitThreshold(units::angle::turn_t newForwardSoftLimitThreshold)
4246 {
4247 ForwardSoftLimitThreshold = std::move(newForwardSoftLimitThreshold);
4248 return *this;
4249 }
4250
4251 /**
4252 * \brief Modifies this configuration's ReverseSoftLimitThreshold parameter and returns itself for
4253 * method-chaining and easier to use config API.
4254 *
4255 * Position threshold for reverse soft limit features.
4256 * ReverseSoftLimitEnable must be enabled for this to take effect.
4257 *
4258 * - Minimum Value: -3.4e+38
4259 * - Maximum Value: 3.4e+38
4260 * - Default Value: 0
4261 * - Units: rotations
4262 *
4263 * \param newReverseSoftLimitThreshold Parameter to modify
4264 * \returns Itself
4265 */
4266 constexpr SoftwareLimitSwitchConfigs &WithReverseSoftLimitThreshold(units::angle::turn_t newReverseSoftLimitThreshold)
4267 {
4268 ReverseSoftLimitThreshold = std::move(newReverseSoftLimitThreshold);
4269 return *this;
4270 }
4271
4272
4273
4274 std::string ToString() const override
4275 {
4276 std::stringstream ss;
4277 ss << "Config Group: SoftwareLimitSwitch" << std::endl;
4278 ss << " ForwardSoftLimitEnable: " << ForwardSoftLimitEnable << std::endl;
4279 ss << " ReverseSoftLimitEnable: " << ReverseSoftLimitEnable << std::endl;
4280 ss << " ForwardSoftLimitThreshold: " << ForwardSoftLimitThreshold.to<double>() << " rotations" << std::endl;
4281 ss << " ReverseSoftLimitThreshold: " << ReverseSoftLimitThreshold.to<double>() << " rotations" << std::endl;
4282 return ss.str();
4283 }
4284
4285 std::string Serialize() const override
4286 {
4287 std::stringstream ss;
4288 char *ref;
4289 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitEnable, ForwardSoftLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4290 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitEnable, ReverseSoftLimitEnable, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4291 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitThreshold, ForwardSoftLimitThreshold.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4292 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitThreshold, ReverseSoftLimitThreshold.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4293 return ss.str();
4294 }
4295
4296 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
4297 {
4298 const char *string_c_str = to_deserialize.c_str();
4299 size_t string_length = to_deserialize.length();
4300 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitEnable, string_c_str, string_length, &ForwardSoftLimitEnable);
4301 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitEnable, string_c_str, string_length, &ReverseSoftLimitEnable);
4302 double ForwardSoftLimitThresholdVal = ForwardSoftLimitThreshold.to<double>();
4303 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ForwardSoftLimitThreshold, string_c_str, string_length, &ForwardSoftLimitThresholdVal);
4304 ForwardSoftLimitThreshold = units::angle::turn_t{ForwardSoftLimitThresholdVal};
4305 double ReverseSoftLimitThresholdVal = ReverseSoftLimitThreshold.to<double>();
4306 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_ReverseSoftLimitThreshold, string_c_str, string_length, &ReverseSoftLimitThresholdVal);
4307 ReverseSoftLimitThreshold = units::angle::turn_t{ReverseSoftLimitThresholdVal};
4308 return 0;
4309 }
4310};
4311
4312
4313/**
4314 * \brief Configs for Motion Magic®.
4315 *
4316 * \details Includes Velocity, Acceleration, Jerk, and Expo
4317 * parameters.
4318 */
4320{
4321public:
4322 constexpr MotionMagicConfigs() = default;
4323
4324 /**
4325 * \brief This is the maximum velocity Motion Magic® based control
4326 * modes are allowed to use. Motion Magic® Velocity control modes do
4327 * not use this config.
4328 *
4329 * When using Motion Magic® Expo control modes, setting this to 0 will
4330 * allow the profile to run to the max possible velocity based on
4331 * Expo_kV.
4332 *
4333 * - Minimum Value: 0
4334 * - Maximum Value: 9999
4335 * - Default Value: 0
4336 * - Units: rot per sec
4337 */
4338 units::angular_velocity::turns_per_second_t MotionMagicCruiseVelocity = 0_tps;
4339 /**
4340 * \brief This is the target acceleration Motion Magic® based control
4341 * modes are allowed to use. Motion Magic® Expo control modes do not
4342 * use this config.
4343 *
4344 * - Minimum Value: 0
4345 * - Maximum Value: 9999
4346 * - Default Value: 0
4347 * - Units: rot per sec²
4348 */
4349 units::angular_acceleration::turns_per_second_squared_t MotionMagicAcceleration = 0_tr_per_s_sq;
4350 /**
4351 * \brief This is the target jerk (acceleration derivative) Motion
4352 * Magic® based control modes are allowed to use. Motion Magic® Expo
4353 * control modes do not use this config. This allows Motion Magic® to
4354 * generate S-Curve profiles.
4355 *
4356 * Jerk is optional; if this is set to zero, then Motion Magic® will
4357 * not apply a Jerk limit.
4358 *
4359 * - Minimum Value: 0
4360 * - Maximum Value: 9999
4361 * - Default Value: 0
4362 * - Units: rot per sec³
4363 */
4364 units::angular_jerk::turns_per_second_cubed_t MotionMagicJerk = 0_tr_per_s_cu;
4365 /**
4366 * \brief This is the target kV used only by Motion Magic® Expo
4367 * control modes. Unlike the kV slot gain, this is always in units of
4368 * V/rps.
4369 *
4370 * This represents the amount of voltage necessary to hold a velocity.
4371 * In terms of the Motion Magic® Expo profile, a higher kV results in
4372 * a slower maximum velocity.
4373 *
4374 * - Minimum Value: 0.001
4375 * - Maximum Value: 100
4376 * - Default Value: 0.12
4377 * - Units: V/rps
4378 */
4379 ctre::unit::volts_per_turn_per_second_t MotionMagicExpo_kV = 0.12_V / 1_tps;
4380 /**
4381 * \brief This is the target kA used only by Motion Magic® Expo
4382 * control modes. Unlike the kA slot gain, this is always in units of
4383 * V/rps².
4384 *
4385 * This represents the amount of voltage necessary to achieve an
4386 * acceleration. In terms of the Motion Magic® Expo profile, a higher
4387 * kA results in a slower acceleration.
4388 *
4389 * - Minimum Value: 1e-05
4390 * - Maximum Value: 100
4391 * - Default Value: 0.1
4392 * - Units: V/rps²
4393 */
4394 ctre::unit::volts_per_turn_per_second_squared_t MotionMagicExpo_kA = 0.1_V / 1_tr_per_s_sq;
4395
4396 /**
4397 * \brief Modifies this configuration's MotionMagicCruiseVelocity parameter and returns itself for
4398 * method-chaining and easier to use config API.
4399 *
4400 * This is the maximum velocity Motion Magic® based control modes are
4401 * allowed to use. Motion Magic® Velocity control modes do not use
4402 * this config.
4403 *
4404 * When using Motion Magic® Expo control modes, setting this to 0 will
4405 * allow the profile to run to the max possible velocity based on
4406 * Expo_kV.
4407 *
4408 * - Minimum Value: 0
4409 * - Maximum Value: 9999
4410 * - Default Value: 0
4411 * - Units: rot per sec
4412 *
4413 * \param newMotionMagicCruiseVelocity Parameter to modify
4414 * \returns Itself
4415 */
4416 constexpr MotionMagicConfigs &WithMotionMagicCruiseVelocity(units::angular_velocity::turns_per_second_t newMotionMagicCruiseVelocity)
4417 {
4418 MotionMagicCruiseVelocity = std::move(newMotionMagicCruiseVelocity);
4419 return *this;
4420 }
4421
4422 /**
4423 * \brief Modifies this configuration's MotionMagicAcceleration parameter and returns itself for
4424 * method-chaining and easier to use config API.
4425 *
4426 * This is the target acceleration Motion Magic® based control modes
4427 * are allowed to use. Motion Magic® Expo control modes do not use
4428 * this config.
4429 *
4430 * - Minimum Value: 0
4431 * - Maximum Value: 9999
4432 * - Default Value: 0
4433 * - Units: rot per sec²
4434 *
4435 * \param newMotionMagicAcceleration Parameter to modify
4436 * \returns Itself
4437 */
4438 constexpr MotionMagicConfigs &WithMotionMagicAcceleration(units::angular_acceleration::turns_per_second_squared_t newMotionMagicAcceleration)
4439 {
4440 MotionMagicAcceleration = std::move(newMotionMagicAcceleration);
4441 return *this;
4442 }
4443
4444 /**
4445 * \brief Modifies this configuration's MotionMagicJerk parameter and returns itself for
4446 * method-chaining and easier to use config API.
4447 *
4448 * This is the target jerk (acceleration derivative) Motion Magic®
4449 * based control modes are allowed to use. Motion Magic® Expo control
4450 * modes do not use this config. This allows Motion Magic® to
4451 * generate S-Curve profiles.
4452 *
4453 * Jerk is optional; if this is set to zero, then Motion Magic® will
4454 * not apply a Jerk limit.
4455 *
4456 * - Minimum Value: 0
4457 * - Maximum Value: 9999
4458 * - Default Value: 0
4459 * - Units: rot per sec³
4460 *
4461 * \param newMotionMagicJerk Parameter to modify
4462 * \returns Itself
4463 */
4464 constexpr MotionMagicConfigs &WithMotionMagicJerk(units::angular_jerk::turns_per_second_cubed_t newMotionMagicJerk)
4465 {
4466 MotionMagicJerk = std::move(newMotionMagicJerk);
4467 return *this;
4468 }
4469
4470 /**
4471 * \brief Modifies this configuration's MotionMagicExpo_kV parameter and returns itself for
4472 * method-chaining and easier to use config API.
4473 *
4474 * This is the target kV used only by Motion Magic® Expo control
4475 * modes. Unlike the kV slot gain, this is always in units of V/rps.
4476 *
4477 * This represents the amount of voltage necessary to hold a velocity.
4478 * In terms of the Motion Magic® Expo profile, a higher kV results in
4479 * a slower maximum velocity.
4480 *
4481 * - Minimum Value: 0.001
4482 * - Maximum Value: 100
4483 * - Default Value: 0.12
4484 * - Units: V/rps
4485 *
4486 * \param newMotionMagicExpo_kV Parameter to modify
4487 * \returns Itself
4488 */
4489 constexpr MotionMagicConfigs &WithMotionMagicExpo_kV(ctre::unit::volts_per_turn_per_second_t newMotionMagicExpo_kV)
4490 {
4491 MotionMagicExpo_kV = std::move(newMotionMagicExpo_kV);
4492 return *this;
4493 }
4494
4495 /**
4496 * \brief Modifies this configuration's MotionMagicExpo_kA parameter and returns itself for
4497 * method-chaining and easier to use config API.
4498 *
4499 * This is the target kA used only by Motion Magic® Expo control
4500 * modes. Unlike the kA slot gain, this is always in units of V/rps².
4501 *
4502 * This represents the amount of voltage necessary to achieve an
4503 * acceleration. In terms of the Motion Magic® Expo profile, a higher
4504 * kA results in a slower acceleration.
4505 *
4506 * - Minimum Value: 1e-05
4507 * - Maximum Value: 100
4508 * - Default Value: 0.1
4509 * - Units: V/rps²
4510 *
4511 * \param newMotionMagicExpo_kA Parameter to modify
4512 * \returns Itself
4513 */
4514 constexpr MotionMagicConfigs &WithMotionMagicExpo_kA(ctre::unit::volts_per_turn_per_second_squared_t newMotionMagicExpo_kA)
4515 {
4516 MotionMagicExpo_kA = std::move(newMotionMagicExpo_kA);
4517 return *this;
4518 }
4519
4520
4521
4522 std::string ToString() const override
4523 {
4524 std::stringstream ss;
4525 ss << "Config Group: MotionMagic" << std::endl;
4526 ss << " MotionMagicCruiseVelocity: " << MotionMagicCruiseVelocity.to<double>() << " rot per sec" << std::endl;
4527 ss << " MotionMagicAcceleration: " << MotionMagicAcceleration.to<double>() << " rot per sec²" << std::endl;
4528 ss << " MotionMagicJerk: " << MotionMagicJerk.to<double>() << " rot per sec³" << std::endl;
4529 ss << " MotionMagicExpo_kV: " << MotionMagicExpo_kV.to<double>() << " V/rps" << std::endl;
4530 ss << " MotionMagicExpo_kA: " << MotionMagicExpo_kA.to<double>() << " V/rps²" << std::endl;
4531 return ss.str();
4532 }
4533
4534 std::string Serialize() const override
4535 {
4536 std::stringstream ss;
4537 char *ref;
4538 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicCruiseVelocity, MotionMagicCruiseVelocity.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4539 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicAcceleration, MotionMagicAcceleration.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4540 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicJerk, MotionMagicJerk.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4541 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicExpo_kV, MotionMagicExpo_kV.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4542 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicExpo_kA, MotionMagicExpo_kA.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4543 return ss.str();
4544 }
4545
4546 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
4547 {
4548 const char *string_c_str = to_deserialize.c_str();
4549 size_t string_length = to_deserialize.length();
4550 double MotionMagicCruiseVelocityVal = MotionMagicCruiseVelocity.to<double>();
4551 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicCruiseVelocity, string_c_str, string_length, &MotionMagicCruiseVelocityVal);
4552 MotionMagicCruiseVelocity = units::angular_velocity::turns_per_second_t{MotionMagicCruiseVelocityVal};
4553 double MotionMagicAccelerationVal = MotionMagicAcceleration.to<double>();
4554 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicAcceleration, string_c_str, string_length, &MotionMagicAccelerationVal);
4555 MotionMagicAcceleration = units::angular_acceleration::turns_per_second_squared_t{MotionMagicAccelerationVal};
4556 double MotionMagicJerkVal = MotionMagicJerk.to<double>();
4557 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicJerk, string_c_str, string_length, &MotionMagicJerkVal);
4558 MotionMagicJerk = units::angular_jerk::turns_per_second_cubed_t{MotionMagicJerkVal};
4559 double MotionMagicExpo_kVVal = MotionMagicExpo_kV.to<double>();
4560 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicExpo_kV, string_c_str, string_length, &MotionMagicExpo_kVVal);
4561 MotionMagicExpo_kV = ctre::unit::volts_per_turn_per_second_t{MotionMagicExpo_kVVal};
4562 double MotionMagicExpo_kAVal = MotionMagicExpo_kA.to<double>();
4563 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_MotionMagicExpo_kA, string_c_str, string_length, &MotionMagicExpo_kAVal);
4564 MotionMagicExpo_kA = ctre::unit::volts_per_turn_per_second_squared_t{MotionMagicExpo_kAVal};
4565 return 0;
4566 }
4567};
4568
4569
4570/**
4571 * \brief Custom Params.
4572 *
4573 * \details Custom paramaters that have no real impact on controller.
4574 */
4576{
4577public:
4578 constexpr CustomParamsConfigs() = default;
4579
4580 /**
4581 * \brief Custom parameter 0. This is provided to allow
4582 * end-applications to store persistent information in the device.
4583 *
4584 * - Minimum Value: -32768
4585 * - Maximum Value: 32767
4586 * - Default Value: 0
4587 * - Units:
4588 */
4590 /**
4591 * \brief Custom parameter 1. This is provided to allow
4592 * end-applications to store persistent information in the device.
4593 *
4594 * - Minimum Value: -32768
4595 * - Maximum Value: 32767
4596 * - Default Value: 0
4597 * - Units:
4598 */
4600
4601 /**
4602 * \brief Modifies this configuration's CustomParam0 parameter and returns itself for
4603 * method-chaining and easier to use config API.
4604 *
4605 * Custom parameter 0. This is provided to allow end-applications to
4606 * store persistent information in the device.
4607 *
4608 * - Minimum Value: -32768
4609 * - Maximum Value: 32767
4610 * - Default Value: 0
4611 * - Units:
4612 *
4613 * \param newCustomParam0 Parameter to modify
4614 * \returns Itself
4615 */
4616 constexpr CustomParamsConfigs &WithCustomParam0(int newCustomParam0)
4617 {
4618 CustomParam0 = std::move(newCustomParam0);
4619 return *this;
4620 }
4621
4622 /**
4623 * \brief Modifies this configuration's CustomParam1 parameter and returns itself for
4624 * method-chaining and easier to use config API.
4625 *
4626 * Custom parameter 1. This is provided to allow end-applications to
4627 * store persistent information in the device.
4628 *
4629 * - Minimum Value: -32768
4630 * - Maximum Value: 32767
4631 * - Default Value: 0
4632 * - Units:
4633 *
4634 * \param newCustomParam1 Parameter to modify
4635 * \returns Itself
4636 */
4637 constexpr CustomParamsConfigs &WithCustomParam1(int newCustomParam1)
4638 {
4639 CustomParam1 = std::move(newCustomParam1);
4640 return *this;
4641 }
4642
4643
4644
4645 std::string ToString() const override
4646 {
4647 std::stringstream ss;
4648 ss << "Config Group: CustomParams" << std::endl;
4649 ss << " CustomParam0: " << CustomParam0 << std::endl;
4650 ss << " CustomParam1: " << CustomParam1 << std::endl;
4651 return ss.str();
4652 }
4653
4654 std::string Serialize() const override
4655 {
4656 std::stringstream ss;
4657 char *ref;
4658 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CustomParam0, CustomParam0, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4659 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CustomParam1, CustomParam1, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4660 return ss.str();
4661 }
4662
4663 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
4664 {
4665 const char *string_c_str = to_deserialize.c_str();
4666 size_t string_length = to_deserialize.length();
4667 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CustomParam0, string_c_str, string_length, &CustomParam0);
4668 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CustomParam1, string_c_str, string_length, &CustomParam1);
4669 return 0;
4670 }
4671};
4672
4673
4674/**
4675 * \brief Configs that affect general behavior during closed-looping.
4676 *
4677 * \details Includes Continuous Wrap features.
4678 */
4680{
4681public:
4682 constexpr ClosedLoopGeneralConfigs() = default;
4683
4684 /**
4685 * \brief Wrap position error within [-0.5,+0.5) mechanism rotations.
4686 * Typically used for continuous position closed-loops like swerve
4687 * azimuth.
4688 *
4689 * \details This uses the mechanism rotation value. If there is a gear
4690 * ratio between the sensor and the mechanism, make sure to apply a
4691 * SensorToMechanismRatio so the closed loop operates on the full
4692 * rotation.
4693 *
4694 * - Default Value: False
4695 */
4696 bool ContinuousWrap = false;
4697
4698 /**
4699 * \brief Modifies this configuration's ContinuousWrap parameter and returns itself for
4700 * method-chaining and easier to use config API.
4701 *
4702 * Wrap position error within [-0.5,+0.5) mechanism rotations.
4703 * Typically used for continuous position closed-loops like swerve
4704 * azimuth.
4705 *
4706 * \details This uses the mechanism rotation value. If there is a gear
4707 * ratio between the sensor and the mechanism, make sure to apply a
4708 * SensorToMechanismRatio so the closed loop operates on the full
4709 * rotation.
4710 *
4711 * - Default Value: False
4712 *
4713 * \param newContinuousWrap Parameter to modify
4714 * \returns Itself
4715 */
4716 constexpr ClosedLoopGeneralConfigs &WithContinuousWrap(bool newContinuousWrap)
4717 {
4718 ContinuousWrap = std::move(newContinuousWrap);
4719 return *this;
4720 }
4721
4722
4723
4724 std::string ToString() const override
4725 {
4726 std::stringstream ss;
4727 ss << "Config Group: ClosedLoopGeneral" << std::endl;
4728 ss << " ContinuousWrap: " << ContinuousWrap << std::endl;
4729 return ss.str();
4730 }
4731
4732 std::string Serialize() const override
4733 {
4734 std::stringstream ss;
4735 char *ref;
4736 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_ContinuousWrap, ContinuousWrap, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4737 return ss.str();
4738 }
4739
4740 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
4741 {
4742 const char *string_c_str = to_deserialize.c_str();
4743 size_t string_length = to_deserialize.length();
4744 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_ContinuousWrap, string_c_str, string_length, &ContinuousWrap);
4745 return 0;
4746 }
4747};
4748
4749
4750/**
4751 * \brief Configs that affect the ToF sensor
4752 *
4753 * \details Includes Update mode and frequency
4754 */
4756{
4757public:
4758 constexpr ToFParamsConfigs() = default;
4759
4760 /**
4761 * \brief Update mode of the CANrange. The CANrange supports
4762 * short-range and long-range detection at various update frequencies.
4763 *
4764 */
4766 /**
4767 * \brief Rate at which the CANrange will take measurements. A lower
4768 * frequency may provide more stable readings but will reduce the data
4769 * rate of the sensor.
4770 *
4771 * - Minimum Value: 5
4772 * - Maximum Value: 50
4773 * - Default Value: 50
4774 * - Units: Hz
4775 */
4776 units::frequency::hertz_t UpdateFrequency = 50_Hz;
4777
4778 /**
4779 * \brief Modifies this configuration's UpdateMode parameter and returns itself for
4780 * method-chaining and easier to use config API.
4781 *
4782 * Update mode of the CANrange. The CANrange supports short-range and
4783 * long-range detection at various update frequencies.
4784 *
4785 *
4786 * \param newUpdateMode Parameter to modify
4787 * \returns Itself
4788 */
4790 {
4791 UpdateMode = std::move(newUpdateMode);
4792 return *this;
4793 }
4794
4795 /**
4796 * \brief Modifies this configuration's UpdateFrequency parameter and returns itself for
4797 * method-chaining and easier to use config API.
4798 *
4799 * Rate at which the CANrange will take measurements. A lower
4800 * frequency may provide more stable readings but will reduce the data
4801 * rate of the sensor.
4802 *
4803 * - Minimum Value: 5
4804 * - Maximum Value: 50
4805 * - Default Value: 50
4806 * - Units: Hz
4807 *
4808 * \param newUpdateFrequency Parameter to modify
4809 * \returns Itself
4810 */
4811 constexpr ToFParamsConfigs &WithUpdateFrequency(units::frequency::hertz_t newUpdateFrequency)
4812 {
4813 UpdateFrequency = std::move(newUpdateFrequency);
4814 return *this;
4815 }
4816
4817
4818
4819 std::string ToString() const override
4820 {
4821 std::stringstream ss;
4822 ss << "Config Group: ToFParams" << std::endl;
4823 ss << " UpdateMode: " << UpdateMode << std::endl;
4824 ss << " UpdateFrequency: " << UpdateFrequency.to<double>() << " Hz" << std::endl;
4825 return ss.str();
4826 }
4827
4828 std::string Serialize() const override
4829 {
4830 std::stringstream ss;
4831 char *ref;
4832 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CANrange_UpdateMode, UpdateMode.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
4833 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANrange_UpdateFreq, UpdateFrequency.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4834 return ss.str();
4835 }
4836
4837 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
4838 {
4839 const char *string_c_str = to_deserialize.c_str();
4840 size_t string_length = to_deserialize.length();
4841 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CANrange_UpdateMode, string_c_str, string_length, &UpdateMode.value);
4842 double UpdateFrequencyVal = UpdateFrequency.to<double>();
4843 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANrange_UpdateFreq, string_c_str, string_length, &UpdateFrequencyVal);
4844 UpdateFrequency = units::frequency::hertz_t{UpdateFrequencyVal};
4845 return 0;
4846 }
4847};
4848
4849
4850/**
4851 * \brief Configs that affect the ToF Proximity detection
4852 *
4853 * \details Includes proximity mode and the threshold for simple
4854 * detection
4855 */
4857{
4858public:
4859 constexpr ProximityParamsConfigs() = default;
4860
4861 /**
4862 * \brief Threshold for object detection.
4863 *
4864 * - Minimum Value: 0
4865 * - Maximum Value: 4
4866 * - Default Value: 0.4
4867 * - Units: m
4868 */
4869 units::length::meter_t ProximityThreshold = 0.4_m;
4870 /**
4871 * \brief How far above and below the threshold the distance needs to
4872 * be to trigger undetected and detected, respectively. This is used
4873 * to prevent bouncing between the detected and undetected states for
4874 * objects on the threshold.
4875 *
4876 * If the threshold is set to 0.1 meters, and the hysteresis is 0.01
4877 * meters, then an object needs to be within 0.09 meters to be
4878 * detected. After the object is first detected, the distance then
4879 * needs to exceed 0.11 meters to become undetected again.
4880 *
4881 * - Minimum Value: 0
4882 * - Maximum Value: 1
4883 * - Default Value: 0.01
4884 * - Units: m
4885 */
4886 units::length::meter_t ProximityHysteresis = 0.01_m;
4887 /**
4888 * \brief The minimum allowable signal strength before determining the
4889 * measurement is valid.
4890 *
4891 * If the signal strength is particularly low, this typically means
4892 * the object is far away and there's fewer total samples to derive
4893 * the distance from. Set this value to be below the lowest strength
4894 * you see when you're detecting an object with the CANrange; the
4895 * default of 2500 is typically acceptable in most cases.
4896 *
4897 * - Minimum Value: 1
4898 * - Maximum Value: 15000
4899 * - Default Value: 2500
4900 * - Units:
4901 */
4902 units::dimensionless::scalar_t MinSignalStrengthForValidMeasurement = 2500;
4903
4904 /**
4905 * \brief Modifies this configuration's ProximityThreshold parameter and returns itself for
4906 * method-chaining and easier to use config API.
4907 *
4908 * Threshold for object detection.
4909 *
4910 * - Minimum Value: 0
4911 * - Maximum Value: 4
4912 * - Default Value: 0.4
4913 * - Units: m
4914 *
4915 * \param newProximityThreshold Parameter to modify
4916 * \returns Itself
4917 */
4918 constexpr ProximityParamsConfigs &WithProximityThreshold(units::length::meter_t newProximityThreshold)
4919 {
4920 ProximityThreshold = std::move(newProximityThreshold);
4921 return *this;
4922 }
4923
4924 /**
4925 * \brief Modifies this configuration's ProximityHysteresis parameter and returns itself for
4926 * method-chaining and easier to use config API.
4927 *
4928 * How far above and below the threshold the distance needs to be to
4929 * trigger undetected and detected, respectively. This is used to
4930 * prevent bouncing between the detected and undetected states for
4931 * objects on the threshold.
4932 *
4933 * If the threshold is set to 0.1 meters, and the hysteresis is 0.01
4934 * meters, then an object needs to be within 0.09 meters to be
4935 * detected. After the object is first detected, the distance then
4936 * needs to exceed 0.11 meters to become undetected again.
4937 *
4938 * - Minimum Value: 0
4939 * - Maximum Value: 1
4940 * - Default Value: 0.01
4941 * - Units: m
4942 *
4943 * \param newProximityHysteresis Parameter to modify
4944 * \returns Itself
4945 */
4946 constexpr ProximityParamsConfigs &WithProximityHysteresis(units::length::meter_t newProximityHysteresis)
4947 {
4948 ProximityHysteresis = std::move(newProximityHysteresis);
4949 return *this;
4950 }
4951
4952 /**
4953 * \brief Modifies this configuration's MinSignalStrengthForValidMeasurement parameter and returns itself for
4954 * method-chaining and easier to use config API.
4955 *
4956 * The minimum allowable signal strength before determining the
4957 * measurement is valid.
4958 *
4959 * If the signal strength is particularly low, this typically means
4960 * the object is far away and there's fewer total samples to derive
4961 * the distance from. Set this value to be below the lowest strength
4962 * you see when you're detecting an object with the CANrange; the
4963 * default of 2500 is typically acceptable in most cases.
4964 *
4965 * - Minimum Value: 1
4966 * - Maximum Value: 15000
4967 * - Default Value: 2500
4968 * - Units:
4969 *
4970 * \param newMinSignalStrengthForValidMeasurement Parameter to modify
4971 * \returns Itself
4972 */
4973 constexpr ProximityParamsConfigs &WithMinSignalStrengthForValidMeasurement(units::dimensionless::scalar_t newMinSignalStrengthForValidMeasurement)
4974 {
4975 MinSignalStrengthForValidMeasurement = std::move(newMinSignalStrengthForValidMeasurement);
4976 return *this;
4977 }
4978
4979
4980
4981 std::string ToString() const override
4982 {
4983 std::stringstream ss;
4984 ss << "Config Group: ProximityParams" << std::endl;
4985 ss << " ProximityThreshold: " << ProximityThreshold.to<double>() << " m" << std::endl;
4986 ss << " ProximityHysteresis: " << ProximityHysteresis.to<double>() << " m" << std::endl;
4987 ss << " MinSignalStrengthForValidMeasurement: " << MinSignalStrengthForValidMeasurement.to<double>() << std::endl;
4988 return ss.str();
4989 }
4990
4991 std::string Serialize() const override
4992 {
4993 std::stringstream ss;
4994 char *ref;
4995 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANrange_ProximityThreshold, ProximityThreshold.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4996 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANrange_ProximityHysteresis, ProximityHysteresis.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4997 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANrange_MinSigStrengthForValidMeas, MinSignalStrengthForValidMeasurement.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
4998 return ss.str();
4999 }
5000
5001 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
5002 {
5003 const char *string_c_str = to_deserialize.c_str();
5004 size_t string_length = to_deserialize.length();
5005 double ProximityThresholdVal = ProximityThreshold.to<double>();
5006 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANrange_ProximityThreshold, string_c_str, string_length, &ProximityThresholdVal);
5007 ProximityThreshold = units::length::meter_t{ProximityThresholdVal};
5008 double ProximityHysteresisVal = ProximityHysteresis.to<double>();
5009 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANrange_ProximityHysteresis, string_c_str, string_length, &ProximityHysteresisVal);
5010 ProximityHysteresis = units::length::meter_t{ProximityHysteresisVal};
5011 double MinSignalStrengthForValidMeasurementVal = MinSignalStrengthForValidMeasurement.to<double>();
5012 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANrange_MinSigStrengthForValidMeas, string_c_str, string_length, &MinSignalStrengthForValidMeasurementVal);
5013 MinSignalStrengthForValidMeasurement = units::dimensionless::scalar_t{MinSignalStrengthForValidMeasurementVal};
5014 return 0;
5015 }
5016};
5017
5018
5019/**
5020 * \brief Configs that affect the ToF Field of View
5021 *
5022 * \details Includes range and center configs
5023 */
5025{
5026public:
5027 constexpr FovParamsConfigs() = default;
5028
5029 /**
5030 * \brief Specifies the target center of the Field of View in the X
5031 * direction.
5032 *
5033 * \details The exact value may be different for different CANrange
5034 * devices due to imperfections in the sensing silicon.
5035 *
5036 * - Minimum Value: -11.8
5037 * - Maximum Value: 11.8
5038 * - Default Value: 0
5039 * - Units: deg
5040 */
5041 units::angle::degree_t FOVCenterX = 0_deg;
5042 /**
5043 * \brief Specifies the target center of the Field of View in the Y
5044 * direction.
5045 *
5046 * \details The exact value may be different for different CANrange
5047 * devices due to imperfections in the sensing silicon.
5048 *
5049 * - Minimum Value: -11.8
5050 * - Maximum Value: 11.8
5051 * - Default Value: 0
5052 * - Units: deg
5053 */
5054 units::angle::degree_t FOVCenterY = 0_deg;
5055 /**
5056 * \brief Specifies the target range of the Field of View in the X
5057 * direction. This is the full range of the FOV.
5058 *
5059 * The magnitude of this is capped to abs(27 - 2*FOVCenterX).
5060 *
5061 * \details The exact value may be different for different CANrange
5062 * devices due to imperfections in the sensing silicon.
5063 *
5064 * - Minimum Value: 6.75
5065 * - Maximum Value: 27
5066 * - Default Value: 27
5067 * - Units: deg
5068 */
5069 units::angle::degree_t FOVRangeX = 27_deg;
5070 /**
5071 * \brief Specifies the target range of the Field of View in the Y
5072 * direction. This is the full range of the FOV.
5073 *
5074 * The magnitude of this is capped to abs(27 - 2*FOVCenterY).
5075 *
5076 * \details The exact value may be different for different CANrange
5077 * devices due to imperfections in the sensing silicon.
5078 *
5079 * - Minimum Value: 6.75
5080 * - Maximum Value: 27
5081 * - Default Value: 27
5082 * - Units: deg
5083 */
5084 units::angle::degree_t FOVRangeY = 27_deg;
5085
5086 /**
5087 * \brief Modifies this configuration's FOVCenterX parameter and returns itself for
5088 * method-chaining and easier to use config API.
5089 *
5090 * Specifies the target center of the Field of View in the X
5091 * direction.
5092 *
5093 * \details The exact value may be different for different CANrange
5094 * devices due to imperfections in the sensing silicon.
5095 *
5096 * - Minimum Value: -11.8
5097 * - Maximum Value: 11.8
5098 * - Default Value: 0
5099 * - Units: deg
5100 *
5101 * \param newFOVCenterX Parameter to modify
5102 * \returns Itself
5103 */
5104 constexpr FovParamsConfigs &WithFOVCenterX(units::angle::degree_t newFOVCenterX)
5105 {
5106 FOVCenterX = std::move(newFOVCenterX);
5107 return *this;
5108 }
5109
5110 /**
5111 * \brief Modifies this configuration's FOVCenterY parameter and returns itself for
5112 * method-chaining and easier to use config API.
5113 *
5114 * Specifies the target center of the Field of View in the Y
5115 * direction.
5116 *
5117 * \details The exact value may be different for different CANrange
5118 * devices due to imperfections in the sensing silicon.
5119 *
5120 * - Minimum Value: -11.8
5121 * - Maximum Value: 11.8
5122 * - Default Value: 0
5123 * - Units: deg
5124 *
5125 * \param newFOVCenterY Parameter to modify
5126 * \returns Itself
5127 */
5128 constexpr FovParamsConfigs &WithFOVCenterY(units::angle::degree_t newFOVCenterY)
5129 {
5130 FOVCenterY = std::move(newFOVCenterY);
5131 return *this;
5132 }
5133
5134 /**
5135 * \brief Modifies this configuration's FOVRangeX parameter and returns itself for
5136 * method-chaining and easier to use config API.
5137 *
5138 * Specifies the target range of the Field of View in the X direction.
5139 * This is the full range of the FOV.
5140 *
5141 * The magnitude of this is capped to abs(27 - 2*FOVCenterX).
5142 *
5143 * \details The exact value may be different for different CANrange
5144 * devices due to imperfections in the sensing silicon.
5145 *
5146 * - Minimum Value: 6.75
5147 * - Maximum Value: 27
5148 * - Default Value: 27
5149 * - Units: deg
5150 *
5151 * \param newFOVRangeX Parameter to modify
5152 * \returns Itself
5153 */
5154 constexpr FovParamsConfigs &WithFOVRangeX(units::angle::degree_t newFOVRangeX)
5155 {
5156 FOVRangeX = std::move(newFOVRangeX);
5157 return *this;
5158 }
5159
5160 /**
5161 * \brief Modifies this configuration's FOVRangeY parameter and returns itself for
5162 * method-chaining and easier to use config API.
5163 *
5164 * Specifies the target range of the Field of View in the Y direction.
5165 * This is the full range of the FOV.
5166 *
5167 * The magnitude of this is capped to abs(27 - 2*FOVCenterY).
5168 *
5169 * \details The exact value may be different for different CANrange
5170 * devices due to imperfections in the sensing silicon.
5171 *
5172 * - Minimum Value: 6.75
5173 * - Maximum Value: 27
5174 * - Default Value: 27
5175 * - Units: deg
5176 *
5177 * \param newFOVRangeY Parameter to modify
5178 * \returns Itself
5179 */
5180 constexpr FovParamsConfigs &WithFOVRangeY(units::angle::degree_t newFOVRangeY)
5181 {
5182 FOVRangeY = std::move(newFOVRangeY);
5183 return *this;
5184 }
5185
5186
5187
5188 std::string ToString() const override
5189 {
5190 std::stringstream ss;
5191 ss << "Config Group: FovParams" << std::endl;
5192 ss << " FOVCenterX: " << FOVCenterX.to<double>() << " deg" << std::endl;
5193 ss << " FOVCenterY: " << FOVCenterY.to<double>() << " deg" << std::endl;
5194 ss << " FOVRangeX: " << FOVRangeX.to<double>() << " deg" << std::endl;
5195 ss << " FOVRangeY: " << FOVRangeY.to<double>() << " deg" << std::endl;
5196 return ss.str();
5197 }
5198
5199 std::string Serialize() const override
5200 {
5201 std::stringstream ss;
5202 char *ref;
5203 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANrange_FOVCenterX, FOVCenterX.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
5204 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANrange_FOVCenterY, FOVCenterY.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
5205 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANrange_FOVRangeX, FOVRangeX.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
5206 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANrange_FOVRangeY, FOVRangeY.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
5207 return ss.str();
5208 }
5209
5210 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
5211 {
5212 const char *string_c_str = to_deserialize.c_str();
5213 size_t string_length = to_deserialize.length();
5214 double FOVCenterXVal = FOVCenterX.to<double>();
5215 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANrange_FOVCenterX, string_c_str, string_length, &FOVCenterXVal);
5216 FOVCenterX = units::angle::degree_t{FOVCenterXVal};
5217 double FOVCenterYVal = FOVCenterY.to<double>();
5218 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANrange_FOVCenterY, string_c_str, string_length, &FOVCenterYVal);
5219 FOVCenterY = units::angle::degree_t{FOVCenterYVal};
5220 double FOVRangeXVal = FOVRangeX.to<double>();
5221 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANrange_FOVRangeX, string_c_str, string_length, &FOVRangeXVal);
5222 FOVRangeX = units::angle::degree_t{FOVRangeXVal};
5223 double FOVRangeYVal = FOVRangeY.to<double>();
5224 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::CANrange_FOVRangeY, string_c_str, string_length, &FOVRangeYVal);
5225 FOVRangeY = units::angle::degree_t{FOVRangeYVal};
5226 return 0;
5227 }
5228};
5229
5230
5231/**
5232 * \brief Configs that determine motor selection and commutation.
5233 *
5234 * \details Set these configs to match your motor setup before
5235 * commanding motor output.
5236 */
5238{
5239public:
5240 constexpr CommutationConfigs() = default;
5241
5242 /**
5243 * \brief Requires Phoenix Pro; Improves commutation and velocity
5244 * measurement for motors with hall sensors. Talon can use advanced
5245 * features to improve commutation and velocity measurement when using
5246 * a motor with hall sensors. This can improve peak efficiency by as
5247 * high as 2% and reduce noise in the measured velocity.
5248 *
5249 */
5251 /**
5252 * \brief Selects the motor and motor connections used with Talon.
5253 *
5254 * This setting determines what kind of motor and sensors are used
5255 * with the Talon. This also determines what signals are used on the
5256 * JST and Gadgeteer port.
5257 *
5258 * Motor drive will not function correctly if this setting does not
5259 * match the physical setup.
5260 *
5261 */
5263 /**
5264 * \brief If a brushed motor is selected with Motor Arrangement, this
5265 * config determines which of three leads to use.
5266 *
5267 */
5269
5270 /**
5271 * \brief Modifies this configuration's AdvancedHallSupport parameter and returns itself for
5272 * method-chaining and easier to use config API.
5273 *
5274 * Requires Phoenix Pro; Improves commutation and velocity measurement
5275 * for motors with hall sensors. Talon can use advanced features to
5276 * improve commutation and velocity measurement when using a motor
5277 * with hall sensors. This can improve peak efficiency by as high as
5278 * 2% and reduce noise in the measured velocity.
5279 *
5280 *
5281 * \param newAdvancedHallSupport Parameter to modify
5282 * \returns Itself
5283 */
5285 {
5286 AdvancedHallSupport = std::move(newAdvancedHallSupport);
5287 return *this;
5288 }
5289
5290 /**
5291 * \brief Modifies this configuration's MotorArrangement parameter and returns itself for
5292 * method-chaining and easier to use config API.
5293 *
5294 * Selects the motor and motor connections used with Talon.
5295 *
5296 * This setting determines what kind of motor and sensors are used
5297 * with the Talon. This also determines what signals are used on the
5298 * JST and Gadgeteer port.
5299 *
5300 * Motor drive will not function correctly if this setting does not
5301 * match the physical setup.
5302 *
5303 *
5304 * \param newMotorArrangement Parameter to modify
5305 * \returns Itself
5306 */
5308 {
5309 MotorArrangement = std::move(newMotorArrangement);
5310 return *this;
5311 }
5312
5313 /**
5314 * \brief Modifies this configuration's BrushedMotorWiring parameter and returns itself for
5315 * method-chaining and easier to use config API.
5316 *
5317 * If a brushed motor is selected with Motor Arrangement, this config
5318 * determines which of three leads to use.
5319 *
5320 *
5321 * \param newBrushedMotorWiring Parameter to modify
5322 * \returns Itself
5323 */
5325 {
5326 BrushedMotorWiring = std::move(newBrushedMotorWiring);
5327 return *this;
5328 }
5329
5330
5331
5332 std::string ToString() const override
5333 {
5334 std::stringstream ss;
5335 ss << "Config Group: Commutation" << std::endl;
5336 ss << " AdvancedHallSupport: " << AdvancedHallSupport << std::endl;
5337 ss << " MotorArrangement: " << MotorArrangement << std::endl;
5338 ss << " BrushedMotorWiring: " << BrushedMotorWiring << std::endl;
5339 return ss.str();
5340 }
5341
5342 std::string Serialize() const override
5343 {
5344 std::stringstream ss;
5345 char *ref;
5346 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_AdvancedHallSupport, AdvancedHallSupport.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5347 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_MotorType, MotorArrangement.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5348 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_BrushedMotorWiring, BrushedMotorWiring.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5349 return ss.str();
5350 }
5351
5352 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
5353 {
5354 const char *string_c_str = to_deserialize.c_str();
5355 size_t string_length = to_deserialize.length();
5356 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_AdvancedHallSupport, string_c_str, string_length, &AdvancedHallSupport.value);
5357 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_MotorType, string_c_str, string_length, &MotorArrangement.value);
5358 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_BrushedMotorWiring, string_c_str, string_length, &BrushedMotorWiring.value);
5359 return 0;
5360 }
5361};
5362
5363
5364/**
5365 * \brief Configs related to the CANdi™ branded device's digital I/O
5366 * settings
5367 *
5368 * \details Contains float-state settings and when to assert the S1/S2
5369 * inputs.
5370 */
5372{
5373public:
5374 constexpr DigitalInputsConfigs() = default;
5375
5376 /**
5377 * \brief The floating state of the Signal 1 input (S1IN).
5378 *
5379 */
5381 /**
5382 * \brief The floating state of the Signal 2 input (S2IN).
5383 *
5384 */
5386 /**
5387 * \brief What value the Signal 1 input (S1IN) needs to be for the CTR
5388 * Electronics' CANdi™ to detect as Closed.
5389 *
5390 * \details Devices using the S1 input as a remote limit switch will
5391 * treat the switch as closed when the S1 input is this state.
5392 *
5393 */
5395 /**
5396 * \brief What value the Signal 2 input (S2IN) needs to be for the CTR
5397 * Electronics' CANdi™ to detect as Closed.
5398 *
5399 * \details Devices using the S2 input as a remote limit switch will
5400 * treat the switch as closed when the S2 input is this state.
5401 *
5402 */
5404
5405 /**
5406 * \brief Modifies this configuration's S1FloatState parameter and returns itself for
5407 * method-chaining and easier to use config API.
5408 *
5409 * The floating state of the Signal 1 input (S1IN).
5410 *
5411 *
5412 * \param newS1FloatState Parameter to modify
5413 * \returns Itself
5414 */
5416 {
5417 S1FloatState = std::move(newS1FloatState);
5418 return *this;
5419 }
5420
5421 /**
5422 * \brief Modifies this configuration's S2FloatState parameter and returns itself for
5423 * method-chaining and easier to use config API.
5424 *
5425 * The floating state of the Signal 2 input (S2IN).
5426 *
5427 *
5428 * \param newS2FloatState Parameter to modify
5429 * \returns Itself
5430 */
5432 {
5433 S2FloatState = std::move(newS2FloatState);
5434 return *this;
5435 }
5436
5437 /**
5438 * \brief Modifies this configuration's S1CloseState parameter and returns itself for
5439 * method-chaining and easier to use config API.
5440 *
5441 * What value the Signal 1 input (S1IN) needs to be for the CTR
5442 * Electronics' CANdi™ to detect as Closed.
5443 *
5444 * \details Devices using the S1 input as a remote limit switch will
5445 * treat the switch as closed when the S1 input is this state.
5446 *
5447 *
5448 * \param newS1CloseState Parameter to modify
5449 * \returns Itself
5450 */
5452 {
5453 S1CloseState = std::move(newS1CloseState);
5454 return *this;
5455 }
5456
5457 /**
5458 * \brief Modifies this configuration's S2CloseState parameter and returns itself for
5459 * method-chaining and easier to use config API.
5460 *
5461 * What value the Signal 2 input (S2IN) needs to be for the CTR
5462 * Electronics' CANdi™ to detect as Closed.
5463 *
5464 * \details Devices using the S2 input as a remote limit switch will
5465 * treat the switch as closed when the S2 input is this state.
5466 *
5467 *
5468 * \param newS2CloseState Parameter to modify
5469 * \returns Itself
5470 */
5472 {
5473 S2CloseState = std::move(newS2CloseState);
5474 return *this;
5475 }
5476
5477
5478
5479 std::string ToString() const override
5480 {
5481 std::stringstream ss;
5482 ss << "Config Group: DigitalInputs" << std::endl;
5483 ss << " S1FloatState: " << S1FloatState << std::endl;
5484 ss << " S2FloatState: " << S2FloatState << std::endl;
5485 ss << " S1CloseState: " << S1CloseState << std::endl;
5486 ss << " S2CloseState: " << S2CloseState << std::endl;
5487 return ss.str();
5488 }
5489
5490 std::string Serialize() const override
5491 {
5492 std::stringstream ss;
5493 char *ref;
5494 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CANdi_S1FloatState, S1FloatState.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5495 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::CANdi_S2FloatState, S2FloatState.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5496 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_S1_CloseState, S1CloseState.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5497 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_S2_CloseState, S2CloseState.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5498 return ss.str();
5499 }
5500
5501 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
5502 {
5503 const char *string_c_str = to_deserialize.c_str();
5504 size_t string_length = to_deserialize.length();
5505 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CANdi_S1FloatState, string_c_str, string_length, &S1FloatState.value);
5506 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::CANdi_S2FloatState, string_c_str, string_length, &S2FloatState.value);
5507 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_S1_CloseState, string_c_str, string_length, &S1CloseState.value);
5508 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_S2_CloseState, string_c_str, string_length, &S2CloseState.value);
5509 return 0;
5510 }
5511};
5512
5513
5514/**
5515 * \brief Configs related to the CANdi™ branded device's quadrature
5516 * interface using both the S1IN and S2IN inputs
5517 *
5518 * \details All the configs related to the quadrature interface for
5519 * the CANdi™ branded device , including encoder edges per
5520 * revolution and sensor direction.
5521 */
5523{
5524public:
5525 constexpr QuadratureConfigs() = default;
5526
5527 /**
5528 * \brief The number of quadrature edges in one rotation for the
5529 * quadrature sensor connected to the Talon data port.
5530 *
5531 * This is the total number of transitions from high-to-low or
5532 * low-to-high across both channels per rotation of the sensor. This
5533 * is also equivalent to the Counts Per Revolution when using 4x
5534 * decoding.
5535 *
5536 * For example, the SRX Mag Encoder has 4096 edges per rotation, and a
5537 * US Digital 1024 CPR (Cycles Per Revolution) quadrature encoder has
5538 * 4096 edges per rotation.
5539 *
5540 * \details On the Talon FXS, this can be at most 2,000,000,000 / Peak
5541 * RPM.
5542 *
5543 * - Minimum Value: 1
5544 * - Maximum Value: 1000000
5545 * - Default Value: 4096
5546 * - Units:
5547 */
5549 /**
5550 * \brief Direction of the quadrature sensor to determine positive
5551 * rotation. Invert this so that forward motion on the mechanism
5552 * results in an increase in quadrature position.
5553 *
5554 * - Default Value: False
5555 */
5556 bool SensorDirection = false;
5557
5558 /**
5559 * \brief Modifies this configuration's QuadratureEdgesPerRotation parameter and returns itself for
5560 * method-chaining and easier to use config API.
5561 *
5562 * The number of quadrature edges in one rotation for the quadrature
5563 * sensor connected to the Talon data port.
5564 *
5565 * This is the total number of transitions from high-to-low or
5566 * low-to-high across both channels per rotation of the sensor. This
5567 * is also equivalent to the Counts Per Revolution when using 4x
5568 * decoding.
5569 *
5570 * For example, the SRX Mag Encoder has 4096 edges per rotation, and a
5571 * US Digital 1024 CPR (Cycles Per Revolution) quadrature encoder has
5572 * 4096 edges per rotation.
5573 *
5574 * \details On the Talon FXS, this can be at most 2,000,000,000 / Peak
5575 * RPM.
5576 *
5577 * - Minimum Value: 1
5578 * - Maximum Value: 1000000
5579 * - Default Value: 4096
5580 * - Units:
5581 *
5582 * \param newQuadratureEdgesPerRotation Parameter to modify
5583 * \returns Itself
5584 */
5585 constexpr QuadratureConfigs &WithQuadratureEdgesPerRotation(int newQuadratureEdgesPerRotation)
5586 {
5587 QuadratureEdgesPerRotation = std::move(newQuadratureEdgesPerRotation);
5588 return *this;
5589 }
5590
5591 /**
5592 * \brief Modifies this configuration's SensorDirection parameter and returns itself for
5593 * method-chaining and easier to use config API.
5594 *
5595 * Direction of the quadrature sensor to determine positive rotation.
5596 * Invert this so that forward motion on the mechanism results in an
5597 * increase in quadrature position.
5598 *
5599 * - Default Value: False
5600 *
5601 * \param newSensorDirection Parameter to modify
5602 * \returns Itself
5603 */
5604 constexpr QuadratureConfigs &WithSensorDirection(bool newSensorDirection)
5605 {
5606 SensorDirection = std::move(newSensorDirection);
5607 return *this;
5608 }
5609
5610
5611
5612 std::string ToString() const override
5613 {
5614 std::stringstream ss;
5615 ss << "Config Group: Quadrature" << std::endl;
5616 ss << " QuadratureEdgesPerRotation: " << QuadratureEdgesPerRotation << std::endl;
5617 ss << " SensorDirection: " << SensorDirection << std::endl;
5618 return ss.str();
5619 }
5620
5621 std::string Serialize() const override
5622 {
5623 std::stringstream ss;
5624 char *ref;
5625 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_QuadratureEdgesPerRotation, QuadratureEdgesPerRotation, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5626 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_Quad_SensorDirection, SensorDirection, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5627 return ss.str();
5628 }
5629
5630 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
5631 {
5632 const char *string_c_str = to_deserialize.c_str();
5633 size_t string_length = to_deserialize.length();
5634 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_QuadratureEdgesPerRotation, string_c_str, string_length, &QuadratureEdgesPerRotation);
5635 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_Quad_SensorDirection, string_c_str, string_length, &SensorDirection);
5636 return 0;
5637 }
5638};
5639
5640
5641/**
5642 * \brief Configs related to the CANdi™ branded device's PWM interface
5643 * on the Signal 1 input (S1IN)
5644 *
5645 * \details All the configs related to the PWM interface for the
5646 * CANdi™ branded device on S1, including absolute sensor
5647 * offset, absolute sensor discontinuity point and sensor
5648 * direction.
5649 */
5651{
5652public:
5653 constexpr PWM1Configs() = default;
5654
5655 /**
5656 * \brief The offset applied to the PWM sensor.
5657 *
5658 * This can be used to zero the sensor position in applications where
5659 * the sensor is 1:1 with the mechanism.
5660 *
5661 * - Minimum Value: -1
5662 * - Maximum Value: 1
5663 * - Default Value: 0.0
5664 * - Units: rotations
5665 */
5666 units::angle::turn_t AbsoluteSensorOffset = 0.0_tr;
5667 /**
5668 * \brief The positive discontinuity point of the absolute sensor in
5669 * rotations. This determines the point at which the absolute sensor
5670 * wraps around, keeping the absolute position (after offset) in the
5671 * range [x-1, x).
5672 *
5673 * - Setting this to 1 makes the absolute position unsigned [0, 1)
5674 * - Setting this to 0.5 makes the absolute position signed [-0.5,
5675 * 0.5)
5676 * - Setting this to 0 makes the absolute position always negative
5677 * [-1, 0)
5678 *
5679 * Many rotational mechanisms such as arms have a region of motion
5680 * that is unreachable. This should be set to the center of that
5681 * region of motion, in non-negative rotations. This affects the
5682 * position of the device at bootup.
5683 *
5684 * \details For example, consider an arm which can travel from -0.2 to
5685 * 0.6 rotations with a little leeway, where 0 is horizontally
5686 * forward. Since -0.2 rotations has the same absolute position as 0.8
5687 * rotations, we can say that the arm typically does not travel in the
5688 * range (0.6, 0.8) rotations. As a result, the discontinuity point
5689 * would be the center of that range, which is 0.7 rotations. This
5690 * results in an absolute sensor range of [-0.3, 0.7) rotations.
5691 *
5692 * Given a total range of motion less than 1 rotation, users can
5693 * calculate the discontinuity point using mean(lowerLimit,
5694 * upperLimit) + 0.5. If that results in a value outside the range [0,
5695 * 1], either cap the value to [0, 1], or add/subtract 1.0 rotation
5696 * from your lower and upper limits of motion.
5697 *
5698 * On a Talon motor controller, this is only supported when using the
5699 * PulseWidth sensor source.
5700 *
5701 * - Minimum Value: 0.0
5702 * - Maximum Value: 1.0
5703 * - Default Value: 0.5
5704 * - Units: rotations
5705 */
5706 units::angle::turn_t AbsoluteSensorDiscontinuityPoint = 0.5_tr;
5707 /**
5708 * \brief Direction of the PWM sensor to determine positive rotation.
5709 * Invert this so that forward motion on the mechanism results in an
5710 * increase in PWM position.
5711 *
5712 * - Default Value: False
5713 */
5714 bool SensorDirection = false;
5715
5716 /**
5717 * \brief Modifies this configuration's AbsoluteSensorOffset parameter and returns itself for
5718 * method-chaining and easier to use config API.
5719 *
5720 * The offset applied to the PWM sensor.
5721 *
5722 * This can be used to zero the sensor position in applications where
5723 * the sensor is 1:1 with the mechanism.
5724 *
5725 * - Minimum Value: -1
5726 * - Maximum Value: 1
5727 * - Default Value: 0.0
5728 * - Units: rotations
5729 *
5730 * \param newAbsoluteSensorOffset Parameter to modify
5731 * \returns Itself
5732 */
5733 constexpr PWM1Configs &WithAbsoluteSensorOffset(units::angle::turn_t newAbsoluteSensorOffset)
5734 {
5735 AbsoluteSensorOffset = std::move(newAbsoluteSensorOffset);
5736 return *this;
5737 }
5738
5739 /**
5740 * \brief Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for
5741 * method-chaining and easier to use config API.
5742 *
5743 * The positive discontinuity point of the absolute sensor in
5744 * rotations. This determines the point at which the absolute sensor
5745 * wraps around, keeping the absolute position (after offset) in the
5746 * range [x-1, x).
5747 *
5748 * - Setting this to 1 makes the absolute position unsigned [0, 1)
5749 * - Setting this to 0.5 makes the absolute position signed [-0.5,
5750 * 0.5)
5751 * - Setting this to 0 makes the absolute position always negative
5752 * [-1, 0)
5753 *
5754 * Many rotational mechanisms such as arms have a region of motion
5755 * that is unreachable. This should be set to the center of that
5756 * region of motion, in non-negative rotations. This affects the
5757 * position of the device at bootup.
5758 *
5759 * \details For example, consider an arm which can travel from -0.2 to
5760 * 0.6 rotations with a little leeway, where 0 is horizontally
5761 * forward. Since -0.2 rotations has the same absolute position as 0.8
5762 * rotations, we can say that the arm typically does not travel in the
5763 * range (0.6, 0.8) rotations. As a result, the discontinuity point
5764 * would be the center of that range, which is 0.7 rotations. This
5765 * results in an absolute sensor range of [-0.3, 0.7) rotations.
5766 *
5767 * Given a total range of motion less than 1 rotation, users can
5768 * calculate the discontinuity point using mean(lowerLimit,
5769 * upperLimit) + 0.5. If that results in a value outside the range [0,
5770 * 1], either cap the value to [0, 1], or add/subtract 1.0 rotation
5771 * from your lower and upper limits of motion.
5772 *
5773 * On a Talon motor controller, this is only supported when using the
5774 * PulseWidth sensor source.
5775 *
5776 * - Minimum Value: 0.0
5777 * - Maximum Value: 1.0
5778 * - Default Value: 0.5
5779 * - Units: rotations
5780 *
5781 * \param newAbsoluteSensorDiscontinuityPoint Parameter to modify
5782 * \returns Itself
5783 */
5784 constexpr PWM1Configs &WithAbsoluteSensorDiscontinuityPoint(units::angle::turn_t newAbsoluteSensorDiscontinuityPoint)
5785 {
5786 AbsoluteSensorDiscontinuityPoint = std::move(newAbsoluteSensorDiscontinuityPoint);
5787 return *this;
5788 }
5789
5790 /**
5791 * \brief Modifies this configuration's SensorDirection parameter and returns itself for
5792 * method-chaining and easier to use config API.
5793 *
5794 * Direction of the PWM sensor to determine positive rotation. Invert
5795 * this so that forward motion on the mechanism results in an increase
5796 * in PWM position.
5797 *
5798 * - Default Value: False
5799 *
5800 * \param newSensorDirection Parameter to modify
5801 * \returns Itself
5802 */
5803 constexpr PWM1Configs &WithSensorDirection(bool newSensorDirection)
5804 {
5805 SensorDirection = std::move(newSensorDirection);
5806 return *this;
5807 }
5808
5809
5810
5811 std::string ToString() const override
5812 {
5813 std::stringstream ss;
5814 ss << "Config Group: PWM1" << std::endl;
5815 ss << " AbsoluteSensorOffset: " << AbsoluteSensorOffset.to<double>() << " rotations" << std::endl;
5816 ss << " AbsoluteSensorDiscontinuityPoint: " << AbsoluteSensorDiscontinuityPoint.to<double>() << " rotations" << std::endl;
5817 ss << " SensorDirection: " << SensorDirection << std::endl;
5818 return ss.str();
5819 }
5820
5821 std::string Serialize() const override
5822 {
5823 std::stringstream ss;
5824 char *ref;
5825 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PWM1_AbsoluteSensorOffset, AbsoluteSensorOffset.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
5826 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PWM1_AbsoluteSensorDiscontinuityPoint, AbsoluteSensorDiscontinuityPoint.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
5827 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_PWM1_SensorDirection, SensorDirection, &ref); if (ref != nullptr) { ss << ref; free(ref); }
5828 return ss.str();
5829 }
5830
5831 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
5832 {
5833 const char *string_c_str = to_deserialize.c_str();
5834 size_t string_length = to_deserialize.length();
5835 double AbsoluteSensorOffsetVal = AbsoluteSensorOffset.to<double>();
5836 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PWM1_AbsoluteSensorOffset, string_c_str, string_length, &AbsoluteSensorOffsetVal);
5837 AbsoluteSensorOffset = units::angle::turn_t{AbsoluteSensorOffsetVal};
5838 double AbsoluteSensorDiscontinuityPointVal = AbsoluteSensorDiscontinuityPoint.to<double>();
5839 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PWM1_AbsoluteSensorDiscontinuityPoint, string_c_str, string_length, &AbsoluteSensorDiscontinuityPointVal);
5840 AbsoluteSensorDiscontinuityPoint = units::angle::turn_t{AbsoluteSensorDiscontinuityPointVal};
5841 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_PWM1_SensorDirection, string_c_str, string_length, &SensorDirection);
5842 return 0;
5843 }
5844};
5845
5846
5847/**
5848 * \brief Configs related to the CANdi™ branded device's PWM interface
5849 * on the Signal 2 input (S2IN)
5850 *
5851 * \details All the configs related to the PWM interface for the
5852 * CANdi™ branded device on S1, including absolute sensor
5853 * offset, absolute sensor discontinuity point and sensor
5854 * direction.
5855 */
5857{
5858public:
5859 constexpr PWM2Configs() = default;
5860
5861 /**
5862 * \brief The offset applied to the PWM sensor.
5863 *
5864 * This can be used to zero the sensor position in applications where
5865 * the sensor is 1:1 with the mechanism.
5866 *
5867 * - Minimum Value: -1
5868 * - Maximum Value: 1
5869 * - Default Value: 0.0
5870 * - Units: rotations
5871 */
5872 units::angle::turn_t AbsoluteSensorOffset = 0.0_tr;
5873 /**
5874 * \brief The positive discontinuity point of the absolute sensor in
5875 * rotations. This determines the point at which the absolute sensor
5876 * wraps around, keeping the absolute position (after offset) in the
5877 * range [x-1, x).
5878 *
5879 * - Setting this to 1 makes the absolute position unsigned [0, 1)
5880 * - Setting this to 0.5 makes the absolute position signed [-0.5,
5881 * 0.5)
5882 * - Setting this to 0 makes the absolute position always negative
5883 * [-1, 0)
5884 *
5885 * Many rotational mechanisms such as arms have a region of motion
5886 * that is unreachable. This should be set to the center of that
5887 * region of motion, in non-negative rotations. This affects the
5888 * position of the device at bootup.
5889 *
5890 * \details For example, consider an arm which can travel from -0.2 to
5891 * 0.6 rotations with a little leeway, where 0 is horizontally
5892 * forward. Since -0.2 rotations has the same absolute position as 0.8
5893 * rotations, we can say that the arm typically does not travel in the
5894 * range (0.6, 0.8) rotations. As a result, the discontinuity point
5895 * would be the center of that range, which is 0.7 rotations. This
5896 * results in an absolute sensor range of [-0.3, 0.7) rotations.
5897 *
5898 * Given a total range of motion less than 1 rotation, users can
5899 * calculate the discontinuity point using mean(lowerLimit,
5900 * upperLimit) + 0.5. If that results in a value outside the range [0,
5901 * 1], either cap the value to [0, 1], or add/subtract 1.0 rotation
5902 * from your lower and upper limits of motion.
5903 *
5904 * On a Talon motor controller, this is only supported when using the
5905 * PulseWidth sensor source.
5906 *
5907 * - Minimum Value: 0.0
5908 * - Maximum Value: 1.0
5909 * - Default Value: 0.5
5910 * - Units: rotations
5911 */
5912 units::angle::turn_t AbsoluteSensorDiscontinuityPoint = 0.5_tr;
5913 /**
5914 * \brief Direction of the PWM sensor to determine positive rotation.
5915 * Invert this so that forward motion on the mechanism results in an
5916 * increase in PWM position.
5917 *
5918 * - Default Value: False
5919 */
5920 bool SensorDirection = false;
5921
5922 /**
5923 * \brief Modifies this configuration's AbsoluteSensorOffset parameter and returns itself for
5924 * method-chaining and easier to use config API.
5925 *
5926 * The offset applied to the PWM sensor.
5927 *
5928 * This can be used to zero the sensor position in applications where
5929 * the sensor is 1:1 with the mechanism.
5930 *
5931 * - Minimum Value: -1
5932 * - Maximum Value: 1
5933 * - Default Value: 0.0
5934 * - Units: rotations
5935 *
5936 * \param newAbsoluteSensorOffset Parameter to modify
5937 * \returns Itself
5938 */
5939 constexpr PWM2Configs &WithAbsoluteSensorOffset(units::angle::turn_t newAbsoluteSensorOffset)
5940 {
5941 AbsoluteSensorOffset = std::move(newAbsoluteSensorOffset);
5942 return *this;
5943 }
5944
5945 /**
5946 * \brief Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for
5947 * method-chaining and easier to use config API.
5948 *
5949 * The positive discontinuity point of the absolute sensor in
5950 * rotations. This determines the point at which the absolute sensor
5951 * wraps around, keeping the absolute position (after offset) in the
5952 * range [x-1, x).
5953 *
5954 * - Setting this to 1 makes the absolute position unsigned [0, 1)
5955 * - Setting this to 0.5 makes the absolute position signed [-0.5,
5956 * 0.5)
5957 * - Setting this to 0 makes the absolute position always negative
5958 * [-1, 0)
5959 *
5960 * Many rotational mechanisms such as arms have a region of motion
5961 * that is unreachable. This should be set to the center of that
5962 * region of motion, in non-negative rotations. This affects the
5963 * position of the device at bootup.
5964 *
5965 * \details For example, consider an arm which can travel from -0.2 to
5966 * 0.6 rotations with a little leeway, where 0 is horizontally
5967 * forward. Since -0.2 rotations has the same absolute position as 0.8
5968 * rotations, we can say that the arm typically does not travel in the
5969 * range (0.6, 0.8) rotations. As a result, the discontinuity point
5970 * would be the center of that range, which is 0.7 rotations. This
5971 * results in an absolute sensor range of [-0.3, 0.7) rotations.
5972 *
5973 * Given a total range of motion less than 1 rotation, users can
5974 * calculate the discontinuity point using mean(lowerLimit,
5975 * upperLimit) + 0.5. If that results in a value outside the range [0,
5976 * 1], either cap the value to [0, 1], or add/subtract 1.0 rotation
5977 * from your lower and upper limits of motion.
5978 *
5979 * On a Talon motor controller, this is only supported when using the
5980 * PulseWidth sensor source.
5981 *
5982 * - Minimum Value: 0.0
5983 * - Maximum Value: 1.0
5984 * - Default Value: 0.5
5985 * - Units: rotations
5986 *
5987 * \param newAbsoluteSensorDiscontinuityPoint Parameter to modify
5988 * \returns Itself
5989 */
5990 constexpr PWM2Configs &WithAbsoluteSensorDiscontinuityPoint(units::angle::turn_t newAbsoluteSensorDiscontinuityPoint)
5991 {
5992 AbsoluteSensorDiscontinuityPoint = std::move(newAbsoluteSensorDiscontinuityPoint);
5993 return *this;
5994 }
5995
5996 /**
5997 * \brief Modifies this configuration's SensorDirection parameter and returns itself for
5998 * method-chaining and easier to use config API.
5999 *
6000 * Direction of the PWM sensor to determine positive rotation. Invert
6001 * this so that forward motion on the mechanism results in an increase
6002 * in PWM position.
6003 *
6004 * - Default Value: False
6005 *
6006 * \param newSensorDirection Parameter to modify
6007 * \returns Itself
6008 */
6009 constexpr PWM2Configs &WithSensorDirection(bool newSensorDirection)
6010 {
6011 SensorDirection = std::move(newSensorDirection);
6012 return *this;
6013 }
6014
6015
6016
6017 std::string ToString() const override
6018 {
6019 std::stringstream ss;
6020 ss << "Config Group: PWM2" << std::endl;
6021 ss << " AbsoluteSensorOffset: " << AbsoluteSensorOffset.to<double>() << " rotations" << std::endl;
6022 ss << " AbsoluteSensorDiscontinuityPoint: " << AbsoluteSensorDiscontinuityPoint.to<double>() << " rotations" << std::endl;
6023 ss << " SensorDirection: " << SensorDirection << std::endl;
6024 return ss.str();
6025 }
6026
6027 std::string Serialize() const override
6028 {
6029 std::stringstream ss;
6030 char *ref;
6031 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PWM2_AbsoluteSensorOffset, AbsoluteSensorOffset.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
6032 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_PWM2_AbsoluteSensorDiscontinuityPoint, AbsoluteSensorDiscontinuityPoint.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
6033 c_ctre_phoenix6_serialize_bool(ctre::phoenix6::spns::SpnValue::Config_PWM2_SensorDirection, SensorDirection, &ref); if (ref != nullptr) { ss << ref; free(ref); }
6034 return ss.str();
6035 }
6036
6037 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
6038 {
6039 const char *string_c_str = to_deserialize.c_str();
6040 size_t string_length = to_deserialize.length();
6041 double AbsoluteSensorOffsetVal = AbsoluteSensorOffset.to<double>();
6042 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PWM2_AbsoluteSensorOffset, string_c_str, string_length, &AbsoluteSensorOffsetVal);
6043 AbsoluteSensorOffset = units::angle::turn_t{AbsoluteSensorOffsetVal};
6044 double AbsoluteSensorDiscontinuityPointVal = AbsoluteSensorDiscontinuityPoint.to<double>();
6045 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_PWM2_AbsoluteSensorDiscontinuityPoint, string_c_str, string_length, &AbsoluteSensorDiscontinuityPointVal);
6046 AbsoluteSensorDiscontinuityPoint = units::angle::turn_t{AbsoluteSensorDiscontinuityPointVal};
6047 c_ctre_phoenix6_deserialize_bool(ctre::phoenix6::spns::SpnValue::Config_PWM2_SensorDirection, string_c_str, string_length, &SensorDirection);
6048 return 0;
6049 }
6050};
6051
6052
6053/**
6054 * \brief Configs related to CANdle LED control.
6055 *
6056 * \details All the configs related to controlling LEDs with the
6057 * CANdle, including LED strip type and brightness.
6058 */
6060{
6061public:
6062 constexpr LEDConfigs() = default;
6063
6064 /**
6065 * \brief The type of LEDs that are being controlled.
6066 *
6067 */
6069 /**
6070 * \brief The brightness scalar for all LEDs controlled. All LED
6071 * values sent to the CANdle will be scaled by this config.
6072 *
6073 * - Minimum Value: 0.0
6074 * - Maximum Value: 1.0
6075 * - Default Value: 1.0
6076 * - Units: scalar
6077 */
6078 units::dimensionless::scalar_t BrightnessScalar = 1.0;
6079 /**
6080 * \brief The behavior of the LEDs when the control signal is lost.
6081 *
6082 */
6084
6085 /**
6086 * \brief Modifies this configuration's StripType parameter and returns itself for
6087 * method-chaining and easier to use config API.
6088 *
6089 * The type of LEDs that are being controlled.
6090 *
6091 *
6092 * \param newStripType Parameter to modify
6093 * \returns Itself
6094 */
6096 {
6097 StripType = std::move(newStripType);
6098 return *this;
6099 }
6100
6101 /**
6102 * \brief Modifies this configuration's BrightnessScalar parameter and returns itself for
6103 * method-chaining and easier to use config API.
6104 *
6105 * The brightness scalar for all LEDs controlled. All LED values sent
6106 * to the CANdle will be scaled by this config.
6107 *
6108 * - Minimum Value: 0.0
6109 * - Maximum Value: 1.0
6110 * - Default Value: 1.0
6111 * - Units: scalar
6112 *
6113 * \param newBrightnessScalar Parameter to modify
6114 * \returns Itself
6115 */
6116 constexpr LEDConfigs &WithBrightnessScalar(units::dimensionless::scalar_t newBrightnessScalar)
6117 {
6118 BrightnessScalar = std::move(newBrightnessScalar);
6119 return *this;
6120 }
6121
6122 /**
6123 * \brief Modifies this configuration's LossOfSignalBehavior parameter and returns itself for
6124 * method-chaining and easier to use config API.
6125 *
6126 * The behavior of the LEDs when the control signal is lost.
6127 *
6128 *
6129 * \param newLossOfSignalBehavior Parameter to modify
6130 * \returns Itself
6131 */
6133 {
6134 LossOfSignalBehavior = std::move(newLossOfSignalBehavior);
6135 return *this;
6136 }
6137
6138
6139
6140 std::string ToString() const override
6141 {
6142 std::stringstream ss;
6143 ss << "Config Group: LED" << std::endl;
6144 ss << " StripType: " << StripType << std::endl;
6145 ss << " BrightnessScalar: " << BrightnessScalar.to<double>() << " scalar" << std::endl;
6146 ss << " LossOfSignalBehavior: " << LossOfSignalBehavior << std::endl;
6147 return ss.str();
6148 }
6149
6150 std::string Serialize() const override
6151 {
6152 std::stringstream ss;
6153 char *ref;
6154 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_LED_StripType, StripType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
6155 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Config_LED_BrightnessScalar, BrightnessScalar.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
6156 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_LED_LossOfSignalBehavior, LossOfSignalBehavior.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
6157 return ss.str();
6158 }
6159
6160 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
6161 {
6162 const char *string_c_str = to_deserialize.c_str();
6163 size_t string_length = to_deserialize.length();
6164 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_LED_StripType, string_c_str, string_length, &StripType.value);
6165 double BrightnessScalarVal = BrightnessScalar.to<double>();
6166 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Config_LED_BrightnessScalar, string_c_str, string_length, &BrightnessScalarVal);
6167 BrightnessScalar = units::dimensionless::scalar_t{BrightnessScalarVal};
6168 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_LED_LossOfSignalBehavior, string_c_str, string_length, &LossOfSignalBehavior.value);
6169 return 0;
6170 }
6171};
6172
6173
6174/**
6175 * \brief Configs related to general CANdle features.
6176 *
6177 * \details This includes configs such as disabling the 5V rail and
6178 * the behavior of VBat output.
6179 */
6181{
6182public:
6183 constexpr CANdleFeaturesConfigs() = default;
6184
6185 /**
6186 * \brief Whether the 5V rail is enabled. Disabling the 5V rail will
6187 * also turn off the onboard LEDs.
6188 *
6189 */
6191 /**
6192 * \brief The behavior of the VBat output. CANdle supports modulating
6193 * VBat output for single-color LED strips.
6194 *
6195 */
6197 /**
6198 * \brief Whether the Status LED is enabled when the CANdle is
6199 * actively being controlled.
6200 *
6201 */
6203
6204 /**
6205 * \brief Modifies this configuration's Enable5VRail parameter and returns itself for
6206 * method-chaining and easier to use config API.
6207 *
6208 * Whether the 5V rail is enabled. Disabling the 5V rail will also
6209 * turn off the onboard LEDs.
6210 *
6211 *
6212 * \param newEnable5VRail Parameter to modify
6213 * \returns Itself
6214 */
6216 {
6217 Enable5VRail = std::move(newEnable5VRail);
6218 return *this;
6219 }
6220
6221 /**
6222 * \brief Modifies this configuration's VBatOutputMode parameter and returns itself for
6223 * method-chaining and easier to use config API.
6224 *
6225 * The behavior of the VBat output. CANdle supports modulating VBat
6226 * output for single-color LED strips.
6227 *
6228 *
6229 * \param newVBatOutputMode Parameter to modify
6230 * \returns Itself
6231 */
6233 {
6234 VBatOutputMode = std::move(newVBatOutputMode);
6235 return *this;
6236 }
6237
6238 /**
6239 * \brief Modifies this configuration's StatusLedWhenActive parameter and returns itself for
6240 * method-chaining and easier to use config API.
6241 *
6242 * Whether the Status LED is enabled when the CANdle is actively being
6243 * controlled.
6244 *
6245 *
6246 * \param newStatusLedWhenActive Parameter to modify
6247 * \returns Itself
6248 */
6250 {
6251 StatusLedWhenActive = std::move(newStatusLedWhenActive);
6252 return *this;
6253 }
6254
6255
6256
6257 std::string ToString() const override
6258 {
6259 std::stringstream ss;
6260 ss << "Config Group: CANdleFeatures" << std::endl;
6261 ss << " Enable5VRail: " << Enable5VRail << std::endl;
6262 ss << " VBatOutputMode: " << VBatOutputMode << std::endl;
6263 ss << " StatusLedWhenActive: " << StatusLedWhenActive << std::endl;
6264 return ss.str();
6265 }
6266
6267 std::string Serialize() const override
6268 {
6269 std::stringstream ss;
6270 char *ref;
6271 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_CANdle_5VRail, Enable5VRail.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
6272 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_CANdle_VBatOutputMode, VBatOutputMode.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
6273 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Config_CANdle_StatusLedWhenActive, StatusLedWhenActive.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
6274 return ss.str();
6275 }
6276
6277 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
6278 {
6279 const char *string_c_str = to_deserialize.c_str();
6280 size_t string_length = to_deserialize.length();
6281 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_CANdle_5VRail, string_c_str, string_length, &Enable5VRail.value);
6282 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_CANdle_VBatOutputMode, string_c_str, string_length, &VBatOutputMode.value);
6283 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Config_CANdle_StatusLedWhenActive, string_c_str, string_length, &StatusLedWhenActive.value);
6284 return 0;
6285 }
6286};
6287
6288
6289/**
6290 * \brief Gains for the specified slot.
6291 *
6292 * \details If this slot is selected, these gains are used in closed
6293 * loop control requests.
6294 */
6296{
6297public:
6298 constexpr Slot0Configs() = default;
6299
6300 /**
6301 * \brief Proportional Gain.
6302 *
6303 * \details The units for this gain is dependent on the control mode.
6304 * Since this gain is multiplied by error in the input, the units
6305 * should be defined as units of output per unit of input error. For
6306 * example, when controlling velocity using a duty cycle closed loop,
6307 * the units for the proportional gain will be duty cycle per rps of
6308 * error, or 1/rps.
6309 *
6310 * - Minimum Value: 0
6311 * - Maximum Value: 3.4e+38
6312 * - Default Value: 0
6313 * - Units:
6314 */
6315 units::dimensionless::scalar_t kP = 0;
6316 /**
6317 * \brief Integral Gain.
6318 *
6319 * \details The units for this gain is dependent on the control mode.
6320 * Since this gain is multiplied by error in the input integrated over
6321 * time (in units of seconds), the units should be defined as units of
6322 * output per unit of integrated input error. For example, when
6323 * controlling velocity using a duty cycle closed loop, integrating
6324 * velocity over time results in rps * s = rotations. Therefore, the
6325 * units for the integral gain will be duty cycle per rotation of
6326 * accumulated error, or 1/rot.
6327 *
6328 * - Minimum Value: 0
6329 * - Maximum Value: 3.4e+38
6330 * - Default Value: 0
6331 * - Units:
6332 */
6333 units::dimensionless::scalar_t kI = 0;
6334 /**
6335 * \brief Derivative Gain.
6336 *
6337 * \details The units for this gain is dependent on the control mode.
6338 * Since this gain is multiplied by the derivative of error in the
6339 * input with respect to time (in units of seconds), the units should
6340 * be defined as units of output per unit of the differentiated input
6341 * error. For example, when controlling velocity using a duty cycle
6342 * closed loop, the derivative of velocity with respect to time is rot
6343 * per sec², which is acceleration. Therefore, the units for the
6344 * derivative gain will be duty cycle per unit of acceleration error,
6345 * or 1/(rot per sec²).
6346 *
6347 * - Minimum Value: 0
6348 * - Maximum Value: 3.4e+38
6349 * - Default Value: 0
6350 * - Units:
6351 */
6352 units::dimensionless::scalar_t kD = 0;
6353 /**
6354 * \brief Static Feedforward Gain.
6355 *
6356 * \details This is added to the closed loop output. The unit for this
6357 * constant is dependent on the control mode, typically fractional
6358 * duty cycle, voltage, or torque current.
6359 *
6360 * The sign is typically determined by reference velocity when using
6361 * position, velocity, and Motion Magic® closed loop modes. However,
6362 * when using position closed loop with zero velocity reference (no
6363 * motion profiling), the application can instead use the position
6364 * closed loop error by setting the Static Feedforward Sign
6365 * configuration parameter. When doing so, we recommend the minimal
6366 * amount of kS, otherwise the motor output may dither when closed
6367 * loop error is near zero.
6368 *
6369 * - Minimum Value: -512
6370 * - Maximum Value: 511
6371 * - Default Value: 0
6372 * - Units:
6373 */
6374 units::dimensionless::scalar_t kS = 0;
6375 /**
6376 * \brief Velocity Feedforward Gain.
6377 *
6378 * \details The units for this gain is dependent on the control mode.
6379 * Since this gain is multiplied by the requested velocity, the units
6380 * should be defined as units of output per unit of requested input
6381 * velocity. For example, when controlling velocity using a duty cycle
6382 * closed loop, the units for the velocity feedfoward gain will be
6383 * duty cycle per requested rps, or 1/rps.
6384 *
6385 * - Minimum Value: 0
6386 * - Maximum Value: 3.4e+38
6387 * - Default Value: 0
6388 * - Units:
6389 */
6390 units::dimensionless::scalar_t kV = 0;
6391 /**
6392 * \brief Acceleration Feedforward Gain.
6393 *
6394 * \details The units for this gain is dependent on the control mode.
6395 * Since this gain is multiplied by the requested acceleration, the
6396 * units should be defined as units of output per unit of requested
6397 * input acceleration. For example, when controlling velocity using a
6398 * duty cycle closed loop, the units for the acceleration feedfoward
6399 * gain will be duty cycle per requested rot per sec², or 1/(rot per
6400 * sec²).
6401 *
6402 * - Minimum Value: 0
6403 * - Maximum Value: 3.4e+38
6404 * - Default Value: 0
6405 * - Units:
6406 */
6407 units::dimensionless::scalar_t kA = 0;
6408 /**
6409 * \brief Gravity Feedforward/Feedback Gain.
6410 *
6411 * \details This is added to the closed loop output. The sign is
6412 * determined by GravityType. The unit for this constant is dependent
6413 * on the control mode, typically fractional duty cycle, voltage, or
6414 * torque current.
6415 *
6416 * - Minimum Value: -512
6417 * - Maximum Value: 511
6418 * - Default Value: 0
6419 * - Units:
6420 */
6421 units::dimensionless::scalar_t kG = 0;
6422 /**
6423 * \brief Gravity Feedforward/Feedback Type.
6424 *
6425 * This determines the type of the gravity feedforward/feedback.
6426 *
6427 * Choose Elevator_Static for systems where the gravity feedforward is
6428 * constant, such as an elevator. The gravity feedforward output will
6429 * always have the same sign.
6430 *
6431 * Choose Arm_Cosine for systems where the gravity feedback is
6432 * dependent on the angular position of the mechanism, such as an arm.
6433 * The gravity feedback output will vary depending on the mechanism
6434 * angular position. Note that the sensor offset and ratios must be
6435 * configured so that the sensor reports a position of 0 when the
6436 * mechanism is horizonal (parallel to the ground), and the reported
6437 * sensor position is 1:1 with the mechanism.
6438 *
6439 */
6441 /**
6442 * \brief Static Feedforward Sign during position closed loop.
6443 *
6444 * This determines the sign of the applied kS during position
6445 * closed-loop modes. The default behavior uses the velocity reference
6446 * sign. This works well with velocity closed loop, Motion Magic®
6447 * controls, and position closed loop when velocity reference is
6448 * specified (motion profiling).
6449 *
6450 * However, when using position closed loop with zero velocity
6451 * reference (no motion profiling), the application may want to apply
6452 * static feedforward based on the sign of closed loop error instead.
6453 * When doing so, we recommend using the minimal amount of kS,
6454 * otherwise the motor output may dither when closed loop error is
6455 * near zero.
6456 *
6457 */
6459
6460 /**
6461 * \brief Modifies this configuration's kP parameter and returns itself for
6462 * method-chaining and easier to use config API.
6463 *
6464 * Proportional Gain.
6465 *
6466 * \details The units for this gain is dependent on the control mode.
6467 * Since this gain is multiplied by error in the input, the units
6468 * should be defined as units of output per unit of input error. For
6469 * example, when controlling velocity using a duty cycle closed loop,
6470 * the units for the proportional gain will be duty cycle per rps of
6471 * error, or 1/rps.
6472 *
6473 * - Minimum Value: 0
6474 * - Maximum Value: 3.4e+38
6475 * - Default Value: 0
6476 * - Units:
6477 *
6478 * \param newKP Parameter to modify
6479 * \returns Itself
6480 */
6481 constexpr Slot0Configs &WithKP(units::dimensionless::scalar_t newKP)
6482 {
6483 kP = std::move(newKP);
6484 return *this;
6485 }
6486
6487 /**
6488 * \brief Modifies this configuration's kI parameter and returns itself for
6489 * method-chaining and easier to use config API.
6490 *
6491 * Integral Gain.
6492 *
6493 * \details The units for this gain is dependent on the control mode.
6494 * Since this gain is multiplied by error in the input integrated over
6495 * time (in units of seconds), the units should be defined as units of
6496 * output per unit of integrated input error. For example, when
6497 * controlling velocity using a duty cycle closed loop, integrating
6498 * velocity over time results in rps * s = rotations. Therefore, the
6499 * units for the integral gain will be duty cycle per rotation of
6500 * accumulated error, or 1/rot.
6501 *
6502 * - Minimum Value: 0
6503 * - Maximum Value: 3.4e+38
6504 * - Default Value: 0
6505 * - Units:
6506 *
6507 * \param newKI Parameter to modify
6508 * \returns Itself
6509 */
6510 constexpr Slot0Configs &WithKI(units::dimensionless::scalar_t newKI)
6511 {
6512 kI = std::move(newKI);
6513 return *this;
6514 }
6515
6516 /**
6517 * \brief Modifies this configuration's kD parameter and returns itself for
6518 * method-chaining and easier to use config API.
6519 *
6520 * Derivative Gain.
6521 *
6522 * \details The units for this gain is dependent on the control mode.
6523 * Since this gain is multiplied by the derivative of error in the
6524 * input with respect to time (in units of seconds), the units should
6525 * be defined as units of output per unit of the differentiated input
6526 * error. For example, when controlling velocity using a duty cycle
6527 * closed loop, the derivative of velocity with respect to time is rot
6528 * per sec², which is acceleration. Therefore, the units for the
6529 * derivative gain will be duty cycle per unit of acceleration error,
6530 * or 1/(rot per sec²).
6531 *
6532 * - Minimum Value: 0
6533 * - Maximum Value: 3.4e+38
6534 * - Default Value: 0
6535 * - Units:
6536 *
6537 * \param newKD Parameter to modify
6538 * \returns Itself
6539 */
6540 constexpr Slot0Configs &WithKD(units::dimensionless::scalar_t newKD)
6541 {
6542 kD = std::move(newKD);
6543 return *this;
6544 }
6545
6546 /**
6547 * \brief Modifies this configuration's kS parameter and returns itself for
6548 * method-chaining and easier to use config API.
6549 *
6550 * Static Feedforward Gain.
6551 *
6552 * \details This is added to the closed loop output. The unit for this
6553 * constant is dependent on the control mode, typically fractional
6554 * duty cycle, voltage, or torque current.
6555 *
6556 * The sign is typically determined by reference velocity when using
6557 * position, velocity, and Motion Magic® closed loop modes. However,
6558 * when using position closed loop with zero velocity reference (no
6559 * motion profiling), the application can instead use the position
6560 * closed loop error by setting the Static Feedforward Sign
6561 * configuration parameter. When doing so, we recommend the minimal
6562 * amount of kS, otherwise the motor output may dither when closed
6563 * loop error is near zero.
6564 *
6565 * - Minimum Value: -512
6566 * - Maximum Value: 511
6567 * - Default Value: 0
6568 * - Units:
6569 *
6570 * \param newKS Parameter to modify
6571 * \returns Itself
6572 */
6573 constexpr Slot0Configs &WithKS(units::dimensionless::scalar_t newKS)
6574 {
6575 kS = std::move(newKS);
6576 return *this;
6577 }
6578
6579 /**
6580 * \brief Modifies this configuration's kV parameter and returns itself for
6581 * method-chaining and easier to use config API.
6582 *
6583 * Velocity Feedforward Gain.
6584 *
6585 * \details The units for this gain is dependent on the control mode.
6586 * Since this gain is multiplied by the requested velocity, the units
6587 * should be defined as units of output per unit of requested input
6588 * velocity. For example, when controlling velocity using a duty cycle
6589 * closed loop, the units for the velocity feedfoward gain will be
6590 * duty cycle per requested rps, or 1/rps.
6591 *
6592 * - Minimum Value: 0
6593 * - Maximum Value: 3.4e+38
6594 * - Default Value: 0
6595 * - Units:
6596 *
6597 * \param newKV Parameter to modify
6598 * \returns Itself
6599 */
6600 constexpr Slot0Configs &WithKV(units::dimensionless::scalar_t newKV)
6601 {
6602 kV = std::move(newKV);
6603 return *this;
6604 }
6605
6606 /**
6607 * \brief Modifies this configuration's kA parameter and returns itself for
6608 * method-chaining and easier to use config API.
6609 *
6610 * Acceleration Feedforward Gain.
6611 *
6612 * \details The units for this gain is dependent on the control mode.
6613 * Since this gain is multiplied by the requested acceleration, the
6614 * units should be defined as units of output per unit of requested
6615 * input acceleration. For example, when controlling velocity using a
6616 * duty cycle closed loop, the units for the acceleration feedfoward
6617 * gain will be duty cycle per requested rot per sec², or 1/(rot per
6618 * sec²).
6619 *
6620 * - Minimum Value: 0
6621 * - Maximum Value: 3.4e+38
6622 * - Default Value: 0
6623 * - Units:
6624 *
6625 * \param newKA Parameter to modify
6626 * \returns Itself
6627 */
6628 constexpr Slot0Configs &WithKA(units::dimensionless::scalar_t newKA)
6629 {
6630 kA = std::move(newKA);
6631 return *this;
6632 }
6633
6634 /**
6635 * \brief Modifies this configuration's kG parameter and returns itself for
6636 * method-chaining and easier to use config API.
6637 *
6638 * Gravity Feedforward/Feedback Gain.
6639 *
6640 * \details This is added to the closed loop output. The sign is
6641 * determined by GravityType. The unit for this constant is dependent
6642 * on the control mode, typically fractional duty cycle, voltage, or
6643 * torque current.
6644 *
6645 * - Minimum Value: -512
6646 * - Maximum Value: 511
6647 * - Default Value: 0
6648 * - Units:
6649 *
6650 * \param newKG Parameter to modify
6651 * \returns Itself
6652 */
6653 constexpr Slot0Configs &WithKG(units::dimensionless::scalar_t newKG)
6654 {
6655 kG = std::move(newKG);
6656 return *this;
6657 }
6658
6659 /**
6660 * \brief Modifies this configuration's GravityType parameter and returns itself for
6661 * method-chaining and easier to use config API.
6662 *
6663 * Gravity Feedforward/Feedback Type.
6664 *
6665 * This determines the type of the gravity feedforward/feedback.
6666 *
6667 * Choose Elevator_Static for systems where the gravity feedforward is
6668 * constant, such as an elevator. The gravity feedforward output will
6669 * always have the same sign.
6670 *
6671 * Choose Arm_Cosine for systems where the gravity feedback is
6672 * dependent on the angular position of the mechanism, such as an arm.
6673 * The gravity feedback output will vary depending on the mechanism
6674 * angular position. Note that the sensor offset and ratios must be
6675 * configured so that the sensor reports a position of 0 when the
6676 * mechanism is horizonal (parallel to the ground), and the reported
6677 * sensor position is 1:1 with the mechanism.
6678 *
6679 *
6680 * \param newGravityType Parameter to modify
6681 * \returns Itself
6682 */
6684 {
6685 GravityType = std::move(newGravityType);
6686 return *this;
6687 }
6688
6689 /**
6690 * \brief Modifies this configuration's StaticFeedforwardSign parameter and returns itself for
6691 * method-chaining and easier to use config API.
6692 *
6693 * Static Feedforward Sign during position closed loop.
6694 *
6695 * This determines the sign of the applied kS during position
6696 * closed-loop modes. The default behavior uses the velocity reference
6697 * sign. This works well with velocity closed loop, Motion Magic®
6698 * controls, and position closed loop when velocity reference is
6699 * specified (motion profiling).
6700 *
6701 * However, when using position closed loop with zero velocity
6702 * reference (no motion profiling), the application may want to apply
6703 * static feedforward based on the sign of closed loop error instead.
6704 * When doing so, we recommend using the minimal amount of kS,
6705 * otherwise the motor output may dither when closed loop error is
6706 * near zero.
6707 *
6708 *
6709 * \param newStaticFeedforwardSign Parameter to modify
6710 * \returns Itself
6711 */
6713 {
6714 StaticFeedforwardSign = std::move(newStaticFeedforwardSign);
6715 return *this;
6716 }
6717
6718 static Slot0Configs From(const SlotConfigs &value);
6719
6720 std::string ToString() const override
6721 {
6722 std::stringstream ss;
6723 ss << "Config Group: Slot0" << std::endl;
6724 ss << " kP: " << kP.to<double>() << std::endl;
6725 ss << " kI: " << kI.to<double>() << std::endl;
6726 ss << " kD: " << kD.to<double>() << std::endl;
6727 ss << " kS: " << kS.to<double>() << std::endl;
6728 ss << " kV: " << kV.to<double>() << std::endl;
6729 ss << " kA: " << kA.to<double>() << std::endl;
6730 ss << " kG: " << kG.to<double>() << std::endl;
6731 ss << " GravityType: " << GravityType << std::endl;
6732 ss << " StaticFeedforwardSign: " << StaticFeedforwardSign << std::endl;
6733 return ss.str();
6734 }
6735
6736 std::string Serialize() const override
6737 {
6738 std::stringstream ss;
6739 char *ref;
6740 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kP, kP.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
6741 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kI, kI.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
6742 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kD, kD.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
6743 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kS, kS.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
6744 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kV, kV.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
6745 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kA, kA.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
6746 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kG, kG.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
6747 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot0_kG_Type, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
6748 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot0_kS_Sign, StaticFeedforwardSign.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
6749 return ss.str();
6750 }
6751
6752 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
6753 {
6754 const char *string_c_str = to_deserialize.c_str();
6755 size_t string_length = to_deserialize.length();
6756 double kPVal = kP.to<double>();
6757 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kP, string_c_str, string_length, &kPVal);
6758 kP = units::dimensionless::scalar_t{kPVal};
6759 double kIVal = kI.to<double>();
6760 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kI, string_c_str, string_length, &kIVal);
6761 kI = units::dimensionless::scalar_t{kIVal};
6762 double kDVal = kD.to<double>();
6763 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kD, string_c_str, string_length, &kDVal);
6764 kD = units::dimensionless::scalar_t{kDVal};
6765 double kSVal = kS.to<double>();
6766 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kS, string_c_str, string_length, &kSVal);
6767 kS = units::dimensionless::scalar_t{kSVal};
6768 double kVVal = kV.to<double>();
6769 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kV, string_c_str, string_length, &kVVal);
6770 kV = units::dimensionless::scalar_t{kVVal};
6771 double kAVal = kA.to<double>();
6772 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kA, string_c_str, string_length, &kAVal);
6773 kA = units::dimensionless::scalar_t{kAVal};
6774 double kGVal = kG.to<double>();
6775 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot0_kG, string_c_str, string_length, &kGVal);
6776 kG = units::dimensionless::scalar_t{kGVal};
6777 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot0_kG_Type, string_c_str, string_length, &GravityType.value);
6778 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot0_kS_Sign, string_c_str, string_length, &StaticFeedforwardSign.value);
6779 return 0;
6780 }
6781};
6782
6783
6784/**
6785 * \brief Gains for the specified slot.
6786 *
6787 * \details If this slot is selected, these gains are used in closed
6788 * loop control requests.
6789 */
6791{
6792public:
6793 constexpr Slot1Configs() = default;
6794
6795 /**
6796 * \brief Proportional Gain.
6797 *
6798 * \details The units for this gain is dependent on the control mode.
6799 * Since this gain is multiplied by error in the input, the units
6800 * should be defined as units of output per unit of input error. For
6801 * example, when controlling velocity using a duty cycle closed loop,
6802 * the units for the proportional gain will be duty cycle per rps, or
6803 * 1/rps.
6804 *
6805 * - Minimum Value: 0
6806 * - Maximum Value: 3.4e+38
6807 * - Default Value: 0
6808 * - Units:
6809 */
6810 units::dimensionless::scalar_t kP = 0;
6811 /**
6812 * \brief Integral Gain.
6813 *
6814 * \details The units for this gain is dependent on the control mode.
6815 * Since this gain is multiplied by error in the input integrated over
6816 * time (in units of seconds), the units should be defined as units of
6817 * output per unit of integrated input error. For example, when
6818 * controlling velocity using a duty cycle closed loop, integrating
6819 * velocity over time results in rps * s = rotations. Therefore, the
6820 * units for the integral gain will be duty cycle per rotation of
6821 * accumulated error, or 1/rot.
6822 *
6823 * - Minimum Value: 0
6824 * - Maximum Value: 3.4e+38
6825 * - Default Value: 0
6826 * - Units:
6827 */
6828 units::dimensionless::scalar_t kI = 0;
6829 /**
6830 * \brief Derivative Gain.
6831 *
6832 * \details The units for this gain is dependent on the control mode.
6833 * Since this gain is multiplied by the derivative of error in the
6834 * input with respect to time (in units of seconds), the units should
6835 * be defined as units of output per unit of the differentiated input
6836 * error. For example, when controlling velocity using a duty cycle
6837 * closed loop, the derivative of velocity with respect to time is rot
6838 * per sec², which is acceleration. Therefore, the units for the
6839 * derivative gain will be duty cycle per unit of acceleration error,
6840 * or 1/(rot per sec²).
6841 *
6842 * - Minimum Value: 0
6843 * - Maximum Value: 3.4e+38
6844 * - Default Value: 0
6845 * - Units:
6846 */
6847 units::dimensionless::scalar_t kD = 0;
6848 /**
6849 * \brief Static Feedforward Gain.
6850 *
6851 * \details This is added to the closed loop output. The unit for this
6852 * constant is dependent on the control mode, typically fractional
6853 * duty cycle, voltage, or torque current.
6854 *
6855 * The sign is typically determined by reference velocity when using
6856 * position, velocity, and Motion Magic® closed loop modes. However,
6857 * when using position closed loop with zero velocity reference (no
6858 * motion profiling), the application can instead use the position
6859 * closed loop error by setting the Static Feedforward Sign
6860 * configuration parameter. When doing so, we recommend the minimal
6861 * amount of kS, otherwise the motor output may dither when closed
6862 * loop error is near zero.
6863 *
6864 * - Minimum Value: -512
6865 * - Maximum Value: 511
6866 * - Default Value: 0
6867 * - Units:
6868 */
6869 units::dimensionless::scalar_t kS = 0;
6870 /**
6871 * \brief Velocity Feedforward Gain.
6872 *
6873 * \details The units for this gain is dependent on the control mode.
6874 * Since this gain is multiplied by the requested velocity, the units
6875 * should be defined as units of output per unit of requested input
6876 * velocity. For example, when controlling velocity using a duty cycle
6877 * closed loop, the units for the velocity feedfoward gain will be
6878 * duty cycle per requested rps, or 1/rps.
6879 *
6880 * - Minimum Value: 0
6881 * - Maximum Value: 3.4e+38
6882 * - Default Value: 0
6883 * - Units:
6884 */
6885 units::dimensionless::scalar_t kV = 0;
6886 /**
6887 * \brief Acceleration Feedforward Gain.
6888 *
6889 * \details The units for this gain is dependent on the control mode.
6890 * Since this gain is multiplied by the requested acceleration, the
6891 * units should be defined as units of output per unit of requested
6892 * input acceleration. For example, when controlling velocity using a
6893 * duty cycle closed loop, the units for the acceleration feedfoward
6894 * gain will be duty cycle per requested rot per sec², or 1/(rot per
6895 * sec²).
6896 *
6897 * - Minimum Value: 0
6898 * - Maximum Value: 3.4e+38
6899 * - Default Value: 0
6900 * - Units:
6901 */
6902 units::dimensionless::scalar_t kA = 0;
6903 /**
6904 * \brief Gravity Feedforward/Feedback Gain.
6905 *
6906 * \details This is added to the closed loop output. The sign is
6907 * determined by GravityType. The unit for this constant is dependent
6908 * on the control mode, typically fractional duty cycle, voltage, or
6909 * torque current.
6910 *
6911 * - Minimum Value: -512
6912 * - Maximum Value: 511
6913 * - Default Value: 0
6914 * - Units:
6915 */
6916 units::dimensionless::scalar_t kG = 0;
6917 /**
6918 * \brief Gravity Feedforward/Feedback Type.
6919 *
6920 * This determines the type of the gravity feedforward/feedback.
6921 *
6922 * Choose Elevator_Static for systems where the gravity feedforward is
6923 * constant, such as an elevator. The gravity feedforward output will
6924 * always be positive.
6925 *
6926 * Choose Arm_Cosine for systems where the gravity feedback is
6927 * dependent on the angular position of the mechanism, such as an arm.
6928 * The gravity feedback output will vary depending on the mechanism
6929 * angular position. Note that the sensor offset and ratios must be
6930 * configured so that the sensor position is 0 when the mechanism is
6931 * horizonal, and one rotation of the mechanism corresponds to one
6932 * rotation of the sensor position.
6933 *
6934 */
6936 /**
6937 * \brief Static Feedforward Sign during position closed loop.
6938 *
6939 * This determines the sign of the applied kS during position
6940 * closed-loop modes. The default behavior uses the velocity reference
6941 * sign. This works well with velocity closed loop, Motion Magic®
6942 * controls, and position closed loop when velocity reference is
6943 * specified (motion profiling).
6944 *
6945 * However, when using position closed loop with zero velocity
6946 * reference (no motion profiling), the application may want to apply
6947 * static feedforward based on the closed loop error sign instead.
6948 * When doing so, we recommend using the minimal amount of kS,
6949 * otherwise the motor output may dither when closed loop error is
6950 * near zero.
6951 *
6952 */
6954
6955 /**
6956 * \brief Modifies this configuration's kP parameter and returns itself for
6957 * method-chaining and easier to use config API.
6958 *
6959 * Proportional Gain.
6960 *
6961 * \details The units for this gain is dependent on the control mode.
6962 * Since this gain is multiplied by error in the input, the units
6963 * should be defined as units of output per unit of input error. For
6964 * example, when controlling velocity using a duty cycle closed loop,
6965 * the units for the proportional gain will be duty cycle per rps, or
6966 * 1/rps.
6967 *
6968 * - Minimum Value: 0
6969 * - Maximum Value: 3.4e+38
6970 * - Default Value: 0
6971 * - Units:
6972 *
6973 * \param newKP Parameter to modify
6974 * \returns Itself
6975 */
6976 constexpr Slot1Configs &WithKP(units::dimensionless::scalar_t newKP)
6977 {
6978 kP = std::move(newKP);
6979 return *this;
6980 }
6981
6982 /**
6983 * \brief Modifies this configuration's kI parameter and returns itself for
6984 * method-chaining and easier to use config API.
6985 *
6986 * Integral Gain.
6987 *
6988 * \details The units for this gain is dependent on the control mode.
6989 * Since this gain is multiplied by error in the input integrated over
6990 * time (in units of seconds), the units should be defined as units of
6991 * output per unit of integrated input error. For example, when
6992 * controlling velocity using a duty cycle closed loop, integrating
6993 * velocity over time results in rps * s = rotations. Therefore, the
6994 * units for the integral gain will be duty cycle per rotation of
6995 * accumulated error, or 1/rot.
6996 *
6997 * - Minimum Value: 0
6998 * - Maximum Value: 3.4e+38
6999 * - Default Value: 0
7000 * - Units:
7001 *
7002 * \param newKI Parameter to modify
7003 * \returns Itself
7004 */
7005 constexpr Slot1Configs &WithKI(units::dimensionless::scalar_t newKI)
7006 {
7007 kI = std::move(newKI);
7008 return *this;
7009 }
7010
7011 /**
7012 * \brief Modifies this configuration's kD parameter and returns itself for
7013 * method-chaining and easier to use config API.
7014 *
7015 * Derivative Gain.
7016 *
7017 * \details The units for this gain is dependent on the control mode.
7018 * Since this gain is multiplied by the derivative of error in the
7019 * input with respect to time (in units of seconds), the units should
7020 * be defined as units of output per unit of the differentiated input
7021 * error. For example, when controlling velocity using a duty cycle
7022 * closed loop, the derivative of velocity with respect to time is rot
7023 * per sec², which is acceleration. Therefore, the units for the
7024 * derivative gain will be duty cycle per unit of acceleration error,
7025 * or 1/(rot per sec²).
7026 *
7027 * - Minimum Value: 0
7028 * - Maximum Value: 3.4e+38
7029 * - Default Value: 0
7030 * - Units:
7031 *
7032 * \param newKD Parameter to modify
7033 * \returns Itself
7034 */
7035 constexpr Slot1Configs &WithKD(units::dimensionless::scalar_t newKD)
7036 {
7037 kD = std::move(newKD);
7038 return *this;
7039 }
7040
7041 /**
7042 * \brief Modifies this configuration's kS parameter and returns itself for
7043 * method-chaining and easier to use config API.
7044 *
7045 * Static Feedforward Gain.
7046 *
7047 * \details This is added to the closed loop output. The unit for this
7048 * constant is dependent on the control mode, typically fractional
7049 * duty cycle, voltage, or torque current.
7050 *
7051 * The sign is typically determined by reference velocity when using
7052 * position, velocity, and Motion Magic® closed loop modes. However,
7053 * when using position closed loop with zero velocity reference (no
7054 * motion profiling), the application can instead use the position
7055 * closed loop error by setting the Static Feedforward Sign
7056 * configuration parameter. When doing so, we recommend the minimal
7057 * amount of kS, otherwise the motor output may dither when closed
7058 * loop error is near zero.
7059 *
7060 * - Minimum Value: -512
7061 * - Maximum Value: 511
7062 * - Default Value: 0
7063 * - Units:
7064 *
7065 * \param newKS Parameter to modify
7066 * \returns Itself
7067 */
7068 constexpr Slot1Configs &WithKS(units::dimensionless::scalar_t newKS)
7069 {
7070 kS = std::move(newKS);
7071 return *this;
7072 }
7073
7074 /**
7075 * \brief Modifies this configuration's kV parameter and returns itself for
7076 * method-chaining and easier to use config API.
7077 *
7078 * Velocity Feedforward Gain.
7079 *
7080 * \details The units for this gain is dependent on the control mode.
7081 * Since this gain is multiplied by the requested velocity, the units
7082 * should be defined as units of output per unit of requested input
7083 * velocity. For example, when controlling velocity using a duty cycle
7084 * closed loop, the units for the velocity feedfoward gain will be
7085 * duty cycle per requested rps, or 1/rps.
7086 *
7087 * - Minimum Value: 0
7088 * - Maximum Value: 3.4e+38
7089 * - Default Value: 0
7090 * - Units:
7091 *
7092 * \param newKV Parameter to modify
7093 * \returns Itself
7094 */
7095 constexpr Slot1Configs &WithKV(units::dimensionless::scalar_t newKV)
7096 {
7097 kV = std::move(newKV);
7098 return *this;
7099 }
7100
7101 /**
7102 * \brief Modifies this configuration's kA parameter and returns itself for
7103 * method-chaining and easier to use config API.
7104 *
7105 * Acceleration Feedforward Gain.
7106 *
7107 * \details The units for this gain is dependent on the control mode.
7108 * Since this gain is multiplied by the requested acceleration, the
7109 * units should be defined as units of output per unit of requested
7110 * input acceleration. For example, when controlling velocity using a
7111 * duty cycle closed loop, the units for the acceleration feedfoward
7112 * gain will be duty cycle per requested rot per sec², or 1/(rot per
7113 * sec²).
7114 *
7115 * - Minimum Value: 0
7116 * - Maximum Value: 3.4e+38
7117 * - Default Value: 0
7118 * - Units:
7119 *
7120 * \param newKA Parameter to modify
7121 * \returns Itself
7122 */
7123 constexpr Slot1Configs &WithKA(units::dimensionless::scalar_t newKA)
7124 {
7125 kA = std::move(newKA);
7126 return *this;
7127 }
7128
7129 /**
7130 * \brief Modifies this configuration's kG parameter and returns itself for
7131 * method-chaining and easier to use config API.
7132 *
7133 * Gravity Feedforward/Feedback Gain.
7134 *
7135 * \details This is added to the closed loop output. The sign is
7136 * determined by GravityType. The unit for this constant is dependent
7137 * on the control mode, typically fractional duty cycle, voltage, or
7138 * torque current.
7139 *
7140 * - Minimum Value: -512
7141 * - Maximum Value: 511
7142 * - Default Value: 0
7143 * - Units:
7144 *
7145 * \param newKG Parameter to modify
7146 * \returns Itself
7147 */
7148 constexpr Slot1Configs &WithKG(units::dimensionless::scalar_t newKG)
7149 {
7150 kG = std::move(newKG);
7151 return *this;
7152 }
7153
7154 /**
7155 * \brief Modifies this configuration's GravityType parameter and returns itself for
7156 * method-chaining and easier to use config API.
7157 *
7158 * Gravity Feedforward/Feedback Type.
7159 *
7160 * This determines the type of the gravity feedforward/feedback.
7161 *
7162 * Choose Elevator_Static for systems where the gravity feedforward is
7163 * constant, such as an elevator. The gravity feedforward output will
7164 * always be positive.
7165 *
7166 * Choose Arm_Cosine for systems where the gravity feedback is
7167 * dependent on the angular position of the mechanism, such as an arm.
7168 * The gravity feedback output will vary depending on the mechanism
7169 * angular position. Note that the sensor offset and ratios must be
7170 * configured so that the sensor position is 0 when the mechanism is
7171 * horizonal, and one rotation of the mechanism corresponds to one
7172 * rotation of the sensor position.
7173 *
7174 *
7175 * \param newGravityType Parameter to modify
7176 * \returns Itself
7177 */
7179 {
7180 GravityType = std::move(newGravityType);
7181 return *this;
7182 }
7183
7184 /**
7185 * \brief Modifies this configuration's StaticFeedforwardSign parameter and returns itself for
7186 * method-chaining and easier to use config API.
7187 *
7188 * Static Feedforward Sign during position closed loop.
7189 *
7190 * This determines the sign of the applied kS during position
7191 * closed-loop modes. The default behavior uses the velocity reference
7192 * sign. This works well with velocity closed loop, Motion Magic®
7193 * controls, and position closed loop when velocity reference is
7194 * specified (motion profiling).
7195 *
7196 * However, when using position closed loop with zero velocity
7197 * reference (no motion profiling), the application may want to apply
7198 * static feedforward based on the closed loop error sign instead.
7199 * When doing so, we recommend using the minimal amount of kS,
7200 * otherwise the motor output may dither when closed loop error is
7201 * near zero.
7202 *
7203 *
7204 * \param newStaticFeedforwardSign Parameter to modify
7205 * \returns Itself
7206 */
7208 {
7209 StaticFeedforwardSign = std::move(newStaticFeedforwardSign);
7210 return *this;
7211 }
7212
7213 static Slot1Configs From(const SlotConfigs &value);
7214
7215 std::string ToString() const override
7216 {
7217 std::stringstream ss;
7218 ss << "Config Group: Slot1" << std::endl;
7219 ss << " kP: " << kP.to<double>() << std::endl;
7220 ss << " kI: " << kI.to<double>() << std::endl;
7221 ss << " kD: " << kD.to<double>() << std::endl;
7222 ss << " kS: " << kS.to<double>() << std::endl;
7223 ss << " kV: " << kV.to<double>() << std::endl;
7224 ss << " kA: " << kA.to<double>() << std::endl;
7225 ss << " kG: " << kG.to<double>() << std::endl;
7226 ss << " GravityType: " << GravityType << std::endl;
7227 ss << " StaticFeedforwardSign: " << StaticFeedforwardSign << std::endl;
7228 return ss.str();
7229 }
7230
7231 std::string Serialize() const override
7232 {
7233 std::stringstream ss;
7234 char *ref;
7235 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kP, kP.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7236 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kI, kI.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7237 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kD, kD.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7238 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kS, kS.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7239 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kV, kV.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7240 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kA, kA.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7241 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kG, kG.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7242 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot1_kG_Type, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
7243 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot1_kS_Sign, StaticFeedforwardSign.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
7244 return ss.str();
7245 }
7246
7247 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
7248 {
7249 const char *string_c_str = to_deserialize.c_str();
7250 size_t string_length = to_deserialize.length();
7251 double kPVal = kP.to<double>();
7252 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kP, string_c_str, string_length, &kPVal);
7253 kP = units::dimensionless::scalar_t{kPVal};
7254 double kIVal = kI.to<double>();
7255 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kI, string_c_str, string_length, &kIVal);
7256 kI = units::dimensionless::scalar_t{kIVal};
7257 double kDVal = kD.to<double>();
7258 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kD, string_c_str, string_length, &kDVal);
7259 kD = units::dimensionless::scalar_t{kDVal};
7260 double kSVal = kS.to<double>();
7261 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kS, string_c_str, string_length, &kSVal);
7262 kS = units::dimensionless::scalar_t{kSVal};
7263 double kVVal = kV.to<double>();
7264 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kV, string_c_str, string_length, &kVVal);
7265 kV = units::dimensionless::scalar_t{kVVal};
7266 double kAVal = kA.to<double>();
7267 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kA, string_c_str, string_length, &kAVal);
7268 kA = units::dimensionless::scalar_t{kAVal};
7269 double kGVal = kG.to<double>();
7270 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot1_kG, string_c_str, string_length, &kGVal);
7271 kG = units::dimensionless::scalar_t{kGVal};
7272 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot1_kG_Type, string_c_str, string_length, &GravityType.value);
7273 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot1_kS_Sign, string_c_str, string_length, &StaticFeedforwardSign.value);
7274 return 0;
7275 }
7276};
7277
7278
7279/**
7280 * \brief Gains for the specified slot.
7281 *
7282 * \details If this slot is selected, these gains are used in closed
7283 * loop control requests.
7284 */
7286{
7287public:
7288 constexpr Slot2Configs() = default;
7289
7290 /**
7291 * \brief Proportional Gain.
7292 *
7293 * \details The units for this gain is dependent on the control mode.
7294 * Since this gain is multiplied by error in the input, the units
7295 * should be defined as units of output per unit of input error. For
7296 * example, when controlling velocity using a duty cycle closed loop,
7297 * the units for the proportional gain will be duty cycle per rps, or
7298 * 1/rps.
7299 *
7300 * - Minimum Value: 0
7301 * - Maximum Value: 3.4e+38
7302 * - Default Value: 0
7303 * - Units:
7304 */
7305 units::dimensionless::scalar_t kP = 0;
7306 /**
7307 * \brief Integral Gain.
7308 *
7309 * \details The units for this gain is dependent on the control mode.
7310 * Since this gain is multiplied by error in the input integrated over
7311 * time (in units of seconds), the units should be defined as units of
7312 * output per unit of integrated input error. For example, when
7313 * controlling velocity using a duty cycle closed loop, integrating
7314 * velocity over time results in rps * s = rotations. Therefore, the
7315 * units for the integral gain will be duty cycle per rotation of
7316 * accumulated error, or 1/rot.
7317 *
7318 * - Minimum Value: 0
7319 * - Maximum Value: 3.4e+38
7320 * - Default Value: 0
7321 * - Units:
7322 */
7323 units::dimensionless::scalar_t kI = 0;
7324 /**
7325 * \brief Derivative Gain.
7326 *
7327 * \details The units for this gain is dependent on the control mode.
7328 * Since this gain is multiplied by the derivative of error in the
7329 * input with respect to time (in units of seconds), the units should
7330 * be defined as units of output per unit of the differentiated input
7331 * error. For example, when controlling velocity using a duty cycle
7332 * closed loop, the derivative of velocity with respect to time is rot
7333 * per sec², which is acceleration. Therefore, the units for the
7334 * derivative gain will be duty cycle per unit of acceleration error,
7335 * or 1/(rot per sec²).
7336 *
7337 * - Minimum Value: 0
7338 * - Maximum Value: 3.4e+38
7339 * - Default Value: 0
7340 * - Units:
7341 */
7342 units::dimensionless::scalar_t kD = 0;
7343 /**
7344 * \brief Static Feedforward Gain.
7345 *
7346 * \details This is added to the closed loop output. The unit for this
7347 * constant is dependent on the control mode, typically fractional
7348 * duty cycle, voltage, or torque current.
7349 *
7350 * The sign is typically determined by reference velocity when using
7351 * position, velocity, and Motion Magic® closed loop modes. However,
7352 * when using position closed loop with zero velocity reference (no
7353 * motion profiling), the application can instead use the position
7354 * closed loop error by setting the Static Feedforward Sign
7355 * configuration parameter. When doing so, we recommend the minimal
7356 * amount of kS, otherwise the motor output may dither when closed
7357 * loop error is near zero.
7358 *
7359 * - Minimum Value: -512
7360 * - Maximum Value: 511
7361 * - Default Value: 0
7362 * - Units:
7363 */
7364 units::dimensionless::scalar_t kS = 0;
7365 /**
7366 * \brief Velocity Feedforward Gain.
7367 *
7368 * \details The units for this gain is dependent on the control mode.
7369 * Since this gain is multiplied by the requested velocity, the units
7370 * should be defined as units of output per unit of requested input
7371 * velocity. For example, when controlling velocity using a duty cycle
7372 * closed loop, the units for the velocity feedfoward gain will be
7373 * duty cycle per requested rps, or 1/rps.
7374 *
7375 * - Minimum Value: 0
7376 * - Maximum Value: 3.4e+38
7377 * - Default Value: 0
7378 * - Units:
7379 */
7380 units::dimensionless::scalar_t kV = 0;
7381 /**
7382 * \brief Acceleration Feedforward Gain.
7383 *
7384 * \details The units for this gain is dependent on the control mode.
7385 * Since this gain is multiplied by the requested acceleration, the
7386 * units should be defined as units of output per unit of requested
7387 * input acceleration. For example, when controlling velocity using a
7388 * duty cycle closed loop, the units for the acceleration feedfoward
7389 * gain will be duty cycle per requested rot per sec², or 1/(rot per
7390 * sec²).
7391 *
7392 * - Minimum Value: 0
7393 * - Maximum Value: 3.4e+38
7394 * - Default Value: 0
7395 * - Units:
7396 */
7397 units::dimensionless::scalar_t kA = 0;
7398 /**
7399 * \brief Gravity Feedforward/Feedback Gain.
7400 *
7401 * \details This is added to the closed loop output. The sign is
7402 * determined by GravityType. The unit for this constant is dependent
7403 * on the control mode, typically fractional duty cycle, voltage, or
7404 * torque current.
7405 *
7406 * - Minimum Value: -512
7407 * - Maximum Value: 511
7408 * - Default Value: 0
7409 * - Units:
7410 */
7411 units::dimensionless::scalar_t kG = 0;
7412 /**
7413 * \brief Gravity Feedforward/Feedback Type.
7414 *
7415 * This determines the type of the gravity feedforward/feedback.
7416 *
7417 * Choose Elevator_Static for systems where the gravity feedforward is
7418 * constant, such as an elevator. The gravity feedforward output will
7419 * always be positive.
7420 *
7421 * Choose Arm_Cosine for systems where the gravity feedback is
7422 * dependent on the angular position of the mechanism, such as an arm.
7423 * The gravity feedback output will vary depending on the mechanism
7424 * angular position. Note that the sensor offset and ratios must be
7425 * configured so that the sensor position is 0 when the mechanism is
7426 * horizonal, and one rotation of the mechanism corresponds to one
7427 * rotation of the sensor position.
7428 *
7429 */
7431 /**
7432 * \brief Static Feedforward Sign during position closed loop.
7433 *
7434 * This determines the sign of the applied kS during position
7435 * closed-loop modes. The default behavior uses the velocity reference
7436 * sign. This works well with velocity closed loop, Motion Magic®
7437 * controls, and position closed loop when velocity reference is
7438 * specified (motion profiling).
7439 *
7440 * However, when using position closed loop with zero velocity
7441 * reference (no motion profiling), the application may want to apply
7442 * static feedforward based on the closed loop error sign instead.
7443 * When doing so, we recommend using the minimal amount of kS,
7444 * otherwise the motor output may dither when closed loop error is
7445 * near zero.
7446 *
7447 */
7449
7450 /**
7451 * \brief Modifies this configuration's kP parameter and returns itself for
7452 * method-chaining and easier to use config API.
7453 *
7454 * Proportional Gain.
7455 *
7456 * \details The units for this gain is dependent on the control mode.
7457 * Since this gain is multiplied by error in the input, the units
7458 * should be defined as units of output per unit of input error. For
7459 * example, when controlling velocity using a duty cycle closed loop,
7460 * the units for the proportional gain will be duty cycle per rps, or
7461 * 1/rps.
7462 *
7463 * - Minimum Value: 0
7464 * - Maximum Value: 3.4e+38
7465 * - Default Value: 0
7466 * - Units:
7467 *
7468 * \param newKP Parameter to modify
7469 * \returns Itself
7470 */
7471 constexpr Slot2Configs &WithKP(units::dimensionless::scalar_t newKP)
7472 {
7473 kP = std::move(newKP);
7474 return *this;
7475 }
7476
7477 /**
7478 * \brief Modifies this configuration's kI parameter and returns itself for
7479 * method-chaining and easier to use config API.
7480 *
7481 * Integral Gain.
7482 *
7483 * \details The units for this gain is dependent on the control mode.
7484 * Since this gain is multiplied by error in the input integrated over
7485 * time (in units of seconds), the units should be defined as units of
7486 * output per unit of integrated input error. For example, when
7487 * controlling velocity using a duty cycle closed loop, integrating
7488 * velocity over time results in rps * s = rotations. Therefore, the
7489 * units for the integral gain will be duty cycle per rotation of
7490 * accumulated error, or 1/rot.
7491 *
7492 * - Minimum Value: 0
7493 * - Maximum Value: 3.4e+38
7494 * - Default Value: 0
7495 * - Units:
7496 *
7497 * \param newKI Parameter to modify
7498 * \returns Itself
7499 */
7500 constexpr Slot2Configs &WithKI(units::dimensionless::scalar_t newKI)
7501 {
7502 kI = std::move(newKI);
7503 return *this;
7504 }
7505
7506 /**
7507 * \brief Modifies this configuration's kD parameter and returns itself for
7508 * method-chaining and easier to use config API.
7509 *
7510 * Derivative Gain.
7511 *
7512 * \details The units for this gain is dependent on the control mode.
7513 * Since this gain is multiplied by the derivative of error in the
7514 * input with respect to time (in units of seconds), the units should
7515 * be defined as units of output per unit of the differentiated input
7516 * error. For example, when controlling velocity using a duty cycle
7517 * closed loop, the derivative of velocity with respect to time is rot
7518 * per sec², which is acceleration. Therefore, the units for the
7519 * derivative gain will be duty cycle per unit of acceleration error,
7520 * or 1/(rot per sec²).
7521 *
7522 * - Minimum Value: 0
7523 * - Maximum Value: 3.4e+38
7524 * - Default Value: 0
7525 * - Units:
7526 *
7527 * \param newKD Parameter to modify
7528 * \returns Itself
7529 */
7530 constexpr Slot2Configs &WithKD(units::dimensionless::scalar_t newKD)
7531 {
7532 kD = std::move(newKD);
7533 return *this;
7534 }
7535
7536 /**
7537 * \brief Modifies this configuration's kS parameter and returns itself for
7538 * method-chaining and easier to use config API.
7539 *
7540 * Static Feedforward Gain.
7541 *
7542 * \details This is added to the closed loop output. The unit for this
7543 * constant is dependent on the control mode, typically fractional
7544 * duty cycle, voltage, or torque current.
7545 *
7546 * The sign is typically determined by reference velocity when using
7547 * position, velocity, and Motion Magic® closed loop modes. However,
7548 * when using position closed loop with zero velocity reference (no
7549 * motion profiling), the application can instead use the position
7550 * closed loop error by setting the Static Feedforward Sign
7551 * configuration parameter. When doing so, we recommend the minimal
7552 * amount of kS, otherwise the motor output may dither when closed
7553 * loop error is near zero.
7554 *
7555 * - Minimum Value: -512
7556 * - Maximum Value: 511
7557 * - Default Value: 0
7558 * - Units:
7559 *
7560 * \param newKS Parameter to modify
7561 * \returns Itself
7562 */
7563 constexpr Slot2Configs &WithKS(units::dimensionless::scalar_t newKS)
7564 {
7565 kS = std::move(newKS);
7566 return *this;
7567 }
7568
7569 /**
7570 * \brief Modifies this configuration's kV parameter and returns itself for
7571 * method-chaining and easier to use config API.
7572 *
7573 * Velocity Feedforward Gain.
7574 *
7575 * \details The units for this gain is dependent on the control mode.
7576 * Since this gain is multiplied by the requested velocity, the units
7577 * should be defined as units of output per unit of requested input
7578 * velocity. For example, when controlling velocity using a duty cycle
7579 * closed loop, the units for the velocity feedfoward gain will be
7580 * duty cycle per requested rps, or 1/rps.
7581 *
7582 * - Minimum Value: 0
7583 * - Maximum Value: 3.4e+38
7584 * - Default Value: 0
7585 * - Units:
7586 *
7587 * \param newKV Parameter to modify
7588 * \returns Itself
7589 */
7590 constexpr Slot2Configs &WithKV(units::dimensionless::scalar_t newKV)
7591 {
7592 kV = std::move(newKV);
7593 return *this;
7594 }
7595
7596 /**
7597 * \brief Modifies this configuration's kA parameter and returns itself for
7598 * method-chaining and easier to use config API.
7599 *
7600 * Acceleration Feedforward Gain.
7601 *
7602 * \details The units for this gain is dependent on the control mode.
7603 * Since this gain is multiplied by the requested acceleration, the
7604 * units should be defined as units of output per unit of requested
7605 * input acceleration. For example, when controlling velocity using a
7606 * duty cycle closed loop, the units for the acceleration feedfoward
7607 * gain will be duty cycle per requested rot per sec², or 1/(rot per
7608 * sec²).
7609 *
7610 * - Minimum Value: 0
7611 * - Maximum Value: 3.4e+38
7612 * - Default Value: 0
7613 * - Units:
7614 *
7615 * \param newKA Parameter to modify
7616 * \returns Itself
7617 */
7618 constexpr Slot2Configs &WithKA(units::dimensionless::scalar_t newKA)
7619 {
7620 kA = std::move(newKA);
7621 return *this;
7622 }
7623
7624 /**
7625 * \brief Modifies this configuration's kG parameter and returns itself for
7626 * method-chaining and easier to use config API.
7627 *
7628 * Gravity Feedforward/Feedback Gain.
7629 *
7630 * \details This is added to the closed loop output. The sign is
7631 * determined by GravityType. The unit for this constant is dependent
7632 * on the control mode, typically fractional duty cycle, voltage, or
7633 * torque current.
7634 *
7635 * - Minimum Value: -512
7636 * - Maximum Value: 511
7637 * - Default Value: 0
7638 * - Units:
7639 *
7640 * \param newKG Parameter to modify
7641 * \returns Itself
7642 */
7643 constexpr Slot2Configs &WithKG(units::dimensionless::scalar_t newKG)
7644 {
7645 kG = std::move(newKG);
7646 return *this;
7647 }
7648
7649 /**
7650 * \brief Modifies this configuration's GravityType parameter and returns itself for
7651 * method-chaining and easier to use config API.
7652 *
7653 * Gravity Feedforward/Feedback Type.
7654 *
7655 * This determines the type of the gravity feedforward/feedback.
7656 *
7657 * Choose Elevator_Static for systems where the gravity feedforward is
7658 * constant, such as an elevator. The gravity feedforward output will
7659 * always be positive.
7660 *
7661 * Choose Arm_Cosine for systems where the gravity feedback is
7662 * dependent on the angular position of the mechanism, such as an arm.
7663 * The gravity feedback output will vary depending on the mechanism
7664 * angular position. Note that the sensor offset and ratios must be
7665 * configured so that the sensor position is 0 when the mechanism is
7666 * horizonal, and one rotation of the mechanism corresponds to one
7667 * rotation of the sensor position.
7668 *
7669 *
7670 * \param newGravityType Parameter to modify
7671 * \returns Itself
7672 */
7674 {
7675 GravityType = std::move(newGravityType);
7676 return *this;
7677 }
7678
7679 /**
7680 * \brief Modifies this configuration's StaticFeedforwardSign parameter and returns itself for
7681 * method-chaining and easier to use config API.
7682 *
7683 * Static Feedforward Sign during position closed loop.
7684 *
7685 * This determines the sign of the applied kS during position
7686 * closed-loop modes. The default behavior uses the velocity reference
7687 * sign. This works well with velocity closed loop, Motion Magic®
7688 * controls, and position closed loop when velocity reference is
7689 * specified (motion profiling).
7690 *
7691 * However, when using position closed loop with zero velocity
7692 * reference (no motion profiling), the application may want to apply
7693 * static feedforward based on the closed loop error sign instead.
7694 * When doing so, we recommend using the minimal amount of kS,
7695 * otherwise the motor output may dither when closed loop error is
7696 * near zero.
7697 *
7698 *
7699 * \param newStaticFeedforwardSign Parameter to modify
7700 * \returns Itself
7701 */
7703 {
7704 StaticFeedforwardSign = std::move(newStaticFeedforwardSign);
7705 return *this;
7706 }
7707
7708 static Slot2Configs From(const SlotConfigs &value);
7709
7710 std::string ToString() const override
7711 {
7712 std::stringstream ss;
7713 ss << "Config Group: Slot2" << std::endl;
7714 ss << " kP: " << kP.to<double>() << std::endl;
7715 ss << " kI: " << kI.to<double>() << std::endl;
7716 ss << " kD: " << kD.to<double>() << std::endl;
7717 ss << " kS: " << kS.to<double>() << std::endl;
7718 ss << " kV: " << kV.to<double>() << std::endl;
7719 ss << " kA: " << kA.to<double>() << std::endl;
7720 ss << " kG: " << kG.to<double>() << std::endl;
7721 ss << " GravityType: " << GravityType << std::endl;
7722 ss << " StaticFeedforwardSign: " << StaticFeedforwardSign << std::endl;
7723 return ss.str();
7724 }
7725
7726 std::string Serialize() const override
7727 {
7728 std::stringstream ss;
7729 char *ref;
7730 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kP, kP.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7731 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kI, kI.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7732 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kD, kD.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7733 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kS, kS.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7734 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kV, kV.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7735 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kA, kA.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7736 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kG, kG.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
7737 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot2_kG_Type, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
7738 c_ctre_phoenix6_serialize_int(ctre::phoenix6::spns::SpnValue::Slot2_kS_Sign, StaticFeedforwardSign.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
7739 return ss.str();
7740 }
7741
7742 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
7743 {
7744 const char *string_c_str = to_deserialize.c_str();
7745 size_t string_length = to_deserialize.length();
7746 double kPVal = kP.to<double>();
7747 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kP, string_c_str, string_length, &kPVal);
7748 kP = units::dimensionless::scalar_t{kPVal};
7749 double kIVal = kI.to<double>();
7750 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kI, string_c_str, string_length, &kIVal);
7751 kI = units::dimensionless::scalar_t{kIVal};
7752 double kDVal = kD.to<double>();
7753 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kD, string_c_str, string_length, &kDVal);
7754 kD = units::dimensionless::scalar_t{kDVal};
7755 double kSVal = kS.to<double>();
7756 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kS, string_c_str, string_length, &kSVal);
7757 kS = units::dimensionless::scalar_t{kSVal};
7758 double kVVal = kV.to<double>();
7759 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kV, string_c_str, string_length, &kVVal);
7760 kV = units::dimensionless::scalar_t{kVVal};
7761 double kAVal = kA.to<double>();
7762 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kA, string_c_str, string_length, &kAVal);
7763 kA = units::dimensionless::scalar_t{kAVal};
7764 double kGVal = kG.to<double>();
7765 c_ctre_phoenix6_deserialize_double(ctre::phoenix6::spns::SpnValue::Slot2_kG, string_c_str, string_length, &kGVal);
7766 kG = units::dimensionless::scalar_t{kGVal};
7767 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot2_kG_Type, string_c_str, string_length, &GravityType.value);
7768 c_ctre_phoenix6_deserialize_int(ctre::phoenix6::spns::SpnValue::Slot2_kS_Sign, string_c_str, string_length, &StaticFeedforwardSign.value);
7769 return 0;
7770 }
7771};
7772
7773/**
7774 * \brief Gains for the specified slot.
7775 *
7776 * \details If this slot is selected, these gains are used in closed
7777 * loop control requests.
7778 */
7780{
7781 struct SlotSpns
7782 {
7783 int kPSpn;
7784 int kISpn;
7785 int kDSpn;
7786 int kSSpn;
7787 int kVSpn;
7788 int kASpn;
7789 int kGSpn;
7790 int GravityTypeSpn;
7791 int StaticFeedforwardSignSpn;
7792 };
7793
7794 static inline std::map<int, SlotSpns> const genericMap{
7795 {0, SlotSpns{
7796 ctre::phoenix6::spns::SpnValue::Slot0_kP,
7797 ctre::phoenix6::spns::SpnValue::Slot0_kI,
7798 ctre::phoenix6::spns::SpnValue::Slot0_kD,
7799 ctre::phoenix6::spns::SpnValue::Slot0_kS,
7800 ctre::phoenix6::spns::SpnValue::Slot0_kV,
7801 ctre::phoenix6::spns::SpnValue::Slot0_kA,
7802 ctre::phoenix6::spns::SpnValue::Slot0_kG,
7803 ctre::phoenix6::spns::SpnValue::Slot0_kG_Type,
7804 ctre::phoenix6::spns::SpnValue::Slot0_kS_Sign,
7805 }},
7806
7807 {1, SlotSpns{
7808 ctre::phoenix6::spns::SpnValue::Slot1_kP,
7809 ctre::phoenix6::spns::SpnValue::Slot1_kI,
7810 ctre::phoenix6::spns::SpnValue::Slot1_kD,
7811 ctre::phoenix6::spns::SpnValue::Slot1_kS,
7812 ctre::phoenix6::spns::SpnValue::Slot1_kV,
7813 ctre::phoenix6::spns::SpnValue::Slot1_kA,
7814 ctre::phoenix6::spns::SpnValue::Slot1_kG,
7815 ctre::phoenix6::spns::SpnValue::Slot1_kG_Type,
7816 ctre::phoenix6::spns::SpnValue::Slot1_kS_Sign,
7817 }},
7818
7819 {2, SlotSpns{
7820 ctre::phoenix6::spns::SpnValue::Slot2_kP,
7821 ctre::phoenix6::spns::SpnValue::Slot2_kI,
7822 ctre::phoenix6::spns::SpnValue::Slot2_kD,
7823 ctre::phoenix6::spns::SpnValue::Slot2_kS,
7824 ctre::phoenix6::spns::SpnValue::Slot2_kV,
7825 ctre::phoenix6::spns::SpnValue::Slot2_kA,
7826 ctre::phoenix6::spns::SpnValue::Slot2_kG,
7827 ctre::phoenix6::spns::SpnValue::Slot2_kG_Type,
7828 ctre::phoenix6::spns::SpnValue::Slot2_kS_Sign,
7829 }},
7830
7831 };
7832
7833public:
7834 constexpr SlotConfigs() = default;
7835
7836 /**
7837 * \brief Proportional Gain.
7838 *
7839 * \details The units for this gain is dependent on the control mode.
7840 * Since this gain is multiplied by error in the input, the units
7841 * should be defined as units of output per unit of input error. For
7842 * example, when controlling velocity using a duty cycle closed loop,
7843 * the units for the proportional gain will be duty cycle per rps of
7844 * error, or 1/rps.
7845 *
7846 * - Minimum Value: 0
7847 * - Maximum Value: 3.4e+38
7848 * - Default Value: 0
7849 * - Units:
7850 */
7851 units::dimensionless::scalar_t kP = 0;
7852 /**
7853 * \brief Integral Gain.
7854 *
7855 * \details The units for this gain is dependent on the control mode.
7856 * Since this gain is multiplied by error in the input integrated over
7857 * time (in units of seconds), the units should be defined as units of
7858 * output per unit of integrated input error. For example, when
7859 * controlling velocity using a duty cycle closed loop, integrating
7860 * velocity over time results in rps * s = rotations. Therefore, the
7861 * units for the integral gain will be duty cycle per rotation of
7862 * accumulated error, or 1/rot.
7863 *
7864 * - Minimum Value: 0
7865 * - Maximum Value: 3.4e+38
7866 * - Default Value: 0
7867 * - Units:
7868 */
7869 units::dimensionless::scalar_t kI = 0;
7870 /**
7871 * \brief Derivative Gain.
7872 *
7873 * \details The units for this gain is dependent on the control mode.
7874 * Since this gain is multiplied by the derivative of error in the
7875 * input with respect to time (in units of seconds), the units should
7876 * be defined as units of output per unit of the differentiated input
7877 * error. For example, when controlling velocity using a duty cycle
7878 * closed loop, the derivative of velocity with respect to time is rot
7879 * per sec², which is acceleration. Therefore, the units for the
7880 * derivative gain will be duty cycle per unit of acceleration error,
7881 * or 1/(rot per sec²).
7882 *
7883 * - Minimum Value: 0
7884 * - Maximum Value: 3.4e+38
7885 * - Default Value: 0
7886 * - Units:
7887 */
7888 units::dimensionless::scalar_t kD = 0;
7889 /**
7890 * \brief Static Feedforward Gain.
7891 *
7892 * \details This is added to the closed loop output. The unit for this
7893 * constant is dependent on the control mode, typically fractional
7894 * duty cycle, voltage, or torque current.
7895 *
7896 * The sign is typically determined by reference velocity when using
7897 * position, velocity, and Motion Magic® closed loop modes. However,
7898 * when using position closed loop with zero velocity reference (no
7899 * motion profiling), the application can instead use the position
7900 * closed loop error by setting the Static Feedforward Sign
7901 * configuration parameter. When doing so, we recommend the minimal
7902 * amount of kS, otherwise the motor output may dither when closed
7903 * loop error is near zero.
7904 *
7905 * - Minimum Value: -512
7906 * - Maximum Value: 511
7907 * - Default Value: 0
7908 * - Units:
7909 */
7910 units::dimensionless::scalar_t kS = 0;
7911 /**
7912 * \brief Velocity Feedforward Gain.
7913 *
7914 * \details The units for this gain is dependent on the control mode.
7915 * Since this gain is multiplied by the requested velocity, the units
7916 * should be defined as units of output per unit of requested input
7917 * velocity. For example, when controlling velocity using a duty cycle
7918 * closed loop, the units for the velocity feedfoward gain will be
7919 * duty cycle per requested rps, or 1/rps.
7920 *
7921 * - Minimum Value: 0
7922 * - Maximum Value: 3.4e+38
7923 * - Default Value: 0
7924 * - Units:
7925 */
7926 units::dimensionless::scalar_t kV = 0;
7927 /**
7928 * \brief Acceleration Feedforward Gain.
7929 *
7930 * \details The units for this gain is dependent on the control mode.
7931 * Since this gain is multiplied by the requested acceleration, the
7932 * units should be defined as units of output per unit of requested
7933 * input acceleration. For example, when controlling velocity using a
7934 * duty cycle closed loop, the units for the acceleration feedfoward
7935 * gain will be duty cycle per requested rot per sec², or 1/(rot per
7936 * sec²).
7937 *
7938 * - Minimum Value: 0
7939 * - Maximum Value: 3.4e+38
7940 * - Default Value: 0
7941 * - Units:
7942 */
7943 units::dimensionless::scalar_t kA = 0;
7944 /**
7945 * \brief Gravity Feedforward/Feedback Gain.
7946 *
7947 * \details This is added to the closed loop output. The sign is
7948 * determined by GravityType. The unit for this constant is dependent
7949 * on the control mode, typically fractional duty cycle, voltage, or
7950 * torque current.
7951 *
7952 * - Minimum Value: -512
7953 * - Maximum Value: 511
7954 * - Default Value: 0
7955 * - Units:
7956 */
7957 units::dimensionless::scalar_t kG = 0;
7958 /**
7959 * \brief Gravity Feedforward/Feedback Type.
7960 *
7961 * This determines the type of the gravity feedforward/feedback.
7962 *
7963 * Choose Elevator_Static for systems where the gravity feedforward is
7964 * constant, such as an elevator. The gravity feedforward output will
7965 * always have the same sign.
7966 *
7967 * Choose Arm_Cosine for systems where the gravity feedback is
7968 * dependent on the angular position of the mechanism, such as an arm.
7969 * The gravity feedback output will vary depending on the mechanism
7970 * angular position. Note that the sensor offset and ratios must be
7971 * configured so that the sensor reports a position of 0 when the
7972 * mechanism is horizonal (parallel to the ground), and the reported
7973 * sensor position is 1:1 with the mechanism.
7974 *
7975 */
7977 /**
7978 * \brief Static Feedforward Sign during position closed loop.
7979 *
7980 * This determines the sign of the applied kS during position
7981 * closed-loop modes. The default behavior uses the velocity reference
7982 * sign. This works well with velocity closed loop, Motion Magic®
7983 * controls, and position closed loop when velocity reference is
7984 * specified (motion profiling).
7985 *
7986 * However, when using position closed loop with zero velocity
7987 * reference (no motion profiling), the application may want to apply
7988 * static feedforward based on the sign of closed loop error instead.
7989 * When doing so, we recommend using the minimal amount of kS,
7990 * otherwise the motor output may dither when closed loop error is
7991 * near zero.
7992 *
7993 */
7995
7996 /**
7997 * \brief Modifies this configuration's kP parameter and returns itself for
7998 * method-chaining and easier to use config API.
7999 *
8000 * Proportional Gain.
8001 *
8002 * \details The units for this gain is dependent on the control mode.
8003 * Since this gain is multiplied by error in the input, the units
8004 * should be defined as units of output per unit of input error. For
8005 * example, when controlling velocity using a duty cycle closed loop,
8006 * the units for the proportional gain will be duty cycle per rps of
8007 * error, or 1/rps.
8008 *
8009 * - Minimum Value: 0
8010 * - Maximum Value: 3.4e+38
8011 * - Default Value: 0
8012 * - Units:
8013 *
8014 * \param newKP Parameter to modify
8015 * \returns Itself
8016 */
8017 constexpr SlotConfigs &WithKP(units::dimensionless::scalar_t newKP)
8018 {
8019 kP = std::move(newKP);
8020 return *this;
8021 }
8022
8023 /**
8024 * \brief Modifies this configuration's kI parameter and returns itself for
8025 * method-chaining and easier to use config API.
8026 *
8027 * Integral Gain.
8028 *
8029 * \details The units for this gain is dependent on the control mode.
8030 * Since this gain is multiplied by error in the input integrated over
8031 * time (in units of seconds), the units should be defined as units of
8032 * output per unit of integrated input error. For example, when
8033 * controlling velocity using a duty cycle closed loop, integrating
8034 * velocity over time results in rps * s = rotations. Therefore, the
8035 * units for the integral gain will be duty cycle per rotation of
8036 * accumulated error, or 1/rot.
8037 *
8038 * - Minimum Value: 0
8039 * - Maximum Value: 3.4e+38
8040 * - Default Value: 0
8041 * - Units:
8042 *
8043 * \param newKI Parameter to modify
8044 * \returns Itself
8045 */
8046 constexpr SlotConfigs &WithKI(units::dimensionless::scalar_t newKI)
8047 {
8048 kI = std::move(newKI);
8049 return *this;
8050 }
8051
8052 /**
8053 * \brief Modifies this configuration's kD parameter and returns itself for
8054 * method-chaining and easier to use config API.
8055 *
8056 * Derivative Gain.
8057 *
8058 * \details The units for this gain is dependent on the control mode.
8059 * Since this gain is multiplied by the derivative of error in the
8060 * input with respect to time (in units of seconds), the units should
8061 * be defined as units of output per unit of the differentiated input
8062 * error. For example, when controlling velocity using a duty cycle
8063 * closed loop, the derivative of velocity with respect to time is rot
8064 * per sec², which is acceleration. Therefore, the units for the
8065 * derivative gain will be duty cycle per unit of acceleration error,
8066 * or 1/(rot per sec²).
8067 *
8068 * - Minimum Value: 0
8069 * - Maximum Value: 3.4e+38
8070 * - Default Value: 0
8071 * - Units:
8072 *
8073 * \param newKD Parameter to modify
8074 * \returns Itself
8075 */
8076 constexpr SlotConfigs &WithKD(units::dimensionless::scalar_t newKD)
8077 {
8078 kD = std::move(newKD);
8079 return *this;
8080 }
8081
8082 /**
8083 * \brief Modifies this configuration's kS parameter and returns itself for
8084 * method-chaining and easier to use config API.
8085 *
8086 * Static Feedforward Gain.
8087 *
8088 * \details This is added to the closed loop output. The unit for this
8089 * constant is dependent on the control mode, typically fractional
8090 * duty cycle, voltage, or torque current.
8091 *
8092 * The sign is typically determined by reference velocity when using
8093 * position, velocity, and Motion Magic® closed loop modes. However,
8094 * when using position closed loop with zero velocity reference (no
8095 * motion profiling), the application can instead use the position
8096 * closed loop error by setting the Static Feedforward Sign
8097 * configuration parameter. When doing so, we recommend the minimal
8098 * amount of kS, otherwise the motor output may dither when closed
8099 * loop error is near zero.
8100 *
8101 * - Minimum Value: -512
8102 * - Maximum Value: 511
8103 * - Default Value: 0
8104 * - Units:
8105 *
8106 * \param newKS Parameter to modify
8107 * \returns Itself
8108 */
8109 constexpr SlotConfigs &WithKS(units::dimensionless::scalar_t newKS)
8110 {
8111 kS = std::move(newKS);
8112 return *this;
8113 }
8114
8115 /**
8116 * \brief Modifies this configuration's kV parameter and returns itself for
8117 * method-chaining and easier to use config API.
8118 *
8119 * Velocity Feedforward Gain.
8120 *
8121 * \details The units for this gain is dependent on the control mode.
8122 * Since this gain is multiplied by the requested velocity, the units
8123 * should be defined as units of output per unit of requested input
8124 * velocity. For example, when controlling velocity using a duty cycle
8125 * closed loop, the units for the velocity feedfoward gain will be
8126 * duty cycle per requested rps, or 1/rps.
8127 *
8128 * - Minimum Value: 0
8129 * - Maximum Value: 3.4e+38
8130 * - Default Value: 0
8131 * - Units:
8132 *
8133 * \param newKV Parameter to modify
8134 * \returns Itself
8135 */
8136 constexpr SlotConfigs &WithKV(units::dimensionless::scalar_t newKV)
8137 {
8138 kV = std::move(newKV);
8139 return *this;
8140 }
8141
8142 /**
8143 * \brief Modifies this configuration's kA parameter and returns itself for
8144 * method-chaining and easier to use config API.
8145 *
8146 * Acceleration Feedforward Gain.
8147 *
8148 * \details The units for this gain is dependent on the control mode.
8149 * Since this gain is multiplied by the requested acceleration, the
8150 * units should be defined as units of output per unit of requested
8151 * input acceleration. For example, when controlling velocity using a
8152 * duty cycle closed loop, the units for the acceleration feedfoward
8153 * gain will be duty cycle per requested rot per sec², or 1/(rot per
8154 * sec²).
8155 *
8156 * - Minimum Value: 0
8157 * - Maximum Value: 3.4e+38
8158 * - Default Value: 0
8159 * - Units:
8160 *
8161 * \param newKA Parameter to modify
8162 * \returns Itself
8163 */
8164 constexpr SlotConfigs &WithKA(units::dimensionless::scalar_t newKA)
8165 {
8166 kA = std::move(newKA);
8167 return *this;
8168 }
8169
8170 /**
8171 * \brief Modifies this configuration's kG parameter and returns itself for
8172 * method-chaining and easier to use config API.
8173 *
8174 * Gravity Feedforward/Feedback Gain.
8175 *
8176 * \details This is added to the closed loop output. The sign is
8177 * determined by GravityType. The unit for this constant is dependent
8178 * on the control mode, typically fractional duty cycle, voltage, or
8179 * torque current.
8180 *
8181 * - Minimum Value: -512
8182 * - Maximum Value: 511
8183 * - Default Value: 0
8184 * - Units:
8185 *
8186 * \param newKG Parameter to modify
8187 * \returns Itself
8188 */
8189 constexpr SlotConfigs &WithKG(units::dimensionless::scalar_t newKG)
8190 {
8191 kG = std::move(newKG);
8192 return *this;
8193 }
8194
8195 /**
8196 * \brief Modifies this configuration's GravityType parameter and returns itself for
8197 * method-chaining and easier to use config API.
8198 *
8199 * Gravity Feedforward/Feedback Type.
8200 *
8201 * This determines the type of the gravity feedforward/feedback.
8202 *
8203 * Choose Elevator_Static for systems where the gravity feedforward is
8204 * constant, such as an elevator. The gravity feedforward output will
8205 * always have the same sign.
8206 *
8207 * Choose Arm_Cosine for systems where the gravity feedback is
8208 * dependent on the angular position of the mechanism, such as an arm.
8209 * The gravity feedback output will vary depending on the mechanism
8210 * angular position. Note that the sensor offset and ratios must be
8211 * configured so that the sensor reports a position of 0 when the
8212 * mechanism is horizonal (parallel to the ground), and the reported
8213 * sensor position is 1:1 with the mechanism.
8214 *
8215 *
8216 * \param newGravityType Parameter to modify
8217 * \returns Itself
8218 */
8220 {
8221 GravityType = std::move(newGravityType);
8222 return *this;
8223 }
8224
8225 /**
8226 * \brief Modifies this configuration's StaticFeedforwardSign parameter and returns itself for
8227 * method-chaining and easier to use config API.
8228 *
8229 * Static Feedforward Sign during position closed loop.
8230 *
8231 * This determines the sign of the applied kS during position
8232 * closed-loop modes. The default behavior uses the velocity reference
8233 * sign. This works well with velocity closed loop, Motion Magic®
8234 * controls, and position closed loop when velocity reference is
8235 * specified (motion profiling).
8236 *
8237 * However, when using position closed loop with zero velocity
8238 * reference (no motion profiling), the application may want to apply
8239 * static feedforward based on the sign of closed loop error instead.
8240 * When doing so, we recommend using the minimal amount of kS,
8241 * otherwise the motor output may dither when closed loop error is
8242 * near zero.
8243 *
8244 *
8245 * \param newStaticFeedforwardSign Parameter to modify
8246 * \returns Itself
8247 */
8249 {
8250 StaticFeedforwardSign = std::move(newStaticFeedforwardSign);
8251 return *this;
8252 }
8253
8254
8255 /**
8256 * \brief Chooses which slot these configs are for.
8257 */
8258 int SlotNumber = 0;
8259
8260 static SlotConfigs From(const Slot0Configs &value);
8261 static SlotConfigs From(const Slot1Configs &value);
8262 static SlotConfigs From(const Slot2Configs &value);
8263
8264 std::string ToString() const
8265 {
8266 std::stringstream ss;
8267 ss << "Config Group: Slot" << std::endl;
8268 ss << " kP: " << kP.to<double>() << std::endl;
8269 ss << " kI: " << kI.to<double>() << std::endl;
8270 ss << " kD: " << kD.to<double>() << std::endl;
8271 ss << " kS: " << kS.to<double>() << std::endl;
8272 ss << " kV: " << kV.to<double>() << std::endl;
8273 ss << " kA: " << kA.to<double>() << std::endl;
8274 ss << " kG: " << kG.to<double>() << std::endl;
8275 ss << " GravityType: " << GravityType << std::endl;
8276 ss << " StaticFeedforwardSign: " << StaticFeedforwardSign << std::endl;
8277 return ss.str();
8278 }
8279
8280 std::string Serialize() const
8281 {
8282 std::stringstream ss;
8283 SlotSpns currentSpns = genericMap.at(SlotNumber);
8284 char *ref;
8285 c_ctre_phoenix6_serialize_double(currentSpns.kPSpn, kP.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
8286 c_ctre_phoenix6_serialize_double(currentSpns.kISpn, kI.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
8287 c_ctre_phoenix6_serialize_double(currentSpns.kDSpn, kD.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
8288 c_ctre_phoenix6_serialize_double(currentSpns.kSSpn, kS.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
8289 c_ctre_phoenix6_serialize_double(currentSpns.kVSpn, kV.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
8290 c_ctre_phoenix6_serialize_double(currentSpns.kASpn, kA.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
8291 c_ctre_phoenix6_serialize_double(currentSpns.kGSpn, kG.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
8292 c_ctre_phoenix6_serialize_int(currentSpns.GravityTypeSpn, GravityType.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
8293 c_ctre_phoenix6_serialize_int(currentSpns.StaticFeedforwardSignSpn, StaticFeedforwardSign.value, &ref); if (ref != nullptr) { ss << ref; free(ref); }
8294 return ss.str();
8295 }
8296
8297 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize)
8298 {
8299 const char *string_c_str = to_deserialize.c_str();
8300 size_t string_length = to_deserialize.length();
8301 SlotSpns currentSpns = genericMap.at(SlotNumber);
8302 double kPVal = kP.to<double>();
8303 c_ctre_phoenix6_deserialize_double(currentSpns.kPSpn, string_c_str, string_length, &kPVal);
8304 kP = units::dimensionless::scalar_t{kPVal};
8305 double kIVal = kI.to<double>();
8306 c_ctre_phoenix6_deserialize_double(currentSpns.kISpn, string_c_str, string_length, &kIVal);
8307 kI = units::dimensionless::scalar_t{kIVal};
8308 double kDVal = kD.to<double>();
8309 c_ctre_phoenix6_deserialize_double(currentSpns.kDSpn, string_c_str, string_length, &kDVal);
8310 kD = units::dimensionless::scalar_t{kDVal};
8311 double kSVal = kS.to<double>();
8312 c_ctre_phoenix6_deserialize_double(currentSpns.kSSpn, string_c_str, string_length, &kSVal);
8313 kS = units::dimensionless::scalar_t{kSVal};
8314 double kVVal = kV.to<double>();
8315 c_ctre_phoenix6_deserialize_double(currentSpns.kVSpn, string_c_str, string_length, &kVVal);
8316 kV = units::dimensionless::scalar_t{kVVal};
8317 double kAVal = kA.to<double>();
8318 c_ctre_phoenix6_deserialize_double(currentSpns.kASpn, string_c_str, string_length, &kAVal);
8319 kA = units::dimensionless::scalar_t{kAVal};
8320 double kGVal = kG.to<double>();
8321 c_ctre_phoenix6_deserialize_double(currentSpns.kGSpn, string_c_str, string_length, &kGVal);
8322 kG = units::dimensionless::scalar_t{kGVal};
8323 c_ctre_phoenix6_deserialize_int(currentSpns.GravityTypeSpn, string_c_str, string_length, &GravityType.value);
8324 c_ctre_phoenix6_deserialize_int(currentSpns.StaticFeedforwardSignSpn, string_c_str, string_length, &StaticFeedforwardSign.value);
8325 return 0;
8326 }
8327};
8328
8329
8330}
8331}
8332}
ii that the Software will be uninterrupted or error free
Definition CTRE_LICENSE.txt:251
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:4021
bool BeepOnConfig
If true, the TalonFX will beep during configuration API calls if device is disabled.
Definition Configs.hpp:4042
bool AllowMusicDurDisable
If true, the TalonFX will allow Orchestra and MusicTone requests during disabled state.
Definition Configs.hpp:4052
std::string Serialize() const override
Definition Configs.hpp:4126
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:4136
std::string ToString() const override
Definition Configs.hpp:4116
constexpr AudioConfigs & WithBeepOnBoot(bool newBeepOnBoot)
Modifies this configuration's BeepOnBoot parameter and returns itself for method-chaining and easier ...
Definition Configs.hpp:4067
constexpr AudioConfigs & WithAllowMusicDurDisable(bool newAllowMusicDurDisable)
Modifies this configuration's AllowMusicDurDisable parameter and returns itself for method-chaining a...
Definition Configs.hpp:4108
constexpr AudioConfigs & WithBeepOnConfig(bool newBeepOnConfig)
Modifies this configuration's BeepOnConfig parameter and returns itself for method-chaining and easie...
Definition Configs.hpp:4087
bool BeepOnBoot
If true, the TalonFX will beep during boot-up.
Definition Configs.hpp:4033
Configs related to general CANdle features.
Definition Configs.hpp:6181
constexpr CANdleFeaturesConfigs & WithVBatOutputMode(signals::VBatOutputModeValue newVBatOutputMode)
Modifies this configuration's VBatOutputMode parameter and returns itself for method-chaining and eas...
Definition Configs.hpp:6232
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:6277
std::string Serialize() const override
Definition Configs.hpp:6267
std::string ToString() const override
Definition Configs.hpp:6257
signals::Enable5VRailValue Enable5VRail
Whether the 5V rail is enabled.
Definition Configs.hpp:6190
signals::VBatOutputModeValue VBatOutputMode
The behavior of the VBat output.
Definition Configs.hpp:6196
constexpr CANdleFeaturesConfigs & WithStatusLedWhenActive(signals::StatusLedWhenActiveValue newStatusLedWhenActive)
Modifies this configuration's StatusLedWhenActive parameter and returns itself for method-chaining an...
Definition Configs.hpp:6249
signals::StatusLedWhenActiveValue StatusLedWhenActive
Whether the Status LED is enabled when the CANdle is actively being controlled.
Definition Configs.hpp:6202
constexpr CANdleFeaturesConfigs & WithEnable5VRail(signals::Enable5VRailValue newEnable5VRail)
Modifies this configuration's Enable5VRail parameter and returns itself for method-chaining and easie...
Definition Configs.hpp:6215
Configs that affect general behavior during closed-looping.
Definition Configs.hpp:4680
bool ContinuousWrap
Wrap position error within [-0.5,+0.5) mechanism rotations.
Definition Configs.hpp:4696
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:4740
constexpr ClosedLoopGeneralConfigs & WithContinuousWrap(bool newContinuousWrap)
Modifies this configuration's ContinuousWrap parameter and returns itself for method-chaining and eas...
Definition Configs.hpp:4716
std::string ToString() const override
Definition Configs.hpp:4724
std::string Serialize() const override
Definition Configs.hpp:4732
Configs that affect the closed-loop control of this motor controller.
Definition Configs.hpp:3252
constexpr ClosedLoopRampsConfigs & WithDutyCycleClosedLoopRampPeriod(units::time::second_t newDutyCycleClosedLoopRampPeriod)
Modifies this configuration's DutyCycleClosedLoopRampPeriod parameter and returns itself for method-c...
Definition Configs.hpp:3333
std::string Serialize() const override
Definition Configs.hpp:3410
units::time::second_t DutyCycleClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0% output to 100% during the closed-loop Duty...
Definition Configs.hpp:3272
constexpr ClosedLoopRampsConfigs & WithTorqueClosedLoopRampPeriod(units::time::second_t newTorqueClosedLoopRampPeriod)
Modifies this configuration's TorqueClosedLoopRampPeriod parameter and returns itself for method-chai...
Definition Configs.hpp:3392
constexpr ClosedLoopRampsConfigs & WithVoltageClosedLoopRampPeriod(units::time::second_t newVoltageClosedLoopRampPeriod)
Modifies this configuration's VoltageClosedLoopRampPeriod parameter and returns itself for method-cha...
Definition Configs.hpp:3361
units::time::second_t TorqueClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0A output to 300A during the closed-loop Torq...
Definition Configs.hpp:3309
units::time::second_t VoltageClosedLoopRampPeriod
If non-zero, this determines how much time to ramp from 0V output to 12V during the closed-loop Volta...
Definition Configs.hpp:3289
std::string ToString() const override
Definition Configs.hpp:3400
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:3420
Configs that determine motor selection and commutation.
Definition Configs.hpp:5238
std::string ToString() const override
Definition Configs.hpp:5332
constexpr CommutationConfigs & WithAdvancedHallSupport(signals::AdvancedHallSupportValue newAdvancedHallSupport)
Modifies this configuration's AdvancedHallSupport parameter and returns itself for method-chaining an...
Definition Configs.hpp:5284
signals::BrushedMotorWiringValue BrushedMotorWiring
If a brushed motor is selected with Motor Arrangement, this config determines which of three leads to...
Definition Configs.hpp:5268
signals::AdvancedHallSupportValue AdvancedHallSupport
Requires Phoenix Pro; Improves commutation and velocity measurement for motors with hall sensors.
Definition Configs.hpp:5250
std::string Serialize() const override
Definition Configs.hpp:5342
signals::MotorArrangementValue MotorArrangement
Selects the motor and motor connections used with Talon.
Definition Configs.hpp:5262
constexpr CommutationConfigs & WithBrushedMotorWiring(signals::BrushedMotorWiringValue newBrushedMotorWiring)
Modifies this configuration's BrushedMotorWiring parameter and returns itself for method-chaining and...
Definition Configs.hpp:5324
constexpr CommutationConfigs & WithMotorArrangement(signals::MotorArrangementValue newMotorArrangement)
Modifies this configuration's MotorArrangement parameter and returns itself for method-chaining and e...
Definition Configs.hpp:5307
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:5352
Configs that directly affect current limiting features.
Definition Configs.hpp:902
bool StatorCurrentLimitEnable
Enable motor stator current limiting.
Definition Configs.hpp:938
std::string Serialize() const override
Definition Configs.hpp:1163
constexpr CurrentLimitsConfigs & WithSupplyCurrentLimitEnable(bool newSupplyCurrentLimitEnable)
Modifies this configuration's SupplyCurrentLimitEnable parameter and returns itself for method-chaini...
Definition Configs.hpp:1095
constexpr CurrentLimitsConfigs & WithSupplyCurrentLimit(units::current::ampere_t newSupplyCurrentLimit)
Modifies this configuration's SupplyCurrentLimit parameter and returns itself for method-chaining and...
Definition Configs.hpp:1078
units::current::ampere_t SupplyCurrentLimit
The absolute maximum amount of supply current allowed.
Definition Configs.hpp:962
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:1176
units::current::ampere_t StatorCurrentLimit
The amount of current allowed in the motor (motoring and regen current).
Definition Configs.hpp:932
constexpr CurrentLimitsConfigs & WithSupplyCurrentLowerTime(units::time::second_t newSupplyCurrentLowerTime)
Modifies this configuration's SupplyCurrentLowerTime parameter and returns itself for method-chaining...
Definition Configs.hpp:1142
constexpr CurrentLimitsConfigs & WithSupplyCurrentLowerLimit(units::current::ampere_t newSupplyCurrentLowerLimit)
Modifies this configuration's SupplyCurrentLowerLimit parameter and returns itself for method-chainin...
Definition Configs.hpp:1120
constexpr CurrentLimitsConfigs & WithStatorCurrentLimit(units::current::ampere_t newStatorCurrentLimit)
Modifies this configuration's StatorCurrentLimit parameter and returns itself for method-chaining and...
Definition Configs.hpp:1026
units::current::ampere_t SupplyCurrentLowerLimit
The amount of supply current allowed after the regular SupplyCurrentLimit is active for longer than S...
Definition Configs.hpp:982
std::string ToString() const override
Definition Configs.hpp:1150
bool SupplyCurrentLimitEnable
Enable motor supply current limiting.
Definition Configs.hpp:968
constexpr CurrentLimitsConfigs & WithStatorCurrentLimitEnable(bool newStatorCurrentLimitEnable)
Modifies this configuration's StatorCurrentLimitEnable parameter and returns itself for method-chaini...
Definition Configs.hpp:1043
units::time::second_t SupplyCurrentLowerTime
Reduces supply current to the SupplyCurrentLowerLimit after limiting to SupplyCurrentLimit for this p...
Definition Configs.hpp:993
Custom Params.
Definition Configs.hpp:4576
std::string ToString() const override
Definition Configs.hpp:4645
int CustomParam0
Custom parameter 0.
Definition Configs.hpp:4589
std::string Serialize() const override
Definition Configs.hpp:4654
int CustomParam1
Custom parameter 1.
Definition Configs.hpp:4599
constexpr CustomParamsConfigs & WithCustomParam0(int newCustomParam0)
Modifies this configuration's CustomParam0 parameter and returns itself for method-chaining and easie...
Definition Configs.hpp:4616
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:4663
constexpr CustomParamsConfigs & WithCustomParam1(int newCustomParam1)
Modifies this configuration's CustomParam1 parameter and returns itself for method-chaining and easie...
Definition Configs.hpp:4637
Configs related to constants used for differential control of a mechanism.
Definition Configs.hpp:2940
units::current::ampere_t PeakDifferentialTorqueCurrent
Maximum differential output during torque current based differential control modes.
Definition Configs.hpp:2973
std::string Serialize() const override
Definition Configs.hpp:3050
std::string ToString() const override
Definition Configs.hpp:3040
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:3060
constexpr DifferentialConstantsConfigs & WithPeakDifferentialVoltage(units::voltage::volt_t newPeakDifferentialVoltage)
Modifies this configuration's PeakDifferentialVoltage parameter and returns itself for method-chainin...
Definition Configs.hpp:3011
units::dimensionless::scalar_t PeakDifferentialDutyCycle
Maximum differential output during duty cycle based differential control modes.
Definition Configs.hpp:2953
constexpr DifferentialConstantsConfigs & WithPeakDifferentialTorqueCurrent(units::current::ampere_t newPeakDifferentialTorqueCurrent)
Modifies this configuration's PeakDifferentialTorqueCurrent parameter and returns itself for method-c...
Definition Configs.hpp:3032
constexpr DifferentialConstantsConfigs & WithPeakDifferentialDutyCycle(units::dimensionless::scalar_t newPeakDifferentialDutyCycle)
Modifies this configuration's PeakDifferentialDutyCycle parameter and returns itself for method-chain...
Definition Configs.hpp:2990
units::voltage::volt_t PeakDifferentialVoltage
Maximum differential output during voltage based differential control modes.
Definition Configs.hpp:2963
Configs related to sensors used for differential control of a mechanism.
Definition Configs.hpp:2761
constexpr DifferentialSensorsConfigs & WithDifferentialTalonFXSensorID(int newDifferentialTalonFXSensorID)
Modifies this configuration's DifferentialTalonFXSensorID parameter and returns itself for method-cha...
Definition Configs.hpp:2871
constexpr DifferentialSensorsConfigs & WithDifferentialSensorSource(signals::DifferentialSensorSourceValue newDifferentialSensorSource)
Modifies this configuration's DifferentialSensorSource parameter and returns itself for method-chaini...
Definition Configs.hpp:2850
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:2921
std::string Serialize() const override
Definition Configs.hpp:2911
std::string ToString() const override
Definition Configs.hpp:2901
signals::DifferentialSensorSourceValue DifferentialSensorSource
Choose what sensor source is used for differential control of a mechanism.
Definition Configs.hpp:2793
int DifferentialRemoteSensorID
Device ID of which remote sensor to use on the differential axis.
Definition Configs.hpp:2814
constexpr DifferentialSensorsConfigs & WithDifferentialRemoteSensorID(int newDifferentialRemoteSensorID)
Modifies this configuration's DifferentialRemoteSensorID parameter and returns itself for method-chai...
Definition Configs.hpp:2893
int DifferentialTalonFXSensorID
Device ID of which remote Talon FX to use.
Definition Configs.hpp:2803
Configs related to the CANdi™ branded device's digital I/O settings.
Definition Configs.hpp:5372
signals::S1CloseStateValue S1CloseState
What value the Signal 1 input (S1IN) needs to be for the CTR Electronics' CANdi™ to detect as Closed.
Definition Configs.hpp:5394
constexpr DigitalInputsConfigs & WithS2FloatState(signals::S2FloatStateValue newS2FloatState)
Modifies this configuration's S2FloatState parameter and returns itself for method-chaining and easie...
Definition Configs.hpp:5431
signals::S2FloatStateValue S2FloatState
The floating state of the Signal 2 input (S2IN).
Definition Configs.hpp:5385
constexpr DigitalInputsConfigs & WithS2CloseState(signals::S2CloseStateValue newS2CloseState)
Modifies this configuration's S2CloseState parameter and returns itself for method-chaining and easie...
Definition Configs.hpp:5471
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:5501
std::string ToString() const override
Definition Configs.hpp:5479
signals::S2CloseStateValue S2CloseState
What value the Signal 2 input (S2IN) needs to be for the CTR Electronics' CANdi™ to detect as Closed.
Definition Configs.hpp:5403
constexpr DigitalInputsConfigs & WithS1CloseState(signals::S1CloseStateValue newS1CloseState)
Modifies this configuration's S1CloseState parameter and returns itself for method-chaining and easie...
Definition Configs.hpp:5451
std::string Serialize() const override
Definition Configs.hpp:5490
signals::S1FloatStateValue S1FloatState
The floating state of the Signal 1 input (S1IN).
Definition Configs.hpp:5380
constexpr DigitalInputsConfigs & WithS1FloatState(signals::S1FloatStateValue newS1FloatState)
Modifies this configuration's S1FloatState parameter and returns itself for method-chaining and easie...
Definition Configs.hpp:5415
Configs that affect the external feedback sensor of this motor controller.
Definition Configs.hpp:2021
constexpr ExternalFeedbackConfigs & WithSensorPhase(signals::SensorPhaseValue newSensorPhase)
Modifies this configuration's SensorPhase parameter and returns itself for method-chaining and easier...
Definition Configs.hpp:2443
units::dimensionless::scalar_t SensorToMechanismRatio
The ratio of sensor rotations to the mechanism's output, where a ratio greater than 1 is a reduction.
Definition Configs.hpp:2044
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:2726
units::angle::turn_t AbsoluteSensorDiscontinuityPoint
The positive discontinuity point of the absolute sensor in rotations.
Definition Configs.hpp:2228
units::time::second_t VelocityFilterTimeConstant
The configurable time constant of the Kalman velocity filter.
Definition Configs.hpp:2086
constexpr ExternalFeedbackConfigs & WithVelocityFilterTimeConstant(units::time::second_t newVelocityFilterTimeConstant)
Modifies this configuration's VelocityFilterTimeConstant parameter and returns itself for method-chai...
Definition Configs.hpp:2330
ExternalFeedbackConfigs & WithSyncCANdiPwm1(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use SyncCANdi PWM 1 by passing in the CANdi object.
ExternalFeedbackConfigs & WithSyncCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use SyncCANcoder by passing in the CANcoder object.
signals::ExternalFeedbackSensorSourceValue ExternalFeedbackSensorSource
Choose what sensor source is reported via API and used by closed-loop and limit features.
Definition Configs.hpp:2150
units::dimensionless::scalar_t RotorToSensorRatio
The ratio of motor rotor rotations to remote sensor rotations, where a ratio greater than 1 is a redu...
Definition Configs.hpp:2061
ExternalFeedbackConfigs & WithFusedCANdiPwm2(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use FusedCANdi PWM 2 by passing in the CANdi object...
ExternalFeedbackConfigs & WithRemoteCANdiPwm1(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use RemoteCANdi PWM 1 by passing in the CANdi objec...
constexpr ExternalFeedbackConfigs & WithQuadratureEdgesPerRotation(int newQuadratureEdgesPerRotation)
Modifies this configuration's QuadratureEdgesPerRotation parameter and returns itself for method-chai...
Definition Configs.hpp:2476
ExternalFeedbackConfigs & WithFusedCANdiPwm1(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use FusedCANdi PWM 1 by passing in the CANdi object...
constexpr ExternalFeedbackConfigs & WithFeedbackRemoteSensorID(int newFeedbackRemoteSensorID)
Modifies this configuration's FeedbackRemoteSensorID parameter and returns itself for method-chaining...
Definition Configs.hpp:2304
ExternalFeedbackConfigs & WithFusedCANdiQuadrature(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use FusedCANdi Quadrature by passing in the CANdi o...
ExternalFeedbackConfigs & WithRemoteCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use RemoteCANcoder by passing in the CANcoder objec...
constexpr ExternalFeedbackConfigs & WithExternalFeedbackSensorSource(signals::ExternalFeedbackSensorSourceValue newExternalFeedbackSensorSource)
Modifies this configuration's ExternalFeedbackSensorSource parameter and returns itself for method-ch...
Definition Configs.hpp:2416
constexpr ExternalFeedbackConfigs & WithRotorToSensorRatio(units::dimensionless::scalar_t newRotorToSensorRatio)
Modifies this configuration's RotorToSensorRatio parameter and returns itself for method-chaining and...
Definition Configs.hpp:2283
ExternalFeedbackConfigs & WithSyncCANdiPwm2(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use SyncCANdi PWM 2 by passing in the CANdi object.
std::string ToString() const override
Definition Configs.hpp:2694
signals::SensorPhaseValue SensorPhase
The relationship between the motor controlled by a Talon and the external sensor connected to the dat...
Definition Configs.hpp:2166
ExternalFeedbackConfigs & WithFusedCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use FusedCANcoder by passing in the CANcoder object...
units::angle::turn_t AbsoluteSensorOffset
The offset applied to any absolute sensor connected to the Talon data port.
Definition Configs.hpp:2100
ExternalFeedbackConfigs & WithRemoteCANdiQuadrature(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use RemoteCANdi Quadrature by passing in the CANdi ...
int FeedbackRemoteSensorID
Device ID of which remote device to use.
Definition Configs.hpp:2071
constexpr ExternalFeedbackConfigs & WithSensorToMechanismRatio(units::dimensionless::scalar_t newSensorToMechanismRatio)
Modifies this configuration's SensorToMechanismRatio parameter and returns itself for method-chaining...
Definition Configs.hpp:2255
constexpr ExternalFeedbackConfigs & WithAbsoluteSensorDiscontinuityPoint(units::angle::turn_t newAbsoluteSensorDiscontinuityPoint)
Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for metho...
Definition Configs.hpp:2527
std::string Serialize() const override
Definition Configs.hpp:2710
ExternalFeedbackConfigs & WithRemoteCANdiPwm2(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use RemoteCANdi PWM 2 by passing in the CANdi objec...
int QuadratureEdgesPerRotation
The number of quadrature edges in one rotation for the quadrature sensor connected to the Talon data ...
Definition Configs.hpp:2188
constexpr ExternalFeedbackConfigs & WithAbsoluteSensorOffset(units::angle::turn_t newAbsoluteSensorOffset)
Modifies this configuration's AbsoluteSensorOffset parameter and returns itself for method-chaining a...
Definition Configs.hpp:2355
Configs that affect the feedback of this motor controller.
Definition Configs.hpp:1501
FeedbackConfigs & WithSyncCANdiPwm2(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use SyncCANdi PWM 2 by passing in the CANdi object.
FeedbackConfigs & WithFusedCANdiPwm1(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use FusedCANdi PWM 1 by passing in the CANdi object...
std::string ToString() const override
Definition Configs.hpp:1962
signals::FeedbackSensorSourceValue FeedbackSensorSource
Choose what sensor source is reported via API and used by closed-loop and limit features.
Definition Configs.hpp:1594
constexpr FeedbackConfigs & WithRotorToSensorRatio(units::dimensionless::scalar_t newRotorToSensorRatio)
Modifies this configuration's RotorToSensorRatio parameter and returns itself for method-chaining and...
Definition Configs.hpp:1696
FeedbackConfigs & WithRemoteCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use RemoteCANcoder by passing in the CANcoder objec...
FeedbackConfigs & WithRemoteCANdiPwm2(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use RemoteCANdi PWM 2 by passing in the CANdi objec...
FeedbackConfigs & WithRemoteCANdiQuadrature(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use RemoteCANdi Quadrature by passing in the CANdi ...
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:1988
constexpr FeedbackConfigs & WithSensorToMechanismRatio(units::dimensionless::scalar_t newSensorToMechanismRatio)
Modifies this configuration's SensorToMechanismRatio parameter and returns itself for method-chaining...
Definition Configs.hpp:1668
units::dimensionless::scalar_t SensorToMechanismRatio
The ratio of sensor rotations to the mechanism's output, where a ratio greater than 1 is a reduction.
Definition Configs.hpp:1535
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:1975
FeedbackConfigs & WithRemoteCANdiPwm1(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use RemoteCANdi PWM 1 by passing in the CANdi objec...
constexpr FeedbackConfigs & WithVelocityFilterTimeConstant(units::time::second_t newVelocityFilterTimeConstant)
Modifies this configuration's VelocityFilterTimeConstant parameter and returns itself for method-chai...
Definition Configs.hpp:1796
FeedbackConfigs & WithFusedCANdiQuadrature(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use FusedCANdi Quadrature by passing in the CANdi o...
units::angle::turn_t FeedbackRotorOffset
The offset applied to the absolute integrated rotor sensor.
Definition Configs.hpp:1515
FeedbackConfigs & WithSyncCANdiPwm1(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use SyncCANdi PWM 1 by passing in the CANdi object.
units::time::second_t VelocityFilterTimeConstant
The configurable time constant of the Kalman velocity filter.
Definition Configs.hpp:1619
units::dimensionless::scalar_t RotorToSensorRatio
The ratio of motor rotor rotations to remote sensor rotations, where a ratio greater than 1 is a redu...
Definition Configs.hpp:1552
int FeedbackRemoteSensorID
Device ID of which remote device to use.
Definition Configs.hpp:1604
FeedbackConfigs & WithFusedCANdiPwm2(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use FusedCANdi PWM 2 by passing in the CANdi object...
constexpr FeedbackConfigs & WithFeedbackSensorSource(signals::FeedbackSensorSourceValue newFeedbackSensorSource)
Modifies this configuration's FeedbackSensorSource parameter and returns itself for method-chaining a...
Definition Configs.hpp:1749
FeedbackConfigs & WithFusedCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use FusedCANcoder by passing in the CANcoder object...
constexpr FeedbackConfigs & WithFeedbackRemoteSensorID(int newFeedbackRemoteSensorID)
Modifies this configuration's FeedbackRemoteSensorID parameter and returns itself for method-chaining...
Definition Configs.hpp:1770
constexpr FeedbackConfigs & WithFeedbackRotorOffset(units::angle::turn_t newFeedbackRotorOffset)
Modifies this configuration's FeedbackRotorOffset parameter and returns itself for method-chaining an...
Definition Configs.hpp:1637
Configs that affect the ToF Field of View.
Definition Configs.hpp:5025
constexpr FovParamsConfigs & WithFOVRangeX(units::angle::degree_t newFOVRangeX)
Modifies this configuration's FOVRangeX parameter and returns itself for method-chaining and easier t...
Definition Configs.hpp:5154
std::string ToString() const override
Definition Configs.hpp:5188
units::angle::degree_t FOVCenterY
Specifies the target center of the Field of View in the Y direction.
Definition Configs.hpp:5054
constexpr FovParamsConfigs & WithFOVRangeY(units::angle::degree_t newFOVRangeY)
Modifies this configuration's FOVRangeY parameter and returns itself for method-chaining and easier t...
Definition Configs.hpp:5180
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:5210
units::angle::degree_t FOVRangeX
Specifies the target range of the Field of View in the X direction.
Definition Configs.hpp:5069
constexpr FovParamsConfigs & WithFOVCenterX(units::angle::degree_t newFOVCenterX)
Modifies this configuration's FOVCenterX parameter and returns itself for method-chaining and easier ...
Definition Configs.hpp:5104
std::string Serialize() const override
Definition Configs.hpp:5199
units::angle::degree_t FOVCenterX
Specifies the target center of the Field of View in the X direction.
Definition Configs.hpp:5041
constexpr FovParamsConfigs & WithFOVCenterY(units::angle::degree_t newFOVCenterY)
Modifies this configuration's FOVCenterY parameter and returns itself for method-chaining and easier ...
Definition Configs.hpp:5128
units::angle::degree_t FOVRangeY
Specifies the target range of the Field of View in the Y direction.
Definition Configs.hpp:5084
Configs to trim the Pigeon2's gyroscope.
Definition Configs.hpp:402
constexpr GyroTrimConfigs & WithGyroScalarX(units::dimensionless::scalar_t newGyroScalarX)
Modifies this configuration's GyroScalarX parameter and returns itself for method-chaining and easier...
Definition Configs.hpp:448
constexpr GyroTrimConfigs & WithGyroScalarY(units::dimensionless::scalar_t newGyroScalarY)
Modifies this configuration's GyroScalarY parameter and returns itself for method-chaining and easier...
Definition Configs.hpp:468
std::string Serialize() const override
Definition Configs.hpp:506
std::string ToString() const override
Definition Configs.hpp:496
units::dimensionless::scalar_t GyroScalarY
The gyro scalar component for the Y axis.
Definition Configs.hpp:423
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:516
units::dimensionless::scalar_t GyroScalarX
The gyro scalar component for the X axis.
Definition Configs.hpp:414
constexpr GyroTrimConfigs & WithGyroScalarZ(units::dimensionless::scalar_t newGyroScalarZ)
Modifies this configuration's GyroScalarZ parameter and returns itself for method-chaining and easier...
Definition Configs.hpp:488
units::dimensionless::scalar_t GyroScalarZ
The gyro scalar component for the Z axis.
Definition Configs.hpp:432
Configs that change how the motor controller behaves under different limit switch states.
Definition Configs.hpp:3447
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:3952
HardwareLimitSwitchConfigs & WithForwardLimitRemoteCANrange(const hardware::core::CoreCANrange &device)
Helper method to configure this feedback group to use the RemoteCANrange by passing in the CANrange o...
signals::ForwardLimitTypeValue ForwardLimitType
Determines if the forward limit switch is normally-open (default) or normally-closed.
Definition Configs.hpp:3456
constexpr HardwareLimitSwitchConfigs & WithForwardLimitAutosetPositionValue(units::angle::turn_t newForwardLimitAutosetPositionValue)
Modifies this configuration's ForwardLimitAutosetPositionValue parameter and returns itself for metho...
Definition Configs.hpp:3628
units::angle::turn_t ForwardLimitAutosetPositionValue
The value to automatically set the position to when the forward limit switch is asserted.
Definition Configs.hpp:3475
signals::ForwardLimitSourceValue ForwardLimitSource
Determines where to poll the forward limit switch.
Definition Configs.hpp:3502
constexpr HardwareLimitSwitchConfigs & WithForwardLimitEnable(bool newForwardLimitEnable)
Modifies this configuration's ForwardLimitEnable parameter and returns itself for method-chaining and...
Definition Configs.hpp:3646
bool ForwardLimitEnable
If enabled, motor output is set to neutral when the forward limit switch is asserted and positive out...
Definition Configs.hpp:3482
bool ReverseLimitAutosetPositionEnable
If enabled, the position is automatically set to a specific value, specified by ReverseLimitAutosetPo...
Definition Configs.hpp:3526
bool ForwardLimitAutosetPositionEnable
If enabled, the position is automatically set to a specific value, specified by ForwardLimitAutosetPo...
Definition Configs.hpp:3464
constexpr HardwareLimitSwitchConfigs & WithReverseLimitAutosetPositionValue(units::angle::turn_t newReverseLimitAutosetPositionValue)
Modifies this configuration's ReverseLimitAutosetPositionValue parameter and returns itself for metho...
Definition Configs.hpp:3755
constexpr HardwareLimitSwitchConfigs & WithReverseLimitSource(signals::ReverseLimitSourceValue newReverseLimitSource)
Modifies this configuration's ReverseLimitSource parameter and returns itself for method-chaining and...
Definition Configs.hpp:3803
signals::ReverseLimitTypeValue ReverseLimitType
Determines if the reverse limit switch is normally-open (default) or normally-closed.
Definition Configs.hpp:3518
units::angle::turn_t ReverseLimitAutosetPositionValue
The value to automatically set the position to when the reverse limit switch is asserted.
Definition Configs.hpp:3537
HardwareLimitSwitchConfigs & WithForwardLimitRemoteCANdiS1(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use RemoteCANdi forward limit switch on Signal 1 In...
constexpr HardwareLimitSwitchConfigs & WithForwardLimitAutosetPositionEnable(bool newForwardLimitAutosetPositionEnable)
Modifies this configuration's ForwardLimitAutosetPositionEnable parameter and returns itself for meth...
Definition Configs.hpp:3606
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:3990
constexpr HardwareLimitSwitchConfigs & WithForwardLimitRemoteSensorID(int newForwardLimitRemoteSensorID)
Modifies this configuration's ForwardLimitRemoteSensorID parameter and returns itself for method-chai...
Definition Configs.hpp:3697
constexpr HardwareLimitSwitchConfigs & WithReverseLimitAutosetPositionEnable(bool newReverseLimitAutosetPositionEnable)
Modifies this configuration's ReverseLimitAutosetPositionEnable parameter and returns itself for meth...
Definition Configs.hpp:3733
HardwareLimitSwitchConfigs & WithReverseLimitRemoteCANcoder(const hardware::core::CoreCANcoder &device)
Helper method to configure this feedback group to use RemoteCANcoder reverse limit switch by passing ...
constexpr HardwareLimitSwitchConfigs & WithReverseLimitType(signals::ReverseLimitTypeValue newReverseLimitType)
Modifies this configuration's ReverseLimitType parameter and returns itself for method-chaining and e...
Definition Configs.hpp:3714
HardwareLimitSwitchConfigs & WithForwardLimitRemoteCANdiS2(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use RemoteCANdi forward limit switch on Signal 2 In...
constexpr HardwareLimitSwitchConfigs & WithReverseLimitEnable(bool newReverseLimitEnable)
Modifies this configuration's ReverseLimitEnable parameter and returns itself for method-chaining and...
Definition Configs.hpp:3773
int ForwardLimitRemoteSensorID
Device ID of the remote device if using remote limit switch features for the forward limit switch.
Definition Configs.hpp:3512
constexpr HardwareLimitSwitchConfigs & WithForwardLimitType(signals::ForwardLimitTypeValue newForwardLimitType)
Modifies this configuration's ForwardLimitType parameter and returns itself for method-chaining and e...
Definition Configs.hpp:3587
signals::ReverseLimitSourceValue ReverseLimitSource
Determines where to poll the reverse limit switch.
Definition Configs.hpp:3564
HardwareLimitSwitchConfigs & WithReverseLimitRemoteCANrange(const hardware::core::CoreCANrange &device)
Helper method to configure this feedback group to use the RemoteCANrange by passing in the CANrange o...
HardwareLimitSwitchConfigs & WithForwardLimitRemoteTalonFX(const hardware::core::CoreTalonFX &device)
Helper method to configure this feedback group to use RemoteTalonFX forward limit switch by passing i...
std::string Serialize() const override
Definition Configs.hpp:3971
HardwareLimitSwitchConfigs & WithReverseLimitRemoteCANdiS2(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use RemoteCANdi reverse limit switch on Signal 2 In...
constexpr HardwareLimitSwitchConfigs & WithReverseLimitRemoteSensorID(int newReverseLimitRemoteSensorID)
Modifies this configuration's ReverseLimitRemoteSensorID parameter and returns itself for method-chai...
Definition Configs.hpp:3824
constexpr HardwareLimitSwitchConfigs & WithForwardLimitSource(signals::ForwardLimitSourceValue newForwardLimitSource)
Modifies this configuration's ForwardLimitSource parameter and returns itself for method-chaining and...
Definition Configs.hpp:3676
HardwareLimitSwitchConfigs & WithReverseLimitRemoteCANdiS1(const hardware::core::CoreCANdi &device)
Helper method to configure this feedback group to use RemoteCANdi reverse limit switch on Signal 1 In...
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:3544
int ReverseLimitRemoteSensorID
Device ID of the remote device if using remote limit switch features for the reverse limit switch.
Definition Configs.hpp:3574
Configs related to CANdle LED control.
Definition Configs.hpp:6060
signals::LossOfSignalBehaviorValue LossOfSignalBehavior
The behavior of the LEDs when the control signal is lost.
Definition Configs.hpp:6083
constexpr LEDConfigs & WithStripType(signals::StripTypeValue newStripType)
Modifies this configuration's StripType parameter and returns itself for method-chaining and easier t...
Definition Configs.hpp:6095
constexpr LEDConfigs & WithBrightnessScalar(units::dimensionless::scalar_t newBrightnessScalar)
Modifies this configuration's BrightnessScalar parameter and returns itself for method-chaining and e...
Definition Configs.hpp:6116
signals::StripTypeValue StripType
The type of LEDs that are being controlled.
Definition Configs.hpp:6068
std::string ToString() const override
Definition Configs.hpp:6140
units::dimensionless::scalar_t BrightnessScalar
The brightness scalar for all LEDs controlled.
Definition Configs.hpp:6078
std::string Serialize() const override
Definition Configs.hpp:6150
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:6160
constexpr LEDConfigs & WithLossOfSignalBehavior(signals::LossOfSignalBehaviorValue newLossOfSignalBehavior)
Modifies this configuration's LossOfSignalBehavior parameter and returns itself for method-chaining a...
Definition Configs.hpp:6132
Configs that affect the magnet sensor and how to interpret it.
Definition Configs.hpp:60
std::string Serialize() const override
Definition Configs.hpp:226
units::angle::turn_t AbsoluteSensorDiscontinuityPoint
The positive discontinuity point of the absolute sensor in rotations.
Definition Configs.hpp:121
constexpr MagnetSensorConfigs & WithMagnetOffset(units::angle::turn_t newMagnetOffset)
Modifies this configuration's MagnetOffset parameter and returns itself for method-chaining and easie...
Definition Configs.hpp:157
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:236
constexpr MagnetSensorConfigs & WithSensorDirection(signals::SensorDirectionValue newSensorDirection)
Modifies this configuration's SensorDirection parameter and returns itself for method-chaining and ea...
Definition Configs.hpp:134
constexpr MagnetSensorConfigs & WithAbsoluteSensorDiscontinuityPoint(units::angle::turn_t newAbsoluteSensorDiscontinuityPoint)
Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for metho...
Definition Configs.hpp:208
units::angle::turn_t MagnetOffset
This offset is added to the reported position, allowing the application to trim the zero position.
Definition Configs.hpp:81
std::string ToString() const override
Definition Configs.hpp:216
signals::SensorDirectionValue SensorDirection
Direction of the sensor to determine positive rotation, as seen facing the LED side of the CANcoder.
Definition Configs.hpp:69
Configs for Motion Magic®.
Definition Configs.hpp:4320
ctre::unit::volts_per_turn_per_second_squared_t MotionMagicExpo_kA
This is the target kA used only by Motion Magic® Expo control modes.
Definition Configs.hpp:4394
constexpr MotionMagicConfigs & WithMotionMagicAcceleration(units::angular_acceleration::turns_per_second_squared_t newMotionMagicAcceleration)
Modifies this configuration's MotionMagicAcceleration parameter and returns itself for method-chainin...
Definition Configs.hpp:4438
ctre::unit::volts_per_turn_per_second_t MotionMagicExpo_kV
This is the target kV used only by Motion Magic® Expo control modes.
Definition Configs.hpp:4379
std::string Serialize() const override
Definition Configs.hpp:4534
constexpr MotionMagicConfigs & WithMotionMagicCruiseVelocity(units::angular_velocity::turns_per_second_t newMotionMagicCruiseVelocity)
Modifies this configuration's MotionMagicCruiseVelocity parameter and returns itself for method-chain...
Definition Configs.hpp:4416
units::angular_acceleration::turns_per_second_squared_t MotionMagicAcceleration
This is the target acceleration Motion Magic® based control modes are allowed to use.
Definition Configs.hpp:4349
constexpr MotionMagicConfigs & WithMotionMagicJerk(units::angular_jerk::turns_per_second_cubed_t newMotionMagicJerk)
Modifies this configuration's MotionMagicJerk parameter and returns itself for method-chaining and ea...
Definition Configs.hpp:4464
units::angular_velocity::turns_per_second_t MotionMagicCruiseVelocity
This is the maximum velocity Motion Magic® based control modes are allowed to use.
Definition Configs.hpp:4338
units::angular_jerk::turns_per_second_cubed_t MotionMagicJerk
This is the target jerk (acceleration derivative) Motion Magic® based control modes are allowed to us...
Definition Configs.hpp:4364
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:4546
std::string ToString() const override
Definition Configs.hpp:4522
constexpr MotionMagicConfigs & WithMotionMagicExpo_kA(ctre::unit::volts_per_turn_per_second_squared_t newMotionMagicExpo_kA)
Modifies this configuration's MotionMagicExpo_kA parameter and returns itself for method-chaining and...
Definition Configs.hpp:4514
constexpr MotionMagicConfigs & WithMotionMagicExpo_kV(ctre::unit::volts_per_turn_per_second_t newMotionMagicExpo_kV)
Modifies this configuration's MotionMagicExpo_kV parameter and returns itself for method-chaining and...
Definition Configs.hpp:4489
Configs that directly affect motor output.
Definition Configs.hpp:661
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:872
units::dimensionless::scalar_t PeakReverseDutyCycle
Minimum (reverse) output during duty cycle based control modes.
Definition Configs.hpp:706
signals::NeutralModeValue NeutralMode
The state of the motor controller bridge when output is neutral or disabled.
Definition Configs.hpp:676
constexpr MotorOutputConfigs & WithNeutralMode(signals::NeutralModeValue newNeutralMode)
Modifies this configuration's NeutralMode parameter and returns itself for method-chaining and easier...
Definition Configs.hpp:751
constexpr MotorOutputConfigs & WithControlTimesyncFreqHz(units::frequency::hertz_t newControlTimesyncFreqHz)
Modifies this configuration's ControlTimesyncFreqHz parameter and returns itself for method-chaining ...
Definition Configs.hpp:838
units::dimensionless::scalar_t PeakForwardDutyCycle
Maximum (forward) output during duty cycle based control modes.
Definition Configs.hpp:696
constexpr MotorOutputConfigs & WithPeakForwardDutyCycle(units::dimensionless::scalar_t newPeakForwardDutyCycle)
Modifies this configuration's PeakForwardDutyCycle parameter and returns itself for method-chaining a...
Definition Configs.hpp:792
constexpr MotorOutputConfigs & WithDutyCycleNeutralDeadband(units::dimensionless::scalar_t newDutyCycleNeutralDeadband)
Modifies this configuration's DutyCycleNeutralDeadband parameter and returns itself for method-chaini...
Definition Configs.hpp:772
std::string ToString() const override
Definition Configs.hpp:846
signals::InvertedValue Inverted
Invert state of the device as seen from the front of the motor.
Definition Configs.hpp:670
std::string Serialize() const override
Definition Configs.hpp:859
constexpr MotorOutputConfigs & WithInverted(signals::InvertedValue newInverted)
Modifies this configuration's Inverted parameter and returns itself for method-chaining and easier to...
Definition Configs.hpp:734
constexpr MotorOutputConfigs & WithPeakReverseDutyCycle(units::dimensionless::scalar_t newPeakReverseDutyCycle)
Modifies this configuration's PeakReverseDutyCycle parameter and returns itself for method-chaining a...
Definition Configs.hpp:812
units::dimensionless::scalar_t DutyCycleNeutralDeadband
Configures the output deadband duty cycle during duty cycle and voltage based control modes.
Definition Configs.hpp:686
units::frequency::hertz_t ControlTimesyncFreqHz
When a control request UseTimesync is enabled, this determines the time-sychronized frequency at whic...
Definition Configs.hpp:722
Configs for Pigeon 2's Mount Pose configuration.
Definition Configs.hpp:260
constexpr MountPoseConfigs & WithMountPoseRoll(units::angle::degree_t newMountPoseRoll)
Modifies this configuration's MountPoseRoll parameter and returns itself for method-chaining and easi...
Definition Configs.hpp:346
constexpr MountPoseConfigs & WithMountPoseYaw(units::angle::degree_t newMountPoseYaw)
Modifies this configuration's MountPoseYaw parameter and returns itself for method-chaining and easie...
Definition Configs.hpp:306
units::angle::degree_t MountPoseRoll
The mounting calibration roll-component.
Definition Configs.hpp:290
units::angle::degree_t MountPosePitch
The mounting calibration pitch-component.
Definition Configs.hpp:281
std::string ToString() const override
Definition Configs.hpp:354
constexpr MountPoseConfigs & WithMountPosePitch(units::angle::degree_t newMountPosePitch)
Modifies this configuration's MountPosePitch parameter and returns itself for method-chaining and eas...
Definition Configs.hpp:326
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:374
units::angle::degree_t MountPoseYaw
The mounting calibration yaw-component.
Definition Configs.hpp:272
std::string Serialize() const override
Definition Configs.hpp:364
Configs that affect the open-loop control of this motor controller.
Definition Configs.hpp:3085
constexpr OpenLoopRampsConfigs & WithVoltageOpenLoopRampPeriod(units::time::second_t newVoltageOpenLoopRampPeriod)
Modifies this configuration's VoltageOpenLoopRampPeriod parameter and returns itself for method-chain...
Definition Configs.hpp:3175
std::string Serialize() const override
Definition Configs.hpp:3217
constexpr OpenLoopRampsConfigs & WithDutyCycleOpenLoopRampPeriod(units::time::second_t newDutyCycleOpenLoopRampPeriod)
Modifies this configuration's DutyCycleOpenLoopRampPeriod parameter and returns itself for method-cha...
Definition Configs.hpp:3150
units::time::second_t VoltageOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0V output to 12V during the open-loop Voltage...
Definition Configs.hpp:3116
units::time::second_t TorqueOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0A output to 300A during the open-loop Torque...
Definition Configs.hpp:3129
std::string ToString() const override
Definition Configs.hpp:3207
constexpr OpenLoopRampsConfigs & WithTorqueOpenLoopRampPeriod(units::time::second_t newTorqueOpenLoopRampPeriod)
Modifies this configuration's TorqueOpenLoopRampPeriod parameter and returns itself for method-chaini...
Definition Configs.hpp:3199
units::time::second_t DutyCycleOpenLoopRampPeriod
If non-zero, this determines how much time to ramp from 0% output to 100% during the open-loop DutyCy...
Definition Configs.hpp:3102
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:3227
Configs related to the CANdi™ branded device's PWM interface on the Signal 1 input (S1IN)
Definition Configs.hpp:5651
constexpr PWM1Configs & WithSensorDirection(bool newSensorDirection)
Modifies this configuration's SensorDirection parameter and returns itself for method-chaining and ea...
Definition Configs.hpp:5803
units::angle::turn_t AbsoluteSensorOffset
The offset applied to the PWM sensor.
Definition Configs.hpp:5666
constexpr PWM1Configs & WithAbsoluteSensorOffset(units::angle::turn_t newAbsoluteSensorOffset)
Modifies this configuration's AbsoluteSensorOffset parameter and returns itself for method-chaining a...
Definition Configs.hpp:5733
bool SensorDirection
Direction of the PWM sensor to determine positive rotation.
Definition Configs.hpp:5714
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:5831
std::string ToString() const override
Definition Configs.hpp:5811
units::angle::turn_t AbsoluteSensorDiscontinuityPoint
The positive discontinuity point of the absolute sensor in rotations.
Definition Configs.hpp:5706
constexpr PWM1Configs & WithAbsoluteSensorDiscontinuityPoint(units::angle::turn_t newAbsoluteSensorDiscontinuityPoint)
Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for metho...
Definition Configs.hpp:5784
std::string Serialize() const override
Definition Configs.hpp:5821
Configs related to the CANdi™ branded device's PWM interface on the Signal 2 input (S2IN)
Definition Configs.hpp:5857
units::angle::turn_t AbsoluteSensorOffset
The offset applied to the PWM sensor.
Definition Configs.hpp:5872
std::string Serialize() const override
Definition Configs.hpp:6027
constexpr PWM2Configs & WithAbsoluteSensorDiscontinuityPoint(units::angle::turn_t newAbsoluteSensorDiscontinuityPoint)
Modifies this configuration's AbsoluteSensorDiscontinuityPoint parameter and returns itself for metho...
Definition Configs.hpp:5990
units::angle::turn_t AbsoluteSensorDiscontinuityPoint
The positive discontinuity point of the absolute sensor in rotations.
Definition Configs.hpp:5912
constexpr PWM2Configs & WithAbsoluteSensorOffset(units::angle::turn_t newAbsoluteSensorOffset)
Modifies this configuration's AbsoluteSensorOffset parameter and returns itself for method-chaining a...
Definition Configs.hpp:5939
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:6037
std::string ToString() const override
Definition Configs.hpp:6017
constexpr PWM2Configs & WithSensorDirection(bool newSensorDirection)
Modifies this configuration's SensorDirection parameter and returns itself for method-chaining and ea...
Definition Configs.hpp:6009
bool SensorDirection
Direction of the PWM sensor to determine positive rotation.
Definition Configs.hpp:5920
friend std::ostream & operator<<(std::ostream &str, const ParentConfiguration &v)
Definition Configs.hpp:43
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:541
constexpr Pigeon2FeaturesConfigs & WithEnableCompass(bool newEnableCompass)
Modifies this configuration's EnableCompass parameter and returns itself for method-chaining and easi...
Definition Configs.hpp:580
bool DisableTemperatureCompensation
Disables using the temperature compensation feature.
Definition Configs.hpp:559
constexpr Pigeon2FeaturesConfigs & WithDisableTemperatureCompensation(bool newDisableTemperatureCompensation)
Modifies this configuration's DisableTemperatureCompensation parameter and returns itself for method-...
Definition Configs.hpp:597
std::string ToString() const override
Definition Configs.hpp:622
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:642
std::string Serialize() const override
Definition Configs.hpp:632
bool DisableNoMotionCalibration
Disables using the no-motion calibration feature.
Definition Configs.hpp:565
constexpr Pigeon2FeaturesConfigs & WithDisableNoMotionCalibration(bool newDisableNoMotionCalibration)
Modifies this configuration's DisableNoMotionCalibration parameter and returns itself for method-chai...
Definition Configs.hpp:614
bool EnableCompass
Turns on or off the magnetometer fusing for 9-axis.
Definition Configs.hpp:553
Configs that affect the ToF Proximity detection.
Definition Configs.hpp:4857
units::dimensionless::scalar_t MinSignalStrengthForValidMeasurement
The minimum allowable signal strength before determining the measurement is valid.
Definition Configs.hpp:4902
std::string ToString() const override
Definition Configs.hpp:4981
constexpr ProximityParamsConfigs & WithProximityThreshold(units::length::meter_t newProximityThreshold)
Modifies this configuration's ProximityThreshold parameter and returns itself for method-chaining and...
Definition Configs.hpp:4918
constexpr ProximityParamsConfigs & WithMinSignalStrengthForValidMeasurement(units::dimensionless::scalar_t newMinSignalStrengthForValidMeasurement)
Modifies this configuration's MinSignalStrengthForValidMeasurement parameter and returns itself for m...
Definition Configs.hpp:4973
std::string Serialize() const override
Definition Configs.hpp:4991
units::length::meter_t ProximityThreshold
Threshold for object detection.
Definition Configs.hpp:4869
constexpr ProximityParamsConfigs & WithProximityHysteresis(units::length::meter_t newProximityHysteresis)
Modifies this configuration's ProximityHysteresis parameter and returns itself for method-chaining an...
Definition Configs.hpp:4946
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:5001
units::length::meter_t ProximityHysteresis
How far above and below the threshold the distance needs to be to trigger undetected and detected,...
Definition Configs.hpp:4886
Configs related to the CANdi™ branded device's quadrature interface using both the S1IN and S2IN inpu...
Definition Configs.hpp:5523
int QuadratureEdgesPerRotation
The number of quadrature edges in one rotation for the quadrature sensor connected to the Talon data ...
Definition Configs.hpp:5548
std::string ToString() const override
Definition Configs.hpp:5612
constexpr QuadratureConfigs & WithSensorDirection(bool newSensorDirection)
Modifies this configuration's SensorDirection parameter and returns itself for method-chaining and ea...
Definition Configs.hpp:5604
std::string Serialize() const override
Definition Configs.hpp:5621
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:5630
bool SensorDirection
Direction of the quadrature sensor to determine positive rotation.
Definition Configs.hpp:5556
constexpr QuadratureConfigs & WithQuadratureEdgesPerRotation(int newQuadratureEdgesPerRotation)
Modifies this configuration's QuadratureEdgesPerRotation parameter and returns itself for method-chai...
Definition Configs.hpp:5585
Gains for the specified slot.
Definition Configs.hpp:6296
units::dimensionless::scalar_t kS
Static Feedforward Gain.
Definition Configs.hpp:6374
constexpr Slot0Configs & WithKI(units::dimensionless::scalar_t newKI)
Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:6510
units::dimensionless::scalar_t kA
Acceleration Feedforward Gain.
Definition Configs.hpp:6407
static Slot0Configs From(const SlotConfigs &value)
signals::StaticFeedforwardSignValue StaticFeedforwardSign
Static Feedforward Sign during position closed loop.
Definition Configs.hpp:6458
constexpr Slot0Configs & WithKA(units::dimensionless::scalar_t newKA)
Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:6628
std::string ToString() const override
Definition Configs.hpp:6720
signals::GravityTypeValue GravityType
Gravity Feedforward/Feedback Type.
Definition Configs.hpp:6440
constexpr Slot0Configs & WithKS(units::dimensionless::scalar_t newKS)
Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:6573
units::dimensionless::scalar_t kP
Proportional Gain.
Definition Configs.hpp:6315
constexpr Slot0Configs & WithKP(units::dimensionless::scalar_t newKP)
Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:6481
constexpr Slot0Configs & WithKV(units::dimensionless::scalar_t newKV)
Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:6600
constexpr Slot0Configs & WithStaticFeedforwardSign(signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining ...
Definition Configs.hpp:6712
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:6752
constexpr Slot0Configs & WithKG(units::dimensionless::scalar_t newKG)
Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:6653
units::dimensionless::scalar_t kD
Derivative Gain.
Definition Configs.hpp:6352
constexpr Slot0Configs & WithGravityType(signals::GravityTypeValue newGravityType)
Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier...
Definition Configs.hpp:6683
units::dimensionless::scalar_t kV
Velocity Feedforward Gain.
Definition Configs.hpp:6390
constexpr Slot0Configs & WithKD(units::dimensionless::scalar_t newKD)
Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:6540
units::dimensionless::scalar_t kG
Gravity Feedforward/Feedback Gain.
Definition Configs.hpp:6421
units::dimensionless::scalar_t kI
Integral Gain.
Definition Configs.hpp:6333
std::string Serialize() const override
Definition Configs.hpp:6736
Gains for the specified slot.
Definition Configs.hpp:6791
units::dimensionless::scalar_t kP
Proportional Gain.
Definition Configs.hpp:6810
std::string Serialize() const override
Definition Configs.hpp:7231
static Slot1Configs From(const SlotConfigs &value)
units::dimensionless::scalar_t kG
Gravity Feedforward/Feedback Gain.
Definition Configs.hpp:6916
constexpr Slot1Configs & WithKI(units::dimensionless::scalar_t newKI)
Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7005
constexpr Slot1Configs & WithKS(units::dimensionless::scalar_t newKS)
Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7068
units::dimensionless::scalar_t kA
Acceleration Feedforward Gain.
Definition Configs.hpp:6902
units::dimensionless::scalar_t kS
Static Feedforward Gain.
Definition Configs.hpp:6869
units::dimensionless::scalar_t kD
Derivative Gain.
Definition Configs.hpp:6847
units::dimensionless::scalar_t kI
Integral Gain.
Definition Configs.hpp:6828
signals::StaticFeedforwardSignValue StaticFeedforwardSign
Static Feedforward Sign during position closed loop.
Definition Configs.hpp:6953
units::dimensionless::scalar_t kV
Velocity Feedforward Gain.
Definition Configs.hpp:6885
constexpr Slot1Configs & WithKP(units::dimensionless::scalar_t newKP)
Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:6976
constexpr Slot1Configs & WithKG(units::dimensionless::scalar_t newKG)
Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7148
constexpr Slot1Configs & WithKV(units::dimensionless::scalar_t newKV)
Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7095
constexpr Slot1Configs & WithKD(units::dimensionless::scalar_t newKD)
Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7035
constexpr Slot1Configs & WithStaticFeedforwardSign(signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining ...
Definition Configs.hpp:7207
constexpr Slot1Configs & WithKA(units::dimensionless::scalar_t newKA)
Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7123
std::string ToString() const override
Definition Configs.hpp:7215
signals::GravityTypeValue GravityType
Gravity Feedforward/Feedback Type.
Definition Configs.hpp:6935
constexpr Slot1Configs & WithGravityType(signals::GravityTypeValue newGravityType)
Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier...
Definition Configs.hpp:7178
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:7247
Gains for the specified slot.
Definition Configs.hpp:7286
std::string Serialize() const override
Definition Configs.hpp:7726
constexpr Slot2Configs & WithKG(units::dimensionless::scalar_t newKG)
Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7643
constexpr Slot2Configs & WithKD(units::dimensionless::scalar_t newKD)
Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7530
constexpr Slot2Configs & WithKS(units::dimensionless::scalar_t newKS)
Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7563
units::dimensionless::scalar_t kA
Acceleration Feedforward Gain.
Definition Configs.hpp:7397
signals::GravityTypeValue GravityType
Gravity Feedforward/Feedback Type.
Definition Configs.hpp:7430
constexpr Slot2Configs & WithGravityType(signals::GravityTypeValue newGravityType)
Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier...
Definition Configs.hpp:7673
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:7742
constexpr Slot2Configs & WithKI(units::dimensionless::scalar_t newKI)
Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7500
constexpr Slot2Configs & WithStaticFeedforwardSign(signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining ...
Definition Configs.hpp:7702
units::dimensionless::scalar_t kS
Static Feedforward Gain.
Definition Configs.hpp:7364
constexpr Slot2Configs & WithKP(units::dimensionless::scalar_t newKP)
Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7471
units::dimensionless::scalar_t kV
Velocity Feedforward Gain.
Definition Configs.hpp:7380
static Slot2Configs From(const SlotConfigs &value)
units::dimensionless::scalar_t kD
Derivative Gain.
Definition Configs.hpp:7342
constexpr Slot2Configs & WithKV(units::dimensionless::scalar_t newKV)
Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7590
units::dimensionless::scalar_t kP
Proportional Gain.
Definition Configs.hpp:7305
signals::StaticFeedforwardSignValue StaticFeedforwardSign
Static Feedforward Sign during position closed loop.
Definition Configs.hpp:7448
units::dimensionless::scalar_t kI
Integral Gain.
Definition Configs.hpp:7323
std::string ToString() const override
Definition Configs.hpp:7710
constexpr Slot2Configs & WithKA(units::dimensionless::scalar_t newKA)
Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:7618
units::dimensionless::scalar_t kG
Gravity Feedforward/Feedback Gain.
Definition Configs.hpp:7411
Gains for the specified slot.
Definition Configs.hpp:7780
static SlotConfigs From(const Slot2Configs &value)
std::string ToString() const
Definition Configs.hpp:8264
constexpr SlotConfigs & WithGravityType(signals::GravityTypeValue newGravityType)
Modifies this configuration's GravityType parameter and returns itself for method-chaining and easier...
Definition Configs.hpp:8219
static SlotConfigs From(const Slot1Configs &value)
units::dimensionless::scalar_t kI
Integral Gain.
Definition Configs.hpp:7869
constexpr SlotConfigs & WithKS(units::dimensionless::scalar_t newKS)
Modifies this configuration's kS parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:8109
constexpr SlotConfigs & WithStaticFeedforwardSign(signals::StaticFeedforwardSignValue newStaticFeedforwardSign)
Modifies this configuration's StaticFeedforwardSign parameter and returns itself for method-chaining ...
Definition Configs.hpp:8248
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize)
Definition Configs.hpp:8297
constexpr SlotConfigs & WithKD(units::dimensionless::scalar_t newKD)
Modifies this configuration's kD parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:8076
signals::StaticFeedforwardSignValue StaticFeedforwardSign
Static Feedforward Sign during position closed loop.
Definition Configs.hpp:7994
units::dimensionless::scalar_t kV
Velocity Feedforward Gain.
Definition Configs.hpp:7926
units::dimensionless::scalar_t kS
Static Feedforward Gain.
Definition Configs.hpp:7910
constexpr SlotConfigs & WithKV(units::dimensionless::scalar_t newKV)
Modifies this configuration's kV parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:8136
units::dimensionless::scalar_t kP
Proportional Gain.
Definition Configs.hpp:7851
constexpr SlotConfigs & WithKA(units::dimensionless::scalar_t newKA)
Modifies this configuration's kA parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:8164
int SlotNumber
Chooses which slot these configs are for.
Definition Configs.hpp:8258
units::dimensionless::scalar_t kD
Derivative Gain.
Definition Configs.hpp:7888
constexpr SlotConfigs & WithKP(units::dimensionless::scalar_t newKP)
Modifies this configuration's kP parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:8017
units::dimensionless::scalar_t kA
Acceleration Feedforward Gain.
Definition Configs.hpp:7943
std::string Serialize() const
Definition Configs.hpp:8280
static SlotConfigs From(const Slot0Configs &value)
constexpr SlotConfigs & WithKI(units::dimensionless::scalar_t newKI)
Modifies this configuration's kI parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:8046
signals::GravityTypeValue GravityType
Gravity Feedforward/Feedback Type.
Definition Configs.hpp:7976
constexpr SlotConfigs & WithKG(units::dimensionless::scalar_t newKG)
Modifies this configuration's kG parameter and returns itself for method-chaining and easier to use c...
Definition Configs.hpp:8189
units::dimensionless::scalar_t kG
Gravity Feedforward/Feedback Gain.
Definition Configs.hpp:7957
Configs that affect how software-limit switches behave.
Definition Configs.hpp:4155
units::angle::turn_t ReverseSoftLimitThreshold
Position threshold for reverse soft limit features.
Definition Configs.hpp:4192
std::string ToString() const override
Definition Configs.hpp:4274
constexpr SoftwareLimitSwitchConfigs & WithForwardSoftLimitThreshold(units::angle::turn_t newForwardSoftLimitThreshold)
Modifies this configuration's ForwardSoftLimitThreshold parameter and returns itself for method-chain...
Definition Configs.hpp:4245
units::angle::turn_t ForwardSoftLimitThreshold
Position threshold for forward soft limit features.
Definition Configs.hpp:4182
constexpr SoftwareLimitSwitchConfigs & WithReverseSoftLimitThreshold(units::angle::turn_t newReverseSoftLimitThreshold)
Modifies this configuration's ReverseSoftLimitThreshold parameter and returns itself for method-chain...
Definition Configs.hpp:4266
constexpr SoftwareLimitSwitchConfigs & WithReverseSoftLimitEnable(bool newReverseSoftLimitEnable)
Modifies this configuration's ReverseSoftLimitEnable parameter and returns itself for method-chaining...
Definition Configs.hpp:4224
std::string Serialize() const override
Definition Configs.hpp:4285
bool ReverseSoftLimitEnable
If enabled, the motor output is set to neutral if position exceeds ReverseSoftLimitThreshold and reve...
Definition Configs.hpp:4172
constexpr SoftwareLimitSwitchConfigs & WithForwardSoftLimitEnable(bool newForwardSoftLimitEnable)
Modifies this configuration's ForwardSoftLimitEnable parameter and returns itself for method-chaining...
Definition Configs.hpp:4206
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:4296
bool ForwardSoftLimitEnable
If enabled, the motor output is set to neutral if position exceeds ForwardSoftLimitThreshold and forw...
Definition Configs.hpp:4165
Configs that affect the ToF sensor.
Definition Configs.hpp:4756
constexpr ToFParamsConfigs & WithUpdateFrequency(units::frequency::hertz_t newUpdateFrequency)
Modifies this configuration's UpdateFrequency parameter and returns itself for method-chaining and ea...
Definition Configs.hpp:4811
std::string Serialize() const override
Definition Configs.hpp:4828
signals::UpdateModeValue UpdateMode
Update mode of the CANrange.
Definition Configs.hpp:4765
constexpr ToFParamsConfigs & WithUpdateMode(signals::UpdateModeValue newUpdateMode)
Modifies this configuration's UpdateMode parameter and returns itself for method-chaining and easier ...
Definition Configs.hpp:4789
units::frequency::hertz_t UpdateFrequency
Rate at which the CANrange will take measurements.
Definition Configs.hpp:4776
std::string ToString() const override
Definition Configs.hpp:4819
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:4837
Configs that affect Torque Current control types.
Definition Configs.hpp:1356
std::string ToString() const override
Definition Configs.hpp:1454
units::current::ampere_t PeakReverseTorqueCurrent
Minimum (reverse) output during torque current based control modes.
Definition Configs.hpp:1379
units::current::ampere_t PeakForwardTorqueCurrent
Maximum (forward) output during torque current based control modes.
Definition Configs.hpp:1369
constexpr TorqueCurrentConfigs & WithPeakForwardTorqueCurrent(units::current::ampere_t newPeakForwardTorqueCurrent)
Modifies this configuration's PeakForwardTorqueCurrent parameter and returns itself for method-chaini...
Definition Configs.hpp:1405
constexpr TorqueCurrentConfigs & WithTorqueNeutralDeadband(units::current::ampere_t newTorqueNeutralDeadband)
Modifies this configuration's TorqueNeutralDeadband parameter and returns itself for method-chaining ...
Definition Configs.hpp:1446
units::current::ampere_t TorqueNeutralDeadband
Configures the output deadband during torque current based control modes.
Definition Configs.hpp:1389
constexpr TorqueCurrentConfigs & WithPeakReverseTorqueCurrent(units::current::ampere_t newPeakReverseTorqueCurrent)
Modifies this configuration's PeakReverseTorqueCurrent parameter and returns itself for method-chaini...
Definition Configs.hpp:1425
std::string Serialize() const override
Definition Configs.hpp:1464
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:1474
Configs that affect Voltage control types.
Definition Configs.hpp:1206
units::voltage::volt_t PeakForwardVoltage
Maximum (forward) output during voltage based control modes.
Definition Configs.hpp:1232
constexpr VoltageConfigs & WithPeakReverseVoltage(units::voltage::volt_t newPeakReverseVoltage)
Modifies this configuration's PeakReverseVoltage parameter and returns itself for method-chaining and...
Definition Configs.hpp:1302
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:1330
std::string Serialize() const override
Definition Configs.hpp:1320
std::string ToString() const override
Definition Configs.hpp:1310
units::time::second_t SupplyVoltageTimeConstant
The time constant (in seconds) of the low-pass filter for the supply voltage.
Definition Configs.hpp:1223
constexpr VoltageConfigs & WithPeakForwardVoltage(units::voltage::volt_t newPeakForwardVoltage)
Modifies this configuration's PeakForwardVoltage parameter and returns itself for method-chaining and...
Definition Configs.hpp:1282
constexpr VoltageConfigs & WithSupplyVoltageTimeConstant(units::time::second_t newSupplyVoltageTimeConstant)
Modifies this configuration's SupplyVoltageTimeConstant parameter and returns itself for method-chain...
Definition Configs.hpp:1262
units::voltage::volt_t PeakReverseVoltage
Minimum (reverse) output during voltage based control modes.
Definition Configs.hpp:1241
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition CoreCANcoder.hpp:657
Class for CTR Electronics' CANdi™ branded device, a device that integrates digital signals into the e...
Definition CoreCANdi.hpp:986
Class for CANrange, a CAN based Time of Flight (ToF) sensor that measures the distance to the front o...
Definition CoreCANrange.hpp:782
Class description for the Talon FX integrated motor controller.
Definition CoreTalonFX.hpp:3256
Requires Phoenix Pro; Improves commutation and velocity measurement for motors with hall sensors.
Definition SpnEnums.hpp:3764
static constexpr int Disabled
Talon will utilize hall sensors without advanced features.
Definition SpnEnums.hpp:3771
If a brushed motor is selected with Motor Arrangement, this config determines which of three leads to...
Definition SpnEnums.hpp:4905
int value
Definition SpnEnums.hpp:4907
static constexpr int Leads_A_and_B
Third party brushed DC motor with two leads.
Definition SpnEnums.hpp:4920
Choose what sensor source is used for differential control of a mechanism.
Definition SpnEnums.hpp:3240
static constexpr int Disabled
Disable differential control.
Definition SpnEnums.hpp:3247
Whether the 5V rail is enabled.
Definition SpnEnums.hpp:5192
static constexpr int Enabled
The 5V rail is enabled, allowing for LED control.
Definition SpnEnums.hpp:5199
int value
Definition SpnEnums.hpp:5194
Choose what sensor source is reported via API and used by closed-loop and limit features.
Definition SpnEnums.hpp:4392
static constexpr int Commutation
Use the external sensor used for motor commutation.
Definition SpnEnums.hpp:4399
Choose what sensor source is reported via API and used by closed-loop and limit features.
Definition SpnEnums.hpp:2411
static constexpr int RotorSensor
Use the internal rotor sensor in the Talon.
Definition SpnEnums.hpp:2418
Determines where to poll the forward limit switch.
Definition SpnEnums.hpp:2703
static constexpr int LimitSwitchPin
Use the forward limit switch pin on the limit switch connector.
Definition SpnEnums.hpp:2710
int value
Definition SpnEnums.hpp:2705
Determines if the forward limit switch is normally-open (default) or normally-closed.
Definition SpnEnums.hpp:2616
static constexpr int NormallyOpen
Definition SpnEnums.hpp:2620
int value
Definition SpnEnums.hpp:2618
Gravity Feedforward/Feedback Type.
Definition SpnEnums.hpp:2138
static constexpr int Elevator_Static
The system's gravity feedforward is constant, such as an elevator.
Definition SpnEnums.hpp:2146
int value
Definition SpnEnums.hpp:2140
Invert state of the device as seen from the front of the motor.
Definition SpnEnums.hpp:2223
static constexpr int CounterClockwise_Positive
Positive motor output results in counter-clockwise motion.
Definition SpnEnums.hpp:2230
int value
Definition SpnEnums.hpp:2225
The behavior of the LEDs when the control signal is lost.
Definition SpnEnums.hpp:5112
static constexpr int KeepRunning
LEDs remain enabled, and animations continue to run.
Definition SpnEnums.hpp:5119
Selects the motor and motor connections used with Talon.
Definition SpnEnums.hpp:3853
int value
Definition SpnEnums.hpp:3855
static constexpr int Disabled
Motor is not selected.
Definition SpnEnums.hpp:3862
The state of the motor controller bridge when output is neutral or disabled.
Definition SpnEnums.hpp:2303
int value
Definition SpnEnums.hpp:2305
static constexpr int Coast
Definition SpnEnums.hpp:2307
Determines where to poll the reverse limit switch.
Definition SpnEnums.hpp:2913
int value
Definition SpnEnums.hpp:2915
static constexpr int LimitSwitchPin
Use the reverse limit switch pin on the limit switch connector.
Definition SpnEnums.hpp:2920
Determines if the reverse limit switch is normally-open (default) or normally-closed.
Definition SpnEnums.hpp:2826
static constexpr int NormallyOpen
Definition SpnEnums.hpp:2830
int value
Definition SpnEnums.hpp:2828
What value the Signal 1 input (S1IN) needs to be for the CTR Electronics' CANdi™ to detect as Closed.
Definition SpnEnums.hpp:4702
int value
Definition SpnEnums.hpp:4704
static constexpr int CloseWhenNotFloating
The S1 input will be treated as closed when it is not floating.
Definition SpnEnums.hpp:4709
The floating state of the Signal 1 input (S1IN).
Definition SpnEnums.hpp:4162
int value
Definition SpnEnums.hpp:4164
static constexpr int FloatDetect
The input will attempt to detect when it is floating.
Definition SpnEnums.hpp:4170
What value the Signal 2 input (S2IN) needs to be for the CTR Electronics' CANdi™ to detect as Closed.
Definition SpnEnums.hpp:4805
int value
Definition SpnEnums.hpp:4807
static constexpr int CloseWhenNotFloating
The S2 input will be treated as closed when it is not floating.
Definition SpnEnums.hpp:4812
The floating state of the Signal 2 input (S2IN).
Definition SpnEnums.hpp:4255
int value
Definition SpnEnums.hpp:4257
static constexpr int FloatDetect
The input will attempt to detect when it is floating.
Definition SpnEnums.hpp:4263
Direction of the sensor to determine positive rotation, as seen facing the LED side of the CANcoder.
Definition SpnEnums.hpp:270
static constexpr int CounterClockwise_Positive
Counter-clockwise motion reports positive rotation.
Definition SpnEnums.hpp:277
int value
Definition SpnEnums.hpp:272
The relationship between the motor controlled by a Talon and the external sensor connected to the dat...
Definition SpnEnums.hpp:4619
int value
Definition SpnEnums.hpp:4621
static constexpr int Aligned
The sensor direction is normally aligned with the motor.
Definition SpnEnums.hpp:4626
Static Feedforward Sign during position closed loop.
Definition SpnEnums.hpp:3370
static constexpr int UseVelocitySign
Use the velocity reference sign.
Definition SpnEnums.hpp:3379
Whether the Status LED is enabled when the CANdle is actively being controlled.
Definition SpnEnums.hpp:5357
static constexpr int Enabled
The status LED is enabled during control.
Definition SpnEnums.hpp:5364
The type of LEDs that are being controlled.
Definition SpnEnums.hpp:5013
static constexpr int GRB
LEDs that are controlled by Green-Red-Blue values.
Definition SpnEnums.hpp:5020
int value
Definition SpnEnums.hpp:5015
Update mode of the CANrange.
Definition SpnEnums.hpp:3674
int value
Definition SpnEnums.hpp:3676
static constexpr int ShortRange100Hz
Updates distance/proximity at 100hz using short-range detection mode.
Definition SpnEnums.hpp:3681
The behavior of the VBat output.
Definition SpnEnums.hpp:5272
static constexpr int On
VBat output is on at full power.
Definition SpnEnums.hpp:5279
int value
Definition SpnEnums.hpp:5274
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
Definition Diff_PositionDutyCycle_Position.hpp:15