autoverse-cli 0.14.1__py3-none-any.whl → 0.15.0__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.14.1.dist-info → autoverse_cli-0.15.0.dist-info}/METADATA +1 -1
- {autoverse_cli-0.14.1.dist-info → autoverse_cli-0.15.0.dist-info}/RECORD +10 -10
- avrs/app_version.py +1 -1
- avrs/race_cloud.py +74 -4
- avrs/race_cloud_cfg_util.py +27 -2
- avrs/race_cloud_util.py +21 -1
- {autoverse_cli-0.14.1.dist-info → autoverse_cli-0.15.0.dist-info}/LICENSE +0 -0
- {autoverse_cli-0.14.1.dist-info → autoverse_cli-0.15.0.dist-info}/WHEEL +0 -0
- {autoverse_cli-0.14.1.dist-info → autoverse_cli-0.15.0.dist-info}/entry_points.txt +0 -0
- {autoverse_cli-0.14.1.dist-info → autoverse_cli-0.15.0.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
avrs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
avrs/app_version.py,sha256=
|
2
|
+
avrs/app_version.py,sha256=59Na2yuqMGePrUbQYBadd_1kANo4tl9ULmjNC8g2WQg,856
|
3
3
|
avrs/argparse_help.py,sha256=EoEaohGXZXqJvs1dFEzbo9vh47CYdHdSY2Im2Ps2iFo,945
|
4
4
|
avrs/avrs.py,sha256=bGF35a72MZU41OVWnFHmchqmgKXBKh9djokzGA_4pL4,4621
|
5
5
|
avrs/can_tool.py,sha256=IBoctKobBJ3wCq4ZdtuXuXH4AMEUxazCfYT6YP0Luw8,7161
|
@@ -7,10 +7,10 @@ avrs/can_tool_util.py,sha256=G3q21dTGMLc09SDq_RieoW7kSn-kXPkXxPDjavPh4hQ,7710
|
|
7
7
|
avrs/cfg.py,sha256=kMn08Z4Ms1PAu2-U1QI8weEJeIVEppP4A4_tFfwnjtg,2924
|
8
8
|
avrs/launcher.py,sha256=kk1lyHHLgFZ4zsFfa_zV5f1kYbUODT6wEILJ8TZ16rQ,9353
|
9
9
|
avrs/launcher_util.py,sha256=sO3k_z3A-HIQdJVkVXNXUAE_MGFwAYiZUqQBoFwOqew,5325
|
10
|
-
avrs/race_cloud.py,sha256=
|
11
|
-
avrs/race_cloud_cfg_util.py,sha256=
|
10
|
+
avrs/race_cloud.py,sha256=XwwSfrSMaCxOaBSmxqDeC7Jlg5mRZnVBUo7cFFaKcso,18863
|
11
|
+
avrs/race_cloud_cfg_util.py,sha256=IV_bKylgfAj5g8aRf817pP-0x55A_jIX-rZYgRJlzxQ,6059
|
12
12
|
avrs/race_cloud_fwd_api.py,sha256=HuLE5kfmzVq08aP3tlEh3f8WNjGL5N3K5EbXg9uQomo,1506
|
13
|
-
avrs/race_cloud_util.py,sha256=
|
13
|
+
avrs/race_cloud_util.py,sha256=ykTFSk9AVDEFAAS7wXBz-By4RnEp_kJKRvvACruv8Sk,10709
|
14
14
|
avrs/simconfig.py,sha256=UZc4FrxVHUkk2e9IglSpuojXkaL_nPrJW7trbEGgOOo,2907
|
15
15
|
avrs/simconfig_util.py,sha256=1RmnmhK5C4HlCicTQeqn-1ORz3Xrku_QMt1Fqr9XjZs,4839
|
16
16
|
avrs/tests.py,sha256=3JeYBjn0tRqHXERDROfzmYuW1KXeCcKur5Bw-EIegto,153
|
@@ -37,9 +37,9 @@ avrs/requests/toggle_hud.py,sha256=sV5t5QZc4uvRihPVk8jEKZiQNsyF9tsUwq5b4jjZplc,3
|
|
37
37
|
avrs/requests/vd.py,sha256=gdt5XCdCCVdECL3qt8y-PKDrlArjeY_lxtT4VpZmAJo,1804
|
38
38
|
avrs/requests/vehicle_input.py,sha256=R1b1xkRtOBkwyU6OSN4bWVlYsIUroZG0WKbYbc4pEH8,729
|
39
39
|
avrs/requests/vehicle_replay.py,sha256=nCAE21VNyKoeIjjXBGAihgOLO7zYHcu-HWvPZYxdQ2c,11099
|
40
|
-
autoverse_cli-0.
|
41
|
-
autoverse_cli-0.
|
42
|
-
autoverse_cli-0.
|
43
|
-
autoverse_cli-0.
|
44
|
-
autoverse_cli-0.
|
45
|
-
autoverse_cli-0.
|
40
|
+
autoverse_cli-0.15.0.dist-info/LICENSE,sha256=d4eWXho-u18HkBsX4K21uHX_bBb2UXZSrJdsb7Z_JlM,2647
|
41
|
+
autoverse_cli-0.15.0.dist-info/METADATA,sha256=eD4w4cQQ9WKA4CkW-_17sgEQkzK8ibJeOdaPZ4Q5Avk,3342
|
42
|
+
autoverse_cli-0.15.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
43
|
+
autoverse_cli-0.15.0.dist-info/entry_points.txt,sha256=Cb9qsUyU5AKkklehCcvtfT0-N3SXbUEqvjze4iEU5kE,40
|
44
|
+
autoverse_cli-0.15.0.dist-info/top_level.txt,sha256=-AJO2e4MCVej6hY0U84pu5NfMeMW5qaAPSMisDT5rmA,5
|
45
|
+
autoverse_cli-0.15.0.dist-info/RECORD,,
|
avrs/app_version.py
CHANGED
avrs/race_cloud.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import subprocess
|
2
2
|
import base64
|
3
3
|
import logging
|
4
|
+
import time
|
4
5
|
from avrs.cfg import *
|
5
6
|
from avrs.race_cloud_util import *
|
6
7
|
from avrs.race_cloud_cfg_util import *
|
@@ -36,6 +37,10 @@ class AvrsRaceCloud(AvrsApiRequest):
|
|
36
37
|
'--instance-id',
|
37
38
|
default = '',
|
38
39
|
help='can be used directly instead of instance name if needed')
|
40
|
+
connect_parser.add_argument(
|
41
|
+
'--no-restart-sim',
|
42
|
+
action='store_true',
|
43
|
+
help='if set, the sim instance will not be restarted after connection')
|
39
44
|
connect_parser.add_argument(
|
40
45
|
'--no-check-cans',
|
41
46
|
action='store_true',
|
@@ -55,6 +60,10 @@ class AvrsRaceCloud(AvrsApiRequest):
|
|
55
60
|
rx_connect_parser.add_argument(
|
56
61
|
'ip',
|
57
62
|
help='the ip address of the incoming connection')
|
63
|
+
rx_connect_parser.add_argument(
|
64
|
+
'--restart',
|
65
|
+
action='store_true',
|
66
|
+
help='should the sim program be restarted after this connection')
|
58
67
|
rx_connect_parser.add_argument(
|
59
68
|
'cfg_data',
|
60
69
|
help='the incoming vehicle configuration data')
|
@@ -150,10 +159,23 @@ class AvrsRaceCloud(AvrsApiRequest):
|
|
150
159
|
|
151
160
|
def race_connect(self, args):
|
152
161
|
logger = logging.getLogger('avrs')
|
162
|
+
|
163
|
+
# make api call to begin connection
|
164
|
+
our_ip = get_local_instance_ip()
|
165
|
+
|
166
|
+
if our_ip == '127.0.0.1':
|
167
|
+
print('this machines IP was returned as localhost. was this run on the cloud instance?')
|
168
|
+
return
|
169
|
+
|
153
170
|
logger.info('starting race-cloud connect for team {} to instance {}'.format(
|
154
171
|
args.team_name, args.sim_index))
|
155
172
|
print('connecting to race with team name: {}'.format(args.team_name))
|
156
173
|
|
174
|
+
if args.no_restart_sim:
|
175
|
+
print('the simulator will NOT be restarted automatically after this connection')
|
176
|
+
else:
|
177
|
+
print('the simulator WILL be restarted automatically after this connection')
|
178
|
+
|
157
179
|
# reset local connection first
|
158
180
|
logger.info('resetting local connection state prior to connection')
|
159
181
|
reset_race_cloud_connection()
|
@@ -179,9 +201,6 @@ class AvrsRaceCloud(AvrsApiRequest):
|
|
179
201
|
if not vcan_ok:
|
180
202
|
return
|
181
203
|
|
182
|
-
# make api call to begin connection
|
183
|
-
our_ip = get_local_instance_ip()
|
184
|
-
|
185
204
|
connection_request = {
|
186
205
|
'action': 'connect',
|
187
206
|
'sim_index': args.sim_index,
|
@@ -189,6 +208,7 @@ class AvrsRaceCloud(AvrsApiRequest):
|
|
189
208
|
'team_name': args.team_name,
|
190
209
|
'sim_id_override': args.instance_id,
|
191
210
|
'ensure_instance_is_running': False,
|
211
|
+
'should_restart_sim_program': args.no_restart_sim,
|
192
212
|
'config_data': vcfg_data
|
193
213
|
}
|
194
214
|
|
@@ -215,11 +235,19 @@ class AvrsRaceCloud(AvrsApiRequest):
|
|
215
235
|
print('issue reserving slot: {}'.format(slot_info['msg']))
|
216
236
|
return
|
217
237
|
|
238
|
+
extra_msg = slot_info.get('extra_msg', '')
|
239
|
+
print(extra_msg)
|
240
|
+
|
218
241
|
sim_slot = slot_info['slot']
|
219
242
|
|
220
243
|
# enable first peer since this is on a client (only will ever have 1, the sim)
|
221
244
|
enable_peer_qos(sim_slot, sim_ip)
|
222
245
|
|
246
|
+
print('creating vcan interfaces found in config locally: {}, {}, {} (if they do not exist)'.format(
|
247
|
+
bsu_vcan, kistler_vcan, badenia_vcan))
|
248
|
+
|
249
|
+
setup_vcans(bsu_vcan, kistler_vcan, badenia_vcan)
|
250
|
+
|
223
251
|
# will need to get port from received slot id to connect peer vcans
|
224
252
|
connect_peer_vcan(sim_slot, sim_ip, 0, bsu_vcan)
|
225
253
|
connect_peer_vcan(sim_slot, sim_ip, 1, kistler_vcan)
|
@@ -242,7 +270,24 @@ class AvrsRaceCloud(AvrsApiRequest):
|
|
242
270
|
# this should only run on sim instances (not dev instances)
|
243
271
|
def rx_connect(self, args):
|
244
272
|
logger = logging.getLogger('avrs')
|
245
|
-
|
273
|
+
|
274
|
+
extra_msg = ''
|
275
|
+
|
276
|
+
# check time-since last connection here. if > 10mins auto reset connection state
|
277
|
+
time_since_last_connection = self.get_and_update_time_since_last_connection()
|
278
|
+
reset_connection_timeout = 600.0
|
279
|
+
if time_since_last_connection > 600.0:
|
280
|
+
logger.info('time since last connection rx {} > {}. resetting connection'.format(
|
281
|
+
time_since_last_connection, reset_connection_timeout))
|
282
|
+
clear_autospawns()
|
283
|
+
reset_race_cloud_connection()
|
284
|
+
extra_msg += 'automatically resetting simulation instance connection state'
|
285
|
+
extra_msg += ' (last connection was > {} seconds ago)'.format(reset_connection_timeout)
|
286
|
+
else:
|
287
|
+
extra_msg += 'NOT resetting connection state. last connection was only {} seconds ago'.format(
|
288
|
+
time_since_last_connection)
|
289
|
+
|
290
|
+
logger.info('rx race cloud connection for team {} with ip {}'.format(args.team_name, args.ip))
|
246
291
|
ok, msg, slot = try_get_open_slot(args.team_name, args.ip)
|
247
292
|
|
248
293
|
bsu_vcan = get_auto_vcan_name(slot, 0)
|
@@ -294,6 +339,15 @@ class AvrsRaceCloud(AvrsApiRequest):
|
|
294
339
|
start_result = start_fwd_api(30333, 30313)
|
295
340
|
logger.info('started fwd-api: {}'.format(start_result))
|
296
341
|
|
342
|
+
if args.should_restart_sim_program:
|
343
|
+
logger.info('restarting sim program for new connection')
|
344
|
+
print('stopping sim program on sim instance')
|
345
|
+
bash_kill_process('Autoverse')
|
346
|
+
print('starting sim program on sim instance')
|
347
|
+
exe_path = os.path.join(get_sim_exe_path())
|
348
|
+
start_exe(exe_path)
|
349
|
+
extra_msg += '\n' if len(extra_msg) > 0 else ''
|
350
|
+
extra_msg += 'automatically restarting sim program on sim instance'
|
297
351
|
|
298
352
|
print(json.dumps(response)) # print this so that when called from the ssh lambda we can get the result
|
299
353
|
|
@@ -401,3 +455,19 @@ class AvrsRaceCloud(AvrsApiRequest):
|
|
401
455
|
handler = ApiForwardHandler(args.target_port)
|
402
456
|
server = HTTPServer(('0.0.0.0', args.source_port), handler)
|
403
457
|
server.serve_forever()
|
458
|
+
|
459
|
+
def test_reset_timeout(self, args):
|
460
|
+
print('testing reset timeout')
|
461
|
+
|
462
|
+
elapsed = self.get_and_update_time_since_last_connection()
|
463
|
+
print('elasped: {}'.format(elapsed))
|
464
|
+
|
465
|
+
def get_and_update_time_since_last_connection(self):
|
466
|
+
t = time.time()
|
467
|
+
# default to zero if not exist to force timeout
|
468
|
+
last_time = self.cfg.get('race-cloud-last-connect-time', 0)
|
469
|
+
elapsed = t - last_time
|
470
|
+
self.cfg['race-cloud-last-connect-time'] = t
|
471
|
+
save_cfg('avrs', self.cfg)
|
472
|
+
return elapsed
|
473
|
+
|
avrs/race_cloud_cfg_util.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import os
|
2
|
+
import glob
|
2
3
|
import json
|
3
4
|
import base64
|
4
5
|
import logging
|
@@ -12,10 +13,13 @@ def get_payload(cfg_object, payload_name):
|
|
12
13
|
return None
|
13
14
|
|
14
15
|
def clear_autospawns():
|
16
|
+
logger = logging.getLogger('avrs')
|
15
17
|
# also need to edit the yas_marina_env.json to have autospawn for this config
|
16
18
|
sim_path = os.environ.get('AVRS_INSTALL_PATH',
|
17
19
|
os.path.join(os.environ['HOME'], 'autoverse-linux'))
|
18
20
|
sim_saved = os.path.join(sim_path, 'Linux', 'Autoverse', 'Saved')
|
21
|
+
logger.info('clearing autospawns from sim saved at {}'.format(sim_saved))
|
22
|
+
|
19
23
|
cfg_files = SimConfigFiles(sim_saved)
|
20
24
|
|
21
25
|
cfg_ok, msg = cfg_files.validate()
|
@@ -23,6 +27,13 @@ def clear_autospawns():
|
|
23
27
|
print(msg)
|
24
28
|
return
|
25
29
|
|
30
|
+
# also remove all configs from Objects dir
|
31
|
+
files = glob.glob(os.path.join(sim_saved, 'Objects'))
|
32
|
+
for f in files:
|
33
|
+
logger.info('removing object config: {}'.format(f))
|
34
|
+
os.remove(f)
|
35
|
+
|
36
|
+
|
26
37
|
cfg_files.files['yas']['autoSpawnObjects'] = []
|
27
38
|
cfg_files.files['main']['objectTemplatePaths'] = []
|
28
39
|
cfg_files.save()
|
@@ -67,12 +78,26 @@ def register_received_vehicle(team_name, slot, cfg_data, bsu_vcan, kistler_vcan,
|
|
67
78
|
})
|
68
79
|
else:
|
69
80
|
logger.info('found Ros2 payload OK'.format())
|
81
|
+
logger.info('setting ros2 domain id to {}'.format(slot))
|
82
|
+
ros2['body']['domainId'] = slot
|
83
|
+
|
84
|
+
# auto add display widget
|
85
|
+
wtc = get_payload(cfg_object, 'WorldTextComponent')
|
86
|
+
if wtc is None:
|
87
|
+
logger.info('no WorldTextComponent payload found. adding')
|
88
|
+
cfg_object['payloads'].append({
|
89
|
+
'typeName': 'WorldTextComponent',
|
90
|
+
'body': {
|
91
|
+
|
92
|
+
}
|
93
|
+
})
|
70
94
|
|
71
95
|
# do not allow default object name (collision)
|
72
96
|
if cfg_object['name'] == 'eav24':
|
73
97
|
logger.info('setting vehicle name from default to team name: {}'.format(team_name))
|
74
98
|
cfg_object['name'] = team_name
|
75
|
-
|
99
|
+
object_spec_name = 'eav24_{}'.format(team_name)
|
100
|
+
cfg_object['specName'] = object_spec_name
|
76
101
|
|
77
102
|
# also need to edit the yas_marina_env.json to have autospawn for this config
|
78
103
|
sim_path = os.environ.get('AVRS_INSTALL_PATH',
|
@@ -105,7 +130,7 @@ def register_received_vehicle(team_name, slot, cfg_data, bsu_vcan, kistler_vcan,
|
|
105
130
|
|
106
131
|
# also need to add the object template to main sim config
|
107
132
|
|
108
|
-
new_cfg_name = 'eav24_{}.json'.format(
|
133
|
+
new_cfg_name = 'eav24_{}.json'.format(object_spec_name)
|
109
134
|
cfg_files.files['main']['objectTemplatePaths'].append(os.path.join('Objects', new_cfg_name))
|
110
135
|
logger.info('saving config file: {}'.format(new_cfg_name))
|
111
136
|
cfg_files.save()
|
avrs/race_cloud_util.py
CHANGED
@@ -114,6 +114,16 @@ CHECK_VCAN_EXISTS_SCRIPT = '''
|
|
114
114
|
fi
|
115
115
|
'''
|
116
116
|
|
117
|
+
CREATE_VCANS_SCRIPT = '''
|
118
|
+
sudo modprobe vcan
|
119
|
+
sudo ip link add name "{a}" type vcan
|
120
|
+
sudo ip link set dev "{a}" up
|
121
|
+
sudo ip link add name "{b}" type vcan
|
122
|
+
sudo ip link set dev "{b}"" up
|
123
|
+
sudo ip link add name "{c}" type vcan
|
124
|
+
sudo ip link set dev "{c}" up
|
125
|
+
'''
|
126
|
+
|
117
127
|
START_FWD_API_SCRIPT = '''
|
118
128
|
nohup avrs race-cloud fwd-api fg {source_port} {target_port} > ~/fwd_api.log 2>&1 < /dev/null &
|
119
129
|
echo "$!" > ~/fwd_api_pid
|
@@ -187,6 +197,16 @@ def check_vcan_exists(vcan_name):
|
|
187
197
|
CHECK_VCAN_EXISTS_SCRIPT.format(**pargs)])
|
188
198
|
return pres.out == 'yes'
|
189
199
|
|
200
|
+
def setup_vcans(vcan0, vcan1, vcan2):
|
201
|
+
pargs = {
|
202
|
+
'a': vcan0,
|
203
|
+
'b': vcan1,
|
204
|
+
'c': vcan2
|
205
|
+
}
|
206
|
+
pres = run_process(['bash'], '-c',
|
207
|
+
CREATE_VCANS_SCRIPT.format(**pargs))
|
208
|
+
return pres.out + ' ' + pres.err
|
209
|
+
|
190
210
|
def start_fwd_api(source_port, target_port):
|
191
211
|
pargs = {
|
192
212
|
'source_port': source_port,
|
@@ -216,7 +236,7 @@ def connect_peer_vcan(peer_id, peer_ip, vcan_id, vcan_name=''):
|
|
216
236
|
'local_port': 20000 + peer_id * 3 + vcan_id,
|
217
237
|
'vcan_name': vcan_name if vcan_name != '' else get_auto_vcan_name(peer_id, vcan_id)
|
218
238
|
}
|
219
|
-
|
239
|
+
logger.info('connecting vcan with args: {}'.format(pargs))
|
220
240
|
return run_process(['bash', '-c',
|
221
241
|
CONNECT_PEER_VCAN_SCRIPT.format(**pargs)])
|
222
242
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|