CTRE Phoenix 6 C++ 24.50.0-alpha-2
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
15#include <units/angle.h>
16#include <units/angular_velocity.h>
17#include <units/dimensionless.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 range, sensor direction, and the magnet
63 * 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 range, sensor direction, and the magnet
81 * 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 */
171 {
172 return Refresh(configs, DefaultTimeoutSeconds);
173 }
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 */
400 {
402 }
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 */
441 {
443 }
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 */
479 {
481 }
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 */
518 {
520 }
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: The magnet distance is not correct or
544 * magnet is missing
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 */
557 {
559 }
560 /**
561 * \brief Clear sticky fault: The magnet distance is not correct or
562 * magnet is missing
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 */
573 ctre::phoenix::StatusCode ClearStickyFault_BadMagnet(units::time::second_t timeoutSeconds)
574 {
575 std::stringstream ss;
576 char *ref;
577 c_ctre_phoenix6_serialize_double(ctre::phoenix6::spns::SpnValue::ClearStickyFault_CANCODER_BadMagnet, 0, &ref); if (ref != nullptr) { ss << ref; free(ref); }
578 return SetConfigsPrivate(ss.str(), timeoutSeconds, false, true);
579 }
580};
581
582}
583
584namespace hardware {
585namespace core {
586
587/**
588 * Class for CANcoder, a CAN based magnetic encoder that provides absolute and
589 * relative position along with filtered velocity.
590 */
592{
593private:
595
596
597public:
598 /**
599 * Constructs a new CANcoder object.
600 *
601 * \param deviceId ID of the device, as configured in Phoenix Tuner.
602 * \param canbus Name of the CAN bus this device is on. Possible CAN bus strings are:
603 * - "rio" for the native roboRIO CAN bus
604 * - CANivore name or serial number
605 * - SocketCAN interface (non-FRC Linux only)
606 * - "*" for any CANivore seen by the program
607 * - empty string (default) to select the default for the system:
608 * - "rio" on roboRIO
609 * - "can0" on Linux
610 * - "*" on Windows
611 */
612 CoreCANcoder(int deviceId, std::string canbus = "");
613
614 /**
615 * Constructs a new CANcoder object.
616 *
617 * \param deviceId ID of the device, as configured in Phoenix Tuner.
618 * \param canbus The CAN bus this device is on.
619 */
620 CoreCANcoder(int deviceId, CANBus canbus) :
621 CoreCANcoder{deviceId, std::string{canbus.GetName()}}
622 {}
623
624 /**
625 * \brief Gets the configurator for this CANcoder
626 *
627 * \details Gets the configurator for this CANcoder
628 *
629 * \returns Configurator for this CANcoder
630 */
632 {
633 return _configs;
634 }
635
636 /**
637 * \brief Gets the configurator for this CANcoder
638 *
639 * \details Gets the configurator for this CANcoder
640 *
641 * \returns Configurator for this CANcoder
642 */
644 {
645 return _configs;
646 }
647
648
649private:
650 std::unique_ptr<sim::CANcoderSimState> _simState{};
651public:
652 /**
653 * \brief Get the simulation state for this device.
654 *
655 * \details This function reuses an allocated simulation
656 * state object, so it is safe to call this function multiple
657 * times in a robot loop.
658 *
659 * \returns Simulation state
660 */
662 {
663 if (_simState == nullptr)
664 _simState = std::make_unique<sim::CANcoderSimState>(*this);
665 return *_simState;
666 }
667
668
669
670 /**
671 * \brief App Major Version number.
672 *
673 * - Minimum Value: 0
674 * - Maximum Value: 255
675 * - Default Value: 0
676 * - Units:
677 *
678 * Default Rates:
679 * - CAN: 4.0 Hz
680 *
681 * This refreshes and returns a cached StatusSignal object.
682 *
683 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
684 * \returns VersionMajor Status Signal Object
685 */
686 StatusSignal<int> &GetVersionMajor(bool refresh = true);
687
688 /**
689 * \brief App Minor Version number.
690 *
691 * - Minimum Value: 0
692 * - Maximum Value: 255
693 * - Default Value: 0
694 * - Units:
695 *
696 * Default Rates:
697 * - CAN: 4.0 Hz
698 *
699 * This refreshes and returns a cached StatusSignal object.
700 *
701 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
702 * \returns VersionMinor Status Signal Object
703 */
704 StatusSignal<int> &GetVersionMinor(bool refresh = true);
705
706 /**
707 * \brief App Bugfix Version number.
708 *
709 * - Minimum Value: 0
710 * - Maximum Value: 255
711 * - Default Value: 0
712 * - Units:
713 *
714 * Default Rates:
715 * - CAN: 4.0 Hz
716 *
717 * This refreshes and returns a cached StatusSignal object.
718 *
719 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
720 * \returns VersionBugfix Status Signal Object
721 */
722 StatusSignal<int> &GetVersionBugfix(bool refresh = true);
723
724 /**
725 * \brief App Build Version number.
726 *
727 * - Minimum Value: 0
728 * - Maximum Value: 255
729 * - Default Value: 0
730 * - Units:
731 *
732 * Default Rates:
733 * - CAN: 4.0 Hz
734 *
735 * This refreshes and returns a cached StatusSignal object.
736 *
737 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
738 * \returns VersionBuild Status Signal Object
739 */
740 StatusSignal<int> &GetVersionBuild(bool refresh = true);
741
742 /**
743 * \brief Full Version. The format is a four byte value.
744 *
745 * \details Full Version of firmware in device. The format is a four
746 * byte value.
747 *
748 * - Minimum Value: 0
749 * - Maximum Value: 4294967295
750 * - Default Value: 0
751 * - Units:
752 *
753 * Default Rates:
754 * - CAN: 4.0 Hz
755 *
756 * This refreshes and returns a cached StatusSignal object.
757 *
758 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
759 * \returns Version Status Signal Object
760 */
761 StatusSignal<int> &GetVersion(bool refresh = true);
762
763 /**
764 * \brief Integer representing all faults
765 *
766 * \details This returns the fault flags reported by the device. These
767 * are device specific and are not used directly in typical
768 * applications. Use the signal specific GetFault_*() methods instead.
769 *
770 * - Minimum Value: 0
771 * - Maximum Value: 4294967295
772 * - Default Value: 0
773 * - Units:
774 *
775 * Default Rates:
776 * - CAN: 4.0 Hz
777 *
778 * This refreshes and returns a cached StatusSignal object.
779 *
780 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
781 * \returns FaultField Status Signal Object
782 */
783 StatusSignal<int> &GetFaultField(bool refresh = true);
784
785 /**
786 * \brief Integer representing all sticky faults
787 *
788 * \details This returns the persistent "sticky" fault flags reported
789 * by the device. These are device specific and are not used directly
790 * in typical applications. Use the signal specific GetStickyFault_*()
791 * methods instead.
792 *
793 * - Minimum Value: 0
794 * - Maximum Value: 4294967295
795 * - Default Value: 0
796 * - Units:
797 *
798 * Default Rates:
799 * - CAN: 4.0 Hz
800 *
801 * This refreshes and returns a cached StatusSignal object.
802 *
803 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
804 * \returns StickyFaultField Status Signal Object
805 */
807
808 /**
809 * \brief Velocity of the device.
810 *
811 * - Minimum Value: -512.0
812 * - Maximum Value: 511.998046875
813 * - Default Value: 0
814 * - Units: rotations per second
815 *
816 * Default Rates:
817 * - CAN 2.0: 100.0 Hz
818 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
819 *
820 * This refreshes and returns a cached StatusSignal object.
821 *
822 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
823 * \returns Velocity Status Signal Object
824 */
826
827 /**
828 * \brief Position of the device. This is initialized to the absolute
829 * position on boot.
830 *
831 * - Minimum Value: -16384.0
832 * - Maximum Value: 16383.999755859375
833 * - Default Value: 0
834 * - Units: rotations
835 *
836 * Default Rates:
837 * - CAN 2.0: 100.0 Hz
838 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
839 *
840 * This refreshes and returns a cached StatusSignal object.
841 *
842 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
843 * \returns Position Status Signal Object
844 */
846
847 /**
848 * \brief Absolute Position of the device. The possible range is
849 * documented below; however, the exact expected range is determined
850 * by the AbsoluteSensorRange. This position is only affected by the
851 * MagnetSensor configs.
852 *
853 * - Minimum Value: -0.5
854 * - Maximum Value: 0.999755859375
855 * - Default Value: 0
856 * - Units: rotations
857 *
858 * Default Rates:
859 * - CAN 2.0: 100.0 Hz
860 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
861 *
862 * This refreshes and returns a cached StatusSignal object.
863 *
864 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
865 * \returns AbsolutePosition Status Signal Object
866 */
868
869 /**
870 * \brief The unfiltered velocity reported by CANcoder.
871 *
872 * \details This is the unfiltered velocity reported by CANcoder. This
873 * signal does not use the fusing algorithm.
874 *
875 * - Minimum Value: -8000.0
876 * - Maximum Value: 7999.755859375
877 * - Default Value: 0
878 * - Units: rotations per second
879 *
880 * Default Rates:
881 * - CAN 2.0: 4.0 Hz
882 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
883 *
884 * This refreshes and returns a cached StatusSignal object.
885 *
886 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
887 * \returns UnfilteredVelocity Status Signal Object
888 */
890
891 /**
892 * \brief The relative position reported by the CANcoder since boot.
893 *
894 * \details This is the total displacement reported by CANcoder since
895 * power up. This signal is relative and is not influenced by the
896 * fusing algorithm.
897 *
898 * - Minimum Value: -16384.0
899 * - Maximum Value: 16383.999755859375
900 * - Default Value: 0
901 * - Units: rotations
902 *
903 * Default Rates:
904 * - CAN 2.0: 4.0 Hz
905 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
906 *
907 * This refreshes and returns a cached StatusSignal object.
908 *
909 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
910 * \returns PositionSinceBoot Status Signal Object
911 */
913
914 /**
915 * \brief Measured supply voltage to the CANcoder.
916 *
917 * - Minimum Value: 4
918 * - Maximum Value: 16.75
919 * - Default Value: 4
920 * - Units: V
921 *
922 * Default Rates:
923 * - CAN 2.0: 4.0 Hz
924 * - CAN FD: 100.0 Hz (TimeSynced with Pro)
925 *
926 * This refreshes and returns a cached StatusSignal object.
927 *
928 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
929 * \returns SupplyVoltage Status Signal Object
930 */
932
933 /**
934 * \brief Magnet health as measured by CANcoder.
935 *
936 * \details Magnet health as measured by CANcoder. Red indicates too
937 * close or too far, Orange is adequate but with reduced accuracy,
938 * green is ideal. Invalid means the accuracy cannot be determined.
939 *
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 MagnetHealth Status Signal Object
949 */
951
952 /**
953 * \brief Whether the device is Phoenix Pro licensed.
954 *
955 * - Default Value: False
956 *
957 * Default Rates:
958 * - CAN: 4.0 Hz
959 *
960 * This refreshes and returns a cached StatusSignal object.
961 *
962 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
963 * \returns IsProLicensed Status Signal Object
964 */
966
967 /**
968 * \brief Hardware fault occurred
969 *
970 * - Default Value: False
971 *
972 * Default Rates:
973 * - CAN: 4.0 Hz
974 *
975 * This refreshes and returns a cached StatusSignal object.
976 *
977 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
978 * \returns Fault_Hardware Status Signal Object
979 */
981
982 /**
983 * \brief Hardware fault occurred
984 *
985 * - Default Value: False
986 *
987 * Default Rates:
988 * - CAN: 4.0 Hz
989 *
990 * This refreshes and returns a cached StatusSignal object.
991 *
992 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
993 * \returns StickyFault_Hardware Status Signal Object
994 */
996
997 /**
998 * \brief Device supply voltage dropped to near brownout levels
999 *
1000 * - Default Value: False
1001 *
1002 * Default Rates:
1003 * - CAN: 4.0 Hz
1004 *
1005 * This refreshes and returns a cached StatusSignal object.
1006 *
1007 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1008 * \returns Fault_Undervoltage Status Signal Object
1009 */
1011
1012 /**
1013 * \brief Device supply voltage dropped to near brownout levels
1014 *
1015 * - Default Value: False
1016 *
1017 * Default Rates:
1018 * - CAN: 4.0 Hz
1019 *
1020 * This refreshes and returns a cached StatusSignal object.
1021 *
1022 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1023 * \returns StickyFault_Undervoltage Status Signal Object
1024 */
1026
1027 /**
1028 * \brief Device boot while detecting the enable signal
1029 *
1030 * - Default Value: False
1031 *
1032 * Default Rates:
1033 * - CAN: 4.0 Hz
1034 *
1035 * This refreshes and returns a cached StatusSignal object.
1036 *
1037 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1038 * \returns Fault_BootDuringEnable Status Signal Object
1039 */
1041
1042 /**
1043 * \brief Device boot while detecting the enable signal
1044 *
1045 * - Default Value: False
1046 *
1047 * Default Rates:
1048 * - CAN: 4.0 Hz
1049 *
1050 * This refreshes and returns a cached StatusSignal object.
1051 *
1052 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1053 * \returns StickyFault_BootDuringEnable Status Signal Object
1054 */
1056
1057 /**
1058 * \brief An unlicensed feature is in use, device may not behave as
1059 * expected.
1060 *
1061 * - Default Value: False
1062 *
1063 * Default Rates:
1064 * - CAN: 4.0 Hz
1065 *
1066 * This refreshes and returns a cached StatusSignal object.
1067 *
1068 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1069 * \returns Fault_UnlicensedFeatureInUse Status Signal Object
1070 */
1072
1073 /**
1074 * \brief An unlicensed feature is in use, device may not behave as
1075 * expected.
1076 *
1077 * - Default Value: False
1078 *
1079 * Default Rates:
1080 * - CAN: 4.0 Hz
1081 *
1082 * This refreshes and returns a cached StatusSignal object.
1083 *
1084 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1085 * \returns StickyFault_UnlicensedFeatureInUse Status Signal Object
1086 */
1088
1089 /**
1090 * \brief The magnet distance is not correct or magnet is missing
1091 *
1092 * - Default Value: False
1093 *
1094 * Default Rates:
1095 * - CAN: 4.0 Hz
1096 *
1097 * This refreshes and returns a cached StatusSignal object.
1098 *
1099 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1100 * \returns Fault_BadMagnet Status Signal Object
1101 */
1103
1104 /**
1105 * \brief The magnet distance is not correct or magnet is missing
1106 *
1107 * - Default Value: False
1108 *
1109 * Default Rates:
1110 * - CAN: 4.0 Hz
1111 *
1112 * This refreshes and returns a cached StatusSignal object.
1113 *
1114 * \param refresh Whether to refresh the StatusSignal before returning it; defaults to true
1115 * \returns StickyFault_BadMagnet Status Signal Object
1116 */
1118
1119
1120
1121 /**
1122 * \brief Control motor with generic control request object. User must make
1123 * sure the specified object is castable to a valid control request,
1124 * otherwise this function will fail at run-time and return the NotSupported
1125 * StatusCode
1126 *
1127 * \param request Control object to request of the device
1128 * \returns Status Code of the request, 0 is OK
1129 */
1131 {
1132 controls::ControlRequest *ptr = &request;
1133 (void)ptr;
1134
1136 }
1137 /**
1138 * \brief Control motor with generic control request object. User must make
1139 * sure the specified object is castable to a valid control request,
1140 * otherwise this function will fail at run-time and return the corresponding
1141 * StatusCode
1142 *
1143 * \param request Control object to request of the device
1144 * \returns Status Code of the request, 0 is OK
1145 */
1147 {
1148 return SetControl(request);
1149 }
1150
1151
1152 /**
1153 * \brief Sets the current position of the device.
1154 *
1155 * \param newValue Value to set to. Units are in rotations.
1156 * \param timeoutSeconds Maximum time to wait up to in seconds.
1157 * \returns StatusCode of the set command
1158 */
1159 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
1160 {
1161 return GetConfigurator().SetPosition(newValue, timeoutSeconds);
1162 }
1163 /**
1164 * \brief Sets the current position of the device.
1165 *
1166 * This will wait up to 0.100 seconds (100ms) by default.
1167 *
1168 * \param newValue Value to set to. Units are in rotations.
1169 * \returns StatusCode of the set command
1170 */
1171 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
1172 {
1173 return SetPosition(newValue, 0.100_s);
1174 }
1175
1176 /**
1177 * \brief Clear the sticky faults in the device.
1178 *
1179 * \details This typically has no impact on the device functionality.
1180 * Instead, it just clears telemetry faults that are accessible via
1181 * API and Tuner Self-Test.
1182 *
1183 * \param timeoutSeconds Maximum time to wait up to in seconds.
1184 * \returns StatusCode of the set command
1185 */
1186 ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
1187 {
1188 return GetConfigurator().ClearStickyFaults(timeoutSeconds);
1189 }
1190 /**
1191 * \brief Clear the sticky faults in the device.
1192 *
1193 * \details This typically has no impact on the device functionality.
1194 * Instead, it just clears telemetry faults that are accessible via
1195 * API and Tuner Self-Test.
1196 *
1197 * This will wait up to 0.100 seconds (100ms) by default.
1198 *
1199 * \returns StatusCode of the set command
1200 */
1202 {
1203 return ClearStickyFaults(0.100_s);
1204 }
1205
1206 /**
1207 * \brief Clear sticky fault: Hardware fault occurred
1208 *
1209 * \param timeoutSeconds Maximum time to wait up to in seconds.
1210 * \returns StatusCode of the set command
1211 */
1212 ctre::phoenix::StatusCode ClearStickyFault_Hardware(units::time::second_t timeoutSeconds)
1213 {
1214 return GetConfigurator().ClearStickyFault_Hardware(timeoutSeconds);
1215 }
1216 /**
1217 * \brief Clear sticky fault: Hardware fault occurred
1218 *
1219 * This will wait up to 0.100 seconds (100ms) by default.
1220 *
1221 * \returns StatusCode of the set command
1222 */
1224 {
1225 return ClearStickyFault_Hardware(0.100_s);
1226 }
1227
1228 /**
1229 * \brief Clear sticky fault: Device supply voltage dropped to near
1230 * brownout levels
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_Undervoltage(units::time::second_t timeoutSeconds)
1236 {
1237 return GetConfigurator().ClearStickyFault_Undervoltage(timeoutSeconds);
1238 }
1239 /**
1240 * \brief Clear sticky fault: Device supply voltage dropped to near
1241 * brownout levels
1242 *
1243 * This will wait up to 0.100 seconds (100ms) by default.
1244 *
1245 * \returns StatusCode of the set command
1246 */
1248 {
1249 return ClearStickyFault_Undervoltage(0.100_s);
1250 }
1251
1252 /**
1253 * \brief Clear sticky fault: Device boot while detecting the enable
1254 * signal
1255 *
1256 * \param timeoutSeconds Maximum time to wait up to in seconds.
1257 * \returns StatusCode of the set command
1258 */
1260 {
1261 return GetConfigurator().ClearStickyFault_BootDuringEnable(timeoutSeconds);
1262 }
1263 /**
1264 * \brief Clear sticky fault: Device boot while detecting the enable
1265 * signal
1266 *
1267 * This will wait up to 0.100 seconds (100ms) by default.
1268 *
1269 * \returns StatusCode of the set command
1270 */
1272 {
1273 return ClearStickyFault_BootDuringEnable(0.100_s);
1274 }
1275
1276 /**
1277 * \brief Clear sticky fault: The magnet distance is not correct or
1278 * magnet is missing
1279 *
1280 * \param timeoutSeconds Maximum time to wait up to in seconds.
1281 * \returns StatusCode of the set command
1282 */
1283 ctre::phoenix::StatusCode ClearStickyFault_BadMagnet(units::time::second_t timeoutSeconds)
1284 {
1285 return GetConfigurator().ClearStickyFault_BadMagnet(timeoutSeconds);
1286 }
1287 /**
1288 * \brief Clear sticky fault: The magnet distance is not correct or
1289 * magnet is missing
1290 *
1291 * This will wait up to 0.100 seconds (100ms) by default.
1292 *
1293 * \returns StatusCode of the set command
1294 */
1296 {
1297 return ClearStickyFault_BadMagnet(0.100_s);
1298 }
1299};
1300
1301}
1302}
1303
1304}
1305}
1306
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
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: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:573
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 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:3555
std::string ToString() const override
Definition: Configs.hpp:3624
std::string Serialize() const override
Definition: Configs.hpp:3633
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:3642
Configs that affect the magnet sensor and how to interpret it.
Definition: Configs.hpp:58
std::string Serialize() const override
Definition: Configs.hpp:156
ctre::phoenix::StatusCode Deserialize(const std::string &to_deserialize) override
Definition: Configs.hpp:166
std::string ToString() const override
Definition: Configs.hpp:146
Definition: Configurator.hpp:21
ctre::phoenix::StatusCode SetConfigsPrivate(const std::string &serializedString, units::time::second_t timeoutSeconds, bool futureProofConfigs, bool overrideIfDuplicate)
Definition: Configurator.hpp:40
ctre::phoenix::StatusCode GetConfigsPrivate(std::string &serializedString, units::time::second_t timeoutSeconds) const
Definition: Configurator.hpp:63
units::time::second_t DefaultTimeoutSeconds
The default maximum amount of time to wait for a config.
Definition: Configurator.hpp:26
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:592
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:1186
CoreCANcoder(int deviceId, CANBus canbus)
Constructs a new CANcoder object.
Definition: CoreCANcoder.hpp:620
ctre::phoenix::StatusCode ClearStickyFault_Undervoltage()
Clear sticky fault: Device supply voltage dropped to near brownout levels.
Definition: CoreCANcoder.hpp:1247
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:1201
configs::CANcoderConfigurator & GetConfigurator()
Gets the configurator for this CANcoder.
Definition: CoreCANcoder.hpp:631
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:1212
StatusSignal< units::angle::turn_t > & GetPosition(bool refresh=true)
Position of the device.
StatusSignal< int > & GetStickyFaultField(bool refresh=true)
Integer representing all sticky faults.
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:1235
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:1171
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:661
ctre::phoenix::StatusCode ClearStickyFault_BadMagnet()
Clear sticky fault: The magnet distance is not correct or magnet is missing.
Definition: CoreCANcoder.hpp:1295
ctre::phoenix::StatusCode SetControl(controls::ControlRequest &request)
Control motor with generic control request object.
Definition: CoreCANcoder.hpp:1130
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:1259
StatusSignal< int > & GetVersion(bool refresh=true)
Full Version.
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:1283
StatusSignal< units::angle::turn_t > & GetPositionSinceBoot(bool refresh=true)
The relative position reported by the CANcoder since boot.
ctre::phoenix::StatusCode SetControl(controls::ControlRequest &&request)
Control motor with generic control request object.
Definition: CoreCANcoder.hpp:1146
StatusSignal< int > & GetFaultField(bool refresh=true)
Integer representing all faults.
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
Sets the current position of the device.
Definition: CoreCANcoder.hpp:1159
StatusSignal< bool > & GetFault_UnlicensedFeatureInUse(bool refresh=true)
An unlicensed feature is in use, device may not behave as expected.
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:1223
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:643
ctre::phoenix::StatusCode ClearStickyFault_BootDuringEnable()
Clear sticky fault: Device boot while detecting the enable signal.
Definition: CoreCANcoder.hpp:1271
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:648
Represents the state of one swerve module.
Definition: StatusCodes.h:18
Definition: span.hpp:401