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