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