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
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.4
2
+ Name: autoverse-cli
3
+ Version: 0.28.1
4
+ Summary: The Autoverse CLI
5
+ Author-email: Dan Kamrath <dan.kamrath@autonomalabs.com>
6
+ License: # End-User License Agreement (EULA) of the Autonoma AutoVerse CLI
7
+
8
+ This End-User License Agreement ("EULA") is a legal agreement between you and Autonoma, Inc.
9
+
10
+ ## License Grant
11
+
12
+ Autonoma, Inc. hereby grants you a personal, non-transferable, non-exclusive licence to use the AutoVerse software in accordance with the terms of this EULA agreement.
13
+
14
+ ## Limitation of Liability
15
+ The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, express or implied. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of the software.
16
+
17
+ ### You are NOT permitted to:
18
+
19
+ - Edit, alter, modify, adapt, translate or otherwise change the whole or any part of the Software nor permit the whole or any part of the Software to be combined with or become incorporated in any other software, nor decompile, disassemble or reverse engineer the Software or attempt to do any such things
20
+ - Reproduce, copy, distribute, resell or otherwise use the Software for any commercial purpose
21
+ - Allow any third party to use the Software on behalf of or for the benefit of any third party
22
+ - Use the Software in any way which breaches any applicable local, national or international law
23
+ use the Software for any purpose that Autonoma, Inc. considers is a breach of this EULA agreement
24
+ Intellectual Property and Ownership
25
+
26
+ Autonoma, Inc. shall at all times retain ownership of the Software as originally downloaded by you and all subsequent downloads of the Software by you. The Software (and the copyright, and other intellectual property rights of whatever nature in the Software, including any modifications made thereto) are and shall remain the property of Autonoma, Inc.
27
+
28
+ Autonoma, Inc. reserves the right to grant licences to use the Software to third parties.
29
+
30
+ ## Termination
31
+
32
+ This EULA agreement is effective from the date you first use the Software and shall continue until terminated. You may terminate it at any time upon written notice to Autonoma, Inc.
33
+
34
+ It will also terminate immediately if you fail to comply with any term of this EULA agreement. Upon such termination, the licenses granted by this EULA agreement will immediately terminate and you agree to stop all access and use of the Software. The provisions that by their nature continue and survive will survive any termination of this EULA agreement.
35
+
36
+ ## Governing Law
37
+
38
+ This EULA agreement, and any dispute arising out of or in connection with this EULA agreement, shall be governed by and construed in accordance with the laws of the USA.
39
+ Classifier: Programming Language :: Python :: 3
40
+ Classifier: Operating System :: OS Independent
41
+ Requires-Python: >=3.8
42
+ Description-Content-Type: text/markdown
43
+ License-File: LICENSE
44
+ Requires-Dist: boto3
45
+ Requires-Dist: cantools
46
+ Requires-Dist: argcomplete
47
+ Dynamic: license-file
48
+
49
+ # Autoverse CLI
50
+
51
+ The new implementation of the Autoverse CLI
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install autoverse-cli
57
+ ```
58
+
59
+ ## Shell Completion
60
+
61
+ To enable tab completion for the `avrs` command, run:
62
+
63
+ ```bash
64
+ avrs --install-completion
65
+ ```
66
+
67
+ Then reload your shell:
68
+
69
+ ```bash
70
+ source ~/.bashrc # or ~/.zshrc, ~/.config/fish/config.fish, etc.
71
+ ```
72
+
73
+ For full details, see [SHELL_COMPLETION.md](SHELL_COMPLETION.md).
74
+
75
+ ### Supported Shells
76
+
77
+ - Bash
78
+ - Zsh
79
+ - Fish
80
+ - Tcsh
81
+
82
+ ### Quick Usage Examples
83
+
84
+ ```bash
85
+ # List all available commands
86
+ avrs <TAB>
87
+
88
+ # Complete subcommand arguments
89
+ avrs launcher <TAB>
90
+ avrs restart <TAB>
91
+ ```
@@ -0,0 +1,51 @@
1
+ autoverse_cli-0.28.1.dist-info/licenses/LICENSE,sha256=d4eWXho-u18HkBsX4K21uHX_bBb2UXZSrJdsb7Z_JlM,2647
2
+ avrs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ avrs/app_version.py,sha256=n0F5-AxHn28rW3tnYoBBzz1bg6bbbTqkanRlDS2UMGw,857
4
+ avrs/argparse_help.py,sha256=EoEaohGXZXqJvs1dFEzbo9vh47CYdHdSY2Im2Ps2iFo,945
5
+ avrs/avrs.py,sha256=pQHc8KLAD0hCxpBoNbXOgj2Et3qiqxSMKyAXFLwWFjE,5787
6
+ avrs/can_tool.py,sha256=IBoctKobBJ3wCq4ZdtuXuXH4AMEUxazCfYT6YP0Luw8,7161
7
+ avrs/can_tool_util.py,sha256=G3q21dTGMLc09SDq_RieoW7kSn-kXPkXxPDjavPh4hQ,7710
8
+ avrs/cfg.py,sha256=kMn08Z4Ms1PAu2-U1QI8weEJeIVEppP4A4_tFfwnjtg,2924
9
+ avrs/launcher.py,sha256=A66k4F2jYG1u4IqGUxn6osK1jl1xQMz1vuc1Uui_Vb0,11588
10
+ avrs/launcher_util.py,sha256=zXUbJByn9M-ErkNM6DvLCFtUkueYH-R0dehjQj0aYEs,6879
11
+ avrs/race_cloud.py,sha256=0m7BdclKhTrqdAA2kLIobwfoYA8X_PRDCFWoizHtPIQ,20124
12
+ avrs/race_cloud_bridge_can.py,sha256=K3is7GFzWo2KBojr6V65kz138UfkVFXXofVxSAziArY,2888
13
+ avrs/race_cloud_cfg_util.py,sha256=TF_gsP7c_39MKs1CyzeXkTH-Fwyd8wLkFkMbqQVmdeo,12066
14
+ avrs/race_cloud_fwd_api.py,sha256=jB4kt6Shu9Pj96WPVjK790PZjucYxmuHjjVKczQfyZI,1620
15
+ avrs/race_cloud_util.py,sha256=g1gCxmK-8n32aNj0NWEiZr79s1rB0EYbGmNLabsIW0U,14297
16
+ avrs/shell_completion.py,sha256=_IM85ADKQHYNMlTa1_nhnYWsgdOzRQ7tIFHxAT6EWWA,4298
17
+ avrs/simconfig.py,sha256=UZc4FrxVHUkk2e9IglSpuojXkaL_nPrJW7trbEGgOOo,2907
18
+ avrs/simconfig_util.py,sha256=ronvXg9Mraz60K99ABBvo_YDI1_rWphUWUn_s_voTKw,6044
19
+ avrs/tests.py,sha256=3JeYBjn0tRqHXERDROfzmYuW1KXeCcKur5Bw-EIegto,153
20
+ avrs/util.py,sha256=SB8Jgsh8IpFdpy3pWPuEoYExLed9XimEAMtYn4gU42g,301
21
+ avrs/requests/change_camera.py,sha256=p7S5C2KtSBuknj4-0jkAJtTQcdlSQ5Mwm0lmZIk3QTI,857
22
+ avrs/requests/code_booz.py,sha256=SXaEAMTqID4lf1o_4Cc1wY9609X-dNcfNa-UZv3FWF4,2471
23
+ avrs/requests/demo.py,sha256=cbGQJK-OfeFUkQwVzafHgoWP15xoKL-ZgYkQ7moEt2A,872
24
+ avrs/requests/dump_sim_config.py,sha256=ePtJZhq3gYLgMQkbi-YObIAaPk3Z2b0NWlWM5IYkCaM,479
25
+ avrs/requests/environment.py,sha256=McaPSE0v7dCKeH7knv3XTlDnEZcIR-lGUBpuAD49_FE,1848
26
+ avrs/requests/fault_injection.py,sha256=UWf_Jzqkd4CdkNpLbxwyuyLPkuIYNz4LDABM0myHv3A,5950
27
+ avrs/requests/get_object_config.py,sha256=Mkwp32lfskQERsqfmAgHi4vf4C0hfjg6Ru8UjyMt3cw,654
28
+ avrs/requests/get_web_viz_meta.py,sha256=Nai4blclKl4ppwiBQQF7K1ywkn5kkmuc9uv1vA8cBt8,467
29
+ avrs/requests/leaderboard.py,sha256=UlZ7NTCU0j0-ysGa_lfI7MxIgBbxiLQN2xCS7vbSjJM,2711
30
+ avrs/requests/list_sim_objects.py,sha256=YWpqHdCHijerPxI5606_KjeFvezcLFN33wO4YOr9G3U,977
31
+ avrs/requests/log_path.py,sha256=FwIx2xhuG3m6FJIqCSDUeqowVBZQKbb0kDkuwNKnaok,1317
32
+ avrs/requests/misc.py,sha256=TtP4D3DKU9AmSNQSqrNgZOatA-8NNJYFXla2ade7KqY,2630
33
+ avrs/requests/move_to_landmark.py,sha256=cLRBKu9XEDsmCoftBJ8JwoBLqzb0IZsxFMBnus4T-kc,702
34
+ avrs/requests/npc.py,sha256=Y_WovbcLomCCcOLAMMO_DHZtc1crAzWo97qEIGS3SvU,9691
35
+ avrs/requests/race_control.py,sha256=FUueCBfkcp8tUm0Nked9LE_X3AF8p34RTtbrfjskSMg,1626
36
+ avrs/requests/request.py,sha256=uUAndVZPbTQgbiXqrd4S3l3TQ0J_3STBtghEFlVr5GA,2058
37
+ avrs/requests/reset_to_track.py,sha256=qM--_3Lix7hqiK2rnoPJjHoJA47goSscGWICBQqIK3M,668
38
+ avrs/requests/rest_request.py,sha256=G4WzZw8OsF7ZnZeCcpRiADP9XK50e5VBaP6qpu9yXLs,1398
39
+ avrs/requests/restart.py,sha256=ih5mnWiU34q3-xhOth45CtOUXxKI0PoMDCnFJV0JbwE,415
40
+ avrs/requests/scenario_control.py,sha256=u-KQx-mdCm6IE_c88a6iEgWUsZZVOayxBo58Ocjg0ZI,1502
41
+ avrs/requests/spawn_object.py,sha256=RzTJprcyPpNIesu4s_GMuEYbHII-sopw1sDcbTDgvrY,1429
42
+ avrs/requests/teleport.py,sha256=LSlKFRlLwQLI1U15VXW0r1F7ylngHOAbw8SeXLJHXOw,1405
43
+ avrs/requests/toggle_hud.py,sha256=sV5t5QZc4uvRihPVk8jEKZiQNsyF9tsUwq5b4jjZplc,397
44
+ avrs/requests/vd.py,sha256=Rd0mCc89m2yKjftVf0cMHMFbJG4iFd09KzrI-DsCLgI,2606
45
+ avrs/requests/vehicle_input.py,sha256=R1b1xkRtOBkwyU6OSN4bWVlYsIUroZG0WKbYbc4pEH8,729
46
+ avrs/requests/vehicle_replay.py,sha256=7HPfVLjSLNbOyzU77Bz29qpHqRsMUAIWvnwvnNiw2nk,15026
47
+ autoverse_cli-0.28.1.dist-info/METADATA,sha256=iQ6Q3XwvtfMn7ikD-X2_v8noFLmSrJ4pfD_s-kdvUPU,3935
48
+ autoverse_cli-0.28.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
+ autoverse_cli-0.28.1.dist-info/entry_points.txt,sha256=Cb9qsUyU5AKkklehCcvtfT0-N3SXbUEqvjze4iEU5kE,40
50
+ autoverse_cli-0.28.1.dist-info/top_level.txt,sha256=-AJO2e4MCVej6hY0U84pu5NfMeMW5qaAPSMisDT5rmA,5
51
+ autoverse_cli-0.28.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ avrs = avrs.avrs:main
@@ -0,0 +1,33 @@
1
+ # End-User License Agreement (EULA) of the Autonoma AutoVerse CLI
2
+
3
+ This End-User License Agreement ("EULA") is a legal agreement between you and Autonoma, Inc.
4
+
5
+ ## License Grant
6
+
7
+ Autonoma, Inc. hereby grants you a personal, non-transferable, non-exclusive licence to use the AutoVerse software in accordance with the terms of this EULA agreement.
8
+
9
+ ## Limitation of Liability
10
+ The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, express or implied. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in action of contract, tort or otherwise, arising from, out of or in connection with the software or the use of the software.
11
+
12
+ ### You are NOT permitted to:
13
+
14
+ - Edit, alter, modify, adapt, translate or otherwise change the whole or any part of the Software nor permit the whole or any part of the Software to be combined with or become incorporated in any other software, nor decompile, disassemble or reverse engineer the Software or attempt to do any such things
15
+ - Reproduce, copy, distribute, resell or otherwise use the Software for any commercial purpose
16
+ - Allow any third party to use the Software on behalf of or for the benefit of any third party
17
+ - Use the Software in any way which breaches any applicable local, national or international law
18
+ use the Software for any purpose that Autonoma, Inc. considers is a breach of this EULA agreement
19
+ Intellectual Property and Ownership
20
+
21
+ Autonoma, Inc. shall at all times retain ownership of the Software as originally downloaded by you and all subsequent downloads of the Software by you. The Software (and the copyright, and other intellectual property rights of whatever nature in the Software, including any modifications made thereto) are and shall remain the property of Autonoma, Inc.
22
+
23
+ Autonoma, Inc. reserves the right to grant licences to use the Software to third parties.
24
+
25
+ ## Termination
26
+
27
+ This EULA agreement is effective from the date you first use the Software and shall continue until terminated. You may terminate it at any time upon written notice to Autonoma, Inc.
28
+
29
+ It will also terminate immediately if you fail to comply with any term of this EULA agreement. Upon such termination, the licenses granted by this EULA agreement will immediately terminate and you agree to stop all access and use of the Software. The provisions that by their nature continue and survive will survive any termination of this EULA agreement.
30
+
31
+ ## Governing Law
32
+
33
+ This EULA agreement, and any dispute arising out of or in connection with this EULA agreement, shall be governed by and construed in accordance with the laws of the USA.
@@ -0,0 +1 @@
1
+ avrs
avrs/__init__.py ADDED
File without changes
avrs/app_version.py ADDED
@@ -0,0 +1,24 @@
1
+ import http.client
2
+ import json
3
+
4
+ def get_app_version():
5
+ return '0.28.1'
6
+
7
+ def check_app_is_latest():
8
+ pass
9
+ # contact API to examine version
10
+
11
+ # This is slow, which will make the CLI annoying to use. This means
12
+ # we need an approach that can try to do this in the background and then
13
+ # caches somewhere so that the user is notified on the next run
14
+
15
+ # api_url = 'zn5boqqk60.execute-api.us-east-1.amazonaws.com'
16
+
17
+ # connection = http.client.HTTPSConnection(api_url)
18
+ # headers = {'Content-type': 'application/json'}
19
+ # body = json.dumps({'hello': 'hello'}).encode('utf-8')
20
+ # connection.request('POST', '/test', body, headers)
21
+ # response = connection.getresponse()
22
+ # if response.status != 200:
23
+ # print('response had status code {}'.format(response))
24
+ # print('{}'.format(response.read().decode('utf-8')))
avrs/argparse_help.py ADDED
@@ -0,0 +1,30 @@
1
+ import argparse
2
+
3
+ def generate_argparse_docs(parser):
4
+ """
5
+ Try to generate a nice markdown with all help from a parser
6
+ """
7
+ s = recursive_get_argparse_help(parser, 'avrs', True)
8
+ #print(s)
9
+
10
+ with open('out.txt', 'w', encoding='utf-8') as f:
11
+ f.write(s)
12
+
13
+ def recursive_get_argparse_help(parser, parent_name, is_root):
14
+
15
+ s = ''
16
+ if not is_root:
17
+ s += '\n' + '_' * 72 + '\n\n'
18
+
19
+ s += '{}\n'.format(parent_name)
20
+ s += '{}\n'.format(parser.format_help())
21
+
22
+ for action in parser._actions:
23
+ if isinstance(action, argparse._SubParsersAction):
24
+ #s += '{}\n'.format(dir(action))
25
+ #s += '{}\n'.format(action._choices_actions)
26
+ #for a in action._choices_actions:
27
+ # s += '{}\n'.format(a.dest)
28
+ for subcmd, subpsr in action.choices.items():
29
+ s += recursive_get_argparse_help(subpsr, parent_name + ' ' + subcmd, False)
30
+ return s
avrs/avrs.py ADDED
@@ -0,0 +1,183 @@
1
+ #!/usr/bin/env python3
2
+ import logging
3
+ import argparse
4
+ import os
5
+ import argcomplete
6
+
7
+ from argparse import RawDescriptionHelpFormatter
8
+ from argparse import RawTextHelpFormatter
9
+
10
+ from avrs.app_version import *
11
+ from avrs.cfg import *
12
+ from avrs.launcher import *
13
+ from avrs.can_tool import *
14
+ from avrs.race_cloud import *
15
+ from avrs.argparse_help import *
16
+ from avrs.shell_completion import install_completion, uninstall_completion
17
+
18
+ from avrs.requests.move_to_landmark import MoveToLandmarkRequest
19
+ from avrs.requests.restart import Restart
20
+ from avrs.requests.reset_to_track import ResetToTrack
21
+ from avrs.requests.teleport import Teleport
22
+ from avrs.requests.npc import Npc
23
+ from avrs.requests.vd import Vd
24
+ from avrs.requests.vehicle_input import AvrsConfigureVehicleInputRequest
25
+ from avrs.requests.log_path import LogPath
26
+ from avrs.requests.demo import AvrsDemoRequest
27
+ from avrs.requests.environment import *
28
+ from avrs.requests.code_booz import *
29
+ from avrs.requests.vehicle_replay import *
30
+ from avrs.requests.scenario_control import *
31
+ from avrs.requests.list_sim_objects import *
32
+ from avrs.requests.fault_injection import *
33
+ from avrs.requests.change_camera import *
34
+ from avrs.requests.toggle_hud import *
35
+ from avrs.requests.race_control import *
36
+ from avrs.simconfig import *
37
+ from avrs.requests.get_object_config import *
38
+ from avrs.requests.misc import *
39
+ from avrs.requests.spawn_object import *
40
+ from avrs.requests.dump_sim_config import *
41
+ from avrs.requests.get_web_viz_meta import *
42
+ from avrs.requests.leaderboard import AvrsLeaderboardRequest
43
+
44
+ def get_version():
45
+ return get_app_version()
46
+
47
+ def init_logging():
48
+ max_log_size = 1024 * 512
49
+ log_path = os.path.join(get_cfg_dir('avrs'), 'avrs.log')
50
+ verbose_log_path = os.path.join(get_cfg_dir('avrs'), 'avrs_verbose.log')
51
+
52
+ if os.path.exists(verbose_log_path) and os.path.getsize(verbose_log_path) > max_log_size:
53
+ os.remove(verbose_log_path)
54
+ if os.path.exists(log_path) and os.path.getsize(log_path) > max_log_size:
55
+ os.remove(log_path)
56
+
57
+ logging.basicConfig(filename=verbose_log_path,
58
+ filemode='a',
59
+ format='%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s',
60
+ datefmt='%H:%M:%S',
61
+ level=logging.DEBUG)
62
+
63
+ # When testing, prevent multiple handler additions to global logging objects
64
+ if 'avrs' in logging.Logger.manager.loggerDict:
65
+ #self.logger = logging.getLogger('alvs')
66
+ del logging.Logger.manager.loggerDict['avrs']
67
+ #return
68
+ logger = logging.getLogger('avrs')
69
+ file_handler = logging.FileHandler(log_path)
70
+ file_handler.setLevel(logging.DEBUG)
71
+ formatter = logging.Formatter('%(asctime)s | %(levelname)s | %(message)s')
72
+ file_handler.setFormatter(formatter)
73
+ console = logging.StreamHandler()
74
+ console.setLevel(logging.DEBUG)
75
+ console.setFormatter(formatter)
76
+ logger.addHandler(file_handler)
77
+ #logger.addHandler(console)
78
+
79
+ def main():
80
+
81
+ # logging will fail in pipeline
82
+ try:
83
+ init_logging()
84
+ except Exception as e:
85
+ pass
86
+
87
+ parser = argparse.ArgumentParser(
88
+ prog='avrs',
89
+ description='Autoverse CLI',
90
+ epilog='',
91
+ formatter_class=RawTextHelpFormatter)
92
+
93
+ version_psr = parser.add_argument(
94
+ '--version',
95
+ help='show the cli version',
96
+ action='version',
97
+ version=get_version())
98
+
99
+ parser.add_argument(
100
+ '--verbose',
101
+ action='store_true',
102
+ help='request verbose output')
103
+
104
+ parser.add_argument(
105
+ '--install-completion',
106
+ action='store_true',
107
+ help='install shell completion for avrs CLI')
108
+
109
+ parser.add_argument(
110
+ '--uninstall-completion',
111
+ action='store_true',
112
+ help='uninstall shell completion for avrs CLI')
113
+
114
+ sps = parser.add_subparsers(required=False, help='sub-command help')
115
+
116
+ cfg = load_cfg('avrs')
117
+ check_app_is_latest()
118
+
119
+ AvrsLauncher(sps, cfg)
120
+
121
+ MoveToLandmarkRequest(sps, cfg)
122
+ Restart(sps, cfg)
123
+ ResetToTrack(sps, cfg)
124
+ Teleport(sps, cfg)
125
+ #Npc(sps, cfg)
126
+ AvrsRaceCloud(sps, cfg)
127
+ Vd(sps, cfg)
128
+ AvrsConfigureVehicleInputRequest(sps, cfg)
129
+ LogPath(sps, cfg)
130
+ AvrsEnvironmentRequests(sps, cfg)
131
+ AvrsCodeBoozRequest(sps, cfg)
132
+ AvrsVehicleReplayRequests(sps, cfg)
133
+ AvrsCanTool(sps, cfg)
134
+ AvrsSimConfig(sps, cfg)
135
+ AvrsScenarioRequests(sps, cfg)
136
+ AvrsListSimObjectsRequest(sps, cfg)
137
+ AvrsLeaderboardRequest(sps, cfg)
138
+ AvrsFaultInjectionRequests(sps, cfg)
139
+ AvrsChangeCameraRequest(sps, cfg)
140
+ AvrsToggleHudRequest(sps, cfg)
141
+ AvrsGetObjectConfigRequest(sps, cfg)
142
+ AvrsGetSimVersionRequest(sps, cfg)
143
+ AvrsGetSessionIdRequest(sps, cfg)
144
+ AvrsGetExitSimRequest(sps, cfg)
145
+ AvrsPingRequest(sps, cfg)
146
+ AvrsConfigureSimLodRequest(sps, cfg)
147
+ AvrsSpawnObjectRequest(sps, cfg)
148
+ AvrsDumpSimConfigRequest(sps, cfg)
149
+ AvrsRaceControlRequest(sps, cfg)
150
+ AvrsSetEnvironmentRequest(sps, cfg)
151
+
152
+ # new api requests
153
+ AvrsDescribeSimRestRequest(sps, cfg)
154
+
155
+ if os.environ.get('AVRS_CLI_WITH_TESTS', '0') == '1':
156
+ AvrsGetWebVizMetaRequest(sps, cfg)
157
+
158
+ if os.environ.get('AVRS_WITH_DEMO', '0') == '1':
159
+ AvrsDemoRequest(sps, cfg)
160
+
161
+ if os.environ.get('AVRS_GEN_DOCS', '0') == '1':
162
+ generate_argparse_docs(parser)
163
+
164
+ argcomplete.autocomplete(parser)
165
+ args = parser.parse_args()
166
+
167
+ # Handle completion installation/uninstallation
168
+ if args.install_completion:
169
+ install_completion()
170
+ return
171
+
172
+ if args.uninstall_completion:
173
+ uninstall_completion()
174
+ return
175
+
176
+ # Handle subcommands
177
+ if hasattr(args, 'func'):
178
+ args.func(args)
179
+ else:
180
+ parser.print_help()
181
+
182
+ if __name__ == '__main__':
183
+ main()
avrs/can_tool.py ADDED
@@ -0,0 +1,192 @@
1
+ from avrs.requests.request import AvrsApiRequest
2
+ import can
3
+ import cantools
4
+ import time
5
+ import os
6
+ import datetime
7
+
8
+ from avrs.cfg import *
9
+ from avrs.can_tool_util import *
10
+
11
+ class AvrsCanTool():
12
+ def __init__(self, parent_parser, cfg):
13
+ self.cfg = cfg
14
+ can_tool_parser = parent_parser.add_parser(
15
+ 'can-tool',
16
+ help='provides CAN utilities (echo certain signals, etc)\n\n')
17
+ sps = can_tool_parser.add_subparsers(required=True, help='can-tool options')
18
+
19
+ add_dbc_parser = sps.add_parser(
20
+ 'add-dbc',
21
+ help='save a dbc file to be used with other commands')
22
+ add_dbc_parser.add_argument(
23
+ 'dbc_file_path',
24
+ help='the path to the dbc file to add')
25
+ add_dbc_parser.add_argument(
26
+ '--overwrite-ok',
27
+ action='store_true',
28
+ help='is it ok to overwrite an existing file')
29
+ add_dbc_parser.set_defaults(func=self.add_dbc)
30
+
31
+ list_dbc_parser = sps.add_parser(
32
+ 'list-dbc',
33
+ help='list the dbc files that are known to avrs')
34
+ list_dbc_parser.set_defaults(func=self.list_dbc)
35
+
36
+ echo_parser = sps.add_parser(
37
+ 'echo',
38
+ help='echos CAN messages')
39
+ echo_parser.add_argument(
40
+ 'can_names',
41
+ nargs='+',
42
+ help='the names of the CAN interfaces, eg "vcan0 vcan1" etc')
43
+ echo_parser.add_argument(
44
+ '--dbc_names',
45
+ nargs='+',
46
+ default='',
47
+ help='the names or indeces of a cached dbc files or path to existing dbc files to use')
48
+ echo_parser.add_argument(
49
+ '--isolate',
50
+ nargs='+',
51
+ default='',
52
+ help='a list of specific signal to echo, ignoring other signals')
53
+ echo_parser.add_argument(
54
+ '--duration',
55
+ type=float,
56
+ default=1.0,
57
+ help='the duration to echo can')
58
+ echo_parser.add_argument(
59
+ '--rates',
60
+ action='store_true',
61
+ help='echo the rates for messages instead of their values')
62
+ echo_parser.add_argument(
63
+ '--save-report-as',
64
+ default='',
65
+ help='if set along with the "--rates" flag, will save results to a json file')
66
+ echo_parser.set_defaults(func=self.echo)
67
+
68
+ eav_input_parser = sps.add_parser(
69
+ 'send-eav24-input',
70
+ help='send some simple input (throttle, brake, steer etc) to an eav24 over CAN')
71
+ eav_input_parser.add_argument(
72
+ 'can_name',
73
+ help='the name of the CAN interface, eg "vcan0"')
74
+ eav_input_parser.add_argument(
75
+ 'dbc_name',
76
+ help='the name or index of a cached dbc file or path to existing dbc file to use')
77
+ eav_input_parser.add_argument(
78
+ '--throttle',
79
+ type=float,
80
+ default=0.0,
81
+ help='throttle to send 0 -> 1.0')
82
+ eav_input_parser.add_argument(
83
+ '--gear',
84
+ type=int,
85
+ default=0,
86
+ help='gear to send')
87
+ eav_input_parser.add_argument(
88
+ '--brake',
89
+ type=float,
90
+ default=0.0,
91
+ help='brake to send 0 -> 1.0')
92
+ eav_input_parser.add_argument(
93
+ '--steer',
94
+ type=float,
95
+ default=0.0,
96
+ help='steer to send -24 -> 24')
97
+ eav_input_parser.add_argument(
98
+ '--duration',
99
+ type=float,
100
+ default=1.0,
101
+ help='the duration to send the command can')
102
+ eav_input_parser.set_defaults(func=self.eav_input)
103
+
104
+ test_latency_parser = sps.add_parser(
105
+ 'test-eav24-bsu-latency',
106
+ help='test the latency in the EAV24 BSU CAN interface by waiting for command ACK')
107
+ test_latency_parser.add_argument(
108
+ 'can_name',
109
+ help='the name of the CAN interface, eg "vcan0"')
110
+ test_latency_parser.add_argument(
111
+ 'dbc_name',
112
+ help='the name or index of a cached dbc file or path to existing dbc file to use')
113
+ test_latency_parser.add_argument(
114
+ '--nsamples',
115
+ type=int,
116
+ default=5,
117
+ help='the number of samples to test')
118
+ test_latency_parser.add_argument(
119
+ '--duration',
120
+ type=float,
121
+ default=1.0,
122
+ help='the duration to send each command can to wait for a given ack')
123
+ test_latency_parser.add_argument(
124
+ '--send-rate-hz',
125
+ type=float,
126
+ default=50,
127
+ help='the rate in hz to send messages to wait for a given ack')
128
+ test_latency_parser.add_argument(
129
+ '--save-report-as',
130
+ default='',
131
+ help='if set will save results to a json file with this name')
132
+
133
+ test_latency_parser.set_defaults(func=self.test_eav24_latency)
134
+
135
+
136
+ def add_dbc(self, args):
137
+ ok, status = add_cached_file(
138
+ 'avrs', 'dbc', args.dbc_file_path, args.overwrite_ok)
139
+ print(status)
140
+
141
+ def list_dbc(self, args):
142
+ files = get_cached_file_list('avrs', 'dbc')
143
+ s = ''
144
+ for i in range(len(files)):
145
+ s += '({}) {} \n'.format(i, files[i])
146
+ print(s) if len(files) > 0 else print('(empty)')
147
+
148
+ def echo(self, args):
149
+ dbcs = self.get_dbcs(args.dbc_names)
150
+ print('echoing {} using {} dbcs'.format(args.can_names, len(dbcs)))
151
+ if len(dbcs) > 0:
152
+ echo_can(args.can_names, dbcs, args.duration, args.isolate, args.rates, args.save_report_as)
153
+ else:
154
+ print('unable to echo can (dbc or can name error)')
155
+
156
+ def eav_input(self, args):
157
+ dbcs = self.get_dbcs([args.dbc_name])
158
+ if len(dbcs) > 0:
159
+ send_eav24_can_values(
160
+ args.can_name, dbcs[0], args.throttle, args.gear, args.brake, args.steer, args.duration)
161
+ else:
162
+ print('unable to echo can (dbc or can name error)')
163
+
164
+ def test_eav24_latency(self, args):
165
+ dbcs = self.get_dbcs([args.dbc_name])
166
+ if len(dbcs) > 0:
167
+ test_eav24_can_latency(
168
+ args.can_name, dbcs[0], args.nsamples, args.send_rate_hz, args.duration, args.save_report_as)
169
+ else:
170
+ print('unable to echo can (dbc or can name error)')
171
+
172
+ def get_dbcs(self, dbc_names):
173
+ dbcs = []
174
+ # If default, find all dbcs and return them
175
+ if dbc_names == '':
176
+ for d in get_cached_file_list('avrs', 'dbc'):
177
+ ok, cache_path = get_cached_file('avrs', 'dbc', d)
178
+ if ok:
179
+ dbcs.append(cantools.database.load_file(cache_path))
180
+ else:
181
+ print(cache_path)
182
+ else:
183
+ for d in dbc_names:
184
+ if os.path.isfile(d):
185
+ dbc = cantools.database.load_file(d)
186
+ else:
187
+ ok, cache_path = get_cached_file('avrs', 'dbc', d)
188
+ if ok:
189
+ dbcs.append(cantools.database.load_file(cache_path))
190
+ else:
191
+ print(cache_path)
192
+ return dbcs