sbp 6.5.0

Rust native implementation of SBP (Swift Binary Protocol) for communicating with devices made by Swift Navigation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
// Copyright (C) 2015-2021 Swift Navigation Inc.
// Contact: https://support.swiftnav.com
//
// This source is subject to the license found in the file 'LICENSE' which must
// be distributed together with this source. All other rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

//****************************************************************************
// Automatically generated from yaml/swiftnav/sbp/orientation.yaml
// with generate.py. Please do not hand edit!
//****************************************************************************/
//! Orientation Messages
pub use msg_angular_rate::MsgAngularRate;
pub use msg_baseline_heading::MsgBaselineHeading;
pub use msg_orient_euler::MsgOrientEuler;
pub use msg_orient_quat::MsgOrientQuat;
pub use msg_orient_quat_cov::MsgOrientQuatCov;

pub mod msg_angular_rate {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Vehicle Body Frame instantaneous angular rates
    ///
    /// This message reports the orientation rates in the vehicle body frame. The
    /// values represent the measurements a strapped down gyroscope would make and
    /// are not equivalent to the time derivative of the Euler angles. The
    /// orientation and origin of the user frame is specified via device settings.
    /// By convention, the vehicle x-axis is expected to be aligned with the
    /// forward direction, while the vehicle y-axis is expected to be aligned with
    /// the right direction, and the vehicle z-axis should be aligned with the
    /// down direction. This message will only be available in future INS versions
    /// of Swift Products and is not produced by Piksi Multi or Duro.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgAngularRate {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// GPS Time of Week
        #[cfg_attr(feature = "serde", serde(rename = "tow"))]
        pub tow: u32,
        /// angular rate about x axis
        #[cfg_attr(feature = "serde", serde(rename = "x"))]
        pub x: i32,
        /// angular rate about y axis
        #[cfg_attr(feature = "serde", serde(rename = "y"))]
        pub y: i32,
        /// angular rate about z axis
        #[cfg_attr(feature = "serde", serde(rename = "z"))]
        pub z: i32,
        /// Status flags
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u8,
    }

    impl MsgAngularRate {
        /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `InsNavigationMode` were added.
        pub fn ins_navigation_mode(&self) -> Result<InsNavigationMode, u8> {
            get_bit_range!(self.flags, u8, u8, 2, 0).try_into()
        }

        /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield.
        pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) {
            set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0);
        }
    }

    impl ConcreteMessage for MsgAngularRate {
        const MESSAGE_TYPE: u16 = 546;
        const MESSAGE_NAME: &'static str = "MSG_ANGULAR_RATE";
    }

    impl SbpMessage for MsgAngularRate {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }

        #[cfg(feature = "swiftnav")]
        fn gps_time(&self) -> Option<std::result::Result<time::MessageTime, time::GpsTimeError>> {
            let tow_s = (self.tow as f64) / 1000.0;
            let gps_time = match time::GpsTime::new(0, tow_s) {
                Ok(gps_time) => gps_time.tow(),
                Err(e) => return Some(Err(e.into())),
            };
            Some(Ok(time::MessageTime::Rover(gps_time.into())))
        }
    }

    impl FriendlyName for MsgAngularRate {
        fn friendly_name() -> &'static str {
            "ANGULAR RATE"
        }
    }

    impl TryFrom<Sbp> for MsgAngularRate {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgAngularRate(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgAngularRate {
        const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.tow)
                + WireFormat::len(&self.x)
                + WireFormat::len(&self.y)
                + WireFormat::len(&self.z)
                + WireFormat::len(&self.flags)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.tow, buf);
            WireFormat::write(&self.x, buf);
            WireFormat::write(&self.y, buf);
            WireFormat::write(&self.z, buf);
            WireFormat::write(&self.flags, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgAngularRate {
                sender_id: None,
                tow: WireFormat::parse_unchecked(buf),
                x: WireFormat::parse_unchecked(buf),
                y: WireFormat::parse_unchecked(buf),
                z: WireFormat::parse_unchecked(buf),
                flags: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// INS Navigation mode
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum InsNavigationMode {
        /// Invalid
        Invalid = 0,

        /// Valid
        Valid = 1,
    }

    impl std::fmt::Display for InsNavigationMode {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                InsNavigationMode::Invalid => f.write_str("Invalid"),
                InsNavigationMode::Valid => f.write_str("Valid"),
            }
        }
    }

    impl TryFrom<u8> for InsNavigationMode {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(InsNavigationMode::Invalid),
                1 => Ok(InsNavigationMode::Valid),
                i => Err(i),
            }
        }
    }
}

pub mod msg_baseline_heading {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Heading relative to True North
    ///
    /// This message reports the baseline heading pointing from the base station
    /// to the rover relative to True North. The full GPS time is given by the
    /// preceding MSG_GPS_TIME with the matching time-of-week (tow). It is
    /// intended that time-matched RTK mode is used when the base station is
    /// moving.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgBaselineHeading {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// GPS Time of Week
        #[cfg_attr(feature = "serde", serde(rename = "tow"))]
        pub tow: u32,
        /// Heading
        #[cfg_attr(feature = "serde", serde(rename = "heading"))]
        pub heading: u32,
        /// Number of satellites used in solution
        #[cfg_attr(feature = "serde", serde(rename = "n_sats"))]
        pub n_sats: u8,
        /// Status flags
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u8,
    }

    impl MsgBaselineHeading {
        /// Gets the [FixMode][self::FixMode] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `FixMode` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `FixMode` were added.
        pub fn fix_mode(&self) -> Result<FixMode, u8> {
            get_bit_range!(self.flags, u8, u8, 2, 0).try_into()
        }

        /// Set the bitrange corresponding to the [FixMode][FixMode] of the `flags` bitfield.
        pub fn set_fix_mode(&mut self, fix_mode: FixMode) {
            set_bit_range!(&mut self.flags, fix_mode, u8, u8, 2, 0);
        }
    }

    impl ConcreteMessage for MsgBaselineHeading {
        const MESSAGE_TYPE: u16 = 527;
        const MESSAGE_NAME: &'static str = "MSG_BASELINE_HEADING";
    }

    impl SbpMessage for MsgBaselineHeading {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }

        #[cfg(feature = "swiftnav")]
        fn gps_time(&self) -> Option<std::result::Result<time::MessageTime, time::GpsTimeError>> {
            let tow_s = (self.tow as f64) / 1000.0;
            let gps_time = match time::GpsTime::new(0, tow_s) {
                Ok(gps_time) => gps_time.tow(),
                Err(e) => return Some(Err(e.into())),
            };
            Some(Ok(time::MessageTime::Rover(gps_time.into())))
        }
    }

    impl FriendlyName for MsgBaselineHeading {
        fn friendly_name() -> &'static str {
            "BASELINE HEADING"
        }
    }

    impl TryFrom<Sbp> for MsgBaselineHeading {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgBaselineHeading(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgBaselineHeading {
        const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN
            + <u32 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.tow)
                + WireFormat::len(&self.heading)
                + WireFormat::len(&self.n_sats)
                + WireFormat::len(&self.flags)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.tow, buf);
            WireFormat::write(&self.heading, buf);
            WireFormat::write(&self.n_sats, buf);
            WireFormat::write(&self.flags, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgBaselineHeading {
                sender_id: None,
                tow: WireFormat::parse_unchecked(buf),
                heading: WireFormat::parse_unchecked(buf),
                n_sats: WireFormat::parse_unchecked(buf),
                flags: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// Fix mode
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum FixMode {
        /// Invalid
        Invalid = 0,

        /// Differential GNSS (DGNSS)
        DifferentialGnss = 2,

        /// Float RTK
        FloatRtk = 3,

        /// Fixed RTK
        FixedRtk = 4,
    }

    impl std::fmt::Display for FixMode {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                FixMode::Invalid => f.write_str("Invalid"),
                FixMode::DifferentialGnss => f.write_str("Differential GNSS (DGNSS)"),
                FixMode::FloatRtk => f.write_str("Float RTK"),
                FixMode::FixedRtk => f.write_str("Fixed RTK"),
            }
        }
    }

    impl TryFrom<u8> for FixMode {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(FixMode::Invalid),
                2 => Ok(FixMode::DifferentialGnss),
                3 => Ok(FixMode::FloatRtk),
                4 => Ok(FixMode::FixedRtk),
                i => Err(i),
            }
        }
    }
}

pub mod msg_orient_euler {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Euler angles
    ///
    /// This message reports the yaw, pitch, and roll angles of the vehicle body
    /// frame. The rotations should applied intrinsically in the order yaw, pitch,
    /// and roll in order to rotate the from a frame aligned with the local-level
    /// NED frame to the vehicle body frame.  This message will only be available
    /// in future INS versions of Swift Products and is not produced by Piksi
    /// Multi or Duro.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgOrientEuler {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// GPS Time of Week
        #[cfg_attr(feature = "serde", serde(rename = "tow"))]
        pub tow: u32,
        /// rotation about the forward axis of the vehicle
        #[cfg_attr(feature = "serde", serde(rename = "roll"))]
        pub roll: i32,
        /// rotation about the rightward axis of the vehicle
        #[cfg_attr(feature = "serde", serde(rename = "pitch"))]
        pub pitch: i32,
        /// rotation about the downward axis of the vehicle
        #[cfg_attr(feature = "serde", serde(rename = "yaw"))]
        pub yaw: i32,
        /// Estimated standard deviation of roll
        #[cfg_attr(feature = "serde", serde(rename = "roll_accuracy"))]
        pub roll_accuracy: f32,
        /// Estimated standard deviation of pitch
        #[cfg_attr(feature = "serde", serde(rename = "pitch_accuracy"))]
        pub pitch_accuracy: f32,
        /// Estimated standard deviation of yaw
        #[cfg_attr(feature = "serde", serde(rename = "yaw_accuracy"))]
        pub yaw_accuracy: f32,
        /// Status flags
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u8,
    }

    impl MsgOrientEuler {
        /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `InsNavigationMode` were added.
        pub fn ins_navigation_mode(&self) -> Result<InsNavigationMode, u8> {
            get_bit_range!(self.flags, u8, u8, 2, 0).try_into()
        }

        /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield.
        pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) {
            set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0);
        }
    }

    impl ConcreteMessage for MsgOrientEuler {
        const MESSAGE_TYPE: u16 = 545;
        const MESSAGE_NAME: &'static str = "MSG_ORIENT_EULER";
    }

    impl SbpMessage for MsgOrientEuler {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }

        #[cfg(feature = "swiftnav")]
        fn gps_time(&self) -> Option<std::result::Result<time::MessageTime, time::GpsTimeError>> {
            let tow_s = (self.tow as f64) / 1000.0;
            let gps_time = match time::GpsTime::new(0, tow_s) {
                Ok(gps_time) => gps_time.tow(),
                Err(e) => return Some(Err(e.into())),
            };
            Some(Ok(time::MessageTime::Rover(gps_time.into())))
        }
    }

    impl FriendlyName for MsgOrientEuler {
        fn friendly_name() -> &'static str {
            "ORIENT EULER"
        }
    }

    impl TryFrom<Sbp> for MsgOrientEuler {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgOrientEuler(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgOrientEuler {
        const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.tow)
                + WireFormat::len(&self.roll)
                + WireFormat::len(&self.pitch)
                + WireFormat::len(&self.yaw)
                + WireFormat::len(&self.roll_accuracy)
                + WireFormat::len(&self.pitch_accuracy)
                + WireFormat::len(&self.yaw_accuracy)
                + WireFormat::len(&self.flags)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.tow, buf);
            WireFormat::write(&self.roll, buf);
            WireFormat::write(&self.pitch, buf);
            WireFormat::write(&self.yaw, buf);
            WireFormat::write(&self.roll_accuracy, buf);
            WireFormat::write(&self.pitch_accuracy, buf);
            WireFormat::write(&self.yaw_accuracy, buf);
            WireFormat::write(&self.flags, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgOrientEuler {
                sender_id: None,
                tow: WireFormat::parse_unchecked(buf),
                roll: WireFormat::parse_unchecked(buf),
                pitch: WireFormat::parse_unchecked(buf),
                yaw: WireFormat::parse_unchecked(buf),
                roll_accuracy: WireFormat::parse_unchecked(buf),
                pitch_accuracy: WireFormat::parse_unchecked(buf),
                yaw_accuracy: WireFormat::parse_unchecked(buf),
                flags: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// INS Navigation mode
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum InsNavigationMode {
        /// Invalid
        Invalid = 0,

        /// Valid
        Valid = 1,
    }

    impl std::fmt::Display for InsNavigationMode {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                InsNavigationMode::Invalid => f.write_str("Invalid"),
                InsNavigationMode::Valid => f.write_str("Valid"),
            }
        }
    }

    impl TryFrom<u8> for InsNavigationMode {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(InsNavigationMode::Invalid),
                1 => Ok(InsNavigationMode::Valid),
                i => Err(i),
            }
        }
    }
}

pub mod msg_orient_quat {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Quaternion 4 component vector
    ///
    /// This message reports the quaternion vector describing the vehicle body
    /// frame's orientation with respect to a local-level NED frame. The
    /// components of the vector should sum to a unit vector assuming that the LSB
    /// of each component as a value of 2^-31. This message will only be available
    /// in future INS versions of Swift Products and is not produced by Piksi
    /// Multi or Duro.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgOrientQuat {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// GPS Time of Week
        #[cfg_attr(feature = "serde", serde(rename = "tow"))]
        pub tow: u32,
        /// Real component
        #[cfg_attr(feature = "serde", serde(rename = "w"))]
        pub w: i32,
        /// 1st imaginary component
        #[cfg_attr(feature = "serde", serde(rename = "x"))]
        pub x: i32,
        /// 2nd imaginary component
        #[cfg_attr(feature = "serde", serde(rename = "y"))]
        pub y: i32,
        /// 3rd imaginary component
        #[cfg_attr(feature = "serde", serde(rename = "z"))]
        pub z: i32,
        /// Estimated standard deviation of w
        #[cfg_attr(feature = "serde", serde(rename = "w_accuracy"))]
        pub w_accuracy: f32,
        /// Estimated standard deviation of x
        #[cfg_attr(feature = "serde", serde(rename = "x_accuracy"))]
        pub x_accuracy: f32,
        /// Estimated standard deviation of y
        #[cfg_attr(feature = "serde", serde(rename = "y_accuracy"))]
        pub y_accuracy: f32,
        /// Estimated standard deviation of z
        #[cfg_attr(feature = "serde", serde(rename = "z_accuracy"))]
        pub z_accuracy: f32,
        /// Status flags
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u8,
    }

    impl MsgOrientQuat {
        /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `InsNavigationMode` were added.
        pub fn ins_navigation_mode(&self) -> Result<InsNavigationMode, u8> {
            get_bit_range!(self.flags, u8, u8, 2, 0).try_into()
        }

        /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield.
        pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) {
            set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0);
        }
    }

    impl ConcreteMessage for MsgOrientQuat {
        const MESSAGE_TYPE: u16 = 544;
        const MESSAGE_NAME: &'static str = "MSG_ORIENT_QUAT";
    }

    impl SbpMessage for MsgOrientQuat {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }

        #[cfg(feature = "swiftnav")]
        fn gps_time(&self) -> Option<std::result::Result<time::MessageTime, time::GpsTimeError>> {
            let tow_s = (self.tow as f64) / 1000.0;
            let gps_time = match time::GpsTime::new(0, tow_s) {
                Ok(gps_time) => gps_time.tow(),
                Err(e) => return Some(Err(e.into())),
            };
            Some(Ok(time::MessageTime::Rover(gps_time.into())))
        }
    }

    impl FriendlyName for MsgOrientQuat {
        fn friendly_name() -> &'static str {
            "ORIENT QUAT"
        }
    }

    impl TryFrom<Sbp> for MsgOrientQuat {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgOrientQuat(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgOrientQuat {
        const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.tow)
                + WireFormat::len(&self.w)
                + WireFormat::len(&self.x)
                + WireFormat::len(&self.y)
                + WireFormat::len(&self.z)
                + WireFormat::len(&self.w_accuracy)
                + WireFormat::len(&self.x_accuracy)
                + WireFormat::len(&self.y_accuracy)
                + WireFormat::len(&self.z_accuracy)
                + WireFormat::len(&self.flags)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.tow, buf);
            WireFormat::write(&self.w, buf);
            WireFormat::write(&self.x, buf);
            WireFormat::write(&self.y, buf);
            WireFormat::write(&self.z, buf);
            WireFormat::write(&self.w_accuracy, buf);
            WireFormat::write(&self.x_accuracy, buf);
            WireFormat::write(&self.y_accuracy, buf);
            WireFormat::write(&self.z_accuracy, buf);
            WireFormat::write(&self.flags, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgOrientQuat {
                sender_id: None,
                tow: WireFormat::parse_unchecked(buf),
                w: WireFormat::parse_unchecked(buf),
                x: WireFormat::parse_unchecked(buf),
                y: WireFormat::parse_unchecked(buf),
                z: WireFormat::parse_unchecked(buf),
                w_accuracy: WireFormat::parse_unchecked(buf),
                x_accuracy: WireFormat::parse_unchecked(buf),
                y_accuracy: WireFormat::parse_unchecked(buf),
                z_accuracy: WireFormat::parse_unchecked(buf),
                flags: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// INS Navigation mode
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum InsNavigationMode {
        /// Invalid
        Invalid = 0,

        /// Valid
        Valid = 1,
    }

    impl std::fmt::Display for InsNavigationMode {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                InsNavigationMode::Invalid => f.write_str("Invalid"),
                InsNavigationMode::Valid => f.write_str("Valid"),
            }
        }
    }

    impl TryFrom<u8> for InsNavigationMode {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(InsNavigationMode::Invalid),
                1 => Ok(InsNavigationMode::Valid),
                i => Err(i),
            }
        }
    }
}

pub mod msg_orient_quat_cov {
    #![allow(unused_imports)]

    use super::*;
    use crate::messages::lib::*;

    /// Quaternion 4 component vector with full attitude covariance
    ///
    /// This message reports the orientation as a unit quaternion together with
    /// the upper triangle of the symmetric 3x3 attitude covariance matrix and a
    /// GPS time-of-week time-tag. The reference frame of the quaternion and the
    /// parameterization of the covariance matrix are both encoded in the flags
    /// field, allowing additional frames or parameterizations to be added later
    /// without introducing a new message. By default the quaternion describes the
    /// orientation of the vehicle body frame with respect to a local-level NED
    /// frame (matching MSG_ORIENT_QUAT) and the covariance is expressed as small-
    /// angle rotation errors about the axes of that NED frame; in this default
    /// case the cov_x_x, cov_y_y, cov_z_z diagonal entries correspond to the
    /// variance of the rotation error about North, East, and Down respectively.
    /// The components of the quaternion sum to a unit vector assuming that the
    /// LSB of each component has a value of 2^-31.
    ///
    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    #[allow(clippy::derive_partial_eq_without_eq)]
    #[derive(Debug, PartialEq, Clone)]
    pub struct MsgOrientQuatCov {
        /// The message sender_id
        #[cfg_attr(feature = "serde", serde(skip_serializing, alias = "sender"))]
        pub sender_id: Option<u16>,
        /// GPS Time of Week
        #[cfg_attr(feature = "serde", serde(rename = "tow"))]
        pub tow: u32,
        /// Real component
        #[cfg_attr(feature = "serde", serde(rename = "w"))]
        pub w: i32,
        /// 1st imaginary component
        #[cfg_attr(feature = "serde", serde(rename = "x"))]
        pub x: i32,
        /// 2nd imaginary component
        #[cfg_attr(feature = "serde", serde(rename = "y"))]
        pub y: i32,
        /// 3rd imaginary component
        #[cfg_attr(feature = "serde", serde(rename = "z"))]
        pub z: i32,
        /// Estimated variance of the rotation error about the 1st axis of the
        /// covariance frame
        #[cfg_attr(feature = "serde", serde(rename = "cov_x_x"))]
        pub cov_x_x: f32,
        /// Estimated covariance of the rotation errors about the 1st and 2nd axes
        /// of the covariance frame
        #[cfg_attr(feature = "serde", serde(rename = "cov_x_y"))]
        pub cov_x_y: f32,
        /// Estimated covariance of the rotation errors about the 1st and 3rd axes
        /// of the covariance frame
        #[cfg_attr(feature = "serde", serde(rename = "cov_x_z"))]
        pub cov_x_z: f32,
        /// Estimated variance of the rotation error about the 2nd axis of the
        /// covariance frame
        #[cfg_attr(feature = "serde", serde(rename = "cov_y_y"))]
        pub cov_y_y: f32,
        /// Estimated covariance of the rotation errors about the 2nd and 3rd axes
        /// of the covariance frame
        #[cfg_attr(feature = "serde", serde(rename = "cov_y_z"))]
        pub cov_y_z: f32,
        /// Estimated variance of the rotation error about the 3rd axis of the
        /// covariance frame
        #[cfg_attr(feature = "serde", serde(rename = "cov_z_z"))]
        pub cov_z_z: f32,
        /// Status flags
        #[cfg_attr(feature = "serde", serde(rename = "flags"))]
        pub flags: u8,
    }

    impl MsgOrientQuatCov {
        /// Gets the [CovarianceParameterization][self::CovarianceParameterization] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `CovarianceParameterization` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `CovarianceParameterization` were added.
        pub fn covariance_parameterization(&self) -> Result<CovarianceParameterization, u8> {
            get_bit_range!(self.flags, u8, u8, 6, 5).try_into()
        }

        /// Set the bitrange corresponding to the [CovarianceParameterization][CovarianceParameterization] of the `flags` bitfield.
        pub fn set_covariance_parameterization(
            &mut self,
            covariance_parameterization: CovarianceParameterization,
        ) {
            set_bit_range!(&mut self.flags, covariance_parameterization, u8, u8, 6, 5);
        }

        /// Gets the [QuaternionReferenceFrame][self::QuaternionReferenceFrame] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `QuaternionReferenceFrame` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `QuaternionReferenceFrame` were added.
        pub fn quaternion_reference_frame(&self) -> Result<QuaternionReferenceFrame, u8> {
            get_bit_range!(self.flags, u8, u8, 4, 3).try_into()
        }

        /// Set the bitrange corresponding to the [QuaternionReferenceFrame][QuaternionReferenceFrame] of the `flags` bitfield.
        pub fn set_quaternion_reference_frame(
            &mut self,
            quaternion_reference_frame: QuaternionReferenceFrame,
        ) {
            set_bit_range!(&mut self.flags, quaternion_reference_frame, u8, u8, 4, 3);
        }

        /// Gets the [InsNavigationMode][self::InsNavigationMode] stored in the `flags` bitfield.
        ///
        /// Returns `Ok` if the bitrange contains a known `InsNavigationMode` variant.
        /// Otherwise the value of the bitrange is returned as an `Err(u8)`. This may be because of a malformed message,
        /// or because new variants of `InsNavigationMode` were added.
        pub fn ins_navigation_mode(&self) -> Result<InsNavigationMode, u8> {
            get_bit_range!(self.flags, u8, u8, 2, 0).try_into()
        }

        /// Set the bitrange corresponding to the [InsNavigationMode][InsNavigationMode] of the `flags` bitfield.
        pub fn set_ins_navigation_mode(&mut self, ins_navigation_mode: InsNavigationMode) {
            set_bit_range!(&mut self.flags, ins_navigation_mode, u8, u8, 2, 0);
        }
    }

    impl ConcreteMessage for MsgOrientQuatCov {
        const MESSAGE_TYPE: u16 = 547;
        const MESSAGE_NAME: &'static str = "MSG_ORIENT_QUAT_COV";
    }

    impl SbpMessage for MsgOrientQuatCov {
        fn message_name(&self) -> &'static str {
            <Self as ConcreteMessage>::MESSAGE_NAME
        }
        fn message_type(&self) -> Option<u16> {
            Some(<Self as ConcreteMessage>::MESSAGE_TYPE)
        }
        fn sender_id(&self) -> Option<u16> {
            self.sender_id
        }
        fn set_sender_id(&mut self, new_id: u16) {
            self.sender_id = Some(new_id);
        }
        fn encoded_len(&self) -> usize {
            WireFormat::len(self) + crate::HEADER_LEN + crate::CRC_LEN
        }
        fn is_valid(&self) -> bool {
            true
        }
        fn into_valid_msg(self) -> Result<Self, crate::messages::invalid::Invalid> {
            Ok(self)
        }

        #[cfg(feature = "swiftnav")]
        fn gps_time(&self) -> Option<std::result::Result<time::MessageTime, time::GpsTimeError>> {
            let tow_s = (self.tow as f64) / 1000.0;
            let gps_time = match time::GpsTime::new(0, tow_s) {
                Ok(gps_time) => gps_time.tow(),
                Err(e) => return Some(Err(e.into())),
            };
            Some(Ok(time::MessageTime::Rover(gps_time.into())))
        }
    }

    impl FriendlyName for MsgOrientQuatCov {
        fn friendly_name() -> &'static str {
            "ORIENT QUAT COV"
        }
    }

    impl TryFrom<Sbp> for MsgOrientQuatCov {
        type Error = TryFromSbpError;
        fn try_from(msg: Sbp) -> Result<Self, Self::Error> {
            match msg {
                Sbp::MsgOrientQuatCov(m) => Ok(m),
                _ => Err(TryFromSbpError(msg)),
            }
        }
    }

    impl WireFormat for MsgOrientQuatCov {
        const MIN_LEN: usize = <u32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <i32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <f32 as WireFormat>::MIN_LEN
            + <u8 as WireFormat>::MIN_LEN;
        fn len(&self) -> usize {
            WireFormat::len(&self.tow)
                + WireFormat::len(&self.w)
                + WireFormat::len(&self.x)
                + WireFormat::len(&self.y)
                + WireFormat::len(&self.z)
                + WireFormat::len(&self.cov_x_x)
                + WireFormat::len(&self.cov_x_y)
                + WireFormat::len(&self.cov_x_z)
                + WireFormat::len(&self.cov_y_y)
                + WireFormat::len(&self.cov_y_z)
                + WireFormat::len(&self.cov_z_z)
                + WireFormat::len(&self.flags)
        }
        fn write<B: BufMut>(&self, buf: &mut B) {
            WireFormat::write(&self.tow, buf);
            WireFormat::write(&self.w, buf);
            WireFormat::write(&self.x, buf);
            WireFormat::write(&self.y, buf);
            WireFormat::write(&self.z, buf);
            WireFormat::write(&self.cov_x_x, buf);
            WireFormat::write(&self.cov_x_y, buf);
            WireFormat::write(&self.cov_x_z, buf);
            WireFormat::write(&self.cov_y_y, buf);
            WireFormat::write(&self.cov_y_z, buf);
            WireFormat::write(&self.cov_z_z, buf);
            WireFormat::write(&self.flags, buf);
        }
        fn parse_unchecked<B: Buf>(buf: &mut B) -> Self {
            MsgOrientQuatCov {
                sender_id: None,
                tow: WireFormat::parse_unchecked(buf),
                w: WireFormat::parse_unchecked(buf),
                x: WireFormat::parse_unchecked(buf),
                y: WireFormat::parse_unchecked(buf),
                z: WireFormat::parse_unchecked(buf),
                cov_x_x: WireFormat::parse_unchecked(buf),
                cov_x_y: WireFormat::parse_unchecked(buf),
                cov_x_z: WireFormat::parse_unchecked(buf),
                cov_y_y: WireFormat::parse_unchecked(buf),
                cov_y_z: WireFormat::parse_unchecked(buf),
                cov_z_z: WireFormat::parse_unchecked(buf),
                flags: WireFormat::parse_unchecked(buf),
            }
        }
    }

    /// Covariance parameterization
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum CovarianceParameterization {
        /// Small-angle rotation errors about the axes of the global frame given by
        /// the quaternion frame field
        SmallAngleRotationErrorsAboutTheAxesOfTheGlobalFrameGivenByTheQuaternionFrameField = 0,

        /// Small-angle rotation errors about the body/vehicle frame axes
        SmallAngleRotationErrorsAboutTheBodyvehicleFrameAxes = 1,

        /// Roll/pitch/yaw Euler-angle covariance (radians)
        RollpitchyawEulerAngleCovariance = 2,
    }

    impl std::fmt::Display for CovarianceParameterization {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
            CovarianceParameterization::SmallAngleRotationErrorsAboutTheAxesOfTheGlobalFrameGivenByTheQuaternionFrameField => f.write_str("Small-angle rotation errors about the axes of the global frame given by the quaternion frame field"),
            CovarianceParameterization::SmallAngleRotationErrorsAboutTheBodyvehicleFrameAxes => f.write_str("Small-angle rotation errors about the body/vehicle frame axes"),
            CovarianceParameterization::RollpitchyawEulerAngleCovariance => f.write_str("Roll/pitch/yaw Euler-angle covariance (radians)"),
        }
        }
    }

    impl TryFrom<u8> for CovarianceParameterization {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
            0 => Ok( CovarianceParameterization :: SmallAngleRotationErrorsAboutTheAxesOfTheGlobalFrameGivenByTheQuaternionFrameField ),
            1 => Ok( CovarianceParameterization :: SmallAngleRotationErrorsAboutTheBodyvehicleFrameAxes ),
            2 => Ok( CovarianceParameterization :: RollpitchyawEulerAngleCovariance ),
            i => Err(i),
        }
        }
    }

    /// Quaternion reference frame
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum QuaternionReferenceFrame {
        /// Local-level NED
        LocalLevelNed = 0,

        /// Local-level ENU
        LocalLevelEnu = 1,

        /// ECEF
        Ecef = 2,
    }

    impl std::fmt::Display for QuaternionReferenceFrame {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                QuaternionReferenceFrame::LocalLevelNed => f.write_str("Local-level NED"),
                QuaternionReferenceFrame::LocalLevelEnu => f.write_str("Local-level ENU"),
                QuaternionReferenceFrame::Ecef => f.write_str("ECEF"),
            }
        }
    }

    impl TryFrom<u8> for QuaternionReferenceFrame {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(QuaternionReferenceFrame::LocalLevelNed),
                1 => Ok(QuaternionReferenceFrame::LocalLevelEnu),
                2 => Ok(QuaternionReferenceFrame::Ecef),
                i => Err(i),
            }
        }
    }

    /// INS Navigation mode
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
    pub enum InsNavigationMode {
        /// Invalid
        Invalid = 0,

        /// Valid
        Valid = 1,
    }

    impl std::fmt::Display for InsNavigationMode {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
            match self {
                InsNavigationMode::Invalid => f.write_str("Invalid"),
                InsNavigationMode::Valid => f.write_str("Valid"),
            }
        }
    }

    impl TryFrom<u8> for InsNavigationMode {
        type Error = u8;
        fn try_from(i: u8) -> Result<Self, u8> {
            match i {
                0 => Ok(InsNavigationMode::Invalid),
                1 => Ok(InsNavigationMode::Valid),
                i => Err(i),
            }
        }
    }
}