MCPcopy Create free account
hub / github.com/OpenDriveLab/TCP / ScenarioRunner

Class ScenarioRunner

scenario_runner/scenario_runner.py:47–490  ·  view source on GitHub ↗

This is the core scenario runner module. It is responsible for running (and repeating) a single scenario or a list of scenarios. Usage: scenario_runner = ScenarioRunner(args) scenario_runner.run() del scenario_runner

Source from the content-addressed store, hash-verified

45
46
47class ScenarioRunner(object):
48
49 """
50 This is the core scenario runner module. It is responsible for
51 running (and repeating) a single scenario or a list of scenarios.
52
53 Usage:
54 scenario_runner = ScenarioRunner(args)
55 scenario_runner.run()
56 del scenario_runner
57 """
58
59 ego_vehicles = []
60
61 # Tunable parameters
62 client_timeout = 10.0 # in seconds
63 wait_for_world = 20.0 # in seconds
64 frame_rate = 20.0 # in Hz
65
66 # CARLA world and scenario handlers
67 world = None
68 manager = None
69
70 additional_scenario_module = None
71
72 agent_instance = None
73 module_agent = None
74
75 def __init__(self, args):
76 """
77 Setup CARLA client and world
78 Setup ScenarioManager
79 """
80 self._args = args
81
82 if args.timeout:
83 self.client_timeout = float(args.timeout)
84
85 # First of all, we need to create the client that will send the requests
86 # to the simulator. Here we'll assume the simulator is accepting
87 # requests in the localhost at port 2000.
88 self.client = carla.Client(args.host, int(args.port))
89 self.client.set_timeout(self.client_timeout)
90
91 dist = pkg_resources.get_distribution("carla")
92 if LooseVersion(dist.version) < LooseVersion('0.9.8'):
93 raise ImportError("CARLA version 0.9.8 or newer required. CARLA version found: {}".format(dist))
94
95 # Load agent if requested via command line args
96 # If something goes wrong an exception will be thrown by importlib (ok here)
97 if self._args.agent is not None:
98 module_name = os.path.basename(args.agent).split('.')[0]
99 sys.path.insert(0, os.path.dirname(args.agent))
100 self.module_agent = importlib.import_module(module_name)
101
102 # Create the ScenarioManager
103 self.manager = ScenarioManager(self._args.debug, self._args.sync, self._args.timeout)
104

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected