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