CTRE Phoenix 6 C++ 25.2.1
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:
637
638 /**
639 * Constructs a new CANcoder object.
640 *
641 * \param deviceId ID of the device, as configured in Phoenix Tuner.
642 * \param canbus Name of the CAN bus this device is on. Possible CAN bus strings are:
643 * - "rio" for the native roboRIO CAN bus
644 * - CANivore name or serial number
645 * - SocketCAN interface (non-FRC Linux only)
646 * - "*" for any CANivore seen by the program
647 * - empty string (default) to select the default for the system:
648 * - "rio" on roboRIO
649 * - "can0" on Linux
650 * - "*" on Windows
651 */
652 CoreCANcoder(int deviceId, std::string canbus = "");
653
654 /**
655 * Constructs a new CANcoder object.
656 *
657 * \param deviceId ID of the device, as configured in Phoenix Tuner.
658 * \param canbus The CAN bus this device is on.
659 */
660 CoreCANcoder(int deviceId, CANBus canbus) :
661 CoreCANcoder{deviceId, std::string{canbus.GetName()}}
662 {}
663
664 /**
665 * \brief Gets the configurator for this CANcoder
666 *
667 * \details Gets the configurator for this CANcoder
668 *
669 * \returns Configurator for this CANcoder
670 */
672 {
673 return _configs;
674 }
675
676 /**
677 * \brief Gets the configurator for this CANcoder
678 *
679 * \details Gets the configurator for this CANcoder
680 *
681 * \returns Configurator for this CANcoder
682 */
684 {
685 return _configs;
686 }
687
688
689private:
690 std::unique_ptr<sim::CANcoderSimState> _simState{};
691public:
692 /**
693 * \brief Get the simulation state for this device.
694 *
695 * \details This function reuses an allocated simulation
696 * state object, so it is safe to call this function multiple
697 * times in a robot loop.
698 *
699 * \returns Simulation state
700 */
702 {
703 if (_simState == nullptr)
704 _simState = std::make_unique<sim::CANcoderSimState>(*this);
705 return *_simState;
706 }
707
708
709
710 /**
711 * \brief App Major Version number.
712 *
713 * - Minimum Value: 0
714 * - Maximum Value: 255
715 * - Default Value: 0
716 * - Units:
717 *
718 * Default Rates:
719 * - CAN: 4.0 Hz
720 *
721 * This refreshes and returns a cached StatusSignal object.
722 *
723 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
724 * \returns VersionMajor Status Signal Object
725 */
726 StatusSignal<int> &GetVersionMajor(bool refresh = true);
727
728 /**
729 * \brief App Minor Version number.
730 *
731 * - Minimum Value: 0
732 * - Maximum Value: 255
733 * - Default Value: 0
734 * - Units:
735 *
736 * Default Rates:
737 * - CAN: 4.0 Hz
738 *
739 * This refreshes and returns a cached StatusSignal object.
740 *
741 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
742 * \returns VersionMinor Status Signal Object
743 */
744 StatusSignal<int> &GetVersionMinor(bool refresh = true);
745
746 /**
747 * \brief App Bugfix Version number.
748 *
749 * - Minimum Value: 0
750 * - Maximum Value: 255
751 * - Default Value: 0
752 * - Units:
753 *
754 * Default Rates:
755 * - CAN: 4.0 Hz
756 *
757 * This refreshes and returns a cached StatusSignal object.
758 *
759 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
760 * \returns VersionBugfix Status Signal Object
761 */
762 StatusSignal<int> &GetVersionBugfix(bool refresh = true);
763
764 /**
765 * \brief App Build Version number.
766 *
767 * - Minimum Value: 0
768 * - Maximum Value: 255
769 * - Default Value: 0
770 * - Units:
771 *
772 * Default Rates:
773 * - CAN: 4.0 Hz
774 *
775 * This refreshes and returns a cached StatusSignal object.
776 *
777 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
778 * \returns VersionBuild Status Signal Object
779 */
780 StatusSignal<int> &GetVersionBuild(bool refresh = true);
781
782 /**
783 * \brief Full Version of firmware in device. The format is a four
784 * byte value.
785 *
786 * - Minimum Value: 0
787 * - Maximum Value: 4294967295
788 * - Default Value: 0
789 * - Units:
790 *
791 * Default Rates:
792 * - CAN: 4.0 Hz
793 *
794 * This refreshes and returns a cached StatusSignal object.
795 *
796 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
797 * \returns Version Status Signal Object
798 */
799 StatusSignal<int> &GetVersion(bool refresh = true);
800
801 /**
802 * \brief Integer representing all fault flags reported by the device.
803 *
804 * \details These are device specific and are not used directly in
805 * typical applications. Use the signal specific GetFault_*() methods
806 * instead.
807 *
808 * - Minimum Value: 0
809 * - Maximum Value: 4294967295
810 * - Default Value: 0
811 * - Units:
812 *
813 * Default Rates:
814 * - CAN: 4.0 Hz
815 *
816 * This refreshes and returns a cached StatusSignal object.
817 *
818 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
819 * \returns FaultField Status Signal Object
820 */
821 StatusSignal<int> &GetFaultField(bool refresh = true);
822
823 /**
824 * \brief Integer representing all (persistent) sticky fault flags
825 * reported by the device.
826 *
827 * \details These are device specific and are not used directly in
828 * typical applications. Use the signal specific GetStickyFault_*()
829 * methods instead.
830 *
831 * - Minimum Value: 0
832 * - Maximum Value: 4294967295
833 * - Default Value: 0
834 * - Units:
835 *
836 * Default Rates:
837 * - CAN: 4.0 Hz
838 *
839 * This refreshes and returns a cached StatusSignal object.
840 *
841 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
842 * \returns StickyFaultField Status Signal Object
843 */
845
846 /**
847 * \brief Velocity of the device.
848 *
849 * - Minimum Value: -512.0
850 * - Maximum Value: 511.998046875
851 * - Default Value: 0
852 * - Units: rotations per second
853 *
854 * Default Rates:
855 * - CAN 2.0: 100.0 Hz
856 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
857 *
858 * This refreshes and returns a cached StatusSignal object.
859 *
860 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
861 * \returns Velocity Status Signal Object
862 */
864
865 /**
866 * \brief Position of the device. This is initialized to the absolute
867 * position on boot.
868 *
869 * - Minimum Value: -16384.0
870 * - Maximum Value: 16383.999755859375
871 * - Default Value: 0
872 * - Units: rotations
873 *
874 * Default Rates:
875 * - CAN 2.0: 100.0 Hz
876 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
877 *
878 * This refreshes and returns a cached StatusSignal object.
879 *
880 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
881 * \returns Position Status Signal Object
882 */
884
885 /**
886 * \brief Absolute Position of the device. The possible range is
887 * documented below; however, the exact expected range is determined
888 * by the AbsoluteSensorDiscontinuityPoint. This position is only
889 * affected by the MagnetSensor configs.
890 *
891 * - Minimum Value: -1.0
892 * - Maximum Value: 0.999755859375
893 * - Default Value: 0
894 * - Units: rotations
895 *
896 * Default Rates:
897 * - CAN 2.0: 100.0 Hz
898 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
899 *
900 * This refreshes and returns a cached StatusSignal object.
901 *
902 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
903 * \returns AbsolutePosition Status Signal Object
904 */
906
907 /**
908 * \brief The unfiltered velocity reported by CANcoder.
909 *
910 * \details This is the unfiltered velocity reported by CANcoder. This
911 * signal does not use the fusing algorithm.
912 *
913 * - Minimum Value: -8000.0
914 * - Maximum Value: 7999.755859375
915 * - Default Value: 0
916 * - Units: rotations per second
917 *
918 * Default Rates:
919 * - CAN 2.0: 4.0 Hz
920 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
921 *
922 * This refreshes and returns a cached StatusSignal object.
923 *
924 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
925 * \returns UnfilteredVelocity Status Signal Object
926 */
928
929 /**
930 * \brief The relative position reported by the CANcoder since boot.
931 *
932 * \details This is the total displacement reported by CANcoder since
933 * power up. This signal is relative and is not influenced by the
934 * fusing algorithm.
935 *
936 * - Minimum Value: -16384.0
937 * - Maximum Value: 16383.999755859375
938 * - Default Value: 0
939 * - Units: rotations
940 *
941 * Default Rates:
942 * - CAN 2.0: 4.0 Hz
943 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
944 *
945 * This refreshes and returns a cached StatusSignal object.
946 *
947 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
948 * \returns PositionSinceBoot Status Signal Object
949 */
951
952 /**
953 * \brief Measured supply voltage to the CANcoder.
954 *
955 * - Minimum Value: 4
956 * - Maximum Value: 16.75
957 * - Default Value: 4
958 * - Units: V
959 *
960 * Default Rates:
961 * - CAN 2.0: 4.0 Hz
962 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
963 *
964 * This refreshes and returns a cached StatusSignal object.
965 *
966 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
967 * \returns SupplyVoltage Status Signal Object
968 */
970
971 /**
972 * \brief Magnet health as measured by CANcoder.
973 *
974 * Red indicates too close or too far, Orange is adequate but with
975 * reduced accuracy, green is ideal. Invalid means the accuracy cannot
976 * be determined.
977 *
978 *
979 * Default Rates:
980 * - CAN 2.0: 4.0 Hz
981 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
982 *
983 * This refreshes and returns a cached StatusSignal object.
984 *
985 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
986 * \returns MagnetHealth Status Signal Object
987 */
989
990 /**
991 * \brief Whether the device is Phoenix Pro licensed.
992 *
993 * - Default Value: False
994 *
995 * Default Rates:
996 * - CAN: 4.0 Hz
997 *
998 * This refreshes and returns a cached StatusSignal object.
999 *
1000 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1001 * \returns IsProLicensed Status Signal Object
1002 */
1004
1005 /**
1006 * \brief Hardware fault occurred
1007 *
1008 * - Default Value: False
1009 *
1010 * Default Rates:
1011 * - CAN: 4.0 Hz
1012 *
1013 * This refreshes and returns a cached StatusSignal object.
1014 *
1015 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1016 * \returns Fault_Hardware Status Signal Object
1017 */
1019
1020 /**
1021 * \brief Hardware fault occurred
1022 *
1023 * - Default Value: False
1024 *
1025 * Default Rates:
1026 * - CAN: 4.0 Hz
1027 *
1028 * This refreshes and returns a cached StatusSignal object.
1029 *
1030 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1031 * \returns StickyFault_Hardware Status Signal Object
1032 */
1034
1035 /**
1036 * \brief Device supply voltage dropped to near brownout levels
1037 *
1038 * - Default Value: False
1039 *
1040 * Default Rates:
1041 * - CAN: 4.0 Hz
1042 *
1043 * This refreshes and returns a cached StatusSignal object.
1044 *
1045 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1046 * \returns Fault_Undervoltage Status Signal Object
1047 */
1049
1050 /**
1051 * \brief Device supply voltage dropped to near brownout levels
1052 *
1053 * - Default Value: False
1054 *
1055 * Default Rates:
1056 * - CAN: 4.0 Hz
1057 *
1058 * This refreshes and returns a cached StatusSignal object.
1059 *
1060 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1061 * \returns StickyFault_Undervoltage Status Signal Object
1062 */
1064
1065 /**
1066 * \brief Device boot while detecting the enable signal
1067 *
1068 * - Default Value: False
1069 *
1070 * Default Rates:
1071 * - CAN: 4.0 Hz
1072 *
1073 * This refreshes and returns a cached StatusSignal object.
1074 *
1075 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1076 * \returns Fault_BootDuringEnable Status Signal Object
1077 */
1079
1080 /**
1081 * \brief Device boot while detecting the enable signal
1082 *
1083 * - Default Value: False
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; defaults to true
1091 * \returns StickyFault_BootDuringEnable Status Signal Object
1092 */
1094
1095 /**
1096 * \brief An unlicensed feature is in use, device may not behave as
1097 * expected.
1098 *
1099 * - Default Value: False
1100 *
1101 * Default Rates:
1102 * - CAN: 4.0 Hz
1103 *
1104 * This refreshes and returns a cached StatusSignal object.
1105 *
1106 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1107 * \returns Fault_UnlicensedFeatureInUse Status Signal Object
1108 */
1110
1111 /**
1112 * \brief An unlicensed feature is in use, device may not behave as
1113 * expected.
1114 *
1115 * - Default Value: False
1116 *
1117 * Default Rates:
1118 * - CAN: 4.0 Hz
1119 *
1120 * This refreshes and returns a cached StatusSignal object.
1121 *
1122 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1123 * \returns StickyFault_UnlicensedFeatureInUse Status Signal Object
1124 */
1126
1127 /**
1128 * \brief The magnet distance is not correct or magnet is missing
1129 *
1130 * - Default Value: False
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; defaults to true
1138 * \returns Fault_BadMagnet Status Signal Object
1139 */
1141
1142 /**
1143 * \brief The magnet distance is not correct or magnet is missing
1144 *
1145 * - Default Value: False
1146 *
1147 * Default Rates:
1148 * - CAN: 4.0 Hz
1149 *
1150 * This refreshes and returns a cached StatusSignal object.
1151 *
1152 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1153 * \returns StickyFault_BadMagnet Status Signal Object
1154 */
1156
1157
1158
1159 /**
1160 * \brief Control device with generic control request object. User must make
1161 * sure the specified object is castable to a valid control request,
1162 * otherwise this function will fail at run-time and return the NotSupported
1163 * StatusCode
1164 *
1165 * \param request Control object to request of the device
1166 * \returns Status Code of the request, 0 is OK
1167 */
1169 {
1170 controls::ControlRequest const *ptr = &request;
1171 (void)ptr;
1172
1174 }
1175
1176
1177 /**
1178 * \brief Sets the current position of the device.
1179 *
1180 * \param newValue Value to set to. Units are in rotations.
1181 * \param timeoutSeconds Maximum time to wait up to in seconds.
1182 * \returns StatusCode of the set command
1183 */
1184 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
1185 {
1186 return GetConfigurator().SetPosition(newValue, timeoutSeconds);
1187 }
1188 /**
1189 * \brief Sets the current position of the device.
1190 *
1191 * This will wait up to 0.100 seconds (100ms) by default.
1192 *
1193 * \param newValue Value to set to. Units are in rotations.
1194 * \returns StatusCode of the set command
1195 */
1196 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
1197 {
1198 return SetPosition(newValue, 0.100_s);
1199 }
1200
1201 /**
1202 * \brief Clear the sticky faults in the device.
1203 *
1204 * \details This typically has no impact on the device functionality.
1205 * Instead, it just clears telemetry faults that are accessible via
1206 * API and Tuner Self-Test.
1207 *
1208 * \param timeoutSeconds Maximum time to wait up to in seconds.
1209 * \returns StatusCode of the set command
1210 */
1211 ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
1212 {
1213 return GetConfigurator().ClearStickyFaults(timeoutSeconds);
1214 }
1215 /**
1216 * \brief Clear the sticky faults in the device.
1217 *
1218 * \details This typically has no impact on the device functionality.
1219 * Instead, it just clears telemetry faults that are accessible via
1220 * API and Tuner Self-Test.
1221 *
1222 * This will wait up to 0.100 seconds (100ms) by default.
1223 *
1224 * \returns StatusCode of the set command
1225 */
1230
1231 /**
1232 * \brief Clear sticky fault: Hardware fault occurred
1233 *
1234 * \param timeoutSeconds Maximum time to wait up to in seconds.
1235 * \returns StatusCode of the set command
1236 */
1237 ctre::phoenix::StatusCode ClearStickyFault_Hardware(units::time::second_t timeoutSeconds)
1238 {
1239 return GetConfigurator().ClearStickyFault_Hardware(timeoutSeconds);
1240 }
1241 /**
1242 * \brief Clear sticky fault: Hardware fault occurred
1243 *
1244 * This will wait up to 0.100 seconds (100ms) by default.
1245 *
1246 * \returns StatusCode of the set command
1247 */
1252
1253 /**
1254 * \brief Clear sticky fault: Device supply voltage dropped to near
1255 * brownout levels
1256 *
1257 * \param timeoutSeconds Maximum time to wait up to in seconds.
1258 * \returns StatusCode of the set command
1259 */
1260 ctre::phoenix::StatusCode ClearStickyFault_Undervoltage(units::time::second_t timeoutSeconds)
1261 {
1262 return GetConfigurator().ClearStickyFault_Undervoltage(timeoutSeconds);
1263 }
1264 /**
1265 * \brief Clear sticky fault: Device supply voltage dropped to near
1266 * brownout levels
1267 *
1268 * This will wait up to 0.100 seconds (100ms) by default.
1269 *
1270 * \returns StatusCode of the set command
1271 */
1276
1277 /**
1278 * \brief Clear sticky fault: Device boot while detecting the enable
1279 * signal
1280 *
1281 * \param timeoutSeconds Maximum time to wait up to in seconds.
1282 * \returns StatusCode of the set command
1283 */
1285 {
1286 return GetConfigurator().ClearStickyFault_BootDuringEnable(timeoutSeconds);
1287 }
1288 /**
1289 * \brief Clear sticky fault: Device boot while detecting the enable
1290 * signal
1291 *
1292 * This will wait up to 0.100 seconds (100ms) by default.
1293 *
1294 * \returns StatusCode of the set command
1295 */
1300
1301 /**
1302 * \brief Clear sticky fault: An unlicensed feature is in use, device
1303 * may not behave as expected.
1304 *
1305 * \param timeoutSeconds Maximum time to wait up to in seconds.
1306 * \returns StatusCode of the set command
1307 */
1309 {
1311 }
1312 /**
1313 * \brief Clear sticky fault: An unlicensed feature is in use, device
1314 * may not behave as expected.
1315 *
1316 * This will wait up to 0.100 seconds (100ms) by default.
1317 *
1318 * \returns StatusCode of the set command
1319 */
1324
1325 /**
1326 * \brief Clear sticky fault: The magnet distance is not correct or
1327 * magnet is missing
1328 *
1329 * \param timeoutSeconds Maximum time to wait up to in seconds.
1330 * \returns StatusCode of the set command
1331 */
1332 ctre::phoenix::StatusCode ClearStickyFault_BadMagnet(units::time::second_t timeoutSeconds)
1333 {
1334 return GetConfigurator().ClearStickyFault_BadMagnet(timeoutSeconds);
1335 }
1336 /**
1337 * \brief Clear sticky fault: The magnet distance is not correct or
1338 * magnet is missing
1339 *
1340 * This will wait up to 0.100 seconds (100ms) by default.
1341 *
1342 * \returns StatusCode of the set command
1343 */
1348};
1349
1350}
1351}
1352
1353}
1354}
1355
ii that the Software will be uninterrupted or error free
Definition CTRE_LICENSE.txt:251
CTREXPORT int c_ctre_phoenix6_serialize_double(int spn, double value, char **str)
Class for getting information about an available CAN bus.
Definition CANBus.hpp:19
Represents a status signal with data of type T, and operations available to retrieve information abou...
Definition StatusSignal.hpp:656
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition CoreCANcoder.hpp:38
MagnetSensorConfigs MagnetSensor
Configs that affect the magnet sensor and how to interpret it.
Definition CoreCANcoder.hpp: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:4258
std::string ToString() const override
Definition Configs.hpp:4327
std::string Serialize() const override
Definition Configs.hpp:4336
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition Configs.hpp:4345
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:30
Definition DeviceIdentifier.hpp:19
Parent class for all devices.
Definition ParentDevice.hpp:28
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition CoreCANcoder.hpp: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:1211
CoreCANcoder(int deviceId, CANBus canbus)
Constructs a new CANcoder object.
Definition CoreCANcoder.hpp:660
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage()
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition CoreCANcoder.hpp:1272
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:1226
configs::CANcoderConfigurator & GetConfigurator()
Gets the configurator for this CANcoder.
Definition CoreCANcoder.hpp:671
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:1237
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:1320
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:1260
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:1196
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:701
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet()
Clear sticky fault: The magnet distance is not correct or magnet is missing.
Definition CoreCANcoder.hpp:1344
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:1284
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:1332
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:1184
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:1308
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:1248
ctre::phoenix::StatusCode SetControl(const controls::ControlRequest &request)
Control device with generic control request object.
Definition CoreCANcoder.hpp:1168
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:683
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable()
Clear sticky fault: Device boot while detecting the enable signal.
Definition CoreCANcoder.hpp:1296
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 MotionMagicExpoTorqueCurrentFOC.hpp:18
Definition span.hpp:401