-
Notifications
You must be signed in to change notification settings - Fork 3
/
run_simulation.py
executable file
·93 lines (84 loc) · 2.61 KB
/
run_simulation.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import carla
import sys
from tqdm import tqdm
from modules import utils, carla_utils, helpers
# Define the possible values for the WEATHER, DAYTIME and TOWN
WEATHERS = [
"Clear",
#"Cloudy",
#"HardRain",
#"MidFoggy"
]
DAYTIMES = [
"Noon",
#"Sunset",
#"Night"
]
TOWNS = [
#"Town01_Opt",
#"Town02_Opt",
#"Town03_Opt",
#"Town04_Opt",
#"Town05_Opt",
"Town06_Opt",
#"Town07_Opt",
#"Town10HD_Opt"
]
if __name__ == "__main__":
# Defien all the possible permutations of the WEATHER and DAYTIME
scenarios = []
for weather in WEATHERS:
for daytime in DAYTIMES:
scenarios.append(
(weather + daytime, carla.WeatherParameters.__dict__[weather + daytime])
)
# Load the args
args = utils.ArgParser(script="run_simulation").parse()
pov = args.pov
slen = args.slen
fps = args.fps
use_lidar = args.lidar
dry = args.dry
# Run the simulation for each scenario
pbar = tqdm(TOWNS, desc="Running the simulations")
for town in TOWNS:
pbar.set_description(
f"Running the simulations for {town}"
) # Update the progress bar description
inner_pbar = tqdm(scenarios, desc="Rendering")
for scenario in inner_pbar:
# Define the CARLA client
client = carla_utils.CarlaClient(timeout=3000)
try:
client.connect()
except RuntimeError as e:
print("Could not connect to CARLA server:\n\t", e)
sys.exit(1)
# Define and generate the output folders
try:
folders = helpers.out_folders_gen(
town_name=town,
weather=scenario,
slen=slen,
pov=pov,
use_lidar=use_lidar,
verbose=False,
)
except ValueError as e:
print(e.args[0])
inner_pbar.set_description(
f"Rendering the {scenario[0]} scenario"
) # Update the progress bar description
# Perform the rendering
client.render_scene(
folders=folders,
town_name=town,
pov=pov,
weather=scenario,
slen=slen,
fps=fps,
use_lidar=use_lidar,
dry=dry,
master_pbar=inner_pbar,
verbose="all" #"minimal"
)