ReduxLib C++ 2026.1.2
Loading...
Searching...
No Matches
CanandgyroDetails.h
1// Copyright (c) Bagholders of Redux Robotics and other contributors.
2// This is open source and can be modified and shared under the Mozilla Public License v2.0.
3
4#pragma once
5#include <cinttypes>
6#include <vector>
7#include <cstring>
8#include "redux/canand/CanandUtils.h"
9#include "redux/canand/CanandAddress.h"
10
11/**
12 * Canandgyro protocol-level definitions.
13 *
14 * This file is autogenerated by canandmessage, <b>do not hand-edit!</b>
15 */
17
18 /** Types. */
19 namespace types {
20 /** SettingReportFlags bitset definition */
22 public:
23 enum : uint8_t {
24 /** Whether the setting set/fetch was successful */
25 kSetSuccess = 1 << 0,
26
27 /** Whether the setting synch commit was successful */
29
30 };
31 };
32
33 /** Faults bitset definition */
34 class Faults {
35 public:
36 enum : uint8_t {
37 /** The power cycle fault flag, which is set to true when the device first boots.
38 Clearing sticky faults and then checking this flag can be used to determine if the device rebooted.
39 */
40 kPowerCycle = 1 << 0,
41
42 /** The CAN ID conflict flag, which is set to true if there is a CAN id conflict.
43 In practice, you should physically inspect the device to ensure it's not flashing blue.
44 */
46
47 /** The CAN general error flag, which will raise if the device encounters a CAN fault during operation.
48 If communication with the device still functions, this will not register as an active fault for long if at all.
49 This may raise due to wiring issues, such as an intermittently shorted CAN bus.
50 */
52
53 /** The temperature range flag, which will raise if the device is not between 0-70 degrees Celsius.
54 This may be of concern if the device is near very active motors.
55 */
57
58 /** The hardware fault flag, which will raise if a hardware issue is detected.
59 Generally will raise if the device's controller cannot read the physical sensor itself.
60 */
62
63 /** The calibration status flag, which will raise if the device is currently calibrating.
64 */
65 kCalibrating = 1 << 5,
66
67 /** The angular velocity saturation flag, which triggers on saturation of angular velocity.
68 */
70
71 /** The acceleration saturation flag, which triggers on saturation of acceleration.
72 */
74
75 };
76 };
77
78 /** CALIBRATION_TYPE enum definition */
80 public:
81 enum : uint8_t {
82 /** Normal calibration routine */
83 kNormal = 0x0,
84
85 /** Save ZRO at calibration complete */
86 kSaveZro = 0x1,
87
88 /** Temperature calibrate slot 0 */
89 kTempCal0 = 0x2,
90
91 /** Temperature calibrate slot 1 */
92 kTempCal1 = 0x3,
93
94 };
95 };
96
97 /** SETTING_COMMAND enum definition */
99 public:
100 enum : uint8_t {
101 /** Fetch all settings from device via a series of :ref:`report setting<msg_report_setting>` messages of all indexes */
103
104 /** Reset all resettanble settings to factory default, and broadcast all setting values via
105 :ref:`report setting<msg_report_setting>` messages.
106 */
108
109 /** Requests to fetch a single setting from device, with its value reported via the
110 :ref:`report setting<msg_report_setting>` message.
111
112 This requires the use of the second byte to specify the setting index to fetch. */
114
115 };
116 };
117
118 /** setting_flags definition */
120 public:
121 /** Whether the setting should be set ephemeral */
123
124 /** Whether the setting should be held until the next synch barrier */
126
127 /** Synch message count */
129
130 /**
131 * Decodes a struct.
132 *
133 * @param data intfield to decode
134 * @return a decoded struct
135 */
136 static constexpr SettingFlags decode(uint64_t data) {
137 return SettingFlags {
139 .synch_hold = redux::canand::utils::extractBool(data, 1),
140 .synch_msg_count = redux::canand::utils::extractU8(data, 4, 4),
141 };
142 }
143
144 /**
145 * Encodes a struct.
146 *
147 * @return an encoded struct.
148 */
149 constexpr uint64_t encode() {
150 return (
151 0 |
152 redux::canand::utils::packBool(this->ephemeral, 0) |
153 redux::canand::utils::packBool(this->synch_hold, 1) |
154 redux::canand::utils::packUInt(this->synch_msg_count, 4, 4)
155 );
156 }
157
158
159 };
160
161 /** firmware_version definition */
163 public:
164 /** Firmware version patch number */
166
167 /** Firmware version minor number */
169
170 /** Firmware version year */
172
173 /**
174 * Decodes a struct.
175 *
176 * @param data intfield to decode
177 * @return a decoded struct
178 */
179 static constexpr FirmwareVersion decode(uint64_t data) {
180 return FirmwareVersion {
182 .firmware_minor = redux::canand::utils::extractU8(data, 8, 8),
183 .firmware_year = redux::canand::utils::extractU16(data, 16, 16),
184 };
185 }
186
187 /**
188 * Encodes a struct.
189 *
190 * @return an encoded struct.
191 */
192 constexpr uint64_t encode() {
193 return (
194 0 |
195 redux::canand::utils::packUInt(this->firmware_patch, 8, 0) |
196 redux::canand::utils::packUInt(this->firmware_minor, 8, 8) |
197 redux::canand::utils::packUInt(this->firmware_year, 16, 16)
198 );
199 }
200
201
202 };
203
204 /** temp_cal_point definition */
206 public:
207 /** Temperature point */
209
210 /** Offset at the temperature */
211 float offset;
212
213 /**
214 * Decodes a struct.
215 *
216 * @param data intfield to decode
217 * @return a decoded struct
218 */
219 static constexpr TempCalPoint decode(uint64_t data) {
220 return TempCalPoint {
222 .offset = redux::canand::utils::extractF32(data, 16),
223 };
224 }
225
226 /**
227 * Encodes a struct.
228 *
229 * @return an encoded struct.
230 */
231 constexpr uint64_t encode() {
232 return (
233 0 |
234 redux::canand::utils::packInt(this->temperature_point, 16, 0) |
235 redux::canand::utils::packF32(this->offset, 16)
236 );
237 }
238
239
240 };
241
242 /** quat_xyz definition */
243 struct QuatXyz {
244 public:
245 /** Quaternion x term */
246 int16_t x;
247
248 /** Quaternion y term */
249 int16_t y;
250
251 /** Quaternion z term */
252 int16_t z;
253
254 /**
255 * Decodes a struct.
256 *
257 * @param data intfield to decode
258 * @return a decoded struct
259 */
260 static constexpr QuatXyz decode(uint64_t data) {
261 return QuatXyz {
262 .x = redux::canand::utils::extractI16(data, 16, 0),
263 .y = redux::canand::utils::extractI16(data, 16, 16),
264 .z = redux::canand::utils::extractI16(data, 16, 32),
265 };
266 }
267
268 /**
269 * Encodes a struct.
270 *
271 * @return an encoded struct.
272 */
273 constexpr uint64_t encode() {
274 return (
275 0 |
276 redux::canand::utils::packInt(this->x, 16, 0) |
277 redux::canand::utils::packInt(this->y, 16, 16) |
278 redux::canand::utils::packInt(this->z, 16, 32)
279 );
280 }
281
282
283 };
284
285 /** yaw definition */
286 struct Yaw {
287 public:
288 /** Yaw angle (f32 between [-pi..pi) radians) */
289 float yaw;
290
291 /** Wraparound counter */
292 int16_t wraparound;
293
294 /**
295 * Decodes a struct.
296 *
297 * @param data intfield to decode
298 * @return a decoded struct
299 */
300 static constexpr Yaw decode(uint64_t data) {
301 return Yaw {
303 .wraparound = redux::canand::utils::extractI16(data, 16, 32),
304 };
305 }
306
307 /**
308 * Encodes a struct.
309 *
310 * @return an encoded struct.
311 */
312 constexpr uint64_t encode() {
313 return (
314 0 |
315 redux::canand::utils::packF32(this->yaw, 0) |
316 redux::canand::utils::packInt(this->wraparound, 16, 32)
317 );
318 }
319
320
321 };
322
323 }
324
325 /** Messages. */
326 namespace msg {
327 enum : uint8_t {
328 /** setting control command */
330
331 /** update setting on device */
333
334 /** setting value report from device */
336
337 /** Clear device sticky faults */
339
340 /** Status frame */
341 kStatus = 0x6,
342
343 /** Party mode */
345
346 /** Device enumerate response */
348
349 /** Yaw angle frame */
351
352 /** Angular position quaternion frame */
354
355 /** Angular velocity frame */
357
358 /** Acceleration frame */
360
361 /** Trigger Calibration */
363
364 /** Calibration Status */
366
367 };
368 /** setting control command struct */
370 public:
371 /** Setting command index */
373
374 /** setting index to fetch */
376
377 /**
378 * Decodes a struct.
379 *
380 * @param data intfield to decode
381 * @return a decoded struct
382 */
383 static constexpr SettingCommand decode(uint64_t data) {
384 return SettingCommand {
386 .setting_index = redux::canand::utils::extractU8(data, 8, 8),
387 };
388 }
389
390 /**
391 * Encodes a struct.
392 *
393 * @return an encoded struct.
394 */
395 constexpr uint64_t encode() {
396 return (
397 0 |
398 redux::canand::utils::packUInt(this->control_flag, 8, 0) |
399 redux::canand::utils::packUInt(this->setting_index, 8, 8)
400 );
401 }
402
403
404 /** Minimum acceptable data length code for this message */
405 static const uint32_t DLC_MIN = 1;
406
407 /** Maximum acceptable data length code for this message */
408 static const uint32_t DLC_MAX = 8;
409
410 /**
411 * Sends the message struct to a CanandAddress.
412 * @param addr the address to send to
413 * @return the return value of SendCANMessage
414 */
416 uint64_t data = this->encode();
417 return addr.SendCANMessage(msg::kSettingCommand, (uint8_t*) &data, 8);
418 }
419
420 };
421
422 /** update setting on device struct */
423 struct SetSetting {
424 public:
425 /** Setting index to write to */
426 uint8_t address;
427
428 /** 6-byte setting value */
429 uint64_t value;
430
431 /** Setting flags */
433
434 /**
435 * Decodes a struct.
436 *
437 * @param data intfield to decode
438 * @return a decoded struct
439 */
440 static constexpr SetSetting decode(uint64_t data) {
441 return SetSetting {
443 .value = redux::canand::utils::extractU64(data, 48, 8),
444 .flags = types::SettingFlags::decode(data >> 56),
445 };
446 }
447
448 /**
449 * Encodes a struct.
450 *
451 * @return an encoded struct.
452 */
453 constexpr uint64_t encode() {
454 return (
455 0 |
456 redux::canand::utils::packUInt(this->address, 8, 0) |
457 redux::canand::utils::packUInt(this->value, 48, 8) |
458 (this->flags.encode() << 56)
459 );
460 }
461
462
463 /** Minimum acceptable data length code for this message */
464 static const uint32_t DLC_MIN = 8;
465
466 /** Maximum acceptable data length code for this message */
467 static const uint32_t DLC_MAX = 8;
468
469 /**
470 * Sends the message struct to a CanandAddress.
471 * @param addr the address to send to
472 * @return the return value of SendCANMessage
473 */
475 uint64_t data = this->encode();
476 return addr.SendCANMessage(msg::kSetSetting, (uint8_t*) &data, 8);
477 }
478
479 };
480
481 /** setting value report from device struct */
483 public:
484 /** Setting index to write to */
485 uint8_t address;
486
487 /** 6-byte setting value */
488 uint64_t value;
489
490 /** Setting receive status */
491 uint8_t flags;
492
493 /**
494 * Decodes a struct.
495 *
496 * @param data intfield to decode
497 * @return a decoded struct
498 */
499 static constexpr ReportSetting decode(uint64_t data) {
500 return ReportSetting {
502 .value = redux::canand::utils::extractU64(data, 48, 8),
503 .flags = redux::canand::utils::extractU8(data, 8, 56),
504 };
505 }
506
507 /**
508 * Encodes a struct.
509 *
510 * @return an encoded struct.
511 */
512 constexpr uint64_t encode() {
513 return (
514 0 |
515 redux::canand::utils::packUInt(this->address, 8, 0) |
516 redux::canand::utils::packUInt(this->value, 48, 8) |
517 redux::canand::utils::packUInt(this->flags, 8, 56)
518 );
519 }
520
521
522 /** Minimum acceptable data length code for this message */
523 static const uint32_t DLC_MIN = 8;
524
525 /** Maximum acceptable data length code for this message */
526 static const uint32_t DLC_MAX = 8;
527
528 /**
529 * Sends the message struct to a CanandAddress.
530 * @param addr the address to send to
531 * @return the return value of SendCANMessage
532 */
534 uint64_t data = this->encode();
535 return addr.SendCANMessage(msg::kReportSetting, (uint8_t*) &data, 8);
536 }
537
538 };
539
540 /** Clear device sticky faults struct */
542 public:
543
544 /**
545 * Decodes a struct.
546 *
547 * @param data intfield to decode
548 * @return a decoded struct
549 */
550 static constexpr ClearStickyFaults decode(uint64_t data) {
551 return ClearStickyFaults {
552
553 };
554 }
555
556 /**
557 * Encodes a struct.
558 *
559 * @return an encoded struct.
560 */
561 constexpr uint64_t encode() {
562 return (
563 0
564 );
565 }
566
567
568 /** Minimum acceptable data length code for this message */
569 static const uint32_t DLC_MIN = 0;
570
571 /** Maximum acceptable data length code for this message */
572 static const uint32_t DLC_MAX = 8;
573
574 /**
575 * Sends the message struct to a CanandAddress.
576 * @param addr the address to send to
577 * @return the return value of SendCANMessage
578 */
580 uint64_t data = this->encode();
581 return addr.SendCANMessage(msg::kClearStickyFaults, (uint8_t*) &data, 8);
582 }
583
584 };
585
586 /** Status frame struct */
587 struct Status {
588 public:
589 /** 8-bit active faults bitfield */
590 uint8_t faults;
591
592 /** 8-bit sticky faults bitfield */
594
595 /** 16-bit signed temperature byte in 1/256ths of a Celsius */
596 int16_t temperature;
597
598 /**
599 * Decodes a struct.
600 *
601 * @param data intfield to decode
602 * @return a decoded struct
603 */
604 static constexpr Status decode(uint64_t data) {
605 return Status {
607 .sticky_faults = redux::canand::utils::extractU8(data, 8, 8),
608 .temperature = redux::canand::utils::extractI16(data, 16, 16),
609 };
610 }
611
612 /**
613 * Encodes a struct.
614 *
615 * @return an encoded struct.
616 */
617 constexpr uint64_t encode() {
618 return (
619 0 |
620 redux::canand::utils::packUInt(this->faults, 8, 0) |
621 redux::canand::utils::packUInt(this->sticky_faults, 8, 8) |
622 redux::canand::utils::packInt(this->temperature, 16, 16)
623 );
624 }
625
626
627 /** Minimum acceptable data length code for this message */
628 static const uint32_t DLC_MIN = 8;
629
630 /** Maximum acceptable data length code for this message */
631 static const uint32_t DLC_MAX = 8;
632
633 /**
634 * Sends the message struct to a CanandAddress.
635 * @param addr the address to send to
636 * @return the return value of SendCANMessage
637 */
639 uint64_t data = this->encode();
640 return addr.SendCANMessage(msg::kStatus, (uint8_t*) &data, 8);
641 }
642
643 };
644
645 /** Party mode struct */
646 struct PartyMode {
647 public:
648 /** Party level. 0 disables the strobe, whereas 1 enables it. */
649 uint8_t party_level;
650
651 /**
652 * Decodes a struct.
653 *
654 * @param data intfield to decode
655 * @return a decoded struct
656 */
657 static constexpr PartyMode decode(uint64_t data) {
658 return PartyMode {
660 };
661 }
662
663 /**
664 * Encodes a struct.
665 *
666 * @return an encoded struct.
667 */
668 constexpr uint64_t encode() {
669 return (
670 0 |
671 redux::canand::utils::packUInt(this->party_level, 8, 0)
672 );
673 }
674
675
676 /** Minimum acceptable data length code for this message */
677 static const uint32_t DLC_MIN = 1;
678
679 /** Maximum acceptable data length code for this message */
680 static const uint32_t DLC_MAX = 8;
681
682 /**
683 * Sends the message struct to a CanandAddress.
684 * @param addr the address to send to
685 * @return the return value of SendCANMessage
686 */
688 uint64_t data = this->encode();
689 return addr.SendCANMessage(msg::kPartyMode, (uint8_t*) &data, 8);
690 }
691
692 };
693
694 /** Device enumerate response struct */
695 struct Enumerate {
696 public:
697 /** Device-unique serial number */
698 uint64_t serial;
699
700 /** Device is in bootloader. */
702
703 /**
704 * Decodes a struct.
705 *
706 * @param data intfield to decode
707 * @return a decoded struct
708 */
709 static constexpr Enumerate decode(uint64_t data) {
710 return Enumerate {
712 .is_bootloader = redux::canand::utils::extractBool(data, 48),
713 };
714 }
715
716 /**
717 * Encodes a struct.
718 *
719 * @return an encoded struct.
720 */
721 constexpr uint64_t encode() {
722 return (
723 0 |
724 redux::canand::utils::packUInt(this->serial, 48, 0) |
725 redux::canand::utils::packBool(this->is_bootloader, 48)
726 );
727 }
728
729
730 /** Minimum acceptable data length code for this message */
731 static const uint32_t DLC_MIN = 8;
732
733 /** Maximum acceptable data length code for this message */
734 static const uint32_t DLC_MAX = 8;
735
736 /**
737 * Sends the message struct to a CanandAddress.
738 * @param addr the address to send to
739 * @return the return value of SendCANMessage
740 */
742 uint64_t data = this->encode();
743 return addr.SendCANMessage(msg::kEnumerate, (uint8_t*) &data, 8);
744 }
745
746 };
747
748 /** Yaw angle frame struct */
749 struct YawOutput {
750 public:
751 /** Yaw value */
753
754 /**
755 * Decodes a struct.
756 *
757 * @param data intfield to decode
758 * @return a decoded struct
759 */
760 static constexpr YawOutput decode(uint64_t data) {
761 return YawOutput {
762 .yaw = types::Yaw::decode(data >> 0),
763 };
764 }
765
766 /**
767 * Encodes a struct.
768 *
769 * @return an encoded struct.
770 */
771 constexpr uint64_t encode() {
772 return (
773 0 |
774 (this->yaw.encode() << 0)
775 );
776 }
777
778
779 /** Minimum acceptable data length code for this message */
780 static const uint32_t DLC_MIN = 6;
781
782 /** Maximum acceptable data length code for this message */
783 static const uint32_t DLC_MAX = 6;
784
785 /**
786 * Sends the message struct to a CanandAddress.
787 * @param addr the address to send to
788 * @return the return value of SendCANMessage
789 */
791 uint64_t data = this->encode();
792 return addr.SendCANMessage(msg::kYawOutput, (uint8_t*) &data, 6);
793 }
794
795 };
796
797 /** Angular position quaternion frame struct */
799 public:
800 /** Quaternion w term */
801 int16_t w;
802
803 /** Quaternion x term */
804 int16_t x;
805
806 /** Quaternion y term */
807 int16_t y;
808
809 /** Quaternion z term */
810 int16_t z;
811
812 /**
813 * Decodes a struct.
814 *
815 * @param data intfield to decode
816 * @return a decoded struct
817 */
818 static constexpr AngularPositionOutput decode(uint64_t data) {
819 return AngularPositionOutput {
820 .w = redux::canand::utils::extractI16(data, 16, 0),
821 .x = redux::canand::utils::extractI16(data, 16, 16),
822 .y = redux::canand::utils::extractI16(data, 16, 32),
823 .z = redux::canand::utils::extractI16(data, 16, 48),
824 };
825 }
826
827 /**
828 * Encodes a struct.
829 *
830 * @return an encoded struct.
831 */
832 constexpr uint64_t encode() {
833 return (
834 0 |
835 redux::canand::utils::packInt(this->w, 16, 0) |
836 redux::canand::utils::packInt(this->x, 16, 16) |
837 redux::canand::utils::packInt(this->y, 16, 32) |
838 redux::canand::utils::packInt(this->z, 16, 48)
839 );
840 }
841
842
843 /** Minimum acceptable data length code for this message */
844 static const uint32_t DLC_MIN = 8;
845
846 /** Maximum acceptable data length code for this message */
847 static const uint32_t DLC_MAX = 8;
848
849 /**
850 * Sends the message struct to a CanandAddress.
851 * @param addr the address to send to
852 * @return the return value of SendCANMessage
853 */
855 uint64_t data = this->encode();
856 return addr.SendCANMessage(msg::kAngularPositionOutput, (uint8_t*) &data, 8);
857 }
858
859 };
860
861 /** Angular velocity frame struct */
863 public:
864 /** Yaw velocity */
865 int16_t yaw;
866
867 /** Pitch velocity */
868 int16_t pitch;
869
870 /** Roll velocity */
871 int16_t roll;
872
873 /**
874 * Decodes a struct.
875 *
876 * @param data intfield to decode
877 * @return a decoded struct
878 */
879 static constexpr AngularVelocityOutput decode(uint64_t data) {
880 return AngularVelocityOutput {
882 .pitch = redux::canand::utils::extractI16(data, 16, 16),
883 .roll = redux::canand::utils::extractI16(data, 16, 32),
884 };
885 }
886
887 /**
888 * Encodes a struct.
889 *
890 * @return an encoded struct.
891 */
892 constexpr uint64_t encode() {
893 return (
894 0 |
895 redux::canand::utils::packInt(this->yaw, 16, 0) |
896 redux::canand::utils::packInt(this->pitch, 16, 16) |
897 redux::canand::utils::packInt(this->roll, 16, 32)
898 );
899 }
900
901
902 /** Minimum acceptable data length code for this message */
903 static const uint32_t DLC_MIN = 6;
904
905 /** Maximum acceptable data length code for this message */
906 static const uint32_t DLC_MAX = 6;
907
908 /**
909 * Sends the message struct to a CanandAddress.
910 * @param addr the address to send to
911 * @return the return value of SendCANMessage
912 */
914 uint64_t data = this->encode();
915 return addr.SendCANMessage(msg::kAngularVelocityOutput, (uint8_t*) &data, 6);
916 }
917
918 };
919
920 /** Acceleration frame struct */
922 public:
923 /** Z-axis acceleration */
924 int16_t z;
925
926 /** Y-axis acceleration */
927 int16_t y;
928
929 /** X-axis acceleration */
930 int16_t x;
931
932 /**
933 * Decodes a struct.
934 *
935 * @param data intfield to decode
936 * @return a decoded struct
937 */
938 static constexpr AccelerationOutput decode(uint64_t data) {
939 return AccelerationOutput {
940 .z = redux::canand::utils::extractI16(data, 16, 0),
941 .y = redux::canand::utils::extractI16(data, 16, 16),
942 .x = redux::canand::utils::extractI16(data, 16, 32),
943 };
944 }
945
946 /**
947 * Encodes a struct.
948 *
949 * @return an encoded struct.
950 */
951 constexpr uint64_t encode() {
952 return (
953 0 |
954 redux::canand::utils::packInt(this->z, 16, 0) |
955 redux::canand::utils::packInt(this->y, 16, 16) |
956 redux::canand::utils::packInt(this->x, 16, 32)
957 );
958 }
959
960
961 /** Minimum acceptable data length code for this message */
962 static const uint32_t DLC_MIN = 6;
963
964 /** Maximum acceptable data length code for this message */
965 static const uint32_t DLC_MAX = 6;
966
967 /**
968 * Sends the message struct to a CanandAddress.
969 * @param addr the address to send to
970 * @return the return value of SendCANMessage
971 */
973 uint64_t data = this->encode();
974 return addr.SendCANMessage(msg::kAccelerationOutput, (uint8_t*) &data, 6);
975 }
976
977 };
978
979 /** Trigger Calibration struct */
980 struct Calibrate {
981 public:
982 /** Calibration type */
984
985 /**
986 * Decodes a struct.
987 *
988 * @param data intfield to decode
989 * @return a decoded struct
990 */
991 static constexpr Calibrate decode(uint64_t data) {
992 return Calibrate {
994 };
995 }
996
997 /**
998 * Encodes a struct.
999 *
1000 * @return an encoded struct.
1001 */
1002 constexpr uint64_t encode() {
1003 return (
1004 0 |
1005 redux::canand::utils::packUInt(this->calibration_type, 8, 0)
1006 );
1007 }
1008
1009
1010 /** Minimum acceptable data length code for this message */
1011 static const uint32_t DLC_MIN = 8;
1012
1013 /** Maximum acceptable data length code for this message */
1014 static const uint32_t DLC_MAX = 8;
1015
1016 /**
1017 * Sends the message struct to a CanandAddress.
1018 * @param addr the address to send to
1019 * @return the return value of SendCANMessage
1020 */
1022 uint64_t data = this->encode();
1023 return addr.SendCANMessage(msg::kCalibrate, (uint8_t*) &data, 8);
1024 }
1025
1026 };
1027
1028 /** Calibration Status struct */
1030 public:
1031
1032 /**
1033 * Decodes a struct.
1034 *
1035 * @param data intfield to decode
1036 * @return a decoded struct
1037 */
1038 static constexpr CalibrationStatus decode(uint64_t data) {
1039 return CalibrationStatus {
1040
1041 };
1042 }
1043
1044 /**
1045 * Encodes a struct.
1046 *
1047 * @return an encoded struct.
1048 */
1049 constexpr uint64_t encode() {
1050 return (
1051 0
1052 );
1053 }
1054
1055
1056 /** Minimum acceptable data length code for this message */
1057 static const uint32_t DLC_MIN = 8;
1058
1059 /** Maximum acceptable data length code for this message */
1060 static const uint32_t DLC_MAX = 8;
1061
1062 /**
1063 * Sends the message struct to a CanandAddress.
1064 * @param addr the address to send to
1065 * @return the return value of SendCANMessage
1066 */
1068 uint64_t data = this->encode();
1069 return addr.SendCANMessage(msg::kCalibrationStatus, (uint8_t*) &data, 8);
1070 }
1071
1072 };
1073
1074 }
1075
1076 /** Settings. */
1077 namespace setting {
1078 enum : uint8_t {
1079 /** Status frame period (ms) */
1081
1082 /** Serial number */
1084
1085 /** Firmware version */
1087
1088 /** Device-specific type identifier */
1090
1091 /** Yaw angle frame period (ms) */
1093
1094 /** Angular position frame period (ms) */
1096
1097 /** Angular velocity frame period (ms) */
1099
1100 /** Acceleration frame period (ms) */
1102
1103 /** Set yaw */
1104 kSetYaw = 0xfb,
1105
1106 /** Set (normed) quaternion assuming positive W */
1108
1109 /** Set (normed) quaternion assuming negative W */
1111
1112 };
1113 /**
1114 * Construct setting STATUS_FRAME_PERIOD
1115 * @param data the data to pack into a setting bitfield
1116 * @return 48-bit data field of settings in the wire format
1117 */
1118 inline uint64_t constructStatusFramePeriod(uint16_t data) {
1119 return redux::canand::utils::packUInt(data, 16, 0);
1120 }
1121
1122 /**
1123 * Unpack setting STATUS_FRAME_PERIOD from the wire format.
1124 * @param data the 48-bit data field to extract a setting struct from.
1125 * @return a setting struct
1126 */
1127 inline uint16_t extractStatusFramePeriod(uint64_t data) {
1128 return redux::canand::utils::extractU16(data, 16, 0);
1129 }
1130
1131 /**
1132 * Construct setting SERIAL_NUMBER
1133 * @param data the data to pack into a setting bitfield
1134 * @return 48-bit data field of settings in the wire format
1135 */
1136 inline uint64_t constructSerialNumber(uint64_t data) {
1137 return redux::canand::utils::packUInt(data, 48, 0);
1138 }
1139
1140 /**
1141 * Unpack setting SERIAL_NUMBER from the wire format.
1142 * @param data the 48-bit data field to extract a setting struct from.
1143 * @return a setting struct
1144 */
1145 inline uint64_t extractSerialNumber(uint64_t data) {
1146 return redux::canand::utils::extractU64(data, 48, 0);
1147 }
1148
1149 /**
1150 * Construct setting FIRMWARE_VERSION
1151 * @param data the data to pack into a setting bitfield
1152 * @return 48-bit data field of settings in the wire format
1153 */
1155 return (data.encode() << 0);
1156 }
1157
1158 /**
1159 * Unpack setting FIRMWARE_VERSION from the wire format.
1160 * @param data the 48-bit data field to extract a setting struct from.
1161 * @return a setting struct
1162 */
1164 return types::FirmwareVersion::decode(data >> 0);
1165 }
1166
1167 /**
1168 * Construct setting DEVICE_TYPE
1169 * @param data the data to pack into a setting bitfield
1170 * @return 48-bit data field of settings in the wire format
1171 */
1172 inline uint64_t constructDeviceType(uint16_t data) {
1173 return redux::canand::utils::packUInt(data, 16, 0);
1174 }
1175
1176 /**
1177 * Unpack setting DEVICE_TYPE from the wire format.
1178 * @param data the 48-bit data field to extract a setting struct from.
1179 * @return a setting struct
1180 */
1181 inline uint16_t extractDeviceType(uint64_t data) {
1182 return redux::canand::utils::extractU16(data, 16, 0);
1183 }
1184
1185 /**
1186 * Construct setting YAW_FRAME_PERIOD
1187 * @param data the data to pack into a setting bitfield
1188 * @return 48-bit data field of settings in the wire format
1189 */
1190 inline uint64_t constructYawFramePeriod(uint16_t data) {
1191 return redux::canand::utils::packUInt(data, 16, 0);
1192 }
1193
1194 /**
1195 * Unpack setting YAW_FRAME_PERIOD from the wire format.
1196 * @param data the 48-bit data field to extract a setting struct from.
1197 * @return a setting struct
1198 */
1199 inline uint16_t extractYawFramePeriod(uint64_t data) {
1200 return redux::canand::utils::extractU16(data, 16, 0);
1201 }
1202
1203 /**
1204 * Construct setting ANGULAR_POSITION_FRAME_PERIOD
1205 * @param data the data to pack into a setting bitfield
1206 * @return 48-bit data field of settings in the wire format
1207 */
1208 inline uint64_t constructAngularPositionFramePeriod(uint16_t data) {
1209 return redux::canand::utils::packUInt(data, 16, 0);
1210 }
1211
1212 /**
1213 * Unpack setting ANGULAR_POSITION_FRAME_PERIOD from the wire format.
1214 * @param data the 48-bit data field to extract a setting struct from.
1215 * @return a setting struct
1216 */
1217 inline uint16_t extractAngularPositionFramePeriod(uint64_t data) {
1218 return redux::canand::utils::extractU16(data, 16, 0);
1219 }
1220
1221 /**
1222 * Construct setting ANGULAR_VELOCITY_FRAME_PERIOD
1223 * @param data the data to pack into a setting bitfield
1224 * @return 48-bit data field of settings in the wire format
1225 */
1226 inline uint64_t constructAngularVelocityFramePeriod(uint16_t data) {
1227 return redux::canand::utils::packUInt(data, 16, 0);
1228 }
1229
1230 /**
1231 * Unpack setting ANGULAR_VELOCITY_FRAME_PERIOD from the wire format.
1232 * @param data the 48-bit data field to extract a setting struct from.
1233 * @return a setting struct
1234 */
1235 inline uint16_t extractAngularVelocityFramePeriod(uint64_t data) {
1236 return redux::canand::utils::extractU16(data, 16, 0);
1237 }
1238
1239 /**
1240 * Construct setting ACCELERATION_FRAME_PERIOD
1241 * @param data the data to pack into a setting bitfield
1242 * @return 48-bit data field of settings in the wire format
1243 */
1244 inline uint64_t constructAccelerationFramePeriod(uint16_t data) {
1245 return redux::canand::utils::packUInt(data, 16, 0);
1246 }
1247
1248 /**
1249 * Unpack setting ACCELERATION_FRAME_PERIOD from the wire format.
1250 * @param data the 48-bit data field to extract a setting struct from.
1251 * @return a setting struct
1252 */
1253 inline uint16_t extractAccelerationFramePeriod(uint64_t data) {
1254 return redux::canand::utils::extractU16(data, 16, 0);
1255 }
1256
1257 /**
1258 * Construct setting SET_YAW
1259 * @param data the data to pack into a setting bitfield
1260 * @return 48-bit data field of settings in the wire format
1261 */
1262 inline uint64_t constructSetYaw(types::Yaw data) {
1263 return (data.encode() << 0);
1264 }
1265
1266 /**
1267 * Unpack setting SET_YAW from the wire format.
1268 * @param data the 48-bit data field to extract a setting struct from.
1269 * @return a setting struct
1270 */
1271 inline types::Yaw extractSetYaw(uint64_t data) {
1272 return types::Yaw::decode(data >> 0);
1273 }
1274
1275 /**
1276 * Construct setting SET_POSE_POSITIVE_W
1277 * @param data the data to pack into a setting bitfield
1278 * @return 48-bit data field of settings in the wire format
1279 */
1281 return (data.encode() << 0);
1282 }
1283
1284 /**
1285 * Unpack setting SET_POSE_POSITIVE_W from the wire format.
1286 * @param data the 48-bit data field to extract a setting struct from.
1287 * @return a setting struct
1288 */
1290 return types::QuatXyz::decode(data >> 0);
1291 }
1292
1293 /**
1294 * Construct setting SET_POSE_NEGATIVE_W
1295 * @param data the data to pack into a setting bitfield
1296 * @return 48-bit data field of settings in the wire format
1297 */
1299 return (data.encode() << 0);
1300 }
1301
1302 /**
1303 * Unpack setting SET_POSE_NEGATIVE_W from the wire format.
1304 * @param data the 48-bit data field to extract a setting struct from.
1305 * @return a setting struct
1306 */
1308 return types::QuatXyz::decode(data >> 0);
1309 }
1310
1311
1312 /**
1313 * Settings that are required for the vdep to flag all values as received.
1314 */
1322
1323 }
1324}
Definition CanandAddress.h:62
bool SendCANMessage(uint16_t apiIndex, uint8_t *data, uint8_t length)
@ kAngularVelocitySaturation
Definition CanandgyroDetails.h:69
@ kCalibrating
Definition CanandgyroDetails.h:65
@ kPowerCycle
Definition CanandgyroDetails.h:40
@ kAccelerationSaturation
Definition CanandgyroDetails.h:73
@ kHardwareFault
Definition CanandgyroDetails.h:61
@ kCanGeneralError
Definition CanandgyroDetails.h:51
@ kOutOfTemperatureRange
Definition CanandgyroDetails.h:56
@ kCanIdConflict
Definition CanandgyroDetails.h:45
@ kResetFactoryDefault
Definition CanandgyroDetails.h:107
@ kFetchSettingValue
Definition CanandgyroDetails.h:113
@ kFetchSettings
Definition CanandgyroDetails.h:102
constexpr uint64_t packInt(int64_t data, uint8_t width, uint8_t offset)
Definition CanandUtils.h:299
constexpr float extractF32(uint64_t data, uint8_t offset)
Definition CanandUtils.h:256
constexpr uint8_t extractU8(uint64_t data, uint8_t width, uint8_t offset)
Definition CanandUtils.h:133
constexpr bool extractBool(uint64_t data, uint8_t offset)
Definition CanandUtils.h:276
constexpr uint64_t extractU64(uint64_t data, uint8_t width, uint8_t offset)
Definition CanandUtils.h:169
constexpr int16_t extractI16(uint64_t data, uint8_t width, uint8_t offset)
Definition CanandUtils.h:197
constexpr uint64_t packF32(float data, uint8_t offset)
Definition CanandUtils.h:321
constexpr uint16_t extractU16(uint64_t data, uint8_t width, uint8_t offset)
Definition CanandUtils.h:145
constexpr uint64_t packUInt(uint64_t data, uint8_t width, uint8_t offset)
Definition CanandUtils.h:287
constexpr uint64_t packBool(bool data, uint8_t offset)
Definition CanandUtils.h:340
@ kSetSetting
Definition CanandgyroDetails.h:332
@ kStatus
Definition CanandgyroDetails.h:341
@ kSettingCommand
Definition CanandgyroDetails.h:329
@ kClearStickyFaults
Definition CanandgyroDetails.h:338
@ kEnumerate
Definition CanandgyroDetails.h:347
@ kYawOutput
Definition CanandgyroDetails.h:350
@ kCalibrationStatus
Definition CanandgyroDetails.h:365
@ kReportSetting
Definition CanandgyroDetails.h:335
@ kPartyMode
Definition CanandgyroDetails.h:344
@ kAngularVelocityOutput
Definition CanandgyroDetails.h:356
@ kCalibrate
Definition CanandgyroDetails.h:362
@ kAccelerationOutput
Definition CanandgyroDetails.h:359
@ kAngularPositionOutput
Definition CanandgyroDetails.h:353
uint16_t extractAccelerationFramePeriod(uint64_t data)
Definition CanandgyroDetails.h:1253
uint64_t constructFirmwareVersion(types::FirmwareVersion data)
Definition CanandgyroDetails.h:1154
uint16_t extractDeviceType(uint64_t data)
Definition CanandgyroDetails.h:1181
uint64_t constructAngularPositionFramePeriod(uint16_t data)
Definition CanandgyroDetails.h:1208
uint16_t extractAngularPositionFramePeriod(uint64_t data)
Definition CanandgyroDetails.h:1217
uint64_t constructYawFramePeriod(uint16_t data)
Definition CanandgyroDetails.h:1190
uint64_t constructSerialNumber(uint64_t data)
Definition CanandgyroDetails.h:1136
uint16_t extractAngularVelocityFramePeriod(uint64_t data)
Definition CanandgyroDetails.h:1235
types::QuatXyz extractSetPosePositiveW(uint64_t data)
Definition CanandgyroDetails.h:1289
uint64_t constructSetPosePositiveW(types::QuatXyz data)
Definition CanandgyroDetails.h:1280
types::Yaw extractSetYaw(uint64_t data)
Definition CanandgyroDetails.h:1271
const std::vector< uint8_t > VDEP_SETTINGS
Definition CanandgyroDetails.h:1315
uint64_t constructAccelerationFramePeriod(uint16_t data)
Definition CanandgyroDetails.h:1244
types::FirmwareVersion extractFirmwareVersion(uint64_t data)
Definition CanandgyroDetails.h:1163
uint64_t constructSetPoseNegativeW(types::QuatXyz data)
Definition CanandgyroDetails.h:1298
uint64_t constructStatusFramePeriod(uint16_t data)
Definition CanandgyroDetails.h:1118
uint64_t constructSetYaw(types::Yaw data)
Definition CanandgyroDetails.h:1262
uint16_t extractStatusFramePeriod(uint64_t data)
Definition CanandgyroDetails.h:1127
@ kAngularPositionFramePeriod
Definition CanandgyroDetails.h:1095
@ kSetYaw
Definition CanandgyroDetails.h:1104
@ kSetPoseNegativeW
Definition CanandgyroDetails.h:1110
@ kStatusFramePeriod
Definition CanandgyroDetails.h:1080
@ kFirmwareVersion
Definition CanandgyroDetails.h:1086
@ kYawFramePeriod
Definition CanandgyroDetails.h:1092
@ kSetPosePositiveW
Definition CanandgyroDetails.h:1107
@ kAngularVelocityFramePeriod
Definition CanandgyroDetails.h:1098
@ kDeviceType
Definition CanandgyroDetails.h:1089
@ kSerialNumber
Definition CanandgyroDetails.h:1083
@ kAccelerationFramePeriod
Definition CanandgyroDetails.h:1101
types::QuatXyz extractSetPoseNegativeW(uint64_t data)
Definition CanandgyroDetails.h:1307
uint64_t extractSerialNumber(uint64_t data)
Definition CanandgyroDetails.h:1145
uint64_t constructDeviceType(uint16_t data)
Definition CanandgyroDetails.h:1172
uint16_t extractYawFramePeriod(uint64_t data)
Definition CanandgyroDetails.h:1199
uint64_t constructAngularVelocityFramePeriod(uint16_t data)
Definition CanandgyroDetails.h:1226
Definition CanandgyroDetails.h:16
static constexpr AccelerationOutput decode(uint64_t data)
Definition CanandgyroDetails.h:938
int16_t z
Definition CanandgyroDetails.h:924
int16_t x
Definition CanandgyroDetails.h:930
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:972
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:965
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:962
constexpr uint64_t encode()
Definition CanandgyroDetails.h:951
int16_t y
Definition CanandgyroDetails.h:927
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:847
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:844
static constexpr AngularPositionOutput decode(uint64_t data)
Definition CanandgyroDetails.h:818
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:854
constexpr uint64_t encode()
Definition CanandgyroDetails.h:832
int16_t pitch
Definition CanandgyroDetails.h:868
int16_t roll
Definition CanandgyroDetails.h:871
constexpr uint64_t encode()
Definition CanandgyroDetails.h:892
static constexpr AngularVelocityOutput decode(uint64_t data)
Definition CanandgyroDetails.h:879
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:913
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:906
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:903
Definition CanandgyroDetails.h:980
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:1014
static constexpr Calibrate decode(uint64_t data)
Definition CanandgyroDetails.h:991
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:1011
constexpr uint64_t encode()
Definition CanandgyroDetails.h:1002
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:1021
uint8_t calibration_type
Definition CanandgyroDetails.h:983
static constexpr CalibrationStatus decode(uint64_t data)
Definition CanandgyroDetails.h:1038
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:1057
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:1060
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:1067
constexpr uint64_t encode()
Definition CanandgyroDetails.h:1049
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:569
static constexpr ClearStickyFaults decode(uint64_t data)
Definition CanandgyroDetails.h:550
constexpr uint64_t encode()
Definition CanandgyroDetails.h:561
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:579
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:572
Definition CanandgyroDetails.h:695
bool is_bootloader
Definition CanandgyroDetails.h:701
uint64_t serial
Definition CanandgyroDetails.h:698
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:731
constexpr uint64_t encode()
Definition CanandgyroDetails.h:721
static constexpr Enumerate decode(uint64_t data)
Definition CanandgyroDetails.h:709
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:741
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:734
Definition CanandgyroDetails.h:646
uint8_t party_level
Definition CanandgyroDetails.h:649
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:680
static constexpr PartyMode decode(uint64_t data)
Definition CanandgyroDetails.h:657
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:677
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:687
constexpr uint64_t encode()
Definition CanandgyroDetails.h:668
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:533
uint8_t address
Definition CanandgyroDetails.h:485
uint64_t value
Definition CanandgyroDetails.h:488
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:526
constexpr uint64_t encode()
Definition CanandgyroDetails.h:512
static constexpr ReportSetting decode(uint64_t data)
Definition CanandgyroDetails.h:499
uint8_t flags
Definition CanandgyroDetails.h:491
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:523
static constexpr SetSetting decode(uint64_t data)
Definition CanandgyroDetails.h:440
constexpr uint64_t encode()
Definition CanandgyroDetails.h:453
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:467
types::SettingFlags flags
Definition CanandgyroDetails.h:432
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:464
uint64_t value
Definition CanandgyroDetails.h:429
uint8_t address
Definition CanandgyroDetails.h:426
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:474
uint8_t control_flag
Definition CanandgyroDetails.h:372
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:408
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:405
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:415
uint8_t setting_index
Definition CanandgyroDetails.h:375
constexpr uint64_t encode()
Definition CanandgyroDetails.h:395
static constexpr SettingCommand decode(uint64_t data)
Definition CanandgyroDetails.h:383
Definition CanandgyroDetails.h:587
uint8_t faults
Definition CanandgyroDetails.h:590
constexpr uint64_t encode()
Definition CanandgyroDetails.h:617
uint8_t sticky_faults
Definition CanandgyroDetails.h:593
int16_t temperature
Definition CanandgyroDetails.h:596
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:631
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:638
static constexpr Status decode(uint64_t data)
Definition CanandgyroDetails.h:604
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:628
Definition CanandgyroDetails.h:749
static const uint32_t DLC_MAX
Definition CanandgyroDetails.h:783
bool send(redux::canand::CanandAddress &addr)
Definition CanandgyroDetails.h:790
static constexpr YawOutput decode(uint64_t data)
Definition CanandgyroDetails.h:760
types::Yaw yaw
Definition CanandgyroDetails.h:752
constexpr uint64_t encode()
Definition CanandgyroDetails.h:771
static const uint32_t DLC_MIN
Definition CanandgyroDetails.h:780
uint16_t firmware_year
Definition CanandgyroDetails.h:171
constexpr uint64_t encode()
Definition CanandgyroDetails.h:192
uint8_t firmware_patch
Definition CanandgyroDetails.h:165
uint8_t firmware_minor
Definition CanandgyroDetails.h:168
static constexpr FirmwareVersion decode(uint64_t data)
Definition CanandgyroDetails.h:179
Definition CanandgyroDetails.h:243
int16_t y
Definition CanandgyroDetails.h:249
constexpr uint64_t encode()
Definition CanandgyroDetails.h:273
static constexpr QuatXyz decode(uint64_t data)
Definition CanandgyroDetails.h:260
int16_t z
Definition CanandgyroDetails.h:252
int16_t x
Definition CanandgyroDetails.h:246
bool synch_hold
Definition CanandgyroDetails.h:125
uint8_t synch_msg_count
Definition CanandgyroDetails.h:128
constexpr uint64_t encode()
Definition CanandgyroDetails.h:149
bool ephemeral
Definition CanandgyroDetails.h:122
static constexpr SettingFlags decode(uint64_t data)
Definition CanandgyroDetails.h:136
constexpr uint64_t encode()
Definition CanandgyroDetails.h:231
int16_t temperature_point
Definition CanandgyroDetails.h:208
float offset
Definition CanandgyroDetails.h:211
static constexpr TempCalPoint decode(uint64_t data)
Definition CanandgyroDetails.h:219
Definition CanandgyroDetails.h:286
int16_t wraparound
Definition CanandgyroDetails.h:292
static constexpr Yaw decode(uint64_t data)
Definition CanandgyroDetails.h:300
constexpr uint64_t encode()
Definition CanandgyroDetails.h:312
float yaw
Definition CanandgyroDetails.h:289