forked from huawei-noah/SMARTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathegoless.py
48 lines (36 loc) · 1.11 KB
/
egoless.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
import logging
import gym
from examples.argument_parser import default_argument_parser
from smarts.core.utils.episodes import episodes
logging.basicConfig(level=logging.INFO)
def main(scenarios, sim_name, headless, num_episodes, seed, max_episode_steps=None):
env = gym.make(
"smarts.env:hiway-v0",
scenarios=scenarios,
agent_specs={},
sim_name=sim_name,
headless=headless,
sumo_headless=True,
visdom=False,
seed=seed,
timestep_sec=0.1,
)
if max_episode_steps is None:
max_episode_steps = 1000
for episode in episodes(n=num_episodes):
env.reset()
episode.record_scenario(env.scenario_log)
for _ in range(max_episode_steps):
env.step({})
episode.record_step({}, {}, {}, {})
env.close()
if __name__ == "__main__":
parser = default_argument_parser("egoless-example")
args = parser.parse_args()
main(
scenarios=args.scenarios,
sim_name=args.sim_name,
headless=args.headless,
num_episodes=args.episodes,
seed=args.seed,
)