CTRE Phoenix 6 C++ 26.70.0-alpha-2
Loading...
Searching...
No Matches
CoreCANdi.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
19
21#include <wpi/units/angle.hpp>
22#include <wpi/units/angular_velocity.hpp>
23#include <wpi/units/current.hpp>
24#include <wpi/units/time.hpp>
25#include <wpi/units/voltage.hpp>
26
27namespace ctre {
28namespace phoenix6 {
29
30namespace hardware {
31namespace core {
32 class CoreCANdi;
33}
34}
35
36namespace configs {
37
38/**
39 * All configurations for the hardware#CANdi.
40 */
42{
43public:
44 constexpr CANdiConfiguration() = default;
45
46 /**
47 * \brief True if we should factory default newer unsupported configs,
48 * false to leave newer unsupported configs alone.
49 *
50 * \details This flag addresses a corner case where the device may have
51 * firmware with newer configs that didn't exist when this
52 * version of the API was built. If this occurs and this
53 * flag is true, unsupported new configs will be factory
54 * defaulted to avoid unexpected behavior.
55 *
56 * This is also the behavior in Phoenix 5, so this flag
57 * is defaulted to true to match.
58 */
60
61
62 /**
63 * \brief Custom Params.
64 *
65 * \details Custom paramaters that have no real impact on controller.
66 *
67 * Parameter list:
68 *
69 * - CustomParamsConfigs#CustomParam0
70 * - CustomParamsConfigs#CustomParam1
71 *
72 */
74
75 /**
76 * \brief Configs related to the CANdi™ branded device's digital I/O
77 * settings
78 *
79 * \details Contains float-state settings and when to assert the S1/S2
80 * inputs.
81 *
82 * Parameter list:
83 *
84 * - DigitalInputsConfigs#S1FloatState
85 * - DigitalInputsConfigs#S2FloatState
86 * - DigitalInputsConfigs#S1CloseState
87 * - DigitalInputsConfigs#S2CloseState
88 *
89 */
91
92 /**
93 * \brief Configs related to the CANdi™ branded device's quadrature
94 * interface using both the S1IN and S2IN inputs
95 *
96 * \details All the configs related to the quadrature interface for
97 * the CANdi™ branded device , including encoder edges per
98 * revolution and sensor direction.
99 *
100 * Parameter list:
101 *
102 * - QuadratureConfigs#QuadratureEdgesPerRotation
103 * - QuadratureConfigs#SensorDirection
104 *
105 */
107
108 /**
109 * \brief Configs related to the CANdi™ branded device's PWM interface
110 * on the Signal 1 input (S1IN)
111 *
112 * \details All the configs related to the PWM interface for the
113 * CANdi™ branded device on S1, including absolute sensor
114 * offset, absolute sensor discontinuity point and sensor
115 * direction.
116 *
117 * Parameter list:
118 *
119 * - PWM1Configs#AbsoluteSensorOffset
120 * - PWM1Configs#AbsoluteSensorDiscontinuityPoint
121 * - PWM1Configs#SensorDirection
122 *
123 */
125
126 /**
127 * \brief Configs related to the CANdi™ branded device's PWM interface
128 * on the Signal 2 input (S2IN)
129 *
130 * \details All the configs related to the PWM interface for the
131 * CANdi™ branded device on S1, including absolute sensor
132 * offset, absolute sensor discontinuity point and sensor
133 * direction.
134 *
135 * Parameter list:
136 *
137 * - PWM2Configs#AbsoluteSensorOffset
138 * - PWM2Configs#AbsoluteSensorDiscontinuityPoint
139 * - PWM2Configs#SensorDirection
140 *
141 */
143
144 /**
145 * \brief Modifies this configuration's CustomParams parameter and returns itself for
146 * method-chaining and easier to use config API.
147 *
148 * Custom Params.
149 *
150 * \details Custom paramaters that have no real impact on controller.
151 *
152 * Parameter list:
153 *
154 * - CustomParamsConfigs#CustomParam0
155 * - CustomParamsConfigs#CustomParam1
156 *
157 *
158 * \param newCustomParams Parameter to modify
159 * \returns Itself
160 */
162 {
163 CustomParams = std::move(newCustomParams);
164 return *this;
165 }
166
167 /**
168 * \brief Modifies this configuration's DigitalInputs parameter and returns itself for
169 * method-chaining and easier to use config API.
170 *
171 * Configs related to the CANdi™ branded device's digital I/O settings
172 *
173 * \details Contains float-state settings and when to assert the S1/S2
174 * inputs.
175 *
176 * Parameter list:
177 *
178 * - DigitalInputsConfigs#S1FloatState
179 * - DigitalInputsConfigs#S2FloatState
180 * - DigitalInputsConfigs#S1CloseState
181 * - DigitalInputsConfigs#S2CloseState
182 *
183 *
184 * \param newDigitalInputs Parameter to modify
185 * \returns Itself
186 */
188 {
189 DigitalInputs = std::move(newDigitalInputs);
190 return *this;
191 }
192
193 /**
194 * \brief Modifies this configuration's Quadrature parameter and returns itself for
195 * method-chaining and easier to use config API.
196 *
197 * Configs related to the CANdi™ branded device's quadrature interface
198 * using both the S1IN and S2IN inputs
199 *
200 * \details All the configs related to the quadrature interface for
201 * the CANdi™ branded device , including encoder edges per
202 * revolution and sensor direction.
203 *
204 * Parameter list:
205 *
206 * - QuadratureConfigs#QuadratureEdgesPerRotation
207 * - QuadratureConfigs#SensorDirection
208 *
209 *
210 * \param newQuadrature Parameter to modify
211 * \returns Itself
212 */
214 {
215 Quadrature = std::move(newQuadrature);
216 return *this;
217 }
218
219 /**
220 * \brief Modifies this configuration's PWM1 parameter and returns itself for
221 * method-chaining and easier to use config API.
222 *
223 * Configs related to the CANdi™ branded device's PWM interface on the
224 * Signal 1 input (S1IN)
225 *
226 * \details All the configs related to the PWM interface for the
227 * CANdi™ branded device on S1, including absolute sensor
228 * offset, absolute sensor discontinuity point and sensor
229 * direction.
230 *
231 * Parameter list:
232 *
233 * - PWM1Configs#AbsoluteSensorOffset
234 * - PWM1Configs#AbsoluteSensorDiscontinuityPoint
235 * - PWM1Configs#SensorDirection
236 *
237 *
238 * \param newPWM1 Parameter to modify
239 * \returns Itself
240 */
242 {
243 PWM1 = std::move(newPWM1);
244 return *this;
245 }
246
247 /**
248 * \brief Modifies this configuration's PWM2 parameter and returns itself for
249 * method-chaining and easier to use config API.
250 *
251 * Configs related to the CANdi™ branded device's PWM interface on the
252 * Signal 2 input (S2IN)
253 *
254 * \details All the configs related to the PWM interface for the
255 * CANdi™ branded device on S1, including absolute sensor
256 * offset, absolute sensor discontinuity point and sensor
257 * direction.
258 *
259 * Parameter list:
260 *
261 * - PWM2Configs#AbsoluteSensorOffset
262 * - PWM2Configs#AbsoluteSensorDiscontinuityPoint
263 * - PWM2Configs#SensorDirection
264 *
265 *
266 * \param newPWM2 Parameter to modify
267 * \returns Itself
268 */
270 {
271 PWM2 = std::move(newPWM2);
272 return *this;
273 }
274
275 /**
276 * \brief Get the string representation of this configuration
277 */
278 std::string ToString() const override;
279
280 /**
281 * \brief Get the serialized form of this configuration
282 */
283 std::string Serialize() const final;
284 /**
285 * \brief Take a string and deserialize it to this configuration
286 */
287 ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final;
288};
289
290/**
291 * Handles applying and refreshing configurations for the hardware#CANdi.
292 */
293class CANdiConfigurator : public ParentConfigurator
294{
295private:
296 CANdiConfigurator(hardware::DeviceIdentifier id) :
297 ParentConfigurator{std::move(id)}
298 {}
299
301
302public:
303 /**
304 * \brief Applies the contents of the specified config to the device.
305 *
306 * This will wait up to #DefaultTimeoutSeconds.
307 *
308 * \details Call to apply the selected configs.
309 *
310 * \param configs Configs to apply against.
311 * \returns Status code of applying the configs
312 */
317
318 /**
319 * \brief Applies the contents of the specified config to the device.
320 *
321 * \details Call to apply the selected configs.
322 *
323 * \param configs Configs to apply against.
324 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
325 * \returns Status code of applying the configs
326 */
327 ctre::phoenix::StatusCode Apply(const CANdiConfiguration &configs, wpi::units::second_t timeoutSeconds)
328 {
329 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, configs.FutureProofConfigs, false);
330 }
331
332 /**
333 * \brief Applies the contents of the specified config to the device.
334 *
335 * This will wait up to #DefaultTimeoutSeconds.
336 *
337 * \details Call to apply the selected configs.
338 *
339 * \param configs Configs to apply against.
340 * \returns Status code of applying the configs
341 */
346
347 /**
348 * \brief Applies the contents of the specified config to the device.
349 *
350 * \details Call to apply the selected configs.
351 *
352 * \param configs Configs to apply against.
353 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
354 * \returns Status code of applying the configs
355 */
356 ctre::phoenix::StatusCode Apply(const CustomParamsConfigs &configs, wpi::units::second_t timeoutSeconds)
357 {
358 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, false, false);
359 }
360
361 /**
362 * \brief Applies the contents of the specified config to the device.
363 *
364 * This will wait up to #DefaultTimeoutSeconds.
365 *
366 * \details Call to apply the selected configs.
367 *
368 * \param configs Configs to apply against.
369 * \returns Status code of applying the configs
370 */
375
376 /**
377 * \brief Applies the contents of the specified config to the device.
378 *
379 * \details Call to apply the selected configs.
380 *
381 * \param configs Configs to apply against.
382 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
383 * \returns Status code of applying the configs
384 */
385 ctre::phoenix::StatusCode Apply(const DigitalInputsConfigs &configs, wpi::units::second_t timeoutSeconds)
386 {
387 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, false, false);
388 }
389
390 /**
391 * \brief Applies the contents of the specified config to the device.
392 *
393 * This will wait up to #DefaultTimeoutSeconds.
394 *
395 * \details Call to apply the selected configs.
396 *
397 * \param configs Configs to apply against.
398 * \returns Status code of applying the configs
399 */
404
405 /**
406 * \brief Applies the contents of the specified config to the device.
407 *
408 * \details Call to apply the selected configs.
409 *
410 * \param configs Configs to apply against.
411 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
412 * \returns Status code of applying the configs
413 */
414 ctre::phoenix::StatusCode Apply(const QuadratureConfigs &configs, wpi::units::second_t timeoutSeconds)
415 {
416 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, false, false);
417 }
418
419 /**
420 * \brief Applies the contents of the specified config to the device.
421 *
422 * This will wait up to #DefaultTimeoutSeconds.
423 *
424 * \details Call to apply the selected configs.
425 *
426 * \param configs Configs to apply against.
427 * \returns Status code of applying the configs
428 */
433
434 /**
435 * \brief Applies the contents of the specified config to the device.
436 *
437 * \details Call to apply the selected configs.
438 *
439 * \param configs Configs to apply against.
440 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
441 * \returns Status code of applying the configs
442 */
443 ctre::phoenix::StatusCode Apply(const PWM1Configs &configs, wpi::units::second_t timeoutSeconds)
444 {
445 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, false, false);
446 }
447
448 /**
449 * \brief Applies the contents of the specified config to the device.
450 *
451 * This will wait up to #DefaultTimeoutSeconds.
452 *
453 * \details Call to apply the selected configs.
454 *
455 * \param configs Configs to apply against.
456 * \returns Status code of applying the configs
457 */
462
463 /**
464 * \brief Applies the contents of the specified config to the device.
465 *
466 * \details Call to apply the selected configs.
467 *
468 * \param configs Configs to apply against.
469 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
470 * \returns Status code of applying the configs
471 */
472 ctre::phoenix::StatusCode Apply(const PWM2Configs &configs, wpi::units::second_t timeoutSeconds)
473 {
474 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, false, false);
475 }
476
477 /**
478 * \brief Refreshes the values of the specified config group.
479 *
480 * This will wait up to #DefaultTimeoutSeconds.
481 *
482 * \details Call to refresh the selected configs from the device.
483 *
484 * \param configs The configs to refresh
485 * \returns Status code of refreshing the configs
486 */
491
492 /**
493 * \brief Refreshes the values of the specified config group.
494 *
495 * \details Call to refresh the selected configs from the device.
496 *
497 * \param configs The configs to refresh
498 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
499 * \returns Status code of refreshing the configs
500 */
501 ctre::phoenix::StatusCode Refresh(CANdiConfiguration &configs, wpi::units::second_t timeoutSeconds) const
502 {
503 std::string ref;
504 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
505 configs.Deserialize(ref);
506 return ret;
507 }
508
509 /**
510 * \brief Refreshes the values of the specified config group.
511 *
512 * This will wait up to #DefaultTimeoutSeconds.
513 *
514 * \details Call to refresh the selected configs from the device.
515 *
516 * \param configs The configs to refresh
517 * \returns Status code of refreshing the configs
518 */
523 /**
524 * \brief Refreshes the values of the specified config group.
525 *
526 * \details Call to refresh the selected configs from the device.
527 *
528 * \param configs The configs to refresh
529 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
530 * \returns Status code of refreshing the configs
531 */
532 ctre::phoenix::StatusCode Refresh(CustomParamsConfigs &configs, wpi::units::second_t timeoutSeconds) const
533 {
534 std::string ref;
535 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
536 configs.Deserialize(ref);
537 return ret;
538 }
539
540 /**
541 * \brief Refreshes the values of the specified config group.
542 *
543 * This will wait up to #DefaultTimeoutSeconds.
544 *
545 * \details Call to refresh the selected configs from the device.
546 *
547 * \param configs The configs to refresh
548 * \returns Status code of refreshing the configs
549 */
554 /**
555 * \brief Refreshes the values of the specified config group.
556 *
557 * \details Call to refresh the selected configs from the device.
558 *
559 * \param configs The configs to refresh
560 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
561 * \returns Status code of refreshing the configs
562 */
563 ctre::phoenix::StatusCode Refresh(DigitalInputsConfigs &configs, wpi::units::second_t timeoutSeconds) const
564 {
565 std::string ref;
566 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
567 configs.Deserialize(ref);
568 return ret;
569 }
570
571 /**
572 * \brief Refreshes the values of the specified config group.
573 *
574 * This will wait up to #DefaultTimeoutSeconds.
575 *
576 * \details Call to refresh the selected configs from the device.
577 *
578 * \param configs The configs to refresh
579 * \returns Status code of refreshing the configs
580 */
585 /**
586 * \brief Refreshes the values of the specified config group.
587 *
588 * \details Call to refresh the selected configs from the device.
589 *
590 * \param configs The configs to refresh
591 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
592 * \returns Status code of refreshing the configs
593 */
594 ctre::phoenix::StatusCode Refresh(QuadratureConfigs &configs, wpi::units::second_t timeoutSeconds) const
595 {
596 std::string ref;
597 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
598 configs.Deserialize(ref);
599 return ret;
600 }
601
602 /**
603 * \brief Refreshes the values of the specified config group.
604 *
605 * This will wait up to #DefaultTimeoutSeconds.
606 *
607 * \details Call to refresh the selected configs from the device.
608 *
609 * \param configs The configs to refresh
610 * \returns Status code of refreshing the configs
611 */
616 /**
617 * \brief Refreshes the values of the specified config group.
618 *
619 * \details Call to refresh the selected configs from the device.
620 *
621 * \param configs The configs to refresh
622 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
623 * \returns Status code of refreshing the configs
624 */
625 ctre::phoenix::StatusCode Refresh(PWM1Configs &configs, wpi::units::second_t timeoutSeconds) const
626 {
627 std::string ref;
628 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
629 configs.Deserialize(ref);
630 return ret;
631 }
632
633 /**
634 * \brief Refreshes the values of the specified config group.
635 *
636 * This will wait up to #DefaultTimeoutSeconds.
637 *
638 * \details Call to refresh the selected configs from the device.
639 *
640 * \param configs The configs to refresh
641 * \returns Status code of refreshing the configs
642 */
647 /**
648 * \brief Refreshes the values of the specified config group.
649 *
650 * \details Call to refresh the selected configs from the device.
651 *
652 * \param configs The configs to refresh
653 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
654 * \returns Status code of refreshing the configs
655 */
656 ctre::phoenix::StatusCode Refresh(PWM2Configs &configs, wpi::units::second_t timeoutSeconds) const
657 {
658 std::string ref;
659 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
660 configs.Deserialize(ref);
661 return ret;
662 }
663
664
665 /**
666 * \brief Sets the position of the quadrature input.
667 *
668 * This will wait up to #DefaultTimeoutSeconds.
669 *
670 * This is available in the configurator in case the user wants
671 * to initialize their device entirely without passing a device
672 * reference down to the code that performs the initialization.
673 * In this case, the user passes down the configurator object
674 * and performs all the initialization code on the object.
675 *
676 * \param newValue Value to set to. Units are in rotations.
677 * \returns StatusCode of the set command
678 */
680 {
682 }
683 /**
684 * \brief Sets the position of the quadrature input.
685 *
686 * This is available in the configurator in case the user wants
687 * to initialize their device entirely without passing a device
688 * reference down to the code that performs the initialization.
689 * In this case, the user passes down the configurator object
690 * and performs all the initialization code on the object.
691 *
692 * \param newValue Value to set to. Units are in rotations.
693 * \param timeoutSeconds Maximum time to wait up to in seconds.
694 * \returns StatusCode of the set command
695 */
696 ctre::phoenix::StatusCode SetQuadraturePosition(wpi::units::turn_t newValue, wpi::units::second_t timeoutSeconds);
697
698 /**
699 * \brief Clear the sticky faults in the device.
700 *
701 * \details This typically has no impact on the device functionality.
702 * Instead, it just clears telemetry faults that are accessible via
703 * API and Tuner Self-Test.
704 *
705 * This will wait up to #DefaultTimeoutSeconds.
706 *
707 * This is available in the configurator in case the user wants
708 * to initialize their device entirely without passing a device
709 * reference down to the code that performs the initialization.
710 * In this case, the user passes down the configurator object
711 * and performs all the initialization code on the object.
712 *
713 * \returns StatusCode of the set command
714 */
719 /**
720 * \brief Clear the sticky faults in the device.
721 *
722 * \details This typically has no impact on the device functionality.
723 * Instead, it just clears telemetry faults that are accessible via
724 * API and Tuner Self-Test.
725 *
726 * This is available in the configurator in case the user wants
727 * to initialize their device entirely without passing a device
728 * reference down to the code that performs the initialization.
729 * In this case, the user passes down the configurator object
730 * and performs all the initialization code on the object.
731 *
732 * \param timeoutSeconds Maximum time to wait up to in seconds.
733 * \returns StatusCode of the set command
734 */
735 ctre::phoenix::StatusCode ClearStickyFaults(wpi::units::second_t timeoutSeconds);
736
737 /**
738 * \brief Clear sticky fault: Hardware fault occurred
739 *
740 * This will wait up to #DefaultTimeoutSeconds.
741 *
742 * This is available in the configurator in case the user wants
743 * to initialize their device entirely without passing a device
744 * reference down to the code that performs the initialization.
745 * In this case, the user passes down the configurator object
746 * and performs all the initialization code on the object.
747 *
748 * \returns StatusCode of the set command
749 */
754 /**
755 * \brief Clear sticky fault: Hardware fault occurred
756 *
757 * This is available in the configurator in case the user wants
758 * to initialize their device entirely without passing a device
759 * reference down to the code that performs the initialization.
760 * In this case, the user passes down the configurator object
761 * and performs all the initialization code on the object.
762 *
763 * \param timeoutSeconds Maximum time to wait up to in seconds.
764 * \returns StatusCode of the set command
765 */
766 ctre::phoenix::StatusCode ClearStickyFault_Hardware(wpi::units::second_t timeoutSeconds);
767
768 /**
769 * \brief Clear sticky fault: Device supply voltage dropped to near
770 * brownout levels
771 *
772 * This will wait up to #DefaultTimeoutSeconds.
773 *
774 * This is available in the configurator in case the user wants
775 * to initialize their device entirely without passing a device
776 * reference down to the code that performs the initialization.
777 * In this case, the user passes down the configurator object
778 * and performs all the initialization code on the object.
779 *
780 * \returns StatusCode of the set command
781 */
786 /**
787 * \brief Clear sticky fault: Device supply voltage dropped to near
788 * brownout levels
789 *
790 * This is available in the configurator in case the user wants
791 * to initialize their device entirely without passing a device
792 * reference down to the code that performs the initialization.
793 * In this case, the user passes down the configurator object
794 * and performs all the initialization code on the object.
795 *
796 * \param timeoutSeconds Maximum time to wait up to in seconds.
797 * \returns StatusCode of the set command
798 */
799 ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(wpi::units::second_t timeoutSeconds);
800
801 /**
802 * \brief Clear sticky fault: Device boot while detecting the enable
803 * signal
804 *
805 * This will wait up to #DefaultTimeoutSeconds.
806 *
807 * This is available in the configurator in case the user wants
808 * to initialize their device entirely without passing a device
809 * reference down to the code that performs the initialization.
810 * In this case, the user passes down the configurator object
811 * and performs all the initialization code on the object.
812 *
813 * \returns StatusCode of the set command
814 */
819 /**
820 * \brief Clear sticky fault: Device boot while detecting the enable
821 * signal
822 *
823 * This is available in the configurator in case the user wants
824 * to initialize their device entirely without passing a device
825 * reference down to the code that performs the initialization.
826 * In this case, the user passes down the configurator object
827 * and performs all the initialization code on the object.
828 *
829 * \param timeoutSeconds Maximum time to wait up to in seconds.
830 * \returns StatusCode of the set command
831 */
833
834 /**
835 * \brief Clear sticky fault: An unlicensed feature is in use, device
836 * may not behave as expected.
837 *
838 * This will wait up to #DefaultTimeoutSeconds.
839 *
840 * This is available in the configurator in case the user wants
841 * to initialize their device entirely without passing a device
842 * reference down to the code that performs the initialization.
843 * In this case, the user passes down the configurator object
844 * and performs all the initialization code on the object.
845 *
846 * \returns StatusCode of the set command
847 */
852 /**
853 * \brief Clear sticky fault: An unlicensed feature is in use, device
854 * may not behave as expected.
855 *
856 * This is available in the configurator in case the user wants
857 * to initialize their device entirely without passing a device
858 * reference down to the code that performs the initialization.
859 * In this case, the user passes down the configurator object
860 * and performs all the initialization code on the object.
861 *
862 * \param timeoutSeconds Maximum time to wait up to in seconds.
863 * \returns StatusCode of the set command
864 */
866
867 /**
868 * \brief Clear sticky fault: The CTR Electronics' CANdi™ branded
869 * device has detected a 5V fault. This may be due to overcurrent or a
870 * short-circuit.
871 *
872 * This will wait up to #DefaultTimeoutSeconds.
873 *
874 * This is available in the configurator in case the user wants
875 * to initialize their device entirely without passing a device
876 * reference down to the code that performs the initialization.
877 * In this case, the user passes down the configurator object
878 * and performs all the initialization code on the object.
879 *
880 * \returns StatusCode of the set command
881 */
886 /**
887 * \brief Clear sticky fault: The CTR Electronics' CANdi™ branded
888 * device has detected a 5V fault. This may be due to overcurrent or a
889 * short-circuit.
890 *
891 * This is available in the configurator in case the user wants
892 * to initialize their device entirely without passing a device
893 * reference down to the code that performs the initialization.
894 * In this case, the user passes down the configurator object
895 * and performs all the initialization code on the object.
896 *
897 * \param timeoutSeconds Maximum time to wait up to in seconds.
898 * \returns StatusCode of the set command
899 */
900 ctre::phoenix::StatusCode ClearStickyFault_5V(wpi::units::second_t timeoutSeconds);
901};
902
903}
904
905namespace hardware {
906namespace core {
907
908#if defined(_WIN32) || defined(_WIN64)
909#pragma warning(push)
910#pragma warning(disable : 4250)
911#endif
912
913/**
914 * Class for CTR Electronics' CANdi™ branded device, a device that integrates
915 * digital signals into the existing CAN bus network.
916 */
918{
919private:
921
922public:
923 /**
924 * \brief The configuration class for this device.
925 */
927
928 /**
929 * Constructs a new CANdi object.
930 *
931 * \param deviceId ID of the device, as configured in Phoenix Tuner
932 * \param canbus The CAN bus this device is on
933 */
934 CoreCANdi(int deviceId, CANBus canbus);
935
936 /**
937 * \brief Constructs a stubbed-out CoreCANdi, where all status signals, controls,
938 * configs, etc. perform no action and immediately return OK. This can be used to
939 * silence error messages for devices that have been completely removed from the robot.
940 *
941 * \returns Stubbed-out CoreCANdi
942 */
944 {
945 return CoreCANdi{-1, CANBus{}};
946 }
947
948 /**
949 * \brief Gets the configurator for this CANdi. Users may use this to refresh
950 * and apply configs.
951 *
952 * \returns Configurator for this CANdi
953 */
955 {
956 return _configs;
957 }
958
959 /**
960 * \brief Gets the configurator for this CANdi
961 *
962 * \details Gets the configurator for this CANdi
963 *
964 * \returns Configurator for this CANdi
965 */
967 {
968 return _configs;
969 }
970
971
972private:
973 std::unique_ptr<sim::CANdiSimState> _simState{};
974public:
975 /**
976 * \brief Get the simulation state for this device.
977 *
978 * \details This function reuses an allocated simulation
979 * state object, so it is safe to call this function multiple
980 * times in a robot loop.
981 *
982 * \returns Simulation state
983 */
985 {
986 if (_simState == nullptr)
987 _simState = std::make_unique<sim::CANdiSimState>(*this);
988 return *_simState;
989 }
990
991
992
993 /**
994 * \brief App Major Version number.
995 *
996 * - Minimum Value: 0
997 * - Maximum Value: 255
998 * - Default Value: 0
999 * - Units:
1000 *
1001 * Default Rates:
1002 * - CAN: 4.0 Hz
1003 *
1004 * This refreshes and returns a cached StatusSignal object.
1005 *
1006 * \param refresh Whether to refresh the StatusSignal before returning it;
1007 * defaults to true
1008 * \returns VersionMajor Status Signal Object
1009 */
1010 StatusSignal<int> &GetVersionMajor(bool refresh = true);
1011
1012 /**
1013 * \brief App Minor Version number.
1014 *
1015 * - Minimum Value: 0
1016 * - Maximum Value: 255
1017 * - Default Value: 0
1018 * - Units:
1019 *
1020 * Default Rates:
1021 * - CAN: 4.0 Hz
1022 *
1023 * This refreshes and returns a cached StatusSignal object.
1024 *
1025 * \param refresh Whether to refresh the StatusSignal before returning it;
1026 * defaults to true
1027 * \returns VersionMinor Status Signal Object
1028 */
1029 StatusSignal<int> &GetVersionMinor(bool refresh = true);
1030
1031 /**
1032 * \brief App Bugfix Version number.
1033 *
1034 * - Minimum Value: 0
1035 * - Maximum Value: 255
1036 * - Default Value: 0
1037 * - Units:
1038 *
1039 * Default Rates:
1040 * - CAN: 4.0 Hz
1041 *
1042 * This refreshes and returns a cached StatusSignal object.
1043 *
1044 * \param refresh Whether to refresh the StatusSignal before returning it;
1045 * defaults to true
1046 * \returns VersionBugfix Status Signal Object
1047 */
1049
1050 /**
1051 * \brief App Build Version number.
1052 *
1053 * - Minimum Value: 0
1054 * - Maximum Value: 255
1055 * - Default Value: 0
1056 * - Units:
1057 *
1058 * Default Rates:
1059 * - CAN: 4.0 Hz
1060 *
1061 * This refreshes and returns a cached StatusSignal object.
1062 *
1063 * \param refresh Whether to refresh the StatusSignal before returning it;
1064 * defaults to true
1065 * \returns VersionBuild Status Signal Object
1066 */
1067 StatusSignal<int> &GetVersionBuild(bool refresh = true);
1068
1069 /**
1070 * \brief Full Version of firmware in device. The format is a four
1071 * byte value.
1072 *
1073 * - Minimum Value: 0
1074 * - Maximum Value: 4294967295
1075 * - Default Value: 0
1076 * - Units:
1077 *
1078 * Default Rates:
1079 * - CAN: 4.0 Hz
1080 *
1081 * This refreshes and returns a cached StatusSignal object.
1082 *
1083 * \param refresh Whether to refresh the StatusSignal before returning it;
1084 * defaults to true
1085 * \returns Version Status Signal Object
1086 */
1087 StatusSignal<int> &GetVersion(bool refresh = true);
1088
1089 /**
1090 * \brief Integer representing all fault flags reported by the device.
1091 *
1092 * \details These are device specific and are not used directly in
1093 * typical applications. Use the signal specific GetFault_*() methods
1094 * instead.
1095 *
1096 * - Minimum Value: 0
1097 * - Maximum Value: 4294967295
1098 * - Default Value: 0
1099 * - Units:
1100 *
1101 * Default Rates:
1102 * - CAN: 4.0 Hz
1103 *
1104 * This refreshes and returns a cached StatusSignal object.
1105 *
1106 * \param refresh Whether to refresh the StatusSignal before returning it;
1107 * defaults to true
1108 * \returns FaultField Status Signal Object
1109 */
1110 StatusSignal<int> &GetFaultField(bool refresh = true);
1111
1112 /**
1113 * \brief Integer representing all (persistent) sticky fault flags
1114 * reported by the device.
1115 *
1116 * \details These are device specific and are not used directly in
1117 * typical applications. Use the signal specific GetStickyFault_*()
1118 * methods instead.
1119 *
1120 * - Minimum Value: 0
1121 * - Maximum Value: 4294967295
1122 * - Default Value: 0
1123 * - Units:
1124 *
1125 * Default Rates:
1126 * - CAN: 4.0 Hz
1127 *
1128 * This refreshes and returns a cached StatusSignal object.
1129 *
1130 * \param refresh Whether to refresh the StatusSignal before returning it;
1131 * defaults to true
1132 * \returns StickyFaultField Status Signal Object
1133 */
1135
1136 /**
1137 * \brief Whether the device is Phoenix Pro licensed.
1138 *
1139 * - Default Value: False
1140 *
1141 * Default Rates:
1142 * - CAN: 4.0 Hz
1143 *
1144 * This refreshes and returns a cached StatusSignal object.
1145 *
1146 * \param refresh Whether to refresh the StatusSignal before returning it;
1147 * defaults to true
1148 * \returns IsProLicensed Status Signal Object
1149 */
1151
1152 /**
1153 * \brief State of the Signal 1 input (S1IN).
1154 *
1155 * - Default Value: signals#S1StateValue#Floating
1156 *
1157 * Default Rates:
1158 * - CAN 2.0: 100.0 Hz
1159 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1160 *
1161 * This refreshes and returns a cached StatusSignal object.
1162 *
1163 * \param refresh Whether to refresh the StatusSignal before returning it;
1164 * defaults to true
1165 * \returns S1State Status Signal Object
1166 */
1168
1169 /**
1170 * \brief State of the Signal 2 input (S2IN).
1171 *
1172 * - Default Value: signals#S2StateValue#Floating
1173 *
1174 * Default Rates:
1175 * - CAN 2.0: 100.0 Hz
1176 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1177 *
1178 * This refreshes and returns a cached StatusSignal object.
1179 *
1180 * \param refresh Whether to refresh the StatusSignal before returning it;
1181 * defaults to true
1182 * \returns S2State Status Signal Object
1183 */
1185
1186 /**
1187 * \brief Position from a quadrature encoder sensor connected to both
1188 * the S1IN and S2IN inputs.
1189 *
1190 * - Minimum Value: -16384.0
1191 * - Maximum Value: 16383.999755859375
1192 * - Default Value: 0
1193 * - Units: rotations
1194 *
1195 * Default Rates:
1196 * - CAN 2.0: 20.0 Hz
1197 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1198 *
1199 * This refreshes and returns a cached StatusSignal object.
1200 *
1201 * \param refresh Whether to refresh the StatusSignal before returning it;
1202 * defaults to true
1203 * \returns QuadraturePosition Status Signal Object
1204 */
1206
1207 /**
1208 * \brief Measured rise to rise time of the PWM signal at the S1 input
1209 * of the CTR Electronics' CANdi™.
1210 *
1211 * - Minimum Value: 0
1212 * - Maximum Value: 131070
1213 * - Default Value: 0
1214 * - Units: us
1215 *
1216 * Default Rates:
1217 * - CAN 2.0: 20.0 Hz
1218 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1219 *
1220 * This refreshes and returns a cached StatusSignal object.
1221 *
1222 * \param refresh Whether to refresh the StatusSignal before returning it;
1223 * defaults to true
1224 * \returns PWM1RiseToRise Status Signal Object
1225 */
1227
1228 /**
1229 * \brief Measured position of the PWM sensor at the S1 input of the
1230 * CTR Electronics' CANdi™.
1231 *
1232 * - Minimum Value: -16384.0
1233 * - Maximum Value: 16383.999755859375
1234 * - Default Value: 0
1235 * - Units: rotations
1236 *
1237 * Default Rates:
1238 * - CAN 2.0: 20.0 Hz
1239 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1240 *
1241 * This refreshes and returns a cached StatusSignal object.
1242 *
1243 * \param refresh Whether to refresh the StatusSignal before returning it;
1244 * defaults to true
1245 * \returns PWM1Position Status Signal Object
1246 */
1248
1249 /**
1250 * \brief Measured velocity of the PWM sensor at the S1 input of the
1251 * CTR Electronics' CANdi™.
1252 *
1253 * - Minimum Value: -512.0
1254 * - Maximum Value: 511.998046875
1255 * - Default Value: 0
1256 * - Units: rotations per second
1257 *
1258 * Default Rates:
1259 * - CAN 2.0: 20.0 Hz
1260 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1261 *
1262 * This refreshes and returns a cached StatusSignal object.
1263 *
1264 * \param refresh Whether to refresh the StatusSignal before returning it;
1265 * defaults to true
1266 * \returns PWM1Velocity Status Signal Object
1267 */
1269
1270 /**
1271 * \brief Measured rise to rise time of the PWM signal at the S2 input
1272 * of the CTR Electronics' CANdi™.
1273 *
1274 * - Minimum Value: 0
1275 * - Maximum Value: 131070
1276 * - Default Value: 0
1277 * - Units: us
1278 *
1279 * Default Rates:
1280 * - CAN 2.0: 20.0 Hz
1281 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1282 *
1283 * This refreshes and returns a cached StatusSignal object.
1284 *
1285 * \param refresh Whether to refresh the StatusSignal before returning it;
1286 * defaults to true
1287 * \returns PWM2RiseToRise Status Signal Object
1288 */
1290
1291 /**
1292 * \brief Measured position of the PWM sensor at the S2 input of the
1293 * CTR Electronics' CANdi™.
1294 *
1295 * - Minimum Value: -16384.0
1296 * - Maximum Value: 16383.999755859375
1297 * - Default Value: 0
1298 * - Units: rotations
1299 *
1300 * Default Rates:
1301 * - CAN 2.0: 20.0 Hz
1302 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1303 *
1304 * This refreshes and returns a cached StatusSignal object.
1305 *
1306 * \param refresh Whether to refresh the StatusSignal before returning it;
1307 * defaults to true
1308 * \returns PWM2Position Status Signal Object
1309 */
1311
1312 /**
1313 * \brief True when the CANdi™ is in overcurrent protection mode. This
1314 * may be due to either overcurrent or a short-circuit.
1315 *
1316 * - Default Value: 0
1317 *
1318 * Default Rates:
1319 * - CAN 2.0: 100.0 Hz
1320 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1321 *
1322 * This refreshes and returns a cached StatusSignal object.
1323 *
1324 * \param refresh Whether to refresh the StatusSignal before returning it;
1325 * defaults to true
1326 * \returns Overcurrent Status Signal Object
1327 */
1328 StatusSignal<bool> &GetOvercurrent(bool refresh = true);
1329
1330 /**
1331 * \brief Measured supply voltage to the CANdi™.
1332 *
1333 * - Minimum Value: 4.0
1334 * - Maximum Value: 29.5
1335 * - Default Value: 0
1336 * - Units: V
1337 *
1338 * Default Rates:
1339 * - CAN 2.0: 100.0 Hz
1340 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1341 *
1342 * This refreshes and returns a cached StatusSignal object.
1343 *
1344 * \param refresh Whether to refresh the StatusSignal before returning it;
1345 * defaults to true
1346 * \returns SupplyVoltage Status Signal Object
1347 */
1349
1350 /**
1351 * \brief Measured output current. This includes both Vbat and 5V
1352 * output current.
1353 *
1354 * - Minimum Value: 0.0
1355 * - Maximum Value: 0.51
1356 * - Default Value: 0
1357 * - Units: A
1358 *
1359 * Default Rates:
1360 * - CAN 2.0: 100.0 Hz
1361 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1362 *
1363 * This refreshes and returns a cached StatusSignal object.
1364 *
1365 * \param refresh Whether to refresh the StatusSignal before returning it;
1366 * defaults to true
1367 * \returns OutputCurrent Status Signal Object
1368 */
1370
1371 /**
1372 * \brief Measured velocity of the PWM sensor at the S2 input of the
1373 * CTR Electronics' CANdi™.
1374 *
1375 * - Minimum Value: -512.0
1376 * - Maximum Value: 511.998046875
1377 * - Default Value: 0
1378 * - Units: rotations per second
1379 *
1380 * Default Rates:
1381 * - CAN 2.0: 20.0 Hz
1382 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1383 *
1384 * This refreshes and returns a cached StatusSignal object.
1385 *
1386 * \param refresh Whether to refresh the StatusSignal before returning it;
1387 * defaults to true
1388 * \returns PWM2Velocity Status Signal Object
1389 */
1391
1392 /**
1393 * \brief Velocity from a quadrature encoder sensor connected to both
1394 * the S1IN and S2IN inputs.
1395 *
1396 * - Minimum Value: -512.0
1397 * - Maximum Value: 511.998046875
1398 * - Default Value: 0
1399 * - Units: rotations per second
1400 *
1401 * Default Rates:
1402 * - CAN 2.0: 20.0 Hz
1403 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1404 *
1405 * This refreshes and returns a cached StatusSignal object.
1406 *
1407 * \param refresh Whether to refresh the StatusSignal before returning it;
1408 * defaults to true
1409 * \returns QuadratureVelocity Status Signal Object
1410 */
1412
1413 /**
1414 * \brief True if the Signal 1 input (S1IN) matches the configured S1
1415 * Closed State.
1416 *
1417 * \details Configure the S1 closed state in the Digitals
1418 * configuration object to change when this is asserted.
1419 *
1420 * - Default Value: False
1421 *
1422 * Default Rates:
1423 * - CAN 2.0: 100.0 Hz
1424 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1425 *
1426 * This refreshes and returns a cached StatusSignal object.
1427 *
1428 * \param refresh Whether to refresh the StatusSignal before returning it;
1429 * defaults to true
1430 * \returns S1Closed Status Signal Object
1431 */
1432 StatusSignal<bool> &GetS1Closed(bool refresh = true);
1433
1434 /**
1435 * \brief True if the Signal 2 input (S2IN) matches the configured S2
1436 * Closed State.
1437 *
1438 * \details Configure the S2 closed state in the Digitals
1439 * configuration object to change when this is asserted.
1440 *
1441 * - Default Value: False
1442 *
1443 * Default Rates:
1444 * - CAN 2.0: 100.0 Hz
1445 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
1446 *
1447 * This refreshes and returns a cached StatusSignal object.
1448 *
1449 * \param refresh Whether to refresh the StatusSignal before returning it;
1450 * defaults to true
1451 * \returns S2Closed Status Signal Object
1452 */
1453 StatusSignal<bool> &GetS2Closed(bool refresh = true);
1454
1455 /**
1456 * \brief Hardware fault occurred
1457 *
1458 * - Default Value: False
1459 *
1460 * Default Rates:
1461 * - CAN: 4.0 Hz
1462 *
1463 * This refreshes and returns a cached StatusSignal object.
1464 *
1465 * \param refresh Whether to refresh the StatusSignal before returning it;
1466 * defaults to true
1467 * \returns Fault_Hardware Status Signal Object
1468 */
1470
1471 /**
1472 * \brief Hardware fault occurred
1473 *
1474 * - Default Value: False
1475 *
1476 * Default Rates:
1477 * - CAN: 4.0 Hz
1478 *
1479 * This refreshes and returns a cached StatusSignal object.
1480 *
1481 * \param refresh Whether to refresh the StatusSignal before returning it;
1482 * defaults to true
1483 * \returns StickyFault_Hardware Status Signal Object
1484 */
1486
1487 /**
1488 * \brief Device supply voltage dropped to near brownout levels
1489 *
1490 * - Default Value: False
1491 *
1492 * Default Rates:
1493 * - CAN: 4.0 Hz
1494 *
1495 * This refreshes and returns a cached StatusSignal object.
1496 *
1497 * \param refresh Whether to refresh the StatusSignal before returning it;
1498 * defaults to true
1499 * \returns Fault_Undervoltage Status Signal Object
1500 */
1502
1503 /**
1504 * \brief Device supply voltage dropped to near brownout levels
1505 *
1506 * - Default Value: False
1507 *
1508 * Default Rates:
1509 * - CAN: 4.0 Hz
1510 *
1511 * This refreshes and returns a cached StatusSignal object.
1512 *
1513 * \param refresh Whether to refresh the StatusSignal before returning it;
1514 * defaults to true
1515 * \returns StickyFault_Undervoltage Status Signal Object
1516 */
1518
1519 /**
1520 * \brief Device boot while detecting the enable signal
1521 *
1522 * - Default Value: False
1523 *
1524 * Default Rates:
1525 * - CAN: 4.0 Hz
1526 *
1527 * This refreshes and returns a cached StatusSignal object.
1528 *
1529 * \param refresh Whether to refresh the StatusSignal before returning it;
1530 * defaults to true
1531 * \returns Fault_BootDuringEnable Status Signal Object
1532 */
1534
1535 /**
1536 * \brief Device boot while detecting the enable signal
1537 *
1538 * - Default Value: False
1539 *
1540 * Default Rates:
1541 * - CAN: 4.0 Hz
1542 *
1543 * This refreshes and returns a cached StatusSignal object.
1544 *
1545 * \param refresh Whether to refresh the StatusSignal before returning it;
1546 * defaults to true
1547 * \returns StickyFault_BootDuringEnable Status Signal Object
1548 */
1550
1551 /**
1552 * \brief An unlicensed feature is in use, device may not behave as
1553 * expected.
1554 *
1555 * - Default Value: False
1556 *
1557 * Default Rates:
1558 * - CAN: 4.0 Hz
1559 *
1560 * This refreshes and returns a cached StatusSignal object.
1561 *
1562 * \param refresh Whether to refresh the StatusSignal before returning it;
1563 * defaults to true
1564 * \returns Fault_UnlicensedFeatureInUse Status Signal Object
1565 */
1567
1568 /**
1569 * \brief An unlicensed feature is in use, device may not behave as
1570 * expected.
1571 *
1572 * - Default Value: False
1573 *
1574 * Default Rates:
1575 * - CAN: 4.0 Hz
1576 *
1577 * This refreshes and returns a cached StatusSignal object.
1578 *
1579 * \param refresh Whether to refresh the StatusSignal before returning it;
1580 * defaults to true
1581 * \returns StickyFault_UnlicensedFeatureInUse Status Signal Object
1582 */
1584
1585 /**
1586 * \brief The CTR Electronics' CANdi™ branded device has detected a 5V
1587 * fault. This may be due to overcurrent or a short-circuit.
1588 *
1589 * - Default Value: False
1590 *
1591 * Default Rates:
1592 * - CAN: 4.0 Hz
1593 *
1594 * This refreshes and returns a cached StatusSignal object.
1595 *
1596 * \param refresh Whether to refresh the StatusSignal before returning it;
1597 * defaults to true
1598 * \returns Fault_5V Status Signal Object
1599 */
1600 StatusSignal<bool> &GetFault_5V(bool refresh = true);
1601
1602 /**
1603 * \brief The CTR Electronics' CANdi™ branded device has detected a 5V
1604 * fault. This may be due to overcurrent or a short-circuit.
1605 *
1606 * - Default Value: False
1607 *
1608 * Default Rates:
1609 * - CAN: 4.0 Hz
1610 *
1611 * This refreshes and returns a cached StatusSignal object.
1612 *
1613 * \param refresh Whether to refresh the StatusSignal before returning it;
1614 * defaults to true
1615 * \returns StickyFault_5V Status Signal Object
1616 */
1618
1619
1620
1621
1622 /**
1623 * \brief Sets the position of the quadrature input.
1624 *
1625 * \param newValue Value to set to. Units are in rotations.
1626 * \param timeoutSeconds Maximum time to wait up to in seconds.
1627 * \returns StatusCode of the set command
1628 */
1629 ctre::phoenix::StatusCode SetQuadraturePosition(wpi::units::turn_t newValue, wpi::units::second_t timeoutSeconds)
1630 {
1631 return GetConfigurator().SetQuadraturePosition(newValue, timeoutSeconds);
1632 }
1633 /**
1634 * \brief Sets the position of the quadrature input.
1635 *
1636 * This will wait up to 0.100 seconds (100ms) by default.
1637 *
1638 * \param newValue Value to set to. Units are in rotations.
1639 * \returns StatusCode of the set command
1640 */
1642 {
1643 return SetQuadraturePosition(newValue, 0.100_s);
1644 }
1645
1646 /**
1647 * \brief Clear the sticky faults in the device.
1648 *
1649 * \details This typically has no impact on the device functionality.
1650 * Instead, it just clears telemetry faults that are accessible via
1651 * API and Tuner Self-Test.
1652 *
1653 * \param timeoutSeconds Maximum time to wait up to in seconds.
1654 * \returns StatusCode of the set command
1655 */
1656 ctre::phoenix::StatusCode ClearStickyFaults(wpi::units::second_t timeoutSeconds)
1657 {
1658 return GetConfigurator().ClearStickyFaults(timeoutSeconds);
1659 }
1660 /**
1661 * \brief Clear the sticky faults in the device.
1662 *
1663 * \details This typically has no impact on the device functionality.
1664 * Instead, it just clears telemetry faults that are accessible via
1665 * API and Tuner Self-Test.
1666 *
1667 * This will wait up to 0.100 seconds (100ms) by default.
1668 *
1669 * \returns StatusCode of the set command
1670 */
1675
1676 /**
1677 * \brief Clear sticky fault: Hardware fault occurred
1678 *
1679 * \param timeoutSeconds Maximum time to wait up to in seconds.
1680 * \returns StatusCode of the set command
1681 */
1682 ctre::phoenix::StatusCode ClearStickyFault_Hardware(wpi::units::second_t timeoutSeconds)
1683 {
1684 return GetConfigurator().ClearStickyFault_Hardware(timeoutSeconds);
1685 }
1686 /**
1687 * \brief Clear sticky fault: Hardware fault occurred
1688 *
1689 * This will wait up to 0.100 seconds (100ms) by default.
1690 *
1691 * \returns StatusCode of the set command
1692 */
1697
1698 /**
1699 * \brief Clear sticky fault: Device supply voltage dropped to near
1700 * brownout levels
1701 *
1702 * \param timeoutSeconds Maximum time to wait up to in seconds.
1703 * \returns StatusCode of the set command
1704 */
1706 {
1707 return GetConfigurator().ClearStickyFault_Undervoltage(timeoutSeconds);
1708 }
1709 /**
1710 * \brief Clear sticky fault: Device supply voltage dropped to near
1711 * brownout levels
1712 *
1713 * This will wait up to 0.100 seconds (100ms) by default.
1714 *
1715 * \returns StatusCode of the set command
1716 */
1721
1722 /**
1723 * \brief Clear sticky fault: Device boot while detecting the enable
1724 * signal
1725 *
1726 * \param timeoutSeconds Maximum time to wait up to in seconds.
1727 * \returns StatusCode of the set command
1728 */
1730 {
1731 return GetConfigurator().ClearStickyFault_BootDuringEnable(timeoutSeconds);
1732 }
1733 /**
1734 * \brief Clear sticky fault: Device boot while detecting the enable
1735 * signal
1736 *
1737 * This will wait up to 0.100 seconds (100ms) by default.
1738 *
1739 * \returns StatusCode of the set command
1740 */
1745
1746 /**
1747 * \brief Clear sticky fault: An unlicensed feature is in use, device
1748 * may not behave as expected.
1749 *
1750 * \param timeoutSeconds Maximum time to wait up to in seconds.
1751 * \returns StatusCode of the set command
1752 */
1754 {
1755 return GetConfigurator().ClearStickyFault_UnlicensedFeatureInUse(timeoutSeconds);
1756 }
1757 /**
1758 * \brief Clear sticky fault: An unlicensed feature is in use, device
1759 * may not behave as expected.
1760 *
1761 * This will wait up to 0.100 seconds (100ms) by default.
1762 *
1763 * \returns StatusCode of the set command
1764 */
1769
1770 /**
1771 * \brief Clear sticky fault: The CTR Electronics' CANdi™ branded
1772 * device has detected a 5V fault. This may be due to overcurrent or a
1773 * short-circuit.
1774 *
1775 * \param timeoutSeconds Maximum time to wait up to in seconds.
1776 * \returns StatusCode of the set command
1777 */
1778 ctre::phoenix::StatusCode ClearStickyFault_5V(wpi::units::second_t timeoutSeconds)
1779 {
1780 return GetConfigurator().ClearStickyFault_5V(timeoutSeconds);
1781 }
1782 /**
1783 * \brief Clear sticky fault: The CTR Electronics' CANdi™ branded
1784 * device has detected a 5V fault. This may be due to overcurrent or a
1785 * short-circuit.
1786 *
1787 * This will wait up to 0.100 seconds (100ms) by default.
1788 *
1789 * \returns StatusCode of the set command
1790 */
1795
1796 void RegisterAlerts(AlertableCollection &collection) override;
1797};
1798
1799#if defined(_WIN32) || defined(_WIN64)
1800#pragma warning(pop)
1801#endif
1802
1803}
1804}
1805
1806}
1807}
1808
Collection of objects that can report alerts.
Definition Alertable.hpp:109
Class for getting information about an available CAN bus.
Definition CANBus.hpp:142
Represents a status signal with data of type T, and operations available to retrieve information abou...
Definition StatusSignal.hpp:523
All configurations for the hardware::CANdi.
Definition CoreCANdi.hpp:42
QuadratureConfigs Quadrature
Configs related to the CANdi™ branded device's quadrature interface using both the S1IN and S2IN inpu...
Definition CoreCANdi.hpp:106
std::string Serialize() const final
Get the serialized form of this configuration.
bool FutureProofConfigs
True if we should factory default newer unsupported configs, false to leave newer unsupported configs...
Definition CoreCANdi.hpp:59
ctre::phoenix::StatusCode Deserialize(std::string const &to_deserialize) final
Take a string and deserialize it to this configuration.
constexpr CANdiConfiguration & WithPWM1(PWM1Configs newPWM1)
Modifies this configuration's PWM1 parameter and returns itself for method-chaining and easier to use...
Definition CoreCANdi.hpp:241
PWM2Configs PWM2
Configs related to the CANdi™ branded device's PWM interface on the Signal 2 input (S2IN).
Definition CoreCANdi.hpp:142
constexpr CANdiConfiguration & WithCustomParams(CustomParamsConfigs newCustomParams)
Modifies this configuration's CustomParams parameter and returns itself for method-chaining and easie...
Definition CoreCANdi.hpp:161
DigitalInputsConfigs DigitalInputs
Configs related to the CANdi™ branded device's digital I/O settings.
Definition CoreCANdi.hpp:90
std::string ToString() const override
Get the string representation of this configuration.
constexpr CANdiConfiguration & WithDigitalInputs(DigitalInputsConfigs newDigitalInputs)
Modifies this configuration's DigitalInputs parameter and returns itself for method-chaining and easi...
Definition CoreCANdi.hpp:187
CustomParamsConfigs CustomParams
Custom Params.
Definition CoreCANdi.hpp:73
constexpr CANdiConfiguration & WithPWM2(PWM2Configs newPWM2)
Modifies this configuration's PWM2 parameter and returns itself for method-chaining and easier to use...
Definition CoreCANdi.hpp:269
constexpr CANdiConfiguration & WithQuadrature(QuadratureConfigs newQuadrature)
Modifies this configuration's Quadrature parameter and returns itself for method-chaining and easier ...
Definition CoreCANdi.hpp:213
PWM1Configs PWM1
Configs related to the CANdi™ branded device's PWM interface on the Signal 1 input (S1IN).
Definition CoreCANdi.hpp:124
Handles applying and refreshing configurations for the hardware::CANdi.
Definition CoreCANdi.hpp:294
ctre::phoenix::StatusCode Refresh(PWM1Configs &configs, wpi::units::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:625
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable(wpi::units::second_t timeoutSeconds)
Clear sticky fault: Device boot while detecting the enable signal.
ctre::phoenix::StatusCode ClearStickyFault_Hardware()
Clear sticky fault: Hardware fault occurred.
Definition CoreCANdi.hpp:750
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(wpi::units::second_t timeoutSeconds)
Clear sticky fault: Device supply voltage dropped to near brownout levels.
ctre::phoenix::StatusCode SetQuadraturePosition(wpi::units::turn_t newValue)
Sets the position of the quadrature input.
Definition CoreCANdi.hpp:679
ctre::phoenix::StatusCode Apply(const QuadratureConfigs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:400
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse(wpi::units::second_t timeoutSeconds)
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
ctre::phoenix::StatusCode Apply(const CustomParamsConfigs &configs, wpi::units::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:356
ctre::phoenix::StatusCode Refresh(PWM2Configs &configs, wpi::units::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:656
ctre::phoenix::StatusCode Apply(const PWM1Configs &configs, wpi::units::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:443
ctre::phoenix::StatusCode Refresh(DigitalInputsConfigs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:550
ctre::phoenix::StatusCode ClearStickyFaults(wpi::units::second_t timeoutSeconds)
Clear the sticky faults in the device.
ctre::phoenix::StatusCode Refresh(CustomParamsConfigs &configs, wpi::units::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:532
ctre::phoenix::StatusCode Refresh(DigitalInputsConfigs &configs, wpi::units::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:563
ctre::phoenix::StatusCode Apply(const PWM1Configs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:429
ctre::phoenix::StatusCode Apply(const CANdiConfiguration &configs, wpi::units::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:327
ctre::phoenix::StatusCode Apply(const DigitalInputsConfigs &configs, wpi::units::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:385
ctre::phoenix::StatusCode ClearStickyFault_Hardware(wpi::units::second_t timeoutSeconds)
Clear sticky fault: Hardware fault occurred.
ctre::phoenix::StatusCode Apply(const QuadratureConfigs &configs, wpi::units::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:414
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage()
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANdi.hpp:782
ctre::phoenix::StatusCode Refresh(QuadratureConfigs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:581
ctre::phoenix::StatusCode Apply(const CANdiConfiguration &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:313
ctre::phoenix::StatusCode SetQuadraturePosition(wpi::units::turn_t newValue, wpi::units::second_t timeoutSeconds)
Sets the position of the quadrature input.
ctre::phoenix::StatusCode Refresh(QuadratureConfigs &configs, wpi::units::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:594
ctre::phoenix::StatusCode ClearStickyFaults()
Clear the sticky faults in the device.
Definition CoreCANdi.hpp:715
ctre::phoenix::StatusCode Refresh(PWM1Configs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:612
ctre::phoenix::StatusCode Refresh(CANdiConfiguration &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:487
ctre::phoenix::StatusCode Refresh(CustomParamsConfigs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:519
ctre::phoenix::StatusCode ClearStickyFault_5V(wpi::units::second_t timeoutSeconds)
Clear sticky fault: The CTR Electronics' CANdi™ branded device has detected a 5V fault.
ctre::phoenix::StatusCode Apply(const DigitalInputsConfigs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:371
ctre::phoenix::StatusCode Refresh(PWM2Configs &configs) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:643
ctre::phoenix::StatusCode Apply(const PWM2Configs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:458
ctre::phoenix::StatusCode ClearStickyFault_5V()
Clear sticky fault: The CTR Electronics' CANdi™ branded device has detected a 5V fault.
Definition CoreCANdi.hpp:882
ctre::phoenix::StatusCode Apply(const CustomParamsConfigs &configs)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:342
ctre::phoenix::StatusCode Refresh(CANdiConfiguration &configs, wpi::units::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition CoreCANdi.hpp:501
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable()
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANdi.hpp:815
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse()
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
Definition CoreCANdi.hpp:848
ctre::phoenix::StatusCode Apply(const PWM2Configs &configs, wpi::units::second_t timeoutSeconds)
Applies the contents of the specified config to the device.
Definition CoreCANdi.hpp:472
Custom Params.
Definition CustomParamsConfigs.hpp:23
Configs related to the CANdi™ branded device's digital I/O settings.
Definition DigitalInputsConfigs.hpp:25
Configs related to the CANdi™ branded device's PWM interface on the Signal 1 input (S1IN).
Definition PWM1Configs.hpp:27
Configs related to the CANdi™ branded device's PWM interface on the Signal 2 input (S2IN).
Definition PWM2Configs.hpp:27
Common interface for all configuration objects.
Definition Configuration.hpp:20
ctre::phoenix::StatusCode SetConfigsPrivate(std::string_view serializedString, wpi::units::second_t timeoutSeconds, bool futureProofConfigs, bool overrideIfDuplicate)
wpi::units::second_t DefaultTimeoutSeconds
The default maximum amount of time to wait for a config.
Definition Configurator.hpp:27
ParentConfigurator(hardware::DeviceIdentifier deviceIdentifier)
ctre::phoenix::StatusCode GetConfigsPrivate(std::string &serializedString, wpi::units::second_t timeoutSeconds) const
Configs related to the CANdi™ branded device's quadrature interface using both the S1IN and S2IN inpu...
Definition QuadratureConfigs.hpp:26
The unique identifier for a device.
Definition DeviceIdentifier.hpp:19
ParentDevice(int deviceID, std::string model, CANBus canbus)
Class for CTR Electronics' CANdi™ branded device, a device that integrates digital signals into the e...
Definition CoreCANdi.hpp:918
StatusSignal< bool > & GetFault_Hardware(bool refresh=true)
Hardware fault occurred.
configs::CANdiConfigurator const & GetConfigurator() const
Gets the configurator for this CANdi.
Definition CoreCANdi.hpp:966
ctre::phoenix::StatusCode SetQuadraturePosition(wpi::units::turn_t newValue)
Sets the position of the quadrature input.
Definition CoreCANdi.hpp:1641
StatusSignal< bool > & GetStickyFault_BootDuringEnable(bool refresh=true)
Device boot while detecting the enable signal.
StatusSignal< wpi::units::turns_per_second_t > & GetQuadratureVelocity(bool refresh=true)
Velocity from a quadrature encoder sensor connected to both the S1IN and S2IN inputs.
ctre::phoenix::StatusCode ClearStickyFault_5V(wpi::units::second_t timeoutSeconds)
Clear sticky fault: The CTR Electronics' CANdi™ branded device has detected a 5V fault.
Definition CoreCANdi.hpp:1778
StatusSignal< bool > & GetFault_5V(bool refresh=true)
The CTR Electronics' CANdi™ branded device has detected a 5V fault.
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage()
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANdi.hpp:1717
StatusSignal< int > & GetVersionBuild(bool refresh=true)
App Build Version number.
StatusSignal< wpi::units::turn_t > & GetPWM2Position(bool refresh=true)
Measured position of the PWM sensor at the S2 input of the CTR Electronics' CANdi™.
StatusSignal< bool > & GetS2Closed(bool refresh=true)
True if the Signal 2 input (S2IN) matches the configured S2 Closed State.
sim::CANdiSimState & GetSimState()
Get the simulation state for this device.
Definition CoreCANdi.hpp:984
StatusSignal< int > & GetVersionBugfix(bool refresh=true)
App Bugfix Version number.
StatusSignal< bool > & GetStickyFault_Undervoltage(bool refresh=true)
Device supply voltage dropped to near brownout levels.
StatusSignal< bool > & GetStickyFault_5V(bool refresh=true)
The CTR Electronics' CANdi™ branded device has detected a 5V fault.
StatusSignal< bool > & GetFault_UnlicensedFeatureInUse(bool refresh=true)
An unlicensed feature is in use, device may not behave as expected.
StatusSignal< wpi::units::turn_t > & GetPWM1Position(bool refresh=true)
Measured position of the PWM sensor at the S1 input of the CTR Electronics' CANdi™.
StatusSignal< bool > & GetFault_Undervoltage(bool refresh=true)
Device supply voltage dropped to near brownout levels.
configs::CANdiConfigurator & GetConfigurator()
Gets the configurator for this CANdi.
Definition CoreCANdi.hpp:954
ctre::phoenix::StatusCode ClearStickyFaults(wpi::units::second_t timeoutSeconds)
Clear the sticky faults in the device.
Definition CoreCANdi.hpp:1656
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(wpi::units::second_t timeoutSeconds)
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANdi.hpp:1705
StatusSignal< signals::S1StateValue > & GetS1State(bool refresh=true)
State of the Signal 1 input (S1IN).
StatusSignal< int > & GetVersion(bool refresh=true)
Full Version of firmware in device.
CoreCANdi(int deviceId, CANBus canbus)
Constructs a new CANdi object.
StatusSignal< bool > & GetStickyFault_UnlicensedFeatureInUse(bool refresh=true)
An unlicensed feature is in use, device may not behave as expected.
StatusSignal< int > & GetStickyFaultField(bool refresh=true)
Integer representing all (persistent) sticky fault flags reported by the device.
StatusSignal< bool > & GetIsProLicensed(bool refresh=true)
Whether the device is Phoenix Pro licensed.
ctre::phoenix::StatusCode ClearStickyFault_Hardware(wpi::units::second_t timeoutSeconds)
Clear sticky fault: Hardware fault occurred.
Definition CoreCANdi.hpp:1682
StatusSignal< wpi::units::microsecond_t > & GetPWM1RiseToRise(bool refresh=true)
Measured rise to rise time of the PWM signal at the S1 input of the CTR Electronics' CANdi™.
StatusSignal< wpi::units::volt_t > & GetSupplyVoltage(bool refresh=true)
Measured supply voltage to the CANdi™.
ctre::phoenix::StatusCode ClearStickyFaults()
Clear the sticky faults in the device.
Definition CoreCANdi.hpp:1671
StatusSignal< int > & GetVersionMajor(bool refresh=true)
App Major Version number.
StatusSignal< bool > & GetOvercurrent(bool refresh=true)
True when the CANdi™ is in overcurrent protection mode.
StatusSignal< wpi::units::turns_per_second_t > & GetPWM1Velocity(bool refresh=true)
Measured velocity of the PWM sensor at the S1 input of the CTR Electronics' CANdi™.
StatusSignal< int > & GetFaultField(bool refresh=true)
Integer representing all fault flags reported by the device.
ctre::phoenix::StatusCode ClearStickyFault_Hardware()
Clear sticky fault: Hardware fault occurred.
Definition CoreCANdi.hpp:1693
StatusSignal< bool > & GetS1Closed(bool refresh=true)
True if the Signal 1 input (S1IN) matches the configured S1 Closed State.
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse(wpi::units::second_t timeoutSeconds)
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
Definition CoreCANdi.hpp:1753
StatusSignal< int > & GetVersionMinor(bool refresh=true)
App Minor Version number.
configs::CANdiConfiguration Configuration
The configuration class for this device.
Definition CoreCANdi.hpp:926
StatusSignal< wpi::units::ampere_t > & GetOutputCurrent(bool refresh=true)
Measured output current.
StatusSignal< wpi::units::microsecond_t > & GetPWM2RiseToRise(bool refresh=true)
Measured rise to rise time of the PWM signal at the S2 input of the CTR Electronics' CANdi™.
StatusSignal< bool > & GetStickyFault_Hardware(bool refresh=true)
Hardware fault occurred.
ctre::phoenix::StatusCode SetQuadraturePosition(wpi::units::turn_t newValue, wpi::units::second_t timeoutSeconds)
Sets the position of the quadrature input.
Definition CoreCANdi.hpp:1629
void RegisterAlerts(AlertableCollection &collection) override
Registers all alerts for this type to the provided collection.
StatusSignal< bool > & GetFault_BootDuringEnable(bool refresh=true)
Device boot while detecting the enable signal.
StatusSignal< signals::S2StateValue > & GetS2State(bool refresh=true)
State of the Signal 2 input (S2IN).
static CoreCANdi None()
Constructs a stubbed-out CoreCANdi, where all status signals, controls, configs, etc.
Definition CoreCANdi.hpp:943
StatusSignal< wpi::units::turn_t > & GetQuadraturePosition(bool refresh=true)
Position from a quadrature encoder sensor connected to both the S1IN and S2IN inputs.
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable()
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANdi.hpp:1741
StatusSignal< wpi::units::turns_per_second_t > & GetPWM2Velocity(bool refresh=true)
Measured velocity of the PWM sensor at the S2 input of the CTR Electronics' CANdi™.
ctre::phoenix::StatusCode ClearStickyFault_5V()
Clear sticky fault: The CTR Electronics' CANdi™ branded device has detected a 5V fault.
Definition CoreCANdi.hpp:1791
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable(wpi::units::second_t timeoutSeconds)
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANdi.hpp:1729
ctre::phoenix::StatusCode ClearStickyFault_UnlicensedFeatureInUse()
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
Definition CoreCANdi.hpp:1765
Class to control the state of a simulated hardware::CANdi.
Definition CANdiSimState.hpp:33
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
Definition ExternalFeedbackConfigs.hpp:21
Definition ExternalFeedbackConfigs.hpp:17
Definition ExternalFeedbackConfigs.hpp:17
Definition ExternalFeedbackConfigs.hpp:16
Definition StatusCodes.h:22
Definition motor_constants.h:14