autoverse-cli 0.28.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- autoverse_cli-0.28.1.dist-info/METADATA +91 -0
- autoverse_cli-0.28.1.dist-info/RECORD +51 -0
- autoverse_cli-0.28.1.dist-info/WHEEL +5 -0
- autoverse_cli-0.28.1.dist-info/entry_points.txt +2 -0
- autoverse_cli-0.28.1.dist-info/licenses/LICENSE +33 -0
- autoverse_cli-0.28.1.dist-info/top_level.txt +1 -0
- avrs/__init__.py +0 -0
- avrs/app_version.py +24 -0
- avrs/argparse_help.py +30 -0
- avrs/avrs.py +183 -0
- avrs/can_tool.py +192 -0
- avrs/can_tool_util.py +190 -0
- avrs/cfg.py +78 -0
- avrs/launcher.py +256 -0
- avrs/launcher_util.py +203 -0
- avrs/race_cloud.py +506 -0
- avrs/race_cloud_bridge_can.py +100 -0
- avrs/race_cloud_cfg_util.py +310 -0
- avrs/race_cloud_fwd_api.py +49 -0
- avrs/race_cloud_util.py +384 -0
- avrs/requests/change_camera.py +24 -0
- avrs/requests/code_booz.py +69 -0
- avrs/requests/demo.py +19 -0
- avrs/requests/dump_sim_config.py +14 -0
- avrs/requests/environment.py +46 -0
- avrs/requests/fault_injection.py +186 -0
- avrs/requests/get_object_config.py +18 -0
- avrs/requests/get_web_viz_meta.py +11 -0
- avrs/requests/leaderboard.py +74 -0
- avrs/requests/list_sim_objects.py +26 -0
- avrs/requests/log_path.py +28 -0
- avrs/requests/misc.py +70 -0
- avrs/requests/move_to_landmark.py +16 -0
- avrs/requests/npc.py +289 -0
- avrs/requests/race_control.py +48 -0
- avrs/requests/request.py +61 -0
- avrs/requests/reset_to_track.py +21 -0
- avrs/requests/rest_request.py +45 -0
- avrs/requests/restart.py +12 -0
- avrs/requests/scenario_control.py +43 -0
- avrs/requests/spawn_object.py +44 -0
- avrs/requests/teleport.py +40 -0
- avrs/requests/toggle_hud.py +11 -0
- avrs/requests/vd.py +64 -0
- avrs/requests/vehicle_input.py +21 -0
- avrs/requests/vehicle_replay.py +454 -0
- avrs/shell_completion.py +121 -0
- avrs/simconfig.py +75 -0
- avrs/simconfig_util.py +170 -0
- avrs/tests.py +9 -0
- avrs/util.py +13 -0
avrs/simconfig_util.py
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
class SimConfigFiles():
|
|
6
|
+
def __init__(self, saved_dir):
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger('avrs')
|
|
9
|
+
|
|
10
|
+
self.required_files = {
|
|
11
|
+
'main': os.path.join(saved_dir, 'simconfig.json'),
|
|
12
|
+
'eav24': os.path.join(saved_dir, 'Objects', 'Eav24_default.json'),
|
|
13
|
+
'yas': os.path.join(saved_dir, 'Environments', 'yasmarina_env.json'),
|
|
14
|
+
'adrome': os.path.join(saved_dir, 'Environments', 'autonodrome.json'),
|
|
15
|
+
'suzuka': os.path.join(saved_dir, "Environments", "Suzuka", "suzuka.json"),
|
|
16
|
+
'yasnorth': os.path.join(saved_dir, "Environments", "YasMarinaNorth", "yasmarinanorth_env.json")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
self.alt_paths = {
|
|
20
|
+
"main": [],
|
|
21
|
+
"eav24": [],
|
|
22
|
+
"yas": [os.path.join(saved_dir, 'Environments', "YasMarina", 'yasmarina_env.json')],
|
|
23
|
+
"adrome": [os.path.join(saved_dir, 'Environments', "Autonodrome", 'autonodrome.json')],
|
|
24
|
+
"suzuka": [os.path.join(saved_dir, "Environments", "Suzuka", "suzuka.json")]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# support alternative paths for new directory structure, but retain backward compat
|
|
28
|
+
for k, v in self.required_files.items():
|
|
29
|
+
if not os.path.exists(v):
|
|
30
|
+
for alt_path in self.alt_paths.get(k, []):
|
|
31
|
+
if os.path.exists(alt_path):
|
|
32
|
+
logger.info("could not find file under {} but found under alt path {}".format(
|
|
33
|
+
v, alt_path))
|
|
34
|
+
self.required_files[k] = alt_path
|
|
35
|
+
|
|
36
|
+
self.files = {}
|
|
37
|
+
|
|
38
|
+
ok, status = self.validate()
|
|
39
|
+
if ok:
|
|
40
|
+
for name, path in self.required_files.items():
|
|
41
|
+
with open(path, 'r', encoding='utf-8') as f:
|
|
42
|
+
self.files[name] = json.load(f)
|
|
43
|
+
|
|
44
|
+
def validate(self):
|
|
45
|
+
for name, path in self.required_files.items():
|
|
46
|
+
if not os.path.exists(path):
|
|
47
|
+
return (False, '{} not found'.format(path))
|
|
48
|
+
return (True, '')
|
|
49
|
+
|
|
50
|
+
def save(self):
|
|
51
|
+
for name, path in self.required_files.items():
|
|
52
|
+
with open(path, 'w', encoding='utf-8') as f:
|
|
53
|
+
json.dump(self.files[name], f, ensure_ascii=False, indent=4)
|
|
54
|
+
|
|
55
|
+
def compare_simconfig_defaults(sim_saved_dir, new_defaults_dir):
|
|
56
|
+
old_cfg_files = SimConfigFiles(sim_saved_dir)
|
|
57
|
+
new_cfg_files = SimConfigFiles(new_defaults_dir)
|
|
58
|
+
|
|
59
|
+
ok, status = old_cfg_files.validate()
|
|
60
|
+
if not ok:
|
|
61
|
+
print(status)
|
|
62
|
+
return
|
|
63
|
+
ok, status = new_cfg_files.validate()
|
|
64
|
+
if not ok:
|
|
65
|
+
print(status)
|
|
66
|
+
return
|
|
67
|
+
|
|
68
|
+
print('comparing config files at {} with those at {}'.format(
|
|
69
|
+
sim_saved_dir, new_defaults_dir))
|
|
70
|
+
|
|
71
|
+
out_cpr = {}
|
|
72
|
+
compare_dicts(old_cfg_files.files['main'], new_cfg_files.files['main'], 'main', out_cpr)
|
|
73
|
+
|
|
74
|
+
#print('{}'.format(out_cpr))
|
|
75
|
+
print_simconfig_compare(out_cpr['main'])
|
|
76
|
+
|
|
77
|
+
def print_simconfig_compare(cpr):
|
|
78
|
+
for i in cpr['only_a']:
|
|
79
|
+
print('{} in a ({}) but not b'.format(i[0], i[1]))
|
|
80
|
+
for i in cpr['only_b']:
|
|
81
|
+
print('{} in b ({}) but not a'.format(i[0], i[1]))
|
|
82
|
+
for i in cpr['type_mismatch']:
|
|
83
|
+
print('{} ({}) does not match type {} ({})'.format(i[0], i[1], i[0], i[2]))
|
|
84
|
+
for i in cpr['value_mismatch']:
|
|
85
|
+
print('{} ({}) value does not match ({})'.format(i[0], i[1], i[2]))
|
|
86
|
+
|
|
87
|
+
for key, value in cpr['sub'].items():
|
|
88
|
+
print_simconfig_compare(value)
|
|
89
|
+
|
|
90
|
+
def compare_dicts(a, b, parent_key, out_checks):
|
|
91
|
+
|
|
92
|
+
only_a = []
|
|
93
|
+
only_b = []
|
|
94
|
+
type_mismatch = []
|
|
95
|
+
value_mismatch = []
|
|
96
|
+
|
|
97
|
+
out_checks[parent_key] = {}
|
|
98
|
+
out_checks[parent_key]['sub'] = {}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
for key, value in a.items():
|
|
102
|
+
key_chain = '{}.{}'.format(parent_key, key)
|
|
103
|
+
if key not in b:
|
|
104
|
+
only_a.append((key_chain, value))
|
|
105
|
+
else:
|
|
106
|
+
if type(value) != type(b[key]):
|
|
107
|
+
type_mismatch.append((key_chain, type(value), type(b[key])))
|
|
108
|
+
elif isinstance(value, dict):
|
|
109
|
+
compare_dicts(value, b[key], key_chain, out_checks[parent_key]['sub'])
|
|
110
|
+
elif value != b[key]:
|
|
111
|
+
value_mismatch.append((key_chain, value, b[key]))
|
|
112
|
+
|
|
113
|
+
for key, value in b.items():
|
|
114
|
+
key_chain = '{}.{}'.format(parent_key, key)
|
|
115
|
+
if key not in a:
|
|
116
|
+
only_b.append((key_chain, value))
|
|
117
|
+
|
|
118
|
+
out_checks[parent_key]['only_a'] = only_a
|
|
119
|
+
out_checks[parent_key]['only_b'] = only_b
|
|
120
|
+
out_checks[parent_key]['type_mismatch'] = type_mismatch
|
|
121
|
+
out_checks[parent_key]['value_mismatch'] = value_mismatch
|
|
122
|
+
|
|
123
|
+
#print('only a \n {} \n\n'.format(only_a))
|
|
124
|
+
#print('only b \n {} \n\n'.format(only_b))
|
|
125
|
+
#print('type mismatch \n {} \n\n'.format(type_mismatch))
|
|
126
|
+
#print('value mismatch \n {} \n\n'.format(value_mismatch))
|
|
127
|
+
#print('sub_checks')
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def apply_simconfig_preset(sim_saved_dir, preset_name):
|
|
132
|
+
cfg_files = SimConfigFiles(sim_saved_dir)
|
|
133
|
+
ok, status = cfg_files.validate()
|
|
134
|
+
if not ok:
|
|
135
|
+
print(status)
|
|
136
|
+
return
|
|
137
|
+
|
|
138
|
+
presets = {
|
|
139
|
+
'default': apply_default_simconfig_preset,
|
|
140
|
+
'lightweight': apply_lightweight_simconfig_preset,
|
|
141
|
+
'a2rl': apply_a2rl_simconfig_preset
|
|
142
|
+
}
|
|
143
|
+
presets[preset_name](cfg_files)
|
|
144
|
+
|
|
145
|
+
def apply_default_simconfig_preset(cfg_files):
|
|
146
|
+
files = cfg_files.files
|
|
147
|
+
|
|
148
|
+
print('globally enabling ROS2 and CAN')
|
|
149
|
+
files['main']['interfaces']['bEnableRos2'] = True
|
|
150
|
+
files['main']['interfaces']['bEnableCan'] = True
|
|
151
|
+
|
|
152
|
+
print('ensuring default eav24 and yasmarina are reference in main config')
|
|
153
|
+
if not 'Environments/yasmarina_env.json' in files['main']['environmentPaths']:
|
|
154
|
+
print('missing yas environment. adding')
|
|
155
|
+
print('{}'.format(files['main']['environmentPaths']))
|
|
156
|
+
if not 'Objects/Eav24_default.json' in files['main']['objectTemplatePaths']:
|
|
157
|
+
print('missing eav24. adding')
|
|
158
|
+
|
|
159
|
+
cfg_files.save()
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def apply_lightweight_simconfig_preset(cfg_files):
|
|
163
|
+
files = cfg_files.files
|
|
164
|
+
|
|
165
|
+
cfg_files.save()
|
|
166
|
+
|
|
167
|
+
def apply_a2rl_simconfig_preset(cfg_files):
|
|
168
|
+
files = cfg_files.files
|
|
169
|
+
|
|
170
|
+
cfg_files.save()
|
avrs/tests.py
ADDED
avrs/util.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
|
|
3
|
+
class ProcessResult():
|
|
4
|
+
def __init__(self, pres):
|
|
5
|
+
self.out = pres.stdout.decode('utf-8')
|
|
6
|
+
self.err = pres.stderr.decode('utf-8')
|
|
7
|
+
|
|
8
|
+
def run_process(args):
|
|
9
|
+
result = subprocess.run(
|
|
10
|
+
args,
|
|
11
|
+
stdout=subprocess.PIPE,
|
|
12
|
+
stderr=subprocess.PIPE)
|
|
13
|
+
return ProcessResult(result)
|