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