CTRE Phoenix Pro C++ 23.0.12
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
12
14#include <units/angle.h>
15#include <units/angular_velocity.h>
16#include <units/dimensionless.h>
17#include <units/voltage.h>
18
19namespace ctre {
20namespace phoenixpro {
21
22namespace hardware {
23namespace core {
24 class CoreCANcoder;
25}
26}
27
28namespace configs {
29
30/**
31 * Class for CANcoder, a CAN based magnetic encoder that provides absolute and
32 * relative position along with filtered velocity.
33 *
34 * This handles the configurations for the hardware#CANcoder
35 */
37{
38public:
39 /**
40 * \brief True if we should factory default newer unsupported configs,
41 * false to leave newer unsupported configs alone.
42 *
43 * \details This flag addresses a corner case where the device may have
44 * firmware with newer configs that didn't exist when this
45 * version of the API was built. If this occurs and this
46 * flag is true, unsupported new configs will be factory
47 * defaulted to avoid unexpected behavior.
48 *
49 * This is also the behavior in Phoenix 5, so this flag
50 * is defaulted to true to match.
51 */
53
54
55 /**
56 * \brief Configs that affect the magnet sensor and how to interpret
57 * it.
58 *
59 * \details Includes sensor range and other configs related to
60 * sensor.
61 */
63
64 /**
65 * \brief Get the string representation of this configuration
66 */
67 std::string ToString() const
68 {
69 std::stringstream ss;
70 ss << MagnetSensor.ToString();
71 return ss.str();
72 }
73
74 /**
75 * \brief Get the serialized form of this configuration
76 */
77 std::string Serialize() const
78 {
79 std::stringstream ss;
80 ss << MagnetSensor.Serialize();
81 return ss.str();
82 }
83
84 /**
85 * \brief Take a string and deserialize it to this configuration
86 */
87 ctre::phoenix::StatusCode Deserialize(const std::string& string)
88 {
89 ctre::phoenix::StatusCode err = ctre::phoenix::StatusCode::OK;
90 err = MagnetSensor.Deserialize(string);
91 return err;
92 }
93};
94
95/**
96 * Class for CANcoder, a CAN based magnetic encoder that provides absolute and
97 * relative position along with filtered velocity.
98 *
99 * This handles the configurations for the hardware#CANcoder
100 */
102{
104 ParentConfigurator{std::move(id)}
105 {}
106
108public:
109
110 /**
111 * Delete the copy constructor, we can only pass by reference
112 */
114
115 /**
116 * \brief Refreshes the values of the specified config group.
117 *
118 * This will wait up to #defaultTimeoutSeconds.
119 *
120 * \details Call to refresh the selected configs from the device.
121 *
122 * \param configs The configs to refresh
123 * \returns StatusCode of refreshing the configs
124 */
125 ctre::phoenix::StatusCode Refresh(CANcoderConfiguration& configs) const
126 {
127 return Refresh(configs, defaultTimeoutSeconds);
128 }
129
130 /**
131 * \brief Refreshes the values of the specified config group.
132 *
133 * \details Call to refresh the selected configs from the device.
134 *
135 * \param configs The configs to refresh
136 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
137 * \returns StatusCode of refreshing the configs
138 */
139 ctre::phoenix::StatusCode Refresh(CANcoderConfiguration& configs, units::time::second_t timeoutSeconds) const
140 {
141 std::string ref;
142 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
143 configs.Deserialize(ref);
144 return ret;
145 }
146
147 /**
148 * \brief Applies the contents of the specified config to the device.
149 *
150 * This will wait up to #defaultTimeoutSeconds.
151 *
152 * \details Call to apply the selected configs.
153 *
154 * \param configs Configs to apply against.
155 * \returns StatusCode of the set command
156 */
157 ctre::phoenix::StatusCode Apply(const CANcoderConfiguration& configs)
158 {
159 return Apply(configs, defaultTimeoutSeconds);
160 }
161
162 /**
163 * \brief Applies the contents of the specified config to the device.
164 *
165 * \details Call to apply the selected configs.
166 *
167 * \param configs Configs to apply against.
168 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
169 * \returns StatusCode of the set command
170 */
171 ctre::phoenix::StatusCode Apply(const CANcoderConfiguration& configs, units::time::second_t timeoutSeconds)
172 {
173 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, configs.FutureProofConfigs, false);
174 }
175
176
177 /**
178 * \brief Refreshes the values of the specified config group.
179 *
180 * This will wait up to #defaultTimeoutSeconds.
181 *
182 * \details Call to refresh the selected configs from the device.
183 *
184 * \param configs The configs to refresh
185 * \returns StatusCode of refreshing the configs
186 */
187 ctre::phoenix::StatusCode Refresh(MagnetSensorConfigs& configs) const
188 {
189 return Refresh(configs, defaultTimeoutSeconds);
190 }
191 /**
192 * \brief Refreshes the values of the specified config group.
193 *
194 * \details Call to refresh the selected configs from the device.
195 *
196 * \param configs The configs to refresh
197 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
198 * \returns StatusCode of refreshing the configs
199 */
200 ctre::phoenix::StatusCode Refresh(MagnetSensorConfigs& configs, units::time::second_t timeoutSeconds) const
201 {
202 std::string ref;
203 ctre::phoenix::StatusCode ret = GetConfigsPrivate(ref, timeoutSeconds);
204 configs.Deserialize(ref);
205 return ret;
206 }
207
208 /**
209 * \brief Applies the contents of the specified config to the device.
210 *
211 * This will wait up to #defaultTimeoutSeconds.
212 *
213 * \details Call to apply the selected configs.
214 *
215 * \param configs Configs to apply against.
216 * \returns StatusCode of the set command
217 */
218 ctre::phoenix::StatusCode Apply(const MagnetSensorConfigs& configs)
219 {
220 return Apply(configs, defaultTimeoutSeconds);
221 }
222
223 /**
224 * \brief Applies the contents of the specified config to the device.
225 *
226 * \details Call to apply the selected configs.
227 *
228 * \param configs Configs to apply against.
229 * \param timeoutSeconds Maximum amount of time to wait when performing configuration
230 * \returns StatusCode of the set command
231 */
232 ctre::phoenix::StatusCode Apply(const MagnetSensorConfigs& configs, units::time::second_t timeoutSeconds)
233 {
234 return SetConfigsPrivate(configs.Serialize(), timeoutSeconds, false, false);
235 }
236
237
238 /**
239 * \brief The position to set the sensor position to right now.
240 *
241 * This will wait up to #defaultTimeoutSeconds.
242 *
243 * This is available in the configurator in case the user wants
244 * to initialize their device entirely without passing a device
245 * reference down to the code that performs the initialization.
246 * In this case, the user passes down the configurator object
247 * and performs all the initialization code on the object.
248 *
249 * \param newValue Value to set to.
250 * \returns StatusCode of the set command
251 */
252 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
253 {
254 return SetPosition(newValue, defaultTimeoutSeconds);
255 }
256 /**
257 * \brief The position to set the sensor position to right now.
258 *
259 * This is available in the configurator in case the user wants
260 * to initialize their device entirely without passing a device
261 * reference down to the code that performs the initialization.
262 * In this case, the user passes down the configurator object
263 * and performs all the initialization code on the object.
264 *
265 * \param newValue Value to set to.
266 * \param timeoutSeconds Maximum time to wait up to in seconds.
267 * \returns StatusCode of the set command
268 */
269 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
270 {
271 std::stringstream ss;
272 char *ref;
273 c_ctre_phoenixpro_serialize_double(1010, newValue.to<double>(), &ref); if(ref != nullptr) { ss << ref; free(ref); }
274 return SetConfigsPrivate(ss.str(), timeoutSeconds, false, true);
275 }
276
277 /**
278 * \brief Clear the sticky faults in the device.
279 *
280 * \details This typically has no impact on the device functionality.
281 * Instead, it just clears telemetry faults that are accessible via
282 * API and Tuner Self-Test.
283 *
284 * This will wait up to #defaultTimeoutSeconds.
285 *
286 * This is available in the configurator in case the user wants
287 * to initialize their device entirely without passing a device
288 * reference down to the code that performs the initialization.
289 * In this case, the user passes down the configurator object
290 * and performs all the initialization code on the object.
291 * \returns StatusCode of the set command
292 */
293 ctre::phoenix::StatusCode ClearStickyFaults()
294 {
296 }
297 /**
298 * \brief Clear the sticky faults in the device.
299 *
300 * \details This typically has no impact on the device functionality.
301 * Instead, it just clears telemetry faults that are accessible via
302 * API and Tuner Self-Test.
303 *
304 * This is available in the configurator in case the user wants
305 * to initialize their device entirely without passing a device
306 * reference down to the code that performs the initialization.
307 * In this case, the user passes down the configurator object
308 * and performs all the initialization code on the object.
309 * \param timeoutSeconds Maximum time to wait up to in seconds.
310 * \returns StatusCode of the set command
311 */
312 ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
313 {
314 std::stringstream ss;
315 char *ref;
316 c_ctre_phoenixpro_serialize_double(1476, 0, &ref); if(ref != nullptr) { ss << ref; free(ref); }
317 return SetConfigsPrivate(ss.str(), timeoutSeconds, false, true);
318 }
319};
320
321}
322
323namespace hardware {
324namespace core {
325
326/**
327 * Class for CANcoder, a CAN based magnetic encoder that provides absolute and
328 * relative position along with filtered velocity.
329 */
331{
332private:
334
335 bool _isInitialized = false;
336 bool _isVersionOk = false;
338 double _timeToRefreshVersion = GetCurrentTimeSeconds();
339
340 StatusSignalValue<int> &_resetFlags = LookupStatusSignalValue<int>(ctre::phoenixpro::spns::SpnValue::Startup_ResetFlags, "ResetFlags", false);
341 units::time::second_t _resetTimestamp{0_s};
342
343 double _creationTime = GetCurrentTimeSeconds();
344
345 void ReportIfTooOld();
346
347
348public:
349 /**
350 * Constructs a new CANcoder object.
351 *
352 * \param deviceId ID of the device, as configured in Phoenix Tuner.
353 * \param canbus Name of the CAN bus this device is on. Possible CAN bus strings are:
354 * - "rio" for the native roboRIO CAN bus
355 * - CANivore name or serial number
356 * - SocketCAN interface (non-FRC Linux only)
357 * - "*" for any CANivore seen by the program
358 * - empty string (default) to select the default for the system:
359 * - "rio" on roboRIO
360 * - "can0" on Linux
361 * - "*" on Windows
362 */
363 CoreCANcoder(int deviceId, std::string canbus = "");
364
365 CoreCANcoder(CoreCANcoder const &) = delete;
367
368 /**
369 * \returns true if device has reset since the previous call of this routine.
370 */
372
373 /**
374 * \brief Gets the configurator for this CANcoder
375 *
376 * \details Gets the configurator for this CANcoder
377 *
378 * \returns Configurator for this CANcoder
379 */
381 {
382 return _configs;
383 }
384
385 /**
386 * \brief Gets the configurator for this CANcoder
387 *
388 * \details Gets the configurator for this CANcoder
389 *
390 * \returns Configurator for this CANcoder
391 */
393 {
394 return _configs;
395 }
396
397
398private:
399 std::unique_ptr<sim::CANcoderSimState> _simState{};
400public:
401 /**
402 * \brief Get the simulation state for this device.
403 *
404 * \details This function reuses an allocated simulation
405 * state object, so it is safe to call this function multiple
406 * times in a robot loop.
407 *
408 * \returns Simulation state
409 */
411 {
412 if (_simState == nullptr)
413 _simState = std::make_unique<sim::CANcoderSimState>(*this);
414 return *_simState;
415 }
416
417
418
419 /**
420 * \brief App Major Version number.
421 *
422 * Minimum Value: 0
423 * Maximum Value: 255
424 * Default Value: 0
425 * Units:
426 *
427 * Default Rates:
428 * CAN: 4.0 Hz
429 *
430 * \returns VersionMajor Status Signal Value object
431 */
433
434 /**
435 * \brief App Minor Version number.
436 *
437 * Minimum Value: 0
438 * Maximum Value: 255
439 * Default Value: 0
440 * Units:
441 *
442 * Default Rates:
443 * CAN: 4.0 Hz
444 *
445 * \returns VersionMinor Status Signal Value object
446 */
448
449 /**
450 * \brief App Bugfix Version number.
451 *
452 * Minimum Value: 0
453 * Maximum Value: 255
454 * Default Value: 0
455 * Units:
456 *
457 * Default Rates:
458 * CAN: 4.0 Hz
459 *
460 * \returns VersionBugfix Status Signal Value object
461 */
463
464 /**
465 * \brief App Build Version number.
466 *
467 * Minimum Value: 0
468 * Maximum Value: 255
469 * Default Value: 0
470 * Units:
471 *
472 * Default Rates:
473 * CAN: 4.0 Hz
474 *
475 * \returns VersionBuild Status Signal Value object
476 */
478
479 /**
480 * \brief Full Version. The format is a four byte value.
481 *
482 * \details Full Version of firmware in device. The format is a four
483 * byte value.
484 *
485 * Minimum Value: 0
486 * Maximum Value: 4294967295
487 * Default Value: 0
488 * Units:
489 *
490 * Default Rates:
491 * CAN: 4.0 Hz
492 *
493 * \returns Version Status Signal Value object
494 */
496
497 /**
498 * \brief Integer representing all faults
499 *
500 * \details This returns the fault flags reported by the device. These
501 * are device specific and are not used directly in typical
502 * applications. Use the signal specific GetFault_*() methods instead.
503 *
504 *
505 * Minimum Value: 0
506 * Maximum Value: 1048575
507 * Default Value: 0
508 * Units:
509 *
510 * Default Rates:
511 * CAN: 4.0 Hz
512 *
513 * \returns FaultField Status Signal Value object
514 */
516
517 /**
518 * \brief Integer representing all sticky faults
519 *
520 * \details This returns the persistent "sticky" fault flags reported
521 * by the device. These are device specific and are not used directly
522 * in typical applications. Use the signal specific GetStickyFault_*()
523 * methods instead.
524 *
525 * Minimum Value: 0
526 * Maximum Value: 1048575
527 * Default Value: 0
528 * Units:
529 *
530 * Default Rates:
531 * CAN: 4.0 Hz
532 *
533 * \returns StickyFaultField Status Signal Value object
534 */
536
537 /**
538 * \brief Velocity of device.
539 *
540 * Minimum Value: -512.0
541 * Maximum Value: 511.998046875
542 * Default Value: 0
543 * Units: rotations per second
544 *
545 * Default Rates:
546 * CAN: 100.0 Hz
547 *
548 * \returns Velocity Status Signal Value object
549 */
551
552 /**
553 * \brief Position of device.
554 *
555 * Minimum Value: -16384.0
556 * Maximum Value: 16383.999755859375
557 * Default Value: 0
558 * Units: rotations
559 *
560 * Default Rates:
561 * CAN: 100.0 Hz
562 *
563 * \returns Position Status Signal Value object
564 */
566
567 /**
568 * \brief Absolute Position of device. The possible range is
569 * documented below, however the exact expected range is determined by
570 * the AbsoluteSensorRange.
571 *
572 * Minimum Value: -0.5
573 * Maximum Value: 0.999755859375
574 * Default Value: 0
575 * Units: rotations
576 *
577 * Default Rates:
578 * CAN: 100.0 Hz
579 *
580 * \returns AbsolutePosition Status Signal Value object
581 */
583
584 /**
585 * \brief The unfiltered velocity reported by CANcoder.
586 *
587 * \details This is the unfiltered velocity reported by CANcoder. This
588 * signal does not use the fusing algorithm. It is also not
589 * timesynced. If you wish to use a signal with timesync, use
590 * Velocity.
591 *
592 * Minimum Value: -8000.0
593 * Maximum Value: 7999.755859375
594 * Default Value: 0
595 * Units: rotations per second
596 *
597 * Default Rates:
598 * CAN 2.0: 10.0 Hz
599 * CAN FD: 100.0 Hz
600 *
601 * \returns UnfilteredVelocity Status Signal Value object
602 */
604
605 /**
606 * \brief The relative position reported by the CANcoder since boot.
607 *
608 * \details This is the total displacement reported by CANcoder since
609 * power up. This signal is relative and is not influenced by the
610 * fusing algorithm. It is also not timesynced. If you wish to use a
611 * signal with timesync, use Position.
612 *
613 * Minimum Value: -16384.0
614 * Maximum Value: 16383.999755859375
615 * Default Value: 0
616 * Units: rotations
617 *
618 * Default Rates:
619 * CAN 2.0: 10.0 Hz
620 * CAN FD: 100.0 Hz
621 *
622 * \returns PositionSinceBoot Status Signal Value object
623 */
625
626 /**
627 * \brief Measured supply voltage to the CANcoder.
628 *
629 * Minimum Value: 4
630 * Maximum Value: 16.75
631 * Default Value: 4
632 * Units: V
633 *
634 * Default Rates:
635 * CAN 2.0: 10.0 Hz
636 * CAN FD: 100.0 Hz
637 *
638 * \returns SupplyVoltage Status Signal Value object
639 */
641
642 /**
643 * \brief Magnet health as measured by CANcoder.
644 *
645 * \details Magnet health as measured by CANcoder. Red indicates too
646 * close or too far, Orange is adequate but with reduced accuracy,
647 * green is ideal. Invalid means the accuracy cannot be determined.
648 *
649 *
650 * Default Rates:
651 * CAN 2.0: 10.0 Hz
652 * CAN FD: 100.0 Hz
653 *
654 * \returns MagnetHealth Status Signal Value object
655 */
657
658 /**
659 * \brief Hardware fault occurred
660 *
661 * Default Value: False
662 *
663 * Default Rates:
664 * CAN: 4.0 Hz
665 *
666 * \returns Fault_Hardware Status Signal Value object
667 */
669
670 /**
671 * \brief Hardware fault occurred
672 *
673 * Default Value: False
674 *
675 * Default Rates:
676 * CAN: 4.0 Hz
677 *
678 * \returns StickyFault_Hardware Status Signal Value object
679 */
681
682 /**
683 * \brief Device supply voltage dropped to near brownout levels
684 *
685 * Default Value: False
686 *
687 * Default Rates:
688 * CAN: 4.0 Hz
689 *
690 * \returns Fault_Undervoltage Status Signal Value object
691 */
693
694 /**
695 * \brief Device supply voltage dropped to near brownout levels
696 *
697 * Default Value: False
698 *
699 * Default Rates:
700 * CAN: 4.0 Hz
701 *
702 * \returns StickyFault_Undervoltage Status Signal Value object
703 */
705
706 /**
707 * \brief Device boot while detecting the enable signal
708 *
709 * Default Value: False
710 *
711 * Default Rates:
712 * CAN: 4.0 Hz
713 *
714 * \returns Fault_BootDuringEnable Status Signal Value object
715 */
717
718 /**
719 * \brief Device boot while detecting the enable signal
720 *
721 * Default Value: False
722 *
723 * Default Rates:
724 * CAN: 4.0 Hz
725 *
726 * \returns StickyFault_BootDuringEnable Status Signal Value object
727 */
729
730 /**
731 * \brief The magnet distance is not correct or magnet is missing
732 *
733 * Default Value: False
734 *
735 * Default Rates:
736 * CAN: 4.0 Hz
737 *
738 * \returns Fault_BadMagnet Status Signal Value object
739 */
741
742 /**
743 * \brief The magnet distance is not correct or magnet is missing
744 *
745 * Default Value: False
746 *
747 * Default Rates:
748 * CAN: 4.0 Hz
749 *
750 * \returns StickyFault_BadMagnet Status Signal Value object
751 */
753
754
755
756 /**
757 * \brief Control motor with generic control request object. User must make
758 * sure the specified object is castable to a valid control request,
759 * otherwise this function will fail at run-time and return the NotSupported
760 * StatusCode
761 *
762 * \param request Control object to request of the device
763 * \returns Status Code of the request, 0 is OK
764 */
765 ctre::phoenix::StatusCode SetControl(controls::ControlRequest& request)
766 {
767 controls::ControlRequest *ptr = &request;
768 (void)ptr;
769
771 }
772 /**
773 * \brief Control motor with generic control request object. User must make
774 * sure the specified object is castable to a valid control request,
775 * otherwise this function will fail at run-time and return the corresponding
776 * StatusCode
777 *
778 * \param request Control object to request of the device
779 * \returns Status Code of the request, 0 is OK
780 */
781 ctre::phoenix::StatusCode SetControl(controls::ControlRequest&& request)
782 {
783 return SetControl(request);
784 }
785
786
787 /**
788 * \brief The position to set the sensor position to right now.
789 *
790 * \param newValue Value to set to.
791 * \param timeoutSeconds Maximum time to wait up to in seconds.
792 * \returns StatusCode of the set command
793 */
794 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
795 {
796 return GetConfigurator().SetPosition(newValue, timeoutSeconds);
797 }
798 /**
799 * \brief The position to set the sensor position to right now.
800 *
801 * This will wait up to 0.050 seconds (50ms) by default.
802 *
803 * \param newValue Value to set to.
804 * \returns StatusCode of the set command
805 */
806 ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
807 {
808 return SetPosition(newValue, 0.050_s);
809 }
810
811 /**
812 * \brief Clear the sticky faults in the device.
813 *
814 * \details This typically has no impact on the device functionality.
815 * Instead, it just clears telemetry faults that are accessible via
816 * API and Tuner Self-Test.
817 * \param timeoutSeconds Maximum time to wait up to in seconds.
818 * \returns StatusCode of the set command
819 */
820 ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
821 {
822 return GetConfigurator().ClearStickyFaults(timeoutSeconds);
823 }
824 /**
825 * \brief Clear the sticky faults in the device.
826 *
827 * \details This typically has no impact on the device functionality.
828 * Instead, it just clears telemetry faults that are accessible via
829 * API and Tuner Self-Test.
830 *
831 * This will wait up to 0.050 seconds (50ms) by default.
832 * \returns StatusCode of the set command
833 */
834 ctre::phoenix::StatusCode ClearStickyFaults()
835 {
836 return ClearStickyFaults(0.050_s);
837 }
838};
839
840}
841}
842
843}
844}
845
ii that the Software will be uninterrupted or error free
Definition: CTRE_LICENSE.txt:191
CTREXPORT int c_ctre_phoenixpro_serialize_double(int spn, double value, char **str)
@ OK
No Error.
Definition: StatusCodes.h:1101
@ NotSupported
This is not supported.
Definition: StatusCodes.h:1704
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CoreCANcoder.hpp:37
ctre::phoenix::StatusCode Deserialize(const std::string &string)
Take a string and deserialize it to this configuration.
Definition: CoreCANcoder.hpp:87
std::string Serialize() const
Get the serialized form of this configuration.
Definition: CoreCANcoder.hpp:77
MagnetSensorConfigs MagnetSensor
Configs that affect the magnet sensor and how to interpret it.
Definition: CoreCANcoder.hpp:62
bool FutureProofConfigs
True if we should factory default newer unsupported configs, false to leave newer unsupported configs...
Definition: CoreCANcoder.hpp:52
std::string ToString() const
Get the string representation of this configuration.
Definition: CoreCANcoder.hpp:67
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CoreCANcoder.hpp:102
ctre::phoenix::StatusCode Refresh(MagnetSensorConfigs &configs) const
Refreshes the values of the specified config group.
Definition: CoreCANcoder.hpp:187
CANcoderConfigurator(const CANcoderConfigurator &)=delete
Delete the copy constructor, we can only pass by reference.
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:171
ctre::phoenix::StatusCode ClearStickyFaults()
Clear the sticky faults in the device.
Definition: CoreCANcoder.hpp:293
ctre::phoenix::StatusCode Refresh(CANcoderConfiguration &configs) const
Refreshes the values of the specified config group.
Definition: CoreCANcoder.hpp:125
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:232
ctre::phoenix::StatusCode Refresh(MagnetSensorConfigs &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition: CoreCANcoder.hpp:200
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
The position to set the sensor position to right now.
Definition: CoreCANcoder.hpp:269
ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
Clear the sticky faults in the device.
Definition: CoreCANcoder.hpp:312
ctre::phoenix::StatusCode Refresh(CANcoderConfiguration &configs, units::time::second_t timeoutSeconds) const
Refreshes the values of the specified config group.
Definition: CoreCANcoder.hpp:139
ctre::phoenix::StatusCode Apply(const MagnetSensorConfigs &configs)
Applies the contents of the specified config to the device.
Definition: CoreCANcoder.hpp:218
ctre::phoenix::StatusCode Apply(const CANcoderConfiguration &configs)
Applies the contents of the specified config to the device.
Definition: CoreCANcoder.hpp:157
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
The position to set the sensor position to right now.
Definition: CoreCANcoder.hpp:252
Configs that affect the magnet sensor and how to interpret it.
Definition: Configs.hpp:42
std::string Serialize() const
Definition: Configs.hpp:81
std::string ToString() const
Definition: Configs.hpp:69
ctre::phoenix::StatusCode Deserialize(const std::string &string)
Definition: Configs.hpp:91
Definition: Configurator.hpp:21
ctre::phoenix::StatusCode GetConfigsPrivate(std::string &serializedString, units::time::second_t timeoutSeconds) const
Definition: Configurator.hpp:61
units::time::second_t defaultTimeoutSeconds
The default amount of time to wait for a config.
Definition: Configurator.hpp:26
ctre::phoenix::StatusCode SetConfigsPrivate(const std::string &serializedString, units::time::second_t timeoutSeconds, bool futureProofConfigs, bool overrideIfDuplicate)
Definition: Configurator.hpp:37
Abstract Control Request class that other control requests extend for use.
Definition: ControlRequest.hpp:65
Definition: DeviceIdentifier.hpp:19
Parent class for all devices.
Definition: ParentDevice.hpp:30
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along w...
Definition: CoreCANcoder.hpp:331
CoreCANcoder & operator=(CoreCANcoder const &)=delete
StatusSignalValue< bool > & GetStickyFault_BadMagnet()
The magnet distance is not correct or magnet is missing.
StatusSignalValue< int > & GetVersionMajor()
App Major Version number.
StatusSignalValue< units::voltage::volt_t > & GetSupplyVoltage()
Measured supply voltage to the CANcoder.
StatusSignalValue< units::angle::turn_t > & GetPositionSinceBoot()
The relative position reported by the CANcoder since boot.
StatusSignalValue< units::angular_velocity::turns_per_second_t > & GetVelocity()
Velocity of device.
ctre::phoenix::StatusCode SetControl(controls::ControlRequest &request)
Control motor with generic control request object.
Definition: CoreCANcoder.hpp:765
StatusSignalValue< int > & GetStickyFaultField()
Integer representing all sticky faults.
StatusSignalValue< bool > & GetStickyFault_Hardware()
Hardware fault occurred.
StatusSignalValue< units::angle::turn_t > & GetAbsolutePosition()
Absolute Position of device.
StatusSignalValue< units::angular_velocity::turns_per_second_t > & GetUnfilteredVelocity()
The unfiltered velocity reported by CANcoder.
StatusSignalValue< bool > & GetFault_Undervoltage()
Device supply voltage dropped to near brownout levels.
StatusSignalValue< int > & GetVersionBuild()
App Build Version number.
StatusSignalValue< int > & GetVersionBugfix()
App Bugfix Version number.
StatusSignalValue< bool > & GetFault_BootDuringEnable()
Device boot while detecting the enable signal.
StatusSignalValue< units::angle::turn_t > & GetPosition()
Position of device.
CoreCANcoder(CoreCANcoder const &)=delete
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue, units::time::second_t timeoutSeconds)
The position to set the sensor position to right now.
Definition: CoreCANcoder.hpp:794
StatusSignalValue< bool > & GetFault_Hardware()
Hardware fault occurred.
sim::CANcoderSimState & GetSimState()
Get the simulation state for this device.
Definition: CoreCANcoder.hpp:410
StatusSignalValue< int > & GetVersionMinor()
App Minor Version number.
StatusSignalValue< int > & GetFaultField()
Integer representing all faults.
configs::CANcoderConfigurator const & GetConfigurator() const
Gets the configurator for this CANcoder.
Definition: CoreCANcoder.hpp:392
StatusSignalValue< bool > & GetFault_BadMagnet()
The magnet distance is not correct or magnet is missing.
StatusSignalValue< bool > & GetStickyFault_BootDuringEnable()
Device boot while detecting the enable signal.
ctre::phoenix::StatusCode ClearStickyFaults(units::time::second_t timeoutSeconds)
Clear the sticky faults in the device.
Definition: CoreCANcoder.hpp:820
StatusSignalValue< bool > & GetStickyFault_Undervoltage()
Device supply voltage dropped to near brownout levels.
ctre::phoenix::StatusCode SetPosition(units::angle::turn_t newValue)
The position to set the sensor position to right now.
Definition: CoreCANcoder.hpp:806
CoreCANcoder(int deviceId, std::string canbus="")
Constructs a new CANcoder object.
StatusSignalValue< signals::MagnetHealthValue > & GetMagnetHealth()
Magnet health as measured by CANcoder.
ctre::phoenix::StatusCode ClearStickyFaults()
Clear the sticky faults in the device.
Definition: CoreCANcoder.hpp:834
configs::CANcoderConfigurator & GetConfigurator()
Gets the configurator for this CANcoder.
Definition: CoreCANcoder.hpp:380
StatusSignalValue< int > & GetVersion()
Full Version.
ctre::phoenix::StatusCode SetControl(controls::ControlRequest &&request)
Control motor with generic control request object.
Definition: CoreCANcoder.hpp:781
Class to control the state of a simulated hardware::CANcoder.
Definition: CANcoderSimState.hpp:31
static constexpr int Startup_ResetFlags
Definition: SpnValue.hpp:26
CTREXPORT double GetCurrentTimeSeconds()
Get the current timestamp in seconds.
Definition: string_util.hpp:14