TinkerYard commited on
Commit
e3cf691
·
verified ·
1 Parent(s): 110d8a8

Upload 13 files

Browse files
.gitignore ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer checkpoints
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
130
+
131
+ .idea
132
+ __pycache__
133
+ LinuxNoEditor
134
+ WindowsNoEditor
135
+
136
+ data
137
+ output
138
+ archive
139
+ misc/*.jpg
140
+ misc/*.png
141
+ misc/*.npy
142
+ misc/logs
143
+ misc/*.h5
144
+ *.h5
145
+ misc/logs/*
146
+ *.ipynb_checkpoints
147
+ misc/depth_nvidia_model_logs
148
+ credential.json
149
+
150
+ .DS_Store
.gitmodules ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [submodule "ROAR_Jetson"]
2
+ path = ROAR_Jetson
3
+ url = https://github.com/augcog/ROAR_Jetson.git
4
+ [submodule "ROAR_Sim"]
5
+ path = ROAR_Sim
6
+ url = https://github.com/augcog/ROAR_Sim.git
7
+ [submodule "ROAR_Gym"]
8
+ path = ROAR_Gym
9
+ url = https://github.com/augcog/ROAR_Gym.git
10
+ [submodule "ROAR_iOS"]
11
+ path = ROAR_iOS
12
+ url = https://github.com/wuxiaohua1011/ROAR-iOS
13
+ [submodule "ROAR_Junior_Racing"]
14
+ path = ROAR_Junior_Racing
15
+ url = https://github.com/augcog/ROAR-Junior-Racing.git
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
handshake.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ from ROAR.utilities_module.utilities import get_ip
3
+ import qrcode
4
+ import cv2
5
+ import numpy as np
6
+ import socket
7
+
8
+
9
+ def showIPUntilAckUDP():
10
+ img = np.array(qrcode.make(f"{get_ip()}").convert('RGB'))
11
+ success = False
12
+ addr = None
13
+
14
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
15
+ s.settimeout(0.1)
16
+
17
+ try:
18
+ s.bind((get_ip(), 8008))
19
+ while success is False:
20
+ try:
21
+ cv2.imshow("Scan this code to connect to phone", img)
22
+ k = cv2.waitKey(1) & 0xff
23
+ seg, addr = s.recvfrom(1024) # this command might timeout
24
+
25
+ if k == ord('q') or k == 27:
26
+ s.close()
27
+ break
28
+ addr = addr
29
+ success = True
30
+ for i in range(10):
31
+ print("data sent")
32
+ s.sendto(b"hi", addr)
33
+ except socket.timeout as e:
34
+ logging.info(f"Please tap on the ip address to scan QR code. ({get_ip()}:{8008}). {e}")
35
+ except Exception as e:
36
+ logging.error(f"Unable to bind socket: {e}")
37
+ finally:
38
+ s.close()
39
+ cv2.destroyWindow("Scan this code to connect to phone")
40
+ return success, addr[0]
41
+
42
+
43
+ logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s '
44
+ '- %(message)s',
45
+ datefmt="%H:%M:%S",
46
+ level=logging.DEBUG)
47
+ print(showIPUntilAckUDP())
handshake_client.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import socket
2
+ from ROAR.utilities_module.utilities import get_ip
3
+
4
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
5
+ s.connect((get_ip(), 8008))
6
+ s.send(b'data')
7
+ print("sent")
handshake_server.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ from ROAR.utilities_module.utilities import get_ip
3
+ import qrcode
4
+ import cv2
5
+ import numpy as np
6
+ import socket
7
+ from ROAR.utilities_module.utilities import get_ip
8
+
9
+ import socket
10
+
11
+
12
+ def showIPUntilAck():
13
+ img = np.array(qrcode.make(f"{get_ip()}").convert('RGB'))
14
+ success = False
15
+ addr = None
16
+
17
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
18
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
19
+
20
+ try:
21
+ s.bind((get_ip(), 8008))
22
+ s.settimeout(1)
23
+ while True:
24
+ try:
25
+ s.listen()
26
+
27
+ cv2.imshow("Scan this code to connect to phone", img)
28
+ k = cv2.waitKey(1) & 0xff
29
+ if k == ord('q') or k == 27:
30
+ s.close()
31
+ break
32
+ conn, addr = s.accept()
33
+ addr = addr[0]
34
+ if conn:
35
+ s.close()
36
+ success = True
37
+ break
38
+ except socket.timeout as e:
39
+ logging.info(f"Please tap on the ip address to scan QR code. ({get_ip()}:{8008}). {e}")
40
+ except Exception as e:
41
+ logging.error(f"Unable to bind socket: {e}")
42
+ finally:
43
+ s.close()
44
+ cv2.destroyWindow("Scan this code to connect to phone")
45
+ return success, addr
46
+
47
+
48
+ print(showIPUntilAck())
mkdocs.yml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ site_name: ROAR Documentation
2
+ site_description: Robot Open Autonomous Racing is a platform/competition dedicated to teaching students to gain a holistic view and hands-on(virtual) experiences about building a high-performance fully-autonomous 1/10 scale RC car from scratch.
3
+ nav:
4
+ - About:
5
+ - Introduction: introduction.md
6
+ - Architecture: architecture.md
7
+ - Coordinate: coordinate.md
8
+ - Quick Start: quickstart.md
9
+ - Code Documentations:
10
+ - Bridges:
11
+ - Bridge: code_documentations/Bridges/bridges.md
12
+ - Carla Bridge: code_documentations/Bridges/carla_bridge.md
13
+ - Jetson Bridge: code_documentations/Bridges/jetson_bridge.md
14
+ - ROAR:
15
+ - Agent Module: code_documentations/ROAR/agent_module.md
16
+ - Configurations: code_documentations/ROAR/config.md
17
+ - Control Module: code_documentations/ROAR/controller_module.md
18
+ - Perception Module: code_documentations/ROAR/perception_module.md
19
+ - Planning Module: code_documentations/ROAR/planning_module.md
20
+ - Utilities Module: code_documentations/ROAR/utilities_module.md
21
+ - Visualization Module: code_documentations/ROAR/visualization.md
22
+ - ROAR Simulation:
23
+ - Carla Client:
24
+ - Carla Runner: code_documentations/ROAR_Sim/carla_client.md
25
+ - Util:
26
+ - Camera Manager: code_documentations/ROAR_Sim/camera.md
27
+ - Hud: code_documentations/ROAR_Sim/hud.md
28
+ - Keyboard Controls: code_documentations/ROAR_Sim/kbc.md
29
+ - Sensors: code_documentations/ROAR_Sim/sensors.md
30
+ - Utilities: code_documentations/ROAR_Sim/util.md
31
+ - World: code_documentations/ROAR_Sim/world.md
32
+ - Configurations: code_documentations/ROAR_Sim/conf.md
33
+ - Runner Sim: code_documentations/runner_sim.md
34
+ - Competition Instruction: competition_instruction.md
35
+ - FAQ: faq.md
36
+
37
+
38
+ markdown_extensions:
39
+ - admonition
40
+ - codehilite:
41
+ guess_lang: false
42
+ - pymdownx.superfences
43
+ - pymdownx.tasklist
44
+ - pymdownx.emoji
45
+ - pymdownx.tabbed
46
+ - toc:
47
+ permalink: "¤"
48
+
49
+
50
+ theme:
51
+ name: material
52
+
53
+ plugins:
54
+ - search
55
+ - mkdocstrings:
56
+ handlers:
57
+ python:
58
+ rendering:
59
+ show_root_heading: no
60
+ show_category_heading: false
61
+ show_if_no_docstring: yes
62
+ show_source: true
63
+ show_root_toc_entry: false
64
+ show_object_full_path: no
65
+
readme.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Robot Open Autonomous Racing (ROAR)
2
+
3
+ ### To Contribute
4
+ - Please click the [Fork](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo) button on the upper right corner and submit a pull request to master branch.
5
+ - For a more in-depth tutorial on recommended setup [video](https://youtu.be/VA13dAZ9iAw)
6
+ - Please follow suggested guidelines on Pull Request.
7
+
8
+ ### Quick start
9
+ For quick start documentation, please visit our documentation site: [https://augcog.github.io/ROAR/quickstart/](https://augcog.github.io/ROAR/quickstart/)
10
+
11
+
12
+ ### Enter the Competition
13
+ Visit [https://augcog.github.io/ROAR/competition_instruction/](https://augcog.github.io/ROAR/competition_instruction/)
requirements.txt ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ addict==2.4.0
2
+ certifi==2021.10.8
3
+ charset-normalizer==2.0.7
4
+ cycler==0.11.0
5
+ fonttools==4.28.4
6
+ idna==3.3
7
+ joblib==1.1.0
8
+ kiwisolver==1.3.2
9
+ matplotlib==3.5.1
10
+ numpy==1.21.3
11
+ open3d==0.14.1
12
+ opencv-contrib-python==4.5.4.58
13
+ opencv-python==4.5.4.58
14
+ packaging==21.3
15
+ pandas==1.3.5
16
+ Pillow==8.4.0
17
+ pydantic==1.8.2
18
+ pygame==2.0.3
19
+ pyparsing==3.0.6
20
+ python-dateutil==2.8.2
21
+ pytz==2021.3
22
+ PyYAML==6.0
23
+ qrcode==7.3.1
24
+ requests==2.26.0
25
+ scikit-learn==1.0.1
26
+ scipy==1.7.1
27
+ simple-websocket-server==0.4.1
28
+ six==1.16.0
29
+ threadpoolctl==3.0.0
30
+ tqdm==4.62.3
31
+ typing-extensions==3.10.0.2
32
+ urllib3==1.26.7
33
+ websocket-client==1.2.1
runner_competition_evaluator.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging, warnings
2
+ import numpy as np
3
+ from ROAR_Sim.configurations.configuration import Configuration as CarlaConfig
4
+ from ROAR.configurations.configuration import Configuration as AgentConfig
5
+ from pathlib import Path
6
+ from ROAR.agent_module.pure_pursuit_agent \
7
+ import PurePursuitAgent
8
+ from ROAR_Sim.carla_client.carla_runner import CarlaRunner
9
+ from typing import Tuple
10
+ from prettytable import PrettyTable
11
+ from ROAR.agent_module.michael_pid_agent import PIDAgent
12
+
13
+
14
+ def compute_score(carla_runner: CarlaRunner) -> Tuple[float, int, int]:
15
+ """
16
+ Calculates the score of the vehicle upon completion of the track based on certain metrics
17
+ Args:
18
+ carla_runner ():
19
+
20
+ Returns:
21
+ time_elapsed:
22
+ num_collision: number of collisions during simulation
23
+ laps_completed: Number of laps completed
24
+
25
+ """
26
+ time_elapsed: float = carla_runner.end_simulation_time - carla_runner.start_simulation_time
27
+ num_collision: int = carla_runner.agent_collision_counter
28
+ laps_completed = 0 if carla_runner.completed_lap_count < 0 else carla_runner.completed_lap_count
29
+
30
+ return time_elapsed, num_collision, laps_completed
31
+
32
+
33
+ def run(agent_class, agent_config_file_path: Path, carla_config_file_path: Path,
34
+ num_laps: int = 10) -> Tuple[float, int, int]:
35
+ """
36
+ Run the agent along the track and produce a score based on certain metrics
37
+ Args:
38
+ num_laps: int number of laps that the agent should run
39
+ agent_class: the participant's agent
40
+ agent_config_file_path: agent configuration path
41
+ carla_config_file_path: carla configuration path
42
+ Returns:
43
+ float between 0 - 1 representing scores
44
+ """
45
+
46
+ agent_config: AgentConfig = AgentConfig.parse_file(agent_config_file_path)
47
+ carla_config = CarlaConfig.parse_file(carla_config_file_path)
48
+
49
+ # hard code agent config such that it reflect competition requirements
50
+ agent_config.num_laps = num_laps
51
+ carla_runner = CarlaRunner(carla_settings=carla_config,
52
+ agent_settings=agent_config,
53
+ npc_agent_class=PurePursuitAgent,
54
+ competition_mode=True,
55
+ lap_count=num_laps)
56
+ try:
57
+ my_vehicle = carla_runner.set_carla_world()
58
+ agent = agent_class(vehicle=my_vehicle, agent_settings=agent_config)
59
+ carla_runner.start_game_loop(agent=agent, use_manual_control=False)
60
+ return compute_score(carla_runner)
61
+ except Exception as e:
62
+ print(f"something bad happened during initialization: {e}")
63
+ carla_runner.on_finish()
64
+ logging.error(f"{e}. Might be a good idea to restart Server")
65
+ return 0, 0, False
66
+
67
+
68
+ def suppress_warnings():
69
+ logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s '
70
+ '- %(message)s',
71
+ level=logging.INFO)
72
+ logging.getLogger("matplotlib").setLevel(logging.WARNING)
73
+ warnings.simplefilter("ignore")
74
+ np.set_printoptions(suppress=True)
75
+
76
+
77
+ def main():
78
+ suppress_warnings()
79
+ agent_class = PIDAgent
80
+ num_trials = 10
81
+ total_score_array = []
82
+ num_laps = 1
83
+ table = PrettyTable()
84
+ table.field_names = ["time_elapsed (sec)", "num_collisions", "laps completed"]
85
+
86
+ for i in range(num_trials):
87
+ print(f"runner_competition_evaluator -> Trial: {i}")
88
+ scores = run(agent_class=agent_class,
89
+ agent_config_file_path=Path("./ROAR/configurations/carla/carla_agent_configuration.json"),
90
+ carla_config_file_path=Path("./ROAR_Sim/configurations/configuration.json"),
91
+ num_laps=num_laps)
92
+ total_score_array.append(scores[0])
93
+ table.add_row(scores)
94
+ table.add_row((f"AVG for {num_trials} trials = {np.average(total_score_array)}", "N/A", "N/A"))
95
+ print(table)
96
+
97
+
98
+ if __name__ == "__main__":
99
+ main()
runner_ios.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ from pathlib import Path
3
+ from ROAR_iOS.ios_runner import iOSRunner
4
+ from ROAR.configurations.configuration import Configuration as AgentConfig
5
+ from ROAR_iOS.config_model import iOSConfig
6
+ from ROAR_Unity.unity_runner import iOSUnityRunner
7
+ from ROAR.agent_module.forward_only_agent import ForwardOnlyAgent
8
+ from ROAR.agent_module.special_agents.recording_agent import RecordingAgent
9
+ from ROAR.utilities_module.vehicle_models import Vehicle
10
+ import logging
11
+ import argparse
12
+ from misc.utils import str2bool
13
+ from ROAR.utilities_module.utilities import get_ip
14
+ import qrcode
15
+ import cv2
16
+ import numpy as np
17
+ import socket
18
+ import json
19
+ import requests
20
+
21
+
22
+ class mode_list(list):
23
+ # list subclass that uses lower() when testing for 'in'
24
+ def __contains__(self, other):
25
+ return super(mode_list, self).__contains__(other.lower())
26
+
27
+
28
+ def showIPUntilAckUDP():
29
+ port = 8890
30
+ img = np.array(qrcode.make(f"{get_ip(),port}").convert('RGB'))
31
+ success = False
32
+ addr = None
33
+
34
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
35
+ s.settimeout(0.1)
36
+
37
+ try:
38
+ s.bind((get_ip(), port))
39
+ while success is False:
40
+ try:
41
+ cv2.imshow("Scan this code to connect to phone", img)
42
+ k = cv2.waitKey(1) & 0xff
43
+ seg, addr = s.recvfrom(1024) # this command might timeout
44
+
45
+ if k == ord('q') or k == 27:
46
+ s.close()
47
+ break
48
+ addr = addr
49
+ success = True
50
+ for i in range(10):
51
+ s.sendto(b"hi", addr)
52
+ except socket.timeout as e:
53
+ logging.info(f"Please tap on the ip address to scan QR code. ({get_ip()}:{8008}). {e}")
54
+ except Exception as e:
55
+ logging.error(f"Unable to bind socket: {e}")
56
+ finally:
57
+ s.close()
58
+ cv2.destroyWindow("Scan this code to connect to phone")
59
+ return success, addr[0]
60
+
61
+
62
+ def showIPUntilAck():
63
+ port = 40001
64
+ img = np.array(qrcode.make(f"{get_ip()},{port}").convert('RGB'))
65
+ success = False
66
+ addr = None
67
+
68
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
69
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
70
+
71
+ try:
72
+ s.bind((get_ip(), port))
73
+ s.settimeout(1)
74
+ while True:
75
+ try:
76
+ s.listen()
77
+
78
+ cv2.imshow("Scan this code to connect to phone", img)
79
+ k = cv2.waitKey(1) & 0xff
80
+ if k == ord('q') or k == 27:
81
+ s.close()
82
+ break
83
+ conn, addr = s.accept()
84
+ addr = addr[0]
85
+ if conn:
86
+ s.close()
87
+ success = True
88
+ break
89
+ except socket.timeout as e:
90
+ logging.info(f"Please tap on the ip address to scan QR code. ({get_ip()}:{8008}). {e}")
91
+ except Exception as e:
92
+ logging.error(f"Unable to bind socket: {e}")
93
+ finally:
94
+ s.close()
95
+ cv2.destroyWindow("Scan this code to connect to phone")
96
+ return success, addr
97
+
98
+
99
+ def is_glove_online(host, port):
100
+ r = requests.get(url=f"http://{host}:{port}", timeout=1)
101
+ if r.status_code == 200:
102
+ return True
103
+ return False
104
+
105
+
106
+ if __name__ == '__main__':
107
+ choices = mode_list(['ar', 'vr'])
108
+ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
109
+ datefmt="%H:%M:%S", level=logging.DEBUG)
110
+ logging.getLogger("matplotlib").setLevel(logging.WARNING)
111
+ logging.getLogger("urllib3").setLevel(logging.WARNING)
112
+
113
+ parser = argparse.ArgumentParser()
114
+ parser.add_argument("-auto", action='store_true', help="Enable auto control")
115
+ parser.add_argument("-m", "--mode", choices=choices, help="AR or VR [WARNING not implemented yet!]", default="vr")
116
+ parser.add_argument("-r", "--reconnect", action='store_true', help="Scan QR code to attach phone to PC")
117
+ parser.add_argument("-u", "--use_unity", action='store_true',
118
+ help="Use unity as rendering and control service")
119
+ parser.add_argument("-g", "--use_glove", help="use glove based controller by supplying its ip address!")
120
+ args = parser.parse_args()
121
+
122
+ try:
123
+ agent_config_file_path = Path("ROAR/configurations/iOS/iOS_agent_configuration.json")
124
+ ios_config_file_path = Path("ROAR_iOS/configurations/ios_config.json")
125
+ agent_config = AgentConfig.parse_file(agent_config_file_path)
126
+ ios_config: iOSConfig = iOSConfig.parse_file(ios_config_file_path)
127
+ ios_config.ar_mode = True if args.mode == "ar" else False
128
+ if args.use_glove:
129
+ try:
130
+ is_glove_online(args.use_glove, port=81)
131
+ ios_config.glove_ip_addr = args.use_glove
132
+ ios_config.should_use_glove = True
133
+ except requests.exceptions.ConnectTimeout as e:
134
+ print(f"ERROR. Cannot find Glove at that ip address {args.use_glove}. Shutting down...")
135
+ exit(0)
136
+ else:
137
+ ios_config.should_use_glove = False
138
+
139
+ success = False
140
+ if args.reconnect:
141
+ success, addr = showIPUntilAck()
142
+ if success:
143
+ ios_config.ios_ip_addr = addr
144
+ json.dump(ios_config.dict(), ios_config_file_path.open('w'), indent=4)
145
+ time.sleep(2)
146
+ if success or args.reconnect is False:
147
+ agent = ForwardOnlyAgent(vehicle=Vehicle(), agent_settings=agent_config, should_init_default_cam=True)
148
+ runner = iOSUnityRunner(agent=agent, ios_config=ios_config, is_unity=args.use_unity)
149
+ runner.start_game_loop(auto_pilot=args.auto)
150
+ except Exception as e:
151
+ print(f"Something bad happened: {e}")
runner_jetson.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ROAR_Jetson.jetson_runner import JetsonRunner
2
+ from ROAR.utilities_module.vehicle_models import Vehicle
3
+ from ROAR_Jetson.configurations.configuration import Configuration as JetsonConfig
4
+ from ROAR.configurations.configuration import Configuration as AgentConfig
5
+ # from ROAR.agent_module.floodfill_based_lane_follower import FloodfillBasedLaneFollower
6
+ # from ROAR.agent_module.michael_pid_agent import PIDAgent
7
+ # from ROAR.agent_module.jetson_pure_pursuit_agent import PurePursuitAgent
8
+ # from ROAR.agent_module.special_agents.waypoint_generating_agent import WaypointGeneratigAgent
9
+ # from ROAR.agent_module.forward_only_agent import ForwardOnlyAgent
10
+ # from ROAR.agent_module.lane_detection_agent import LaneDetectionAgent
11
+ from ROAR.agent_module.occupancy_map_agent import OccupancyMapAgent
12
+ # from ROAR.agent_module.special_agents.recording_agent import RecordingAgent
13
+ from ROAR.agent_module.michael_pid_agent import PIDAgent
14
+ from pathlib import Path
15
+ import logging
16
+ import warnings
17
+ import numpy as np
18
+ import os
19
+ import json
20
+ import sys
21
+ import serial
22
+ import argparse
23
+
24
+
25
+ def main(auto=False):
26
+ try:
27
+ agent_config = AgentConfig.parse_file(Path("./ROAR_Jetson/configurations/agent_configuration.json"))
28
+ jetson_config = JetsonConfig.parse_file(Path("./ROAR_Jetson/configurations/configuration.json"))
29
+
30
+ try:
31
+ prepare(jetson_config=jetson_config)
32
+ except Exception as e:
33
+ logging.error(f"Ignoring Error during setup: {e}")
34
+ agent = OccupancyMapAgent(vehicle=Vehicle(), agent_settings=agent_config, should_init_default_cam=False)
35
+ jetson_runner = JetsonRunner(agent=agent, jetson_config=jetson_config)
36
+ jetson_runner.start_game_loop(use_manual_control=not auto)
37
+ except Exception as e:
38
+ print(f"Something bad happened {e}")
39
+
40
+
41
+ def prepare(jetson_config: JetsonConfig):
42
+ if 'win' in sys.platform:
43
+ # windows, just detect whether arduino exist on COM4
44
+ s = serial.Serial(jetson_config.win_serial_port)
45
+ status = s.isOpen()
46
+ else:
47
+ # assume that this is going to be a unix based system
48
+ status = allow_dev_access(read_password(Path(jetson_config.jetson_sudo_password_file_path)))
49
+ assert status is True, "Port not successfully opened"
50
+
51
+
52
+ def read_password(jetson_sudo_setup_f_path: Path):
53
+ d = json.load(fp=jetson_sudo_setup_f_path.open("r"))
54
+ return d["sudo_password"]
55
+
56
+
57
+ def allow_dev_access(pwd):
58
+ command = 'chmod 777 /dev/ttyACM0'
59
+ p = os.system(f'echo {pwd}|sudo -S {command}')
60
+ return True if p == 0 else False
61
+
62
+
63
+ def str2bool(v):
64
+ if isinstance(v, bool):
65
+ return v
66
+ if v.lower() in ('yes', 'true', 't', 'y', '1'):
67
+ return True
68
+ elif v.lower() in ('no', 'false', 'f', 'n', '0'):
69
+ return False
70
+ else:
71
+ raise argparse.ArgumentTypeError('Boolean value expected.')
72
+
73
+
74
+ if __name__ == "__main__":
75
+ parser = argparse.ArgumentParser()
76
+ parser.add_argument("--debug", default=False, help="debug flag", type=str2bool)
77
+ parser.add_argument("--auto", default=False, help="enable or disable auto drive", type=str2bool)
78
+ args = parser.parse_args()
79
+ logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
80
+ datefmt="%H:%M:%S", level=logging.DEBUG if args.debug is True else logging.INFO)
81
+ logging.getLogger("Vive Tracker Client [tracker_1]").setLevel(logging.WARNING)
82
+ logging.getLogger("matplotlib").setLevel(logging.WARNING)
83
+ warnings.simplefilter("ignore")
84
+ np.set_printoptions(suppress=True)
85
+ main(args.auto)
runner_sim.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ from pathlib import Path
3
+ from ROAR_Sim.configurations.configuration import Configuration as CarlaConfig
4
+ from ROAR_Sim.carla_client.carla_runner import CarlaRunner
5
+ from ROAR.agent_module.pure_pursuit_agent import PurePursuitAgent
6
+ from ROAR.configurations.configuration import Configuration as AgentConfig
7
+ import argparse
8
+ from misc.utils import str2bool
9
+ from ROAR.agent_module.michael_pid_agent import PIDAgent
10
+ from ROAR.agent_module.forward_only_agent import ForwardOnlyAgent
11
+
12
+
13
+ def main(args):
14
+ """Starts game loop"""
15
+ agent_config = AgentConfig.parse_file(Path("./ROAR/configurations/carla/carla_agent_configuration.json"))
16
+ carla_config = CarlaConfig.parse_file(Path("./ROAR_Sim/configurations/configuration.json"))
17
+
18
+ carla_runner = CarlaRunner(carla_settings=carla_config,
19
+ agent_settings=agent_config,
20
+ npc_agent_class=PurePursuitAgent)
21
+ try:
22
+ my_vehicle = carla_runner.set_carla_world()
23
+ agent = ForwardOnlyAgent(vehicle=my_vehicle,
24
+ agent_settings=agent_config)
25
+ carla_runner.start_game_loop(agent=agent,
26
+ use_manual_control=not args.auto)
27
+
28
+ except Exception as e:
29
+ logging.error(f"Something bad happened during initialization: {e}")
30
+ carla_runner.on_finish()
31
+ logging.error(f"{e}. Might be a good idea to restart Server")
32
+
33
+
34
+ if __name__ == "__main__":
35
+ logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s '
36
+ '- %(message)s',
37
+ datefmt="%H:%M:%S",
38
+ level=logging.DEBUG)
39
+ logging.getLogger(" streaming client").setLevel(logging.WARNING)
40
+ import warnings
41
+
42
+ warnings.filterwarnings("ignore", module="carla")
43
+ parser = argparse.ArgumentParser()
44
+ parser.add_argument("--auto", type=str2bool, default=False, help="True to use auto control")
45
+
46
+ warnings.filterwarnings("ignore", module="carla")
47
+ args = parser.parse_args()
48
+ main(args)