CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

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