Loading [MathJax]/extensions/tex2jax.js
CTRE Phoenix 6 C++ 25.4.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CoreCANcoder.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
13
14
16#include <units/angle.h>
17#include <units/angular_velocity.h>
18#include <units/voltage.h>
19
20namespace ctre {
21namespace phoenix6 {
22
23namespace hardware {
24namespace core {
25 class CoreCANcoder;
26}
27}
28
29namespace configs {
30
31/**
32 * Class for CANcoder, a CAN based magnetic encoder that provides absolute and
33 * relative position along with filtered velocity.
34 *
35 * This handles the configurations for the hardware#CANcoder
36 */
38{
39public:
40 constexpr CANcoderConfiguration() = default;
41
42 /**
43 * \brief True if we should factory default newer unsupported configs,
44 * false to leave newer unsupported configs alone.
45 *
46 * \details This flag addresses a corner case where the device may have
47 * firmware with newer configs that didn't exist when this
48 * version of the API was built. If this occurs and this
49 * flag is true, unsupported new configs will be factory
50 * defaulted to avoid unexpected behavior.
51 *
52 * This is also the behavior in Phoenix 5, so this flag
53 * is defaulted to true to match.
54 */
56
57
58 /**
59 * \brief Configs that affect the magnet sensor and how to interpret
60 * it.
61 *
62 * \details Includes sensor direction, the sensor discontinuity point,
63 * and the magnet offset.
64 *
65 * Parameter list:
66 *
67 * - MagnetSensorConfigs#SensorDirection
68 * - MagnetSensorConfigs#MagnetOffset
69 * - MagnetSensorConfigs#AbsoluteSensorDiscontinuityPoint
70 *
71 */
73
74 /**
75 * \brief Custom Params.
76 *
77 * \details Custom paramaters that have no real impact on controller.
78 *
79 * Parameter list:
80 *
81 * - CustomParamsConfigs#CustomParam0
82 * - CustomParamsConfigs#CustomParam1
83 *
84 */
86
87 /**
88 * \brief Modifies this configuration's MagnetSensor parameter and returns itself for
89 * method-chaining and easier to use config API.
90 *
91 * Configs that affect the magnet sensor and how to interpret it.
92 *
93 * \details Includes sensor direction, the sensor discontinuity point,
94 * and the magnet offset.
95 *
96 * Parameter list:
97 *
98 * - MagnetSensorConfigs#SensorDirection
99 * - MagnetSensorConfigs#MagnetOffset
100 * - MagnetSensorConfigs#AbsoluteSensorDiscontinuityPoint
101 *
102 *
103 * \param newMagnetSensor Parameter to modify
104 * \returns Itself
105 */
107 {
108 MagnetSensor = std::move(newMagnetSensor);
109 return *this;
110 }
111
112 /**
113 * \brief Modifies this configuration's CustomParams parameter and returns itself for
114 * method-chaining and easier to use config API.
115 *
116 * Custom Params.
117 *
118 * \details Custom paramaters that have no real impact on controller.
119 *
120 * Parameter list:
121 *
122 * - CustomParamsConfigs#CustomParam0
123 * - CustomParamsConfigs#CustomParam1
124 *
125 *
126 * \param newCustomParams Parameter to modify
127 * \returns Itself
128 */
130 {
131 CustomParams = std::move(newCustomParams);
132 return *this;
133 }
134
135 /**
136 * \brief Get the string representation of this configuration
137 */
138 std::string ToString() const
139 {
140 std::stringstream ss;
141 ss << "CANcoderConfiguration" << std::endl;
142 ss << MagnetSensor.ToString();
143 ss << CustomParams.ToString();
144 return ss.str();
145 }
146
147 /**
148 * \brief Get the serialized form of this configuration
149 */
150 std::string Serialize() const
151 {
152 std::stringstream ss;
153 ss << MagnetSensor.Serialize();
154 ss << CustomParams.Serialize();
155 return ss.str();
156 }
157
158 /**
159 * \brief Take a string and deserialize it to this configuration
160 */
161 ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize)
162 {
164 err = MagnetSensor.Deserialize(to_deserialize);
165 err = CustomParams.Deserialize(to_deserialize);
166 return err;
167 }
168};
169
170/**
171 * Class for CANcoder, a CAN based magnetic encoder that provides absolute and
172 * relative position along with filtered velocity.
173 *
174 * This handles the configurations for the hardware#CANcoder
175 */
177{
178private:
180 ParentConfigurator{std::move(id)}
181 {}
182
184
185public:
186 /**
187 * \brief Refreshes the values of the specified config group.
188 *
189 * This will wait up to #DefaultTimeoutSeconds.
190 *
191 * \details Call to refresh the selected configs from the device.
192 *
193 * \param configs The configs to refresh
194 * \returns StatusCode of refreshing the configs
195 */
200
201 /**
202 * \brief Refreshes the values of the specified config group.
203 *
204 * \details Call to refresh the selected configs from the device.
205 *
206 * \param configs The configs to refresh
207 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
208 * \returns StatusCode of refreshing the configs
209 */
210 ctre::phoenix::StatusCode Refresh(CANcoderConfiguration &configs, units::time::second_t timeoutSeconds) const
211 {
212 std::string ref;
213 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
214 configs.Deserialize(ref);
215 return ret;
216 }
217
218 /**
219 * \brief Applies the contents of the specified config to the device.
220 *
221 * This will wait up to #DefaultTimeoutSeconds.
222 *
223 * \details Call to apply the selected configs.
224 *
225 * \param configs Configs to apply against.
226 * \returns StatusCode of the set command
227 */
229 {
230 return Apply(configs, DefaultTimeoutSeconds);
231 }
232
233 /**
234 * \brief Applies the contents of the specified config to the device.
235 *
236 * \details Call to apply the selected configs.
237 *
238 * \param configs Configs to apply against.
239 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
240 * \returns StatusCode of the set command
241 */
242 ctre::phoenix::StatusCode Apply(const CANcoderConfiguration &configs, units::time::second_t timeoutSeconds)
243 {
244 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, configs.FutureProofConfigs, false);
245 }
246
247
248 /**
249 * \brief Refreshes the values of the specified config group.
250 *
251 * This will wait up to #DefaultTimeoutSeconds.
252 *
253 * \details Call to refresh the selected configs from the device.
254 *
255 * \param configs The configs to refresh
256 * \returns StatusCode of refreshing the configs
257 */
259 {
260 return Refresh(configs, DefaultTimeoutSeconds);
261 }
262 /**
263 * \brief Refreshes the values of the specified config group.
264 *
265 * \details Call to refresh the selected configs from the device.
266 *
267 * \param configs The configs to refresh
268 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
269 * \returns StatusCode of refreshing the configs
270 */
271 ctre::phoenix::StatusCode Refresh(MagnetSensorConfigs &configs, units::time::second_t timeoutSeconds) const
272 {
273 std::string ref;
274 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
275 configs.Deserialize(ref);
276 return ret;
277 }
278
279 /**
280 * \brief Applies the contents of the specified config to the device.
281 *
282 * This will wait up to #DefaultTimeoutSeconds.
283 *
284 * \details Call to apply the selected configs.
285 *
286 * \param configs Configs to apply against.
287 * \returns StatusCode of the set command
288 */
290 {
291 return Apply(configs, DefaultTimeoutSeconds);
292 }
293
294 /**
295 * \brief Applies the contents of the specified config to the device.
296 *
297 * \details Call to apply the selected configs.
298 *
299 * \param configs Configs to apply against.
300 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
301 * \returns StatusCode of the set command
302 */
303 ctre::phoenix::StatusCode Apply(const MagnetSensorConfigs &configs, units::time::second_t timeoutSeconds)
304 {
305 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, false, false);
306 }
307
308 /**
309 * \brief Refreshes the values of the specified config group.
310 *
311 * This will wait up to #DefaultTimeoutSeconds.
312 *
313 * \details Call to refresh the selected configs from the device.
314 *
315 * \param configs The configs to refresh
316 * \returns StatusCode of refreshing the configs
317 */
319 {
320 return Refresh(configs, DefaultTimeoutSeconds);
321 }
322 /**
323 * \brief Refreshes the values of the specified config group.
324 *
325 * \details Call to refresh the selected configs from the device.
326 *
327 * \param configs The configs to refresh
328 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
329 * \returns StatusCode of refreshing the configs
330 */
331 ctre::phoenix::StatusCode Refresh(CustomParamsConfigs &configs, units::time::second_t timeoutSeconds) const
332 {
333 std::string ref;
334 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
335 configs.Deserialize(ref);
336 return ret;
337 }
338
339 /**
340 * \brief Applies the contents of the specified config to the device.
341 *
342 * This will wait up to #DefaultTimeoutSeconds.
343 *
344 * \details Call to apply the selected configs.
345 *
346 * \param configs Configs to apply against.
347 * \returns StatusCode of the set command
348 */
350 {
351 return Apply(configs, DefaultTimeoutSeconds);
352 }
353
354 /**
355 * \brief Applies the contents of the specified config to the device.
356 *
357 * \details Call to apply the selected configs.
358 *
359 * \param configs Configs to apply against.
360 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
361 * \returns StatusCode of the set command
362 */
363 ctre::phoenix::StatusCode Apply(const CustomParamsConfigs &configs, units::time::second_t timeoutSeconds)
364 {
365 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, false, false);
366 }
367
368
369 /**
370 * \brief Sets the current position of the device.
371 *
372 * This will wait up to #DefaultTimeoutSeconds.
373 *
374 * This is available in the configurator in case the user wants
375 * to initialize their device entirely without passing a device
376 * reference down to the code that performs the initialization.
377 * In this case, the user passes down the configurator object
378 * and performs all the initialization code on the object.
379 *
380 * \param newValue Value to set to. Units are in rotations.
381 * \returns StatusCode of the set command
382 */
383 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
384 {
385 return SetPosition(newValue, DefaultTimeoutSeconds);
386 }
387 /**
388 * \brief Sets the current position of the device.
389 *
390 * This is available in the configurator in case the user wants
391 * to initialize their device entirely without passing a device
392 * reference down to the code that performs the initialization.
393 * In this case, the user passes down the configurator object
394 * and performs all the initialization code on the object.
395 *
396 * \param newValue Value to set to. Units are in rotations.
397 * \param timeoutSeconds Maximum time to wait up to in seconds.
398 * \returns StatusCode of the set command
399 */
400 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
401 {
402 std::stringstream ss;
403 char *ref;
404 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::CANcoder_SetSensorPosition, newValue.to<double>(), &ref); if (ref != nullptr) { ss << ref; free(ref); }
405 return SetConfigsPrivate(ss.str(), timeoutSeconds, false, true);
406 }
407
408 /**
409 * \brief Clear the sticky faults in the device.
410 *
411 * \details This typically has no impact on the device functionality.
412 * Instead, it just clears telemetry faults that are accessible via
413 * API and Tuner Self-Test.
414 *
415 * This will wait up to #DefaultTimeoutSeconds.
416 *
417 * This is available in the configurator in case the user wants
418 * to initialize their device entirely without passing a device
419 * reference down to the code that performs the initialization.
420 * In this case, the user passes down the configurator object
421 * and performs all the initialization code on the object.
422 *
423 * \returns StatusCode of the set command
424 */
429 /**
430 * \brief Clear the sticky faults in the device.
431 *
432 * \details This typically has no impact on the device functionality.
433 * Instead, it just clears telemetry faults that are accessible via
434 * API and Tuner Self-Test.
435 *
436 * This is available in the configurator in case the user wants
437 * to initialize their device entirely without passing a device
438 * reference down to the code that performs the initialization.
439 * In this case, the user passes down the configurator object
440 * and performs all the initialization code on the object.
441 *
442 * \param timeoutSeconds Maximum time to wait up to in seconds.
443 * \returns StatusCode of the set command
444 */
445 ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
446 {
447 std::stringstream ss;
448 char *ref;
449 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::SPN_ClearStickyFaults, 0, &ref); if (ref != nullptr) { ss << ref; free(ref); }
450 return SetConfigsPrivate(ss.str(), timeoutSeconds, false, true);
451 }
452
453 /**
454 * \brief Clear sticky fault: Hardware fault occurred
455 *
456 * This will wait up to #DefaultTimeoutSeconds.
457 *
458 * This is available in the configurator in case the user wants
459 * to initialize their device entirely without passing a device
460 * reference down to the code that performs the initialization.
461 * In this case, the user passes down the configurator object
462 * and performs all the initialization code on the object.
463 *
464 * \returns StatusCode of the set command
465 */
470 /**
471 * \brief Clear sticky fault: Hardware fault occurred
472 *
473 * This is available in the configurator in case the user wants
474 * to initialize their device entirely without passing a device
475 * reference down to the code that performs the initialization.
476 * In this case, the user passes down the configurator object
477 * and performs all the initialization code on the object.
478 *
479 * \param timeoutSeconds Maximum time to wait up to in seconds.
480 * \returns StatusCode of the set command
481 */
482 ctre::phoenix::StatusCode ClearStickyFault_Hardware(units::time::second_t timeoutSeconds)
483 {
484 std::stringstream ss;
485 char *ref;
486 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::ClearStickyFault_Hardware, 0, &ref); if (ref != nullptr) { ss << ref; free(ref); }
487 return SetConfigsPrivate(ss.str(), timeoutSeconds, false, true);
488 }
489
490 /**
491 * \brief Clear sticky fault: Device supply voltage dropped to near
492 * brownout levels
493 *
494 * This will wait up to #DefaultTimeoutSeconds.
495 *
496 * This is available in the configurator in case the user wants
497 * to initialize their device entirely without passing a device
498 * reference down to the code that performs the initialization.
499 * In this case, the user passes down the configurator object
500 * and performs all the initialization code on the object.
501 *
502 * \returns StatusCode of the set command
503 */
508 /**
509 * \brief Clear sticky fault: Device supply voltage dropped to near
510 * brownout levels
511 *
512 * This is available in the configurator in case the user wants
513 * to initialize their device entirely without passing a device
514 * reference down to the code that performs the initialization.
515 * In this case, the user passes down the configurator object
516 * and performs all the initialization code on the object.
517 *
518 * \param timeoutSeconds Maximum time to wait up to in seconds.
519 * \returns StatusCode of the set command
520 */
521 ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(units::time::second_t timeoutSeconds)
522 {
523 std::stringstream ss;
524 char *ref;
525 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::ClearStickyFault_Undervoltage, 0, &ref); if (ref != nullptr) { ss << ref; free(ref); }
526 return SetConfigsPrivate(ss.str(), timeoutSeconds, false, true);
527 }
528
529 /**
530 * \brief Clear sticky fault: Device boot while detecting the enable
531 * signal
532 *
533 * This will wait up to #DefaultTimeoutSeconds.
534 *
535 * This is available in the configurator in case the user wants
536 * to initialize their device entirely without passing a device
537 * reference down to the code that performs the initialization.
538 * In this case, the user passes down the configurator object
539 * and performs all the initialization code on the object.
540 *
541 * \returns StatusCode of the set command
542 */
547 /**
548 * \brief Clear sticky fault: Device boot while detecting the enable
549 * signal
550 *
551 * This is available in the configurator in case the user wants
552 * to initialize their device entirely without passing a device
553 * reference down to the code that performs the initialization.
554 * In this case, the user passes down the configurator object
555 * and performs all the initialization code on the object.
556 *
557 * \param timeoutSeconds Maximum time to wait up to in seconds.
558 * \returns StatusCode of the set command
559 */
561 {
562 std::stringstream ss;
563 char *ref;
564 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::ClearStickyFault_BootDuringEnable, 0, &ref); if (ref != nullptr) { ss << ref; free(ref); }
565 return SetConfigsPrivate(ss.str(), timeoutSeconds, false, true);
566 }
567
568 /**
569 * \brief Clear sticky fault: An unlicensed feature is in use, device
570 * may not behave as expected.
571 *
572 * This will wait up to #DefaultTimeoutSeconds.
573 *
574 * This is available in the configurator in case the user wants
575 * to initialize their device entirely without passing a device
576 * reference down to the code that performs the initialization.
577 * In this case, the user passes down the configurator object
578 * and performs all the initialization code on the object.
579 *
580 * \returns StatusCode of the set command
581 */
586 /**
587 * \brief Clear sticky fault: An unlicensed feature is in use, device
588 * may not behave as expected.
589 *
590 * This is available in the configurator in case the user wants
591 * to initialize their device entirely without passing a device
592 * reference down to the code that performs the initialization.
593 * In this case, the user passes down the configurator object
594 * and performs all the initialization code on the object.
595 *
596 * \param timeoutSeconds Maximum time to wait up to in seconds.
597 * \returns StatusCode of the set command
598 */
600 {
601 std::stringstream ss;
602 char *ref;
603 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::ClearStickyFault_UnlicensedFeatureInUse, 0, &ref); if (ref != nullptr) { ss << ref; free(ref); }
604 return SetConfigsPrivate(ss.str(), timeoutSeconds, false, true);
605 }
606
607 /**
608 * \brief Clear sticky fault: The magnet distance is not correct or
609 * magnet is missing
610 *
611 * This will wait up to #DefaultTimeoutSeconds.
612 *
613 * This is available in the configurator in case the user wants
614 * to initialize their device entirely without passing a device
615 * reference down to the code that performs the initialization.
616 * In this case, the user passes down the configurator object
617 * and performs all the initialization code on the object.
618 *
619 * \returns StatusCode of the set command
620 */
625 /**
626 * \brief Clear sticky fault: The magnet distance is not correct or
627 * magnet is missing
628 *
629 * This is available in the configurator in case the user wants
630 * to initialize their device entirely without passing a device
631 * reference down to the code that performs the initialization.
632 * In this case, the user passes down the configurator object
633 * and performs all the initialization code on the object.
634 *
635 * \param timeoutSeconds Maximum time to wait up to in seconds.
636 * \returns StatusCode of the set command
637 */
638 ctre::phoenix::StatusCode ClearStickyFault_BadMagnet(units::time::second_t timeoutSeconds)
639 {
640 std::stringstream ss;
641 char *ref;
642 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::ClearStickyFault_CANCODER_BadMagnet, 0, &ref); if (ref != nullptr) { ss << ref; free(ref); }
643 return SetConfigsPrivate(ss.str(), timeoutSeconds, false, true);
644 }
645};
646
647}
648
649namespace hardware {
650namespace core {
651
652/**
653 * Class for CANcoder, a CAN based magnetic encoder that provides absolute and
654 * relative position along with filtered velocity.
655 */
657{
658private:
660
661public:
663
664 /**
665 * Constructs a new CANcoder object.
666 *
667 * \param deviceId ID of the device, as configured in Phoenix Tuner.
668 * \param canbus Name of the CAN bus this device is on. Possible CAN bus strings are:
669 * - "rio" for the native roboRIO CAN bus
670 * - CANivore name or serial number
671 * - SocketCAN interface (non-FRC Linux only)
672 * - "*" for any CANivore seen by the program
673 * - empty string (default) to select the default for the system:
674 * - "rio" on roboRIO
675 * - "can0" on Linux
676 * - "*" on Windows
677 */
678 CoreCANcoder(int deviceId, std::string canbus = "");
679
680 /**
681 * Constructs a new CANcoder object.
682 *
683 * \param deviceId ID of the device, as configured in Phoenix Tuner.
684 * \param canbus The CAN bus this device is on.
685 */
686 CoreCANcoder(int deviceId, CANBus canbus) :
687 CoreCANcoder{deviceId, std::string{canbus.GetName()}}
688 {}
689
690 /**
691 * \brief Gets the configurator for this CANcoder
692 *
693 * \details Gets the configurator for this CANcoder
694 *
695 * \returns Configurator for this CANcoder
696 */
698 {
699 return _configs;
700 }
701
702 /**
703 * \brief Gets the configurator for this CANcoder
704 *
705 * \details Gets the configurator for this CANcoder
706 *
707 * \returns Configurator for this CANcoder
708 */
710 {
711 return _configs;
712 }
713
714
715private:
716 std::unique_ptr<sim::CANcoderSimState> _simState{};
717public:
718 /**
719 * \brief Get the simulation state for this device.
720 *
721 * \details This function reuses an allocated simulation
722 * state object, so it is safe to call this function multiple
723 * times in a robot loop.
724 *
725 * \returns Simulation state
726 */
728 {
729 if (_simState == nullptr)
730 _simState = std::make_unique<sim::CANcoderSimState>(*this);
731 return *_simState;
732 }
733
734
735
736 /**
737 * \brief App Major Version number.
738 *
739 * - Minimum Value: 0
740 * - Maximum Value: 255
741 * - Default Value: 0
742 * - Units:
743 *
744 * Default Rates:
745 * - CAN: 4.0 Hz
746 *
747 * This refreshes and returns a cached StatusSignal object.
748 *
749 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
750 * \returns VersionMajor Status Signal Object
751 */
752 StatusSignal<int> &GetVersionMajor(bool refresh = true);
753
754 /**
755 * \brief App Minor Version number.
756 *
757 * - Minimum Value: 0
758 * - Maximum Value: 255
759 * - Default Value: 0
760 * - Units:
761 *
762 * Default Rates:
763 * - CAN: 4.0 Hz
764 *
765 * This refreshes and returns a cached StatusSignal object.
766 *
767 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
768 * \returns VersionMinor Status Signal Object
769 */
770 StatusSignal<int> &GetVersionMinor(bool refresh = true);
771
772 /**
773 * \brief App Bugfix Version number.
774 *
775 * - Minimum Value: 0
776 * - Maximum Value: 255
777 * - Default Value: 0
778 * - Units:
779 *
780 * Default Rates:
781 * - CAN: 4.0 Hz
782 *
783 * This refreshes and returns a cached StatusSignal object.
784 *
785 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
786 * \returns VersionBugfix Status Signal Object
787 */
788 StatusSignal<int> &GetVersionBugfix(bool refresh = true);
789
790 /**
791 * \brief App Build Version number.
792 *
793 * - Minimum Value: 0
794 * - Maximum Value: 255
795 * - Default Value: 0
796 * - Units:
797 *
798 * Default Rates:
799 * - CAN: 4.0 Hz
800 *
801 * This refreshes and returns a cached StatusSignal object.
802 *
803 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
804 * \returns VersionBuild Status Signal Object
805 */
806 StatusSignal<int> &GetVersionBuild(bool refresh = true);
807
808 /**
809 * \brief Full Version of firmware in device. The format is a four
810 * byte value.
811 *
812 * - Minimum Value: 0
813 * - Maximum Value: 4294967295
814 * - Default Value: 0
815 * - Units:
816 *
817 * Default Rates:
818 * - CAN: 4.0 Hz
819 *
820 * This refreshes and returns a cached StatusSignal object.
821 *
822 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
823 * \returns Version Status Signal Object
824 */
825 StatusSignal<int> &GetVersion(bool refresh = true);
826
827 /**
828 * \brief Integer representing all fault flags reported by the device.
829 *
830 * \details These are device specific and are not used directly in
831 * typical applications. Use the signal specific GetFault_*() methods
832 * instead.
833 *
834 * - Minimum Value: 0
835 * - Maximum Value: 4294967295
836 * - Default Value: 0
837 * - Units:
838 *
839 * Default Rates:
840 * - CAN: 4.0 Hz
841 *
842 * This refreshes and returns a cached StatusSignal object.
843 *
844 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
845 * \returns FaultField Status Signal Object
846 */
847 StatusSignal<int> &GetFaultField(bool refresh = true);
848
849 /**
850 * \brief Integer representing all (persistent) sticky fault flags
851 * reported by the device.
852 *
853 * \details These are device specific and are not used directly in
854 * typical applications. Use the signal specific GetStickyFault_*()
855 * methods instead.
856 *
857 * - Minimum Value: 0
858 * - Maximum Value: 4294967295
859 * - Default Value: 0
860 * - Units:
861 *
862 * Default Rates:
863 * - CAN: 4.0 Hz
864 *
865 * This refreshes and returns a cached StatusSignal object.
866 *
867 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
868 * \returns StickyFaultField Status Signal Object
869 */
871
872 /**
873 * \brief Velocity of the device.
874 *
875 * - Minimum Value: -512.0
876 * - Maximum Value: 511.998046875
877 * - Default Value: 0
878 * - Units: rotations per second
879 *
880 * Default Rates:
881 * - CAN 2.0: 100.0 Hz
882 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
883 *
884 * This refreshes and returns a cached StatusSignal object.
885 *
886 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
887 * \returns Velocity Status Signal Object
888 */
890
891 /**
892 * \brief Position of the device. This is initialized to the absolute
893 * position on boot.
894 *
895 * - Minimum Value: -16384.0
896 * - Maximum Value: 16383.999755859375
897 * - Default Value: 0
898 * - Units: rotations
899 *
900 * Default Rates:
901 * - CAN 2.0: 100.0 Hz
902 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
903 *
904 * This refreshes and returns a cached StatusSignal object.
905 *
906 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
907 * \returns Position Status Signal Object
908 */
910
911 /**
912 * \brief Absolute Position of the device. The possible range is
913 * documented below; however, the exact expected range is determined
914 * by the AbsoluteSensorDiscontinuityPoint. This position is only
915 * affected by the MagnetSensor configs.
916 *
917 * - Minimum Value: -1.0
918 * - Maximum Value: 0.999755859375
919 * - Default Value: 0
920 * - Units: rotations
921 *
922 * Default Rates:
923 * - CAN 2.0: 100.0 Hz
924 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
925 *
926 * This refreshes and returns a cached StatusSignal object.
927 *
928 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
929 * \returns AbsolutePosition Status Signal Object
930 */
932
933 /**
934 * \brief The unfiltered velocity reported by CANcoder.
935 *
936 * \details This is the unfiltered velocity reported by CANcoder. This
937 * signal does not use the fusing algorithm.
938 *
939 * - Minimum Value: -8000.0
940 * - Maximum Value: 7999.755859375
941 * - Default Value: 0
942 * - Units: rotations per second
943 *
944 * Default Rates:
945 * - CAN 2.0: 4.0 Hz
946 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
947 *
948 * This refreshes and returns a cached StatusSignal object.
949 *
950 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
951 * \returns UnfilteredVelocity Status Signal Object
952 */
954
955 /**
956 * \brief The relative position reported by the CANcoder since boot.
957 *
958 * \details This is the total displacement reported by CANcoder since
959 * power up. This signal is relative and is not influenced by the
960 * fusing algorithm.
961 *
962 * - Minimum Value: -16384.0
963 * - Maximum Value: 16383.999755859375
964 * - Default Value: 0
965 * - Units: rotations
966 *
967 * Default Rates:
968 * - CAN 2.0: 4.0 Hz
969 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
970 *
971 * This refreshes and returns a cached StatusSignal object.
972 *
973 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
974 * \returns PositionSinceBoot Status Signal Object
975 */
977
978 /**
979 * \brief Measured supply voltage to the CANcoder.
980 *
981 * - Minimum Value: 4
982 * - Maximum Value: 16.75
983 * - Default Value: 4
984 * - Units: V
985 *
986 * Default Rates:
987 * - CAN 2.0: 4.0 Hz
988 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
989 *
990 * This refreshes and returns a cached StatusSignal object.
991 *
992 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
993 * \returns SupplyVoltage Status Signal Object
994 */
996
997 /**
998 * \brief Magnet health as measured by CANcoder.
999 *
1000 * Red indicates too close or too far, Orange is adequate but with
1001 * reduced accuracy, green is ideal. Invalid means the accuracy cannot
1002 * be determined.
1003 *
1004 *
1005 * Default Rates:
1006 * - CAN 2.0: 4.0 Hz
1007 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1008 *
1009 * This refreshes and returns a cached StatusSignal object.
1010 *
1011 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1012 * \returns MagnetHealth Status Signal Object
1013 */
1015
1016 /**
1017 * \brief Whether the device is Phoenix Pro licensed.
1018 *
1019 * - Default Value: False
1020 *
1021 * Default Rates:
1022 * - CAN: 4.0 Hz
1023 *
1024 * This refreshes and returns a cached StatusSignal object.
1025 *
1026 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1027 * \returns IsProLicensed Status Signal Object
1028 */
1030
1031 /**
1032 * \brief Hardware fault occurred
1033 *
1034 * - Default Value: False
1035 *
1036 * Default Rates:
1037 * - CAN: 4.0 Hz
1038 *
1039 * This refreshes and returns a cached StatusSignal object.
1040 *
1041 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1042 * \returns Fault_Hardware Status Signal Object
1043 */
1045
1046 /**
1047 * \brief Hardware fault occurred
1048 *
1049 * - Default Value: False
1050 *
1051 * Default Rates:
1052 * - CAN: 4.0 Hz
1053 *
1054 * This refreshes and returns a cached StatusSignal object.
1055 *
1056 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1057 * \returns StickyFault_Hardware Status Signal Object
1058 */
1060
1061 /**
1062 * \brief Device supply voltage dropped to near brownout levels
1063 *
1064 * - Default Value: False
1065 *
1066 * Default Rates:
1067 * - CAN: 4.0 Hz
1068 *
1069 * This refreshes and returns a cached StatusSignal object.
1070 *
1071 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1072 * \returns Fault_Undervoltage Status Signal Object
1073 */
1075
1076 /**
1077 * \brief Device supply voltage dropped to near brownout levels
1078 *
1079 * - Default Value: False
1080 *
1081 * Default Rates:
1082 * - CAN: 4.0 Hz
1083 *
1084 * This refreshes and returns a cached StatusSignal object.
1085 *
1086 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1087 * \returns StickyFault_Undervoltage Status Signal Object
1088 */
1090
1091 /**
1092 * \brief Device boot while detecting the enable signal
1093 *
1094 * - Default Value: False
1095 *
1096 * Default Rates:
1097 * - CAN: 4.0 Hz
1098 *
1099 * This refreshes and returns a cached StatusSignal object.
1100 *
1101 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1102 * \returns Fault_BootDuringEnable Status Signal Object
1103 */
1105
1106 /**
1107 * \brief Device boot while detecting the enable signal
1108 *
1109 * - Default Value: False
1110 *
1111 * Default Rates:
1112 * - CAN: 4.0 Hz
1113 *
1114 * This refreshes and returns a cached StatusSignal object.
1115 *
1116 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1117 * \returns StickyFault_BootDuringEnable Status Signal Object
1118 */
1120
1121 /**
1122 * \brief An unlicensed feature is in use, device may not behave as
1123 * expected.
1124 *
1125 * - Default Value: False
1126 *
1127 * Default Rates:
1128 * - CAN: 4.0 Hz
1129 *
1130 * This refreshes and returns a cached StatusSignal object.
1131 *
1132 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1133 * \returns Fault_UnlicensedFeatureInUse Status Signal Object
1134 */
1136
1137 /**
1138 * \brief An unlicensed feature is in use, device may not behave as
1139 * expected.
1140 *
1141 * - Default Value: False
1142 *
1143 * Default Rates:
1144 * - CAN: 4.0 Hz
1145 *
1146 * This refreshes and returns a cached StatusSignal object.
1147 *
1148 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1149 * \returns StickyFault_UnlicensedFeatureInUse Status Signal Object
1150 */
1152
1153 /**
1154 * \brief The magnet distance is not correct or magnet is missing
1155 *
1156 * - Default Value: False
1157 *
1158 * Default Rates:
1159 * - CAN: 4.0 Hz
1160 *
1161 * This refreshes and returns a cached StatusSignal object.
1162 *
1163 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1164 * \returns Fault_BadMagnet Status Signal Object
1165 */
1167
1168 /**
1169 * \brief The magnet distance is not correct or magnet is missing
1170 *
1171 * - Default Value: False
1172 *
1173 * Default Rates:
1174 * - CAN: 4.0 Hz
1175 *
1176 * This refreshes and returns a cached StatusSignal object.
1177 *
1178 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1179 * \returns StickyFault_BadMagnet Status Signal Object
1180 */
1182
1183
1184
1185 /**
1186 * \brief Control device with generic control request object. User must make
1187 * sure the specified object is castable to a valid control request,
1188 * otherwise this function will fail at run-time and return the NotSupported
1189 * StatusCode
1190 *
1191 * \param request Control object to request of the device
1192 * \returns Status Code of the request, 0 is OK
1193 */
1195 {
1196 controls::ControlRequest const *ptr = &request;
1197 (void)ptr;
1198
1200 }
1201
1202
1203 /**
1204 * \brief Sets the current position of the device.
1205 *
1206 * \param newValue Value to set to. Units are in rotations.
1207 * \param timeoutSeconds Maximum time to wait up to in seconds.
1208 * \returns StatusCode of the set command
1209 */
1210 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
1211 {
1212 return GetConfigurator().SetPosition(newValue, timeoutSeconds);
1213 }
1214 /**
1215 * \brief Sets the current position of the device.
1216 *
1217 * This will wait up to 0.100 seconds (100ms) by default.
1218 *
1219 * \param newValue Value to set to. Units are in rotations.
1220 * \returns StatusCode of the set command
1221 */
1222 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
1223 {
1224 return SetPosition(newValue, 0.100_s);
1225 }
1226
1227 /**
1228 * \brief Clear the sticky faults in the device.
1229 *
1230 * \details This typically has no impact on the device functionality.
1231 * Instead, it just clears telemetry faults that are accessible via
1232 * API and Tuner Self-Test.
1233 *
1234 * \param timeoutSeconds Maximum time to wait up to in seconds.
1235 * \returns StatusCode of the set command
1236 */
1237 ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
1238 {
1239 return GetConfigurator().ClearStickyFaults(timeoutSeconds);
1240 }
1241 /**
1242 * \brief Clear the sticky faults in the device.
1243 *
1244 * \details This typically has no impact on the device functionality.
1245 * Instead, it just clears telemetry faults that are accessible via
1246 * API and Tuner Self-Test.
1247 *
1248 * This will wait up to 0.100 seconds (100ms) by default.
1249 *
1250 * \returns StatusCode of the set command
1251 */
1256
1257 /**
1258 * \brief Clear sticky fault: Hardware fault occurred
1259 *
1260 * \param timeoutSeconds Maximum time to wait up to in seconds.
1261 * \returns StatusCode of the set command
1262 */
1263 ctre::phoenix::StatusCode ClearStickyFault_Hardware(units::time::second_t timeoutSeconds)
1264 {
1265 return GetConfigurator().ClearStickyFault_Hardware(timeoutSeconds);
1266 }
1267 /**
1268 * \brief Clear sticky fault: Hardware fault occurred
1269 *
1270 * This will wait up to 0.100 seconds (100ms) by default.
1271 *
1272 * \returns StatusCode of the set command
1273 */
1278
1279 /**
1280 * \brief Clear sticky fault: Device supply voltage dropped to near
1281 * brownout levels
1282 *
1283 * \param timeoutSeconds Maximum time to wait up to in seconds.
1284 * \returns StatusCode of the set command
1285 */
1286 ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(units::time::second_t timeoutSeconds)
1287 {
1288 return GetConfigurator().ClearStickyFault_Undervoltage(timeoutSeconds);
1289 }
1290 /**
1291 * \brief Clear sticky fault: Device supply voltage dropped to near
1292 * brownout levels
1293 *
1294 * This will wait up to 0.100 seconds (100ms) by default.
1295 *
1296 * \returns StatusCode of the set command
1297 */
1302
1303 /**
1304 * \brief Clear sticky fault: Device boot while detecting the enable
1305 * signal
1306 *
1307 * \param timeoutSeconds Maximum time to wait up to in seconds.
1308 * \returns StatusCode of the set command
1309 */
1311 {
1312 return GetConfigurator().ClearStickyFault_BootDuringEnable(timeoutSeconds);
1313 }
1314 /**
1315 * \brief Clear sticky fault: Device boot while detecting the enable
1316 * signal
1317 *
1318 * This will wait up to 0.100 seconds (100ms) by default.
1319 *
1320 * \returns StatusCode of the set command
1321 */
1326
1327 /**
1328 * \brief Clear sticky fault: An unlicensed feature is in use, device
1329 * may not behave as expected.
1330 *
1331 * \param timeoutSeconds Maximum time to wait up to in seconds.
1332 * \returns StatusCode of the set command
1333 */
1335 {
1337 }
1338 /**
1339 * \brief Clear sticky fault: An unlicensed feature is in use, device
1340 * may not behave as expected.
1341 *
1342 * This will wait up to 0.100 seconds (100ms) by default.
1343 *
1344 * \returns StatusCode of the set command
1345 */
1350
1351 /**
1352 * \brief Clear sticky fault: The magnet distance is not correct or
1353 * magnet is missing
1354 *
1355 * \param timeoutSeconds Maximum time to wait up to in seconds.
1356 * \returns StatusCode of the set command
1357 */
1358 ctre::phoenix::StatusCode ClearStickyFault_BadMagnet(units::time::second_t timeoutSeconds)
1359 {
1360 return GetConfigurator().ClearStickyFault_BadMagnet(timeoutSeconds);
1361 }
1362 /**
1363 * \brief Clear sticky fault: The magnet distance is not correct or
1364 * magnet is missing
1365 *
1366 * This will wait up to 0.100 seconds (100ms) by default.
1367 *
1368 * \returns StatusCode of the set command
1369 */
1374};
1375
1376}
1377}
1378
1379}
1380}
1381
ii that the Software will be uninterrupted or error free
Definition CTRE_LICENSE.txt:251
CTREXPORT int c_ctre_phoenix6_serialize_double(int spn, double value, char **str)
Class for getting information about an available CAN bus.
Definition CANBus.hpp:19
Represents a status signal with data of type T, and operations available to retrieve information abou...
Definition StatusSignal.hpp:656
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition CoreCANcoder.hpp:38
MagnetSensorConfigs MagnetSensor
Configs that affect the magnet sensor and how to interpret it.
Definition CoreCANcoder.hpp:72
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize)
Take a string and deserialize it to this configuration.
Definition CoreCANcoder.hpp:161
constexpr CANcoderConfiguration & WithMagnetSensor(MagnetSensorConfigs newMagnetSensor)
Modifies this configuration's MagnetSensor parameter and returns itself for method-chaining and easie...
Definition CoreCANcoder.hpp:106
bool FutureProofConfigs
True if we should factory default newer unsupported configs, false to leave newer unsupported configs...
Definition CoreCANcoder.hpp:55
CustomParamsConfigs CustomParams
Custom Params.
Definition CoreCANcoder.hpp:85
constexpr CANcoderConfiguration & WithCustomParams(CustomParamsConfigs newCustomParams)
Modifies this configuration's CustomParams parameter and returns itself for method-chaining and easie...
Definition CoreCANcoder.hpp:129
std::string ToString() const
Get the string representation of this configuration.
Definition CoreCANcoder.hpp:138
std::string Serialize() const
Get the serialized form of this configuration.
Definition CoreCANcoder.hpp:150
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition CoreCANcoder.hpp:177
ctre::phoenix::StatusCode Refresh(MagnetSensorConfigs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANcoder.hpp:258
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet()
Clear sticky fault: The magnet distance is not correct or magnet is missing.
Definition CoreCANcoder.hpp:621
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse()
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
Definition CoreCANcoder.hpp:582
ctre::phoenix::StatusCode Apply(const CustomParamsConfigs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANcoder.hpp:349
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet(units::time::second_t timeoutSeconds)
Clear sticky fault: The magnet distance is not correct or magnet is missing.
Definition CoreCANcoder.hpp:638
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage()
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANcoder.hpp:504
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable()
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANcoder.hpp:543
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable(units::time::second_t timeoutSeconds)
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANcoder.hpp:560
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
Sets the current position of the device.
Definition CoreCANcoder.hpp:383
ctre::phoenix::StatusCode ClearStickyFaults()
Clear the sticky faults in the device.
Definition CoreCANcoder.hpp:425
ctre::phoenix::StatusCode Apply(const CANcoderConfiguration &configs)
Applies the contents of the specified config to the device.
Definition CoreCANcoder.hpp:228
ctre::phoenix::StatusCode Apply(const CANcoderConfiguration &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANcoder.hpp:242
ctre::phoenix::StatusCode Refresh(CANcoderConfiguration &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANcoder.hpp:210
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(units::time::second_t timeoutSeconds)
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANcoder.hpp:521
ctre::phoenix::StatusCode Apply(const CustomParamsConfigs &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANcoder.hpp:363
ctre::phoenix::StatusCode Apply(const MagnetSensorConfigs &configs, units::time::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANcoder.hpp:303
ctre::phoenix::StatusCode ClearStickyFault_Hardware()
Clear sticky fault: Hardware fault occurred.
Definition CoreCANcoder.hpp:466
ctre::phoenix::StatusCode Refresh(CANcoderConfiguration &configs) const
Refreshes the values of the specified config group.
Definition CoreCANcoder.hpp:196
ctre::phoenix::StatusCode Refresh(CustomParamsConfigs &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANcoder.hpp:331
ctre::phoenix::StatusCode ClearStickyFault_Hardware(units::time::second_t timeoutSeconds)
Clear sticky fault: Hardware fault occurred.
Definition CoreCANcoder.hpp:482
ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
Clear the sticky faults in the device.
Definition CoreCANcoder.hpp:445
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse(units::time::second_t timeoutSeconds)
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
Definition CoreCANcoder.hpp:599
ctre::phoenix::StatusCode Refresh(CustomParamsConfigs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANcoder.hpp:318
ctre::phoenix::StatusCode Refresh(MagnetSensorConfigs &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANcoder.hpp:271
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
Sets the current position of the device.
Definition CoreCANcoder.hpp:400
ctre::phoenix::StatusCode Apply(const MagnetSensorConfigs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANcoder.hpp:289
Custom Params.
Definition Configs.hpp:4576
std::string ToString() const override
Definition Configs.hpp:4645
std::string Serialize() const override
Definition Configs.hpp:4654
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:4663
Configs that affect the magnet sensor and how to interpret it.
Definition Configs.hpp:60
std::string Serialize() const override
Definition Configs.hpp:226
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:236
std::string ToString() const override
Definition Configs.hpp:216
Definition Configurator.hpp:22
ctre::phoenix::StatusCode SetConfigsPrivate(const std::string &serializedString, units::time::second_t timeoutSeconds, bool futureProofConfigs, bool overrideIfDuplicate)
Definition Configurator.hpp:77
ctre::phoenix::StatusCode GetConfigsPrivate(std::string &serializedString, units::time::second_t timeoutSeconds) const
Definition Configurator.hpp:101
units::time::second_t DefaultTimeoutSeconds
The default maximum amount of time to wait for a config.
Definition Configurator.hpp:27
Abstract Control Request class that other control requests extend for use.
Definition ControlRequest.hpp:30
Definition DeviceIdentifier.hpp:19
Parent class for all devices.
Definition ParentDevice.hpp:28
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition CoreCANcoder.hpp:657
StatusSignal< int > & GetVersionMinor(bool refresh=true)
App Minor Version number.
StatusSignal< int > & GetVersionBugfix(bool refresh=true)
App Bugfix Version number.
ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
Clear the sticky faults in the device.
Definition CoreCANcoder.hpp:1237
CoreCANcoder(int deviceId, CANBus canbus)
Constructs a new CANcoder object.
Definition CoreCANcoder.hpp:686
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage()
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANcoder.hpp:1298
StatusSignal< bool > & GetStickyFault_Hardware(bool refresh=true)
Hardware fault occurred.
StatusSignal< bool > & GetFault_Hardware(bool refresh=true)
Hardware fault occurred.
StatusSignal< bool > & GetStickyFault_BadMagnet(bool refresh=true)
The magnet distance is not correct or magnet is missing.
StatusSignal< bool > & GetStickyFault_BootDuringEnable(bool refresh=true)
Device boot while detecting the enable signal.
ctre::phoenix::StatusCode ClearStickyFaults()
Clear the sticky faults in the device.
Definition CoreCANcoder.hpp:1252
configs::CANcoderConfigurator & GetConfigurator()
Gets the configurator for this CANcoder.
Definition CoreCANcoder.hpp:697
CoreCANcoder(int deviceId, std::string canbus="")
Constructs a new CANcoder object.
StatusSignal< int > & GetVersionBuild(bool refresh=true)
App Build Version number.
StatusSignal< units::angular_velocity::turns_per_second_t > & GetUnfilteredVelocity(bool refresh=true)
The unfiltered velocity reported by CANcoder.
ctre::phoenix::StatusCode ClearStickyFault_Hardware(units::time::second_t timeoutSeconds)
Clear sticky fault: Hardware fault occurred.
Definition CoreCANcoder.hpp:1263
StatusSignal< units::angle::turn_t > & GetPosition(bool refresh=true)
Position of the device.
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse()
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
Definition CoreCANcoder.hpp:1346
StatusSignal< int > & GetStickyFaultField(bool refresh=true)
Integer representing all (persistent) sticky fault flags reported by the device.
StatusSignal< units::angular_velocity::turns_per_second_t > & GetVelocity(bool refresh=true)
Velocity of the device.
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(units::time::second_t timeoutSeconds)
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANcoder.hpp:1286
StatusSignal< int > & GetVersionMajor(bool refresh=true)
App Major Version number.
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
Sets the current position of the device.
Definition CoreCANcoder.hpp:1222
StatusSignal< signals::MagnetHealthValue > & GetMagnetHealth(bool refresh=true)
Magnet health as measured by CANcoder.
sim::CANcoderSimState & GetSimState()
Get the simulation state for this device.
Definition CoreCANcoder.hpp:727
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet()
Clear sticky fault: The magnet distance is not correct or magnet is missing.
Definition CoreCANcoder.hpp:1370
StatusSignal< units::angle::turn_t > & GetAbsolutePosition(bool refresh=true)
Absolute Position of the device.
StatusSignal< units::voltage::volt_t > & GetSupplyVoltage(bool refresh=true)
Measured supply voltage to the CANcoder.
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable(units::time::second_t timeoutSeconds)
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANcoder.hpp:1310
StatusSignal< int > & GetVersion(bool refresh=true)
Full Version of firmware in device.
StatusSignal< bool > & GetStickyFault_UnlicensedFeatureInUse(bool refresh=true)
An unlicensed feature is in use, device may not behave as expected.
StatusSignal< bool > & GetFault_BootDuringEnable(bool refresh=true)
Device boot while detecting the enable signal.
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet(units::time::second_t timeoutSeconds)
Clear sticky fault: The magnet distance is not correct or magnet is missing.
Definition CoreCANcoder.hpp:1358
StatusSignal< units::angle::turn_t > & GetPositionSinceBoot(bool refresh=true)
The relative position reported by the CANcoder since boot.
StatusSignal< int > & GetFaultField(bool refresh=true)
Integer representing all fault flags reported by the device.
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
Sets the current position of the device.
Definition CoreCANcoder.hpp:1210
StatusSignal< bool > & GetFault_UnlicensedFeatureInUse(bool refresh=true)
An unlicensed feature is in use, device may not behave as expected.
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse(units::time::second_t timeoutSeconds)
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
Definition CoreCANcoder.hpp:1334
StatusSignal< bool > & GetIsProLicensed(bool refresh=true)
Whether the device is Phoenix Pro licensed.
ctre::phoenix::StatusCode ClearStickyFault_Hardware()
Clear sticky fault: Hardware fault occurred.
Definition CoreCANcoder.hpp:1274
ctre::phoenix::StatusCode SetControl(const controls::ControlRequest &request)
Control device with generic control request object.
Definition CoreCANcoder.hpp:1194
StatusSignal< bool > & GetFault_Undervoltage(bool refresh=true)
Device supply voltage dropped to near brownout levels.
StatusSignal< bool > & GetStickyFault_Undervoltage(bool refresh=true)
Device supply voltage dropped to near brownout levels.
StatusSignal< bool > & GetFault_BadMagnet(bool refresh=true)
The magnet distance is not correct or magnet is missing.
configs::CANcoderConfigurator const & GetConfigurator() const
Gets the configurator for this CANcoder.
Definition CoreCANcoder.hpp:709
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable()
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANcoder.hpp:1322
Class to control the state of a simulated hardware::CANcoder.
Definition CANcoderSimState.hpp:32
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:27
static constexpr int OK
No Error.
Definition StatusCodes.h:34
static constexpr int NotSupported
This is not supported.
Definition StatusCodes.h:652
Definition Diff_PositionDutyCycle_Position.hpp:15
Definition span.hpp:401