-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathconfiguration.py
More file actions
1984 lines (1605 loc) · 68.2 KB
/
configuration.py
File metadata and controls
1984 lines (1605 loc) · 68.2 KB
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
import re
from typing import Any, Iterable, NamedTuple, Optional, List, Union, Tuple
import construct
from construct import (Struct, Padding, this, Flag, Bytes, Array,
Float32l, Float64l, Int64ul, Int32ul, Int16ul, Int8ul, Int64sl, Int32sl, Int16sl, Int8sl, PaddedString)
from ..utils.construct_utils import NamedTupleAdapter, AutoEnum, construct_message_to_string
from ..utils.enum_utils import IntEnum
from .defs import *
################################################################################
# Device Configuration Support
################################################################################
class ConfigurationSource(IntEnum):
ACTIVE = 0
SAVED = 1
DEFAULT = 2
class ConfigType(IntEnum):
INVALID = 0
DEVICE_LEVER_ARM = 16
DEVICE_COARSE_ORIENTATION = 17
GNSS_LEVER_ARM = 18
OUTPUT_LEVER_ARM = 19
VEHICLE_DETAILS = 20
WHEEL_CONFIG = 21
HARDWARE_TICK_CONFIG = 22
DEPRECATED_HEADING_BIAS = 23
GNSS_AUX_LEVER_ARM = 24
ENABLED_GNSS_SYSTEMS = 50
ENABLED_GNSS_FREQUENCY_BANDS = 51
LEAP_SECOND = 52
GPS_WEEK_ROLLOVER = 53
IONOSPHERE_CONFIG = 54
TROPOSPHERE_CONFIG = 55
INTERFACE_CONFIG = 200
UART1_BAUD = 256
UART2_BAUD = 257
UART1_OUTPUT_DIAGNOSTICS_MESSAGES = 258
UART2_OUTPUT_DIAGNOSTICS_MESSAGES = 259
ENABLE_WATCHDOG_TIMER = 300
USER_DEVICE_ID = 301
LBAND_PARAMETERS = 1024
class InterfaceConfigType(IntEnum):
INVALID = 0
OUTPUT_DIAGNOSTICS_MESSAGES = 1
BAUD_RATE = 2
REMOTE_ADDRESS = 3
PATH = 3 # Alias for REMOTE_ADDRESS
PORT = 4
ENABLED = 5
DIRECTION = 6
SOCKET_TYPE = 7
ALL_PARAMETERS = 8
class Direction(IntEnum):
## Aligned with vehicle +x axis.
FORWARD = 0
## Aligned with vehicle -x axis.
BACKWARD = 1
## Aligned with vehicle +y axis.
LEFT = 2
## Aligned with vehicle -y axis.
RIGHT = 3
## Aligned with vehicle +z axis.
UP = 4
## Aligned with vehicle -z axis.
DOWN = 5
## Error value.
INVALID = 255
class VehicleModel(IntEnum):
UNKNOWN_VEHICLE = 0
DATASPEED_CD4 = 1
## In general, all J1939 vehicles support a subset of the J1939 standard and
## may be set to vehicle model `J1939`. Their 29-bit CAN IDs may differ
## based on how the platform assigns message priorities and source
## addresses, but the underlying program group number (PGN) and message
## contents will be consistent.
##
## For most vehicles, it is not necessary to specify and particular make and
## model.
J1939 = 2
LEXUS_CT200H = 20
KIA_SORENTO = 40
KIA_SPORTAGE = 41
AUDI_Q7 = 60
AUDI_A8L = 61
TESLA_MODEL_X = 80
TESLA_MODEL_3 = 81
HYUNDAI_ELANTRA = 100
PEUGEOT_206 = 120
MAN_TGX = 140
FACTION = 160
FACTION_V2 = 161
LINCOLN_MKZ = 180
BMW_7 = 200
BMW_MOTORRAD = 201
VW_4 = 220
RIVIAN = 240
class WheelSensorType(IntEnum):
NONE = 0
# RESERVED = 1
TICKS = 2
WHEEL_SPEED = 3
VEHICLE_SPEED = 4
VEHICLE_TICKS = 5
class AppliedSpeedType(IntEnum):
NONE = 0
REAR_WHEELS = 1
FRONT_WHEELS = 2
FRONT_AND_REAR_WHEELS = 3
VEHICLE_BODY = 4
class SteeringType(IntEnum):
UNKNOWN = 0
FRONT = 1
FRONT_AND_REAR = 2
class TickMode(IntEnum):
OFF = 0
RISING_EDGE = 1
FALLING_EDGE = 2
class TickDirection(IntEnum):
OFF = 0
FORWARD_ACTIVE_HIGH = 1
FORWARD_ACTIVE_LOW = 2
class TransportType(IntEnum):
INVALID = 0
SERIAL = 1
FILE = 2
# RESERVED 3
TCP = 4
UDP = 5
# RESERVED = 6
WEBSOCKET = 7
UNIX = 8
## Set/get the configuration for the interface on which the command was received.
CURRENT = 254
## Set/get the configuration for the all I/O interfaces.
ALL = 255
class InterfaceID(NamedTuple):
type: TransportType = TransportType.INVALID
index: int = 0
_InterfaceIDConstructRaw = Struct(
"type" / AutoEnum(Int8ul, TransportType),
"index" / Int8ul,
Padding(2)
)
_InterfaceIDConstruct = NamedTupleAdapter(InterfaceID, _InterfaceIDConstructRaw)
class TransportDirection(IntEnum):
INVALID = 0
SERVER = 1
CLIENT = 2
class SocketType(IntEnum):
INVALID = 0
STREAM = 1
DATAGRAM = 2
SEQPACKET = 3
class UpdateAction(IntEnum):
REPLACE = 0
class ProtocolType(IntEnum):
INVALID = 0
FUSION_ENGINE = 1
NMEA = 2
RTCM = 3
ALL = 255
class MessageRate(IntEnum):
OFF = 0
ON_CHANGE = 1
MAX_RATE = 1
INTERVAL_10_MS = 2
INTERVAL_20_MS = 3
INTERVAL_40_MS = 4
INTERVAL_50_MS = 5
INTERVAL_100_MS = 6
INTERVAL_200_MS = 7
INTERVAL_500_MS = 8
INTERVAL_1_S = 9
INTERVAL_2_S = 10
INTERVAL_5_S = 11
INTERVAL_10_S = 12
INTERVAL_30_S = 13
INTERVAL_60_S = 14
DEFAULT = 255
ALL_MESSAGES_ID = 0xFFFF
class NmeaMessageType(IntEnum):
INVALID = 0
GGA = 1
GLL = 2
GSA = 3
GSV = 4
RMC = 5
VTG = 6
ZDA = 7
P1CALSTATUS = 1000
P1MSG = 1001
PQTMVERNO = 1200
PQTMVER = 1201
PQTMGNSS = 1202
PQTMVERNO_SUB = 1203
PQTMVER_SUB = 1204
PQTMTXT = 1205
class IonoDelayModel(IntEnum):
AUTO = 0
OFF = 1
KLOBUCHAR = 2
SBAS = 3
class TropoDelayModel(IntEnum):
AUTO = 0
OFF = 1
SAASTAMOINEN = 2
def get_message_type_string(protocol: ProtocolType, message_id: int):
if message_id == ALL_MESSAGES_ID:
return 'ALL (%d)' % message_id
else:
enum = None
try:
if protocol == ProtocolType.NMEA:
enum = NmeaMessageType(message_id)
elif protocol == ProtocolType.FUSION_ENGINE:
enum = MessageType(message_id)
except ValueError:
pass
if enum is None:
return str(message_id)
else:
return '%s (%d)' % (str(enum), int(enum))
def _define_enum_config_classes(enum_type, construct_type=Int8ul):
class EnumVal(NamedTuple):
value: enum_type = list(enum_type)[0]
construct = Struct("value" / AutoEnum(construct_type, enum_type))
return EnumVal, construct
class _ConfigClassGenerator:
"""!
@brief Internal class for generating `ConfigClass` children.
These classes consist of 3 pieces:
- The `ConfigType` associated with the class.
- An accessor class. This is the class that's used to get/set the values for the config object.
- A serialization class. This is the class that (de)serializes the data for the config object.
To generate a ConfigClass:
- Declared as a child of `NamedTuple`. The `NamedTuple` defines the fields.
- Add a `create_config_class` decorator that takes the `ConfigType` and serialization Construct associated with the
class.
For example:
```{.py}
_gen = _ConfigClassGenerator()
class _FooData(NamedTuple):
x: int
_FooConstruct = Struct(
"x" / Int32ul
)
@_gen.create_config_class(ConfigType.BAR, _FooConstruct)
class Bar(_FooData): pass
```
Would create a new `ConfigClass` Bar. Messages with ConfigType.BAR will attempt to (de)serialize to Bar. This
serialization is defined by _FooConstruct. The user accessible fields are defined in _FooData.
"""
class ConfigClass:
"""!
@brief Abstract base class for accessing configuration types.
"""
@classmethod
def GetType(cls) -> ConfigType:
raise ValueError('Accessing `GetType()` of base class')
class InterfaceConfigClass(ConfigClass):
"""!
@brief Abstract base class for accessing I/O interface configuration types.
"""
@classmethod
def GetType(cls) -> ConfigType:
return ConfigType.INTERFACE_CONFIG
@classmethod
def GetSubtype(cls) -> InterfaceConfigType:
raise ValueError('Accessing `GetSubtype()` of base class')
def __init__(self):
# Gets populated with the mappings from ConfigType to constructs.
self.CONFIG_MAP = {}
self.INTERFACE_CONFIG_MAP = {}
def create_config_class(self, config_type, construct_class):
"""!
@brief Decorator for generating ConfigClass children.
@copydoc _ConfigClassGenerator
"""
def inner(config_class):
# Make the decorated class a child of ConfigClass. Add the GetType method.
class InnerClass(config_class, self.ConfigClass):
@classmethod
def GetType(cls) -> ConfigType:
return config_type
InnerClass.__name__ = config_class.__name__
# Register the construct with the MessageType.
self.CONFIG_MAP[config_type] = NamedTupleAdapter(InnerClass, construct_class)
return InnerClass
return inner
def create_interface_config_class(self, config_subtype, construct_class, transport_type: TransportType = None):
"""!
@brief Decorator for generating InterfaceConfigClass children.
@copydoc _ConfigClassGenerator
"""
def inner(config_class):
# Make the decorated class a child of ConfigClass. Add the GetType method.
class InnerClass(config_class, self.InterfaceConfigClass):
@classmethod
def GetSubtype(cls) -> InterfaceConfigType:
return config_subtype
InnerClass.__name__ = config_class.__name__
# Register the construct with the MessageType.
self.INTERFACE_CONFIG_MAP[(transport_type, config_subtype)] = NamedTupleAdapter(InnerClass, construct_class)
return InnerClass
return inner
def find_interface_config_construct(self, interface: InterfaceID, config_subtype: InterfaceConfigType):
construct_obj = _conf_gen.INTERFACE_CONFIG_MAP.get((interface.type, config_subtype), None)
if construct_obj is None:
construct_obj = _conf_gen.INTERFACE_CONFIG_MAP.get((None, config_subtype), None)
if construct_obj is None:
raise KeyError(f'No interface config mapping found for {interface}, config type {config_subtype}.')
return construct_obj
class Point3F(NamedTuple):
"""!
@brief 3D coordinate specifier, stored as 32-bit float values.
"""
x: float = math.nan
y: float = math.nan
z: float = math.nan
# Construct to serialize Point3F.
Point3FConstruct = Struct(
"x" / Float32l,
"y" / Float32l,
"z" / Float32l,
)
class IntegerVal(NamedTuple):
"""!
@brief Integer value specifier.
"""
value: int = 0
# Construct to serialize different sized IntegerVal types.
UInt64Construct = Struct(
"value" / Int64ul,
)
UInt32Construct = Struct(
"value" / Int32ul,
)
UInt16Construct = Struct(
"value" / Int16ul,
)
UInt8Construct = Struct(
"value" / Int8ul,
)
Int64Construct = Struct(
"value" / Int64sl,
)
Int32Construct = Struct(
"value" / Int32sl,
)
Int16Construct = Struct(
"value" / Int16sl,
)
Int8Construct = Struct(
"value" / Int8sl,
)
class BoolVal(NamedTuple):
"""!
@brief Bool value specifier.
"""
value: bool = False
# Construct to serialize 8 bit boolean types.
BoolConstruct = Struct(
"value" / Flag,
)
TransportDirectionVal, TransportDirectionConstruct = _define_enum_config_classes(TransportDirection, Int8ul)
SocketTypeVal, SocketTypeConstruct = _define_enum_config_classes(SocketType, Int8ul)
class StringVal(NamedTuple):
"""!
@brief String value specifier.
"""
value: str = ""
@staticmethod
def StringConstruct(max_len):
return Struct(
"value" / PaddedString(max_len, 'utf8'),
)
class SatelliteTypeMaskVal(IntegerVal):
"""!
@brief Bitmask specifying enabled @ref SatelliteType%s.
"""
def __new__(cls, *args, **kwargs):
# Check if the user specified a single SatelliteType or a list of values, and convert to a mask.
if len(args) == 1:
# SatelliteTypeMaskVal(SatelliteType.GPS)
# SatelliteTypeMaskVal('GPS')
if isinstance(args[0], SatelliteType) or isinstance(args[0], str):
args = (SatelliteTypeMask.to_bitmask(args),)
# SatelliteTypeMaskVal([SatelliteType.GPS, SatelliteType.GALILEO])
# SatelliteTypeMaskVal(['GPS', 'GALILEO'])
elif isinstance(args[0], Iterable):
args = (SatelliteTypeMask.to_bitmask(args[0])),
# SatelliteTypeMaskVal(bit_mask)
else:
pass
# Check if the user specified one or more SatelliteTypes values, and convert to a mask:
# SatelliteTypeMaskVal(SatelliteType.GPS, SatelliteType.GALILEO)
# SatelliteTypeMaskVal('GPS', 'GALILEO')
elif len(args) > 1:
args = (SatelliteTypeMask.to_bitmask(args),)
return super().__new__(cls, *args, **kwargs)
def __repr__(self):
return f'{self.__class__.__name__}(value=0x{self.value:02x} ' \
f'({SatelliteTypeMask.to_string(self.value)}))'
class FrequencyBandMaskVal(IntegerVal):
"""!
@brief Bitmask specifying enabled @ref FrequencyBand%s.
"""
def __new__(cls, *args, **kwargs):
# Check if the user specified a single FrequencyBand or a list of values, and convert to a mask.
if len(args) == 1:
# FrequencyBandMaskVal(FrequencyBand.L1)
# FrequencyBandMaskVal('L1')
if isinstance(args[0], FrequencyBand) or isinstance(args[0], str):
args = (FrequencyBandMask.to_bitmask(args),)
# FrequencyBandMaskVal([FrequencyBand.L1, FrequencyBand.L5])
# FrequencyBandMaskVal(['L1', 'L5'])
elif isinstance(args[0], Iterable):
args = (FrequencyBandMask.to_bitmask(args[0])),
# FrequencyBandMaskVal(bit_mask)
else:
pass
# Check if the user specified one or more FrequencyBands values, and convert to a mask:
# FrequencyBandMaskVal(FrequencyBand.L1, FrequencyBand.L5)
# FrequencyBandMaskVal('L1', 'L5')
elif len(args) > 1:
args = (FrequencyBandMask.to_bitmask(args),)
return super().__new__(cls, *args, **kwargs)
def __repr__(self):
return f'{self.__class__.__name__}(value=0x{self.value:02x} ' \
f'({FrequencyBandMask.to_string(self.value)}))'
class CoarseOrientation(NamedTuple):
"""!
@brief The orientation of a device with respect to the vehicle body axes.
"""
## The direction of the device +x axis relative to the vehicle body axes.
x_direction: Direction = Direction.FORWARD
## The direction of the device +z axis relative to the vehicle body axes.
z_direction: Direction = Direction.UP
CoarseOrientationConstruct = Struct(
"x_direction" / AutoEnum(Int8ul, Direction),
"z_direction" / AutoEnum(Int8ul, Direction),
Padding(2),
)
class VehicleDetails(NamedTuple):
"""!
@brief Information including vehicle model and dimensions.
"""
vehicle_model: VehicleModel = VehicleModel.UNKNOWN_VEHICLE
## The distance between the front axle and rear axle (in meters).
wheelbase_m: float = math.nan
## The distance between the two front wheels (in meters).
front_track_width_m: float = math.nan
## The distance between the two rear wheels (in meters).
rear_track_width_m: float = math.nan
VehicleDetailsConstruct = Struct(
"vehicle_model" / AutoEnum(Int16ul, VehicleModel),
Padding(10),
"wheelbase_m" / Float32l,
"front_track_width_m" / Float32l,
"rear_track_width_m" / Float32l,
)
class WheelConfig(NamedTuple):
"""!
@brief Vehicle/wheel speed measurement configuration settings.
See:
- @ref WheelSpeedMeasurement
- @ref VehicleSpeedMeasurement
- @ref WheelTickMeasurement
- @ref VehicleTickMeasurement
"""
## The type of vehicle/wheel speed measurements produced by the vehicle.
wheel_sensor_type: WheelSensorType = WheelSensorType.NONE
## The type of vehicle/wheel speed measurements to be applied to the navigation solution.
applied_speed_type: AppliedSpeedType = AppliedSpeedType.REAR_WHEELS
## Indication of which of the vehicle's wheels are steered.
steering_type: SteeringType = SteeringType.UNKNOWN
##
# The rate at which wheel speed/tick measurements will be sent to the device (in seconds).
#
# @note
# This parameter is required when using software wheel measurements. It may not be `NAN` if wheel measurements
# are enabled, and cannot be determined automatically by the device.
wheel_update_interval_sec: float = math.nan
##
# Override the rate at which wheel tick measurements will be used by the navigation engine (in seconds).
#
# If this parameter is `NAN`, the best rate will be selected automatically by
# the device based on the input rate (@ref wheel_update_interval_sec) and the
# wheel tick quantization (@ref wheel_ticks_to_m).
#
# @warning
# For most system configurations, we recommend setting this value to `NAN` to let the device choose the
# appropriate setting. Use this setting with caution.
wheel_tick_output_interval_sec: float = math.nan
##
# Ratio between angle of the steering wheel and the angle of the wheels on the ground.
#
# Used when applying measurements from steered wheels only, ignored otherwise.
steering_ratio: float = math.nan
##
# The scale factor to convert from wheel encoder ticks to distance (in meters/tick).
#
# Used for @ref WheelSensorType::TICKS and @ref WheelSensorType::VEHICLE_TICKS, ignored for wheel speed input.
wheel_ticks_to_m: float = math.nan
##
# The maximum value (inclusive) before the wheel tick measurement will roll over.
#
# Used for @ref WheelSensorType::TICKS and @ref WheelSensorType::VEHICLE_TICKS, ignored for wheel speed input.
wheel_tick_max_value: int = 0
##
# `True` if the reported wheel tick measurements should be interpreted as signed integers, or `False` if they
# should be interpreted as unsigned integers.
#
# Used for @ref WheelSensorType::TICKS and @ref WheelSensorType::VEHICLE_TICKS, ignored for wheel speed input.
wheel_ticks_signed: bool = False
##
# `True` if the wheel tick measurements increase by a positive amount when driving forward or backward.
# `False` if wheel tick measurements decrease when driving backward.
#
# Used for @ref WheelSensorType::TICKS and @ref WheelSensorType::VEHICLE_TICKS, ignored for wheel speed input.
wheel_ticks_always_increase: bool = True
WheelConfigConstruct = Struct(
"wheel_sensor_type" / AutoEnum(Int8ul, WheelSensorType),
"applied_speed_type" / AutoEnum(Int8ul, AppliedSpeedType),
"steering_type" / AutoEnum(Int8ul, SteeringType),
Padding(1),
"wheel_update_interval_sec" / Float32l,
"wheel_tick_output_interval_sec" / Float32l,
"steering_ratio" / Float32l,
"wheel_ticks_to_m" / Float32l,
"wheel_tick_max_value" / Int32ul,
"wheel_ticks_signed" / Flag,
"wheel_ticks_always_increase" / Flag,
Padding(2),
)
class HardwareTickConfig(NamedTuple):
"""!
@brief Hardware wheel encoder configuration settings.
See @ref VehicleTickMeasurement.
"""
##
# If enabled -- tick mode is not OFF -- the device will accumulate ticks received on the I/O pin, and use them
# as an indication of vehicle speed. If enabled, you must also specify @ref wheel_ticks_to_m to indicate the
# mapping of wheel tick encoder angle to tire circumference. All other wheel tick-related parameters such as
# tick capture rate, rollover value, etc. will be set internally.
tick_mode: TickMode = TickMode.OFF
##
# When direction is OFF, the incoming ticks will be treated as unsigned, meaning the tick count will continue
# to increase in either direction of travel. If direction is not OFF, a second direction I/O pin will be used
# to indicate the direction of travel and the accumulated tick count will increase/decrease accordingly.
tick_direction: TickDirection = TickDirection.OFF
## The scale factor to convert from wheel encoder ticks to distance (in meters/tick).
wheel_ticks_to_m: float = math.nan
HardwareTickConfigConstruct = Struct(
"tick_mode" / AutoEnum(Int8ul, TickMode),
"tick_direction" / AutoEnum(Int8ul, TickDirection),
Padding(2),
"wheel_ticks_to_m" / Float32l,
)
class IonosphereConfig(NamedTuple):
"""!
@brief Ionospheric delay model configuration.
"""
## The ionospheric delay model to use.
iono_delay_model: IonoDelayModel = IonoDelayModel.AUTO
IonosphereConfigConstruct = Struct(
"iono_delay_model" / AutoEnum(Int8ul, IonoDelayModel),
Padding(3),
)
class TroposphereConfig(NamedTuple):
"""!
@brief Tropospheric delay model configuration.
"""
## The tropospheric delay model to use.
tropo_delay_model: TropoDelayModel = TropoDelayModel.AUTO
TroposphereConfigConstruct = Struct(
"tropo_delay_model" / AutoEnum(Int8ul, TropoDelayModel),
Padding(3),
)
class LBandConfig(NamedTuple):
"""!
@brief Configuration of the L-band demodulator parameters.
"""
## The center frequency of the L-band beam (Hz).
center_frequency_hz: float = 1555492500.0
## The size of the signal acquisition search space (in Hz) around the center
## frequency.
##
## For example, a value of 6000 will search +/- 3 kHz around the center
## frequency.
search_window_hz: float = 2000.0
## If `true`, only output data frames with the configured service ID.
## Otherwise, output all decoded frames.
filter_data_by_service_id: bool = True
## Enable/disable the descrambler. */
use_descrambler: bool = True
## Service ID of the provider.
pmp_service_id: int = 0x5555
## Unique word of the provider.
pmp_unique_word: int = 0xE15AE893E15AE893
## Data rate of the provider (bps).
pmp_data_rate_bps: int = 4800
## The initialization value for the descrambling vector.
descrambler_init: int = 0x6969
LBandConfigConstruct = Struct(
"center_frequency_hz" / Float64l,
"search_window_hz" / Float32l,
"filter_data_by_service_id" / Flag,
"use_descrambler" / Flag,
"pmp_service_id" / Int16ul,
"pmp_unique_word" / Int64ul,
"pmp_data_rate_bps" / Int16ul,
"descrambler_init" / Int16ul,
)
class Empty(NamedTuple):
"""!
@brief Dummy specifier for empty config.
"""
pass
# Empty construct
EmptyConstruct = Struct()
_conf_gen = _ConfigClassGenerator()
########################################################################################################################
# Device configuration settings (lever arms, orientation, wheel speed settings, etc.).
#
# The classes below may be passed to a SetConfigMessage or returned by a ConfigResponseMessage using the `config_object`
# field. For example:
# ```
# SetConfigMessage(GNSSLeverArmConfig(0.4, 0.0, 1.2))
# SetConfigMessage(EnabledGNSSSystemsConfig(SatelliteType.GPS, SatelliteType.GALILEO))
#
# GetConfigMessage(GNSSLeverArmConfig)
# config_response.config_object.x == 0.4
# ```
#
# Note that many of these configuration classes share common parameters, and their fields are defined by their specified
# base classes. For example, `GNSSLeverArmConfig` inherits from `Point3F` and contains `x`, `y`, and `z` fields as
# follows:
# ```
# class Point3F(NamedTuple):
# """!
# @brief 3D coordinate specifier, stored as 32-bit float values.
# """
# x: float = math.nan
# y: float = math.nan
# z: float = math.nan
# class GNSSLeverArmConfig(_conf_gen.Point3F): ...
# ```
########################################################################################################################
@_conf_gen.create_config_class(ConfigType.DEVICE_LEVER_ARM, _conf_gen.Point3FConstruct)
class DeviceLeverArmConfig(_conf_gen.Point3F):
"""!
@brief The location of the device IMU with respect to the vehicle body frame, resolved in the vehicle body frame (in
meters).
"""
pass
@_conf_gen.create_config_class(ConfigType.GNSS_LEVER_ARM, _conf_gen.Point3FConstruct)
class GNSSLeverArmConfig(_conf_gen.Point3F):
"""!
@brief The location of the primary GNSS antenna with respect to the vehicle body frame, resolved in the vehicle body
frame (in meters).
"""
pass
# Alias for convenience.
GnssLeverArmConfig = GNSSLeverArmConfig
@_conf_gen.create_config_class(ConfigType.GNSS_AUX_LEVER_ARM, _conf_gen.Point3FConstruct)
class GNSSAuxLeverArmConfig(_conf_gen.Point3F):
"""!
@brief The location of the secondary GNSS antenna with respect to the vehicle body frame on a dual-antenna platform,
resolved in the vehicle body frame (in meters).
"""
pass
@_conf_gen.create_config_class(ConfigType.OUTPUT_LEVER_ARM, _conf_gen.Point3FConstruct)
class OutputLeverArmConfig(_conf_gen.Point3F):
"""!
@brief The location of the desired output location with respect to the vehicle body frame, resolved in the vehicle
body frame (in meters).
"""
pass
@_conf_gen.create_config_class(ConfigType.ENABLED_GNSS_SYSTEMS, _conf_gen.UInt32Construct)
class EnabledGNSSSystemsConfig(_conf_gen.SatelliteTypeMaskVal):
"""!
@brief A bitmask indicating which GNSS constellations are enabled.
"""
pass
@_conf_gen.create_config_class(ConfigType.ENABLED_GNSS_FREQUENCY_BANDS, _conf_gen.UInt32Construct)
class EnabledGNSSFrequencyBandsConfig(_conf_gen.FrequencyBandMaskVal):
"""!
@brief A bitmask indicating which GNSS frequency bands are enabled.
"""
pass
@_conf_gen.create_config_class(ConfigType.LEAP_SECOND, _conf_gen.Int32Construct)
class LeapSecondConfig(_conf_gen.IntegerVal):
"""!
@brief Specify a UTC leap second count override value to use for all UTC time conversions.
Setting this value will disable all internal leap second sources, including data received from the GNSS almanac
decoded from available signals.
Set to -1 to disable leap second override and re-enable internal leap second handling.
"""
def __new__(cls, value: int = -1):
return super().__new__(cls, value)
@_conf_gen.create_config_class(ConfigType.GPS_WEEK_ROLLOVER, _conf_gen.Int32Construct)
class GPSWeekRolloverConfig(_conf_gen.IntegerVal):
"""!
@brief Specify a GPS legacy week rollover count override to use when converting all legacy 10-bit GPS week numbers
Setting this value will disable all internal week rollover sources, including data received from modern GPS
navigation messages (CNAV, CNAV2) or non-GPS constellations.
Set to -1 to disable week rollover override and re-enable internal handling.
"""
def __new__(cls, value: int = -1):
return super().__new__(cls, value)
@_conf_gen.create_config_class(ConfigType.IONOSPHERE_CONFIG, _conf_gen.IonosphereConfigConstruct)
class IonosphereConfig(_conf_gen.IonosphereConfig):
"""!
@brief Ionospheric delay model configuration.
"""
pass
@_conf_gen.create_config_class(ConfigType.TROPOSPHERE_CONFIG, _conf_gen.TroposphereConfigConstruct)
class TroposphereConfig(_conf_gen.TroposphereConfig):
"""!
@brief Tropospheric delay model configuration.
"""
pass
@_conf_gen.create_config_class(ConfigType.LBAND_PARAMETERS, _conf_gen.LBandConfigConstruct)
class LBandConfig(_conf_gen.LBandConfig):
"""!
@brief Configuration of the L-band demodulator parameters.
"""
pass
@_conf_gen.create_config_class(ConfigType.UART1_BAUD, _conf_gen.UInt32Construct)
class Uart1BaudConfig(_conf_gen.IntegerVal):
"""!
@brief The UART1 serial baud rate (in bits/second).
"""
pass
@_conf_gen.create_config_class(ConfigType.UART2_BAUD, _conf_gen.UInt32Construct)
class Uart2BaudConfig(_conf_gen.IntegerVal):
"""!
@brief The UART2 serial baud rate (in bits/second).
"""
pass
@_conf_gen.create_config_class(ConfigType.UART1_OUTPUT_DIAGNOSTICS_MESSAGES, _conf_gen.BoolConstruct)
class Uart1DiagnosticMessagesEnabled(_conf_gen.BoolVal):
"""!
@brief Whether to output the diagnostic message set on UART1.
"""
pass
@_conf_gen.create_config_class(ConfigType.UART2_OUTPUT_DIAGNOSTICS_MESSAGES, _conf_gen.BoolConstruct)
class Uart2DiagnosticMessagesEnabled(_conf_gen.BoolVal):
"""!
@brief Whether to output the diagnostic message set on UART2.
"""
pass
@_conf_gen.create_config_class(ConfigType.ENABLE_WATCHDOG_TIMER, _conf_gen.BoolConstruct)
class WatchdogTimerEnabled(_conf_gen.BoolVal):
"""!
@brief Enable watchdog timer to restart device after fatal errors.
"""
pass
@_conf_gen.create_config_class(ConfigType.USER_DEVICE_ID, _conf_gen.StringConstruct(32))
class UserDeviceID(_conf_gen.StringVal):
"""!
@brief A string for identifying a device.
"""
pass
@_conf_gen.create_config_class(ConfigType.DEVICE_COARSE_ORIENTATION, _conf_gen.CoarseOrientationConstruct)
class DeviceCourseOrientationConfig(_conf_gen.CoarseOrientation):
"""!
@brief The orientation of a device with respect to the vehicle body axes.
A device's orientation is defined by specifying how the +x and +z axes of its
IMU are aligned with the vehicle body axes. For example, in a car:
- `forward,up`: device +x = vehicle +x, device +z = vehicle +z (i.e.,
IMU pointed towards the front of the vehicle).
- `left,up`: device +x = vehicle +y, device +z = vehicle +z (i.e., IMU
pointed towards the left side of the vehicle)
- `up,backward`: device +x = vehicle +z, device +z = vehicle -x (i.e.,
IMU pointed vertically upward, with the top of the IMU pointed towards the
trunk)
"""
pass
@_conf_gen.create_config_class(ConfigType.VEHICLE_DETAILS, _conf_gen.VehicleDetailsConstruct)
class VehicleDetailsConfig(_conf_gen.VehicleDetails):
"""!
@brief Information including vehicle model and dimensions.
"""
pass
@_conf_gen.create_config_class(ConfigType.WHEEL_CONFIG, _conf_gen.WheelConfigConstruct)
class WheelConfig(_conf_gen.WheelConfig):
"""!
@brief Information pertaining to wheel speeds.
"""
pass
@_conf_gen.create_config_class(ConfigType.HARDWARE_TICK_CONFIG, _conf_gen.HardwareTickConfigConstruct)
class HardwareTickConfig(_conf_gen.HardwareTickConfig):
"""!
@brief Tick configuration settings.
"""
pass
@_conf_gen.create_config_class(ConfigType.INVALID, _conf_gen.EmptyConstruct)
class InvalidConfig(_conf_gen.Empty):
"""!
@brief Placeholder for empty invalid configuration messages.
"""
pass
########################################################################################################################
# Input/output interface controls.
#
# When configuring I/O interfaces, you must specify the desired interface:
#
# Examples:
# ```
# SetConfigMessage(
# InterfaceDiagnosticMessagesEnabled(True),
# interface=InterfaceID(TransportType.TCP, 0))