forked from wuxiaohua1011/ROAR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner_sim.py
48 lines (40 loc) · 2 KB
/
runner_sim.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
from pathlib import Path
from ROAR_Sim.configurations.configuration import Configuration as CarlaConfig
from ROAR_Sim.carla_client.carla_runner import CarlaRunner
from ROAR.agent_module.pure_pursuit_agent import PurePursuitAgent
from ROAR.configurations.configuration import Configuration as AgentConfig
import argparse
from misc.utils import str2bool
from ROAR.agent_module.michael_pid_agent import PIDAgent
from ROAR.agent_module.forward_only_agent import ForwardOnlyAgent
def main(args):
"""Starts game loop"""
agent_config = AgentConfig.parse_file(Path("./ROAR/configurations/carla/carla_agent_configuration.json"))
carla_config = CarlaConfig.parse_file(Path("./ROAR_Sim/configurations/configuration.json"))
carla_runner = CarlaRunner(carla_settings=carla_config,
agent_settings=agent_config,
npc_agent_class=PurePursuitAgent)
try:
my_vehicle = carla_runner.set_carla_world()
agent = ForwardOnlyAgent(vehicle=my_vehicle,
agent_settings=agent_config)
carla_runner.start_game_loop(agent=agent,
use_manual_control=not args.auto)
except Exception as e:
logging.error(f"Something bad happened during initialization: {e}")
carla_runner.on_finish()
logging.error(f"{e}. Might be a good idea to restart Server")
if __name__ == "__main__":
logging.basicConfig(format='%(levelname)s - %(asctime)s - %(name)s '
'- %(message)s',
datefmt="%H:%M:%S",
level=logging.DEBUG)
logging.getLogger(" streaming client").setLevel(logging.WARNING)
import warnings
warnings.filterwarnings("ignore", module="carla")
parser = argparse.ArgumentParser()
parser.add_argument("--auto", type=str2bool, default=False, help="True to use auto control")
warnings.filterwarnings("ignore", module="carla")
args = parser.parse_args()
main(args)