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.
Files changed (51) hide show
  1. autoverse_cli-0.28.1.dist-info/METADATA +91 -0
  2. autoverse_cli-0.28.1.dist-info/RECORD +51 -0
  3. autoverse_cli-0.28.1.dist-info/WHEEL +5 -0
  4. autoverse_cli-0.28.1.dist-info/entry_points.txt +2 -0
  5. autoverse_cli-0.28.1.dist-info/licenses/LICENSE +33 -0
  6. autoverse_cli-0.28.1.dist-info/top_level.txt +1 -0
  7. avrs/__init__.py +0 -0
  8. avrs/app_version.py +24 -0
  9. avrs/argparse_help.py +30 -0
  10. avrs/avrs.py +183 -0
  11. avrs/can_tool.py +192 -0
  12. avrs/can_tool_util.py +190 -0
  13. avrs/cfg.py +78 -0
  14. avrs/launcher.py +256 -0
  15. avrs/launcher_util.py +203 -0
  16. avrs/race_cloud.py +506 -0
  17. avrs/race_cloud_bridge_can.py +100 -0
  18. avrs/race_cloud_cfg_util.py +310 -0
  19. avrs/race_cloud_fwd_api.py +49 -0
  20. avrs/race_cloud_util.py +384 -0
  21. avrs/requests/change_camera.py +24 -0
  22. avrs/requests/code_booz.py +69 -0
  23. avrs/requests/demo.py +19 -0
  24. avrs/requests/dump_sim_config.py +14 -0
  25. avrs/requests/environment.py +46 -0
  26. avrs/requests/fault_injection.py +186 -0
  27. avrs/requests/get_object_config.py +18 -0
  28. avrs/requests/get_web_viz_meta.py +11 -0
  29. avrs/requests/leaderboard.py +74 -0
  30. avrs/requests/list_sim_objects.py +26 -0
  31. avrs/requests/log_path.py +28 -0
  32. avrs/requests/misc.py +70 -0
  33. avrs/requests/move_to_landmark.py +16 -0
  34. avrs/requests/npc.py +289 -0
  35. avrs/requests/race_control.py +48 -0
  36. avrs/requests/request.py +61 -0
  37. avrs/requests/reset_to_track.py +21 -0
  38. avrs/requests/rest_request.py +45 -0
  39. avrs/requests/restart.py +12 -0
  40. avrs/requests/scenario_control.py +43 -0
  41. avrs/requests/spawn_object.py +44 -0
  42. avrs/requests/teleport.py +40 -0
  43. avrs/requests/toggle_hud.py +11 -0
  44. avrs/requests/vd.py +64 -0
  45. avrs/requests/vehicle_input.py +21 -0
  46. avrs/requests/vehicle_replay.py +454 -0
  47. avrs/shell_completion.py +121 -0
  48. avrs/simconfig.py +75 -0
  49. avrs/simconfig_util.py +170 -0
  50. avrs/tests.py +9 -0
  51. 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
@@ -0,0 +1,9 @@
1
+ import os
2
+ import unittest
3
+ import shutil
4
+ import subprocess
5
+
6
+ class TestMisc(unittest.TestCase):
7
+
8
+ def test_misc(self):
9
+ self.assertTrue(True)
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)