forked from wuxiaohua1011/ROAR
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathchange_engine.py
More file actions
59 lines (46 loc) · 2.31 KB
/
change_engine.py
File metadata and controls
59 lines (46 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import json
#mode='2e'
mode='2b'
with open('ROAR_Sim/configurations/carla_version.txt','w') as f:
if mode=='2b':
f.write('0.9.10')
elif mode=='2e':
f.write('0.9.9')
with open('ROAR_Sim/configurations/occu_map_config.json') as f:
occu_map_config=json.load(f)
if mode == '2b':
occu_map_config['absolute_maximum_map_size']=1500
elif mode == '2e':
occu_map_config['absolute_maximum_map_size']=550
with open('ROAR_Sim/configurations/occu_map_config.json','w') as f:
json.dump(occu_map_config, f,indent=4)
with open('ROAR_gym/configurations/agent_configuration.json') as f:
agent_config = json.load(f)
if mode == '2b':
agent_config["waypoint_file_path"] = "../ROAR_Sim/data/berkeley_minor_sdzl_waypoints.txt"
elif mode == '2e':
agent_config["waypoint_file_path"] = '../ROAR_Sim/data/easy_map_waypoints.txt'
with open('ROAR_gym/configurations/agent_configuration.json', 'w') as f:
json.dump(agent_config, f,indent=4)
with open('ROAR/configurations/configuration.py') as f:
lines=f.readlines()
for i in range(len(lines)):
line=lines[i]
if 'waypoint_file_path:' in line and '=' in line and 'txt' in line:
if mode == '2b':
lines[i] = line[:line.find('waypoint_file_path:')]+'waypoint_file_path: str = Field(default=(Path(os.getcwd()) / "data" / "berkeley_minor_sdzl_waypoints.txt").as_posix())\n'
elif mode == '2e':
lines[i] = line[:line.find('waypoint_file_path:')]+'waypoint_file_path: str = Field(default=(Path(os.getcwd()) / "data" / "easy_map_waypoints.txt").as_posix())\n'
with open('ROAR/configurations/configuration.py', 'w') as f:
f.writelines(lines)
with open('ROAR/agent_module/rl_e2e_ppo_agent.py') as f:
lines=f.readlines()
for i in range(len(lines)):
line=lines[i]
if 'occ_file_path' in line and '=' in line and 'Path' in line:
if mode == '2b':
lines[i] = line[:line.find('occ_file_path')]+'occ_file_path = Path("../ROAR_Sim/data/berkeley_minor_cleaned_global_occu_map.npy")\n'
elif mode == '2e':
lines[i] = line[:line.find('occ_file_path')]+'occ_file_path = Path("../ROAR_Sim/data/easy_map_global_occu_map.npy")\n'
with open('ROAR/agent_module/rl_e2e_ppo_agent.py','w') as f:
f.writelines(lines)