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