Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Ardupilot
GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/autotest/param_metadata/param.py
9594 views
1
# flake8: noqa
2
3
4
class Parameter(object):
5
def __init__(self, name, real_path):
6
self.name = name
7
self.real_path = real_path
8
9
def change_name(self, name):
10
self.name = name
11
12
13
class Vehicle(object):
14
def __init__(self, name, path, reference=None):
15
self.name = name
16
self.path = path
17
self.reference = reference
18
if reference is None:
19
self.reference = self.truename
20
self.params = []
21
22
23
class Library(object):
24
def __init__(self, name, reference=None, not_rst=False, check_duplicates=False):
25
self.set_name(name)
26
self.params = []
27
if reference is not None:
28
self.reference = reference
29
self.not_rst = not_rst
30
self.check_duplicates = check_duplicates
31
32
def set_name(self, name):
33
self.name = name
34
self.reference = name
35
36
def has_param(self, pname):
37
for p in self.params:
38
if pname == p.name:
39
return True
40
return False
41
42
known_param_fields = [
43
'Description',
44
'DisplayName',
45
'Values',
46
'Range',
47
'Units',
48
'Increment',
49
'User',
50
'RebootRequired',
51
'Bitmask',
52
'Volatile',
53
'ReadOnly',
54
'Calibration',
55
'Vector3Parameter',
56
'SortValues',
57
'Legacy',
58
]
59
60
# Follow SI units conventions from:
61
# http://physics.nist.gov/cuu/Units/units.html
62
# http://physics.nist.gov/cuu/Units/outside.html
63
# and
64
# http://physics.nist.gov/cuu/Units/checklist.html
65
# http://www.bipm.org/en/publications/si-brochure/
66
# http://www1.bipm.org/en/CGPM/db/3/2/ g_n unit for G-force
67
# one further constrain is that only printable (7bit) ASCII characters are allowed
68
known_units = {
69
# abbreviation : full-text (used in .html .rst and .wiki files)
70
# time
71
's' : 'seconds' ,
72
'ds' : 'deciseconds' ,
73
'cs' : 'centiseconds' ,
74
'ms' : 'milliseconds' ,
75
'us' : 'microseconds' ,
76
'PWM' : 'PWM in microseconds' , # should be microseconds, this is NOT a SI unit, but follows https://github.com/ArduPilot/ardupilot/pull/5538#issuecomment-271943061
77
'Hz' : 'hertz' ,
78
'kHz' : 'kilohertz' ,
79
'1/s' : 'per second' , # Not SI but in some situations more user-friendly than hertz
80
# distance
81
'km' : 'kilometers' , # metre is the SI unit name, meter is the american spelling of it
82
'm' : 'meters' , # metre is the SI unit name, meter is the american spelling of it
83
'm/s' : 'meters per second' , # metre is the SI unit name, meter is the american spelling of it
84
'm/s/s' : 'meters per square second' , # metre is the SI unit name, meter is the american spelling of it
85
'm/s/s/s' : 'meters per cubic second' , # metre is the SI unit name, meter is the american spelling of it
86
'cm' : 'centimeters' , # metre is the SI unit name, meter is the american spelling of it
87
'cm/s' : 'centimeters per second' , # metre is the SI unit name, meter is the american spelling of it
88
'cm/s/s' : 'centimeters per square second', # metre is the SI unit name, meter is the american spelling of it
89
'cm/s/s/s': 'centimeters per cubic second' , # metre is the SI unit name, meter is the american spelling of it
90
'mm' : 'millimeters' , # metre is the SI unit name, meter is the american spelling of it
91
# temperature
92
'degC' : 'degrees Celsius' , # Not SI, but Kelvin is too cumbersome for most users
93
# angle
94
'deg' : 'degrees' , # Not SI, but is some situations more user-friendly than radians
95
'deg/s' : 'degrees per second' , # Not SI, but is some situations more user-friendly than radians
96
'deg/s/s' : 'degrees per square second', # Not SI, but is some situations more user-friendly than radians
97
'deg/s/s/s' : 'degrees per cube second', # Not SI, but is some situations more user-friendly than radians
98
'cdeg' : 'centidegrees' , # Not SI, but is some situations more user-friendly than radians
99
'cdeg/s' : 'centidegrees per second', # Not SI, but is some situations more user-friendly than radians
100
'cdeg/s/s': 'centidegrees per square second' , # Not SI, but is some situations more user-friendly than radians
101
'rad' : 'radians' ,
102
'rad/s' : 'radians per second' ,
103
'rad/s/s' : 'radians per square second' ,
104
# electricity
105
'A' : 'ampere' ,
106
'V' : 'volt' ,
107
'W' : 'watt' ,
108
# magnetism
109
'Gauss' : 'gauss' , # Gauss is not an SI unit, but 1 tesla = 10000 gauss so a simple replacement is not possible here
110
'Gauss/s' : 'gauss per second' , # Gauss is not an SI unit, but 1 tesla = 10000 gauss so a simple replacement is not possible here
111
'mGauss' : 'milligauss' , # Gauss is not an SI unit, but 1 tesla = 10000 gauss so a simple replacement is not possible here
112
# pressure
113
'Pa' : 'pascal' ,
114
'hPa' : 'hectopascal' ,
115
# ratio
116
'%' : 'percent' ,
117
'%/s' : 'percent per second' ,
118
'd%' : 'decipercent' , # decipercent is strange, but "per-mille" is even more exotic
119
'dB' : 'decibel' ,
120
# compound
121
122
'kB' : 'kilobytes' ,
123
'KiB' : 'kibibytes',
124
'MB' : 'megabyte' ,
125
'm.m/s/s' : 'square meter per square second',
126
'deg/m/s' : 'degrees per meter per second' ,
127
'm/s/m' : 'meters per second per meter' , # Why not use Hz here ????
128
'mGauss/A': 'milligauss per ampere' ,
129
'mAh' : 'milliampere hour' ,
130
'Ah' : 'ampere hour' ,
131
'A/V' : 'ampere per volt' ,
132
'm/V' : 'meters per volt' ,
133
'gravities': 'standard acceleration due to gravity' , # g_n would be a more correct unit, but IMHO no one understands what g_n means
134
'octal' : 'octal' ,
135
'RPM' : 'Revolutions Per Minute',
136
'kg' : 'kilograms',
137
'kg/m/m' : 'kilograms per square meter', # metre is the SI unit name, meter is the american spelling of it
138
'kg/m/m/m': 'kilograms per cubic meter',
139
'litres' : 'litres',
140
'Ohm' : 'Ohm',
141
'N' : 'Newtons',
142
}
143
144
required_param_fields = [
145
'Description',
146
'DisplayName',
147
'User',
148
]
149
150
required_library_param_fields = [
151
'Description',
152
'DisplayName',
153
]
154
155
known_group_fields = [
156
'Path',
157
]
158
159