Setup CARLA client and world Setup ScenarioManager
(self, args)
| 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 | |
| 105 | # Create signal handler for SIGINT |
| 106 | self._shutdown_requested = False |
| 107 | if sys.platform != 'win32': |
| 108 | signal.signal(signal.SIGHUP, self._signal_handler) |
| 109 | signal.signal(signal.SIGINT, self._signal_handler) |
| 110 | signal.signal(signal.SIGTERM, self._signal_handler) |
| 111 | |
| 112 | self._start_wall_time = datetime.now() |
| 113 | |
| 114 | def destroy(self): |
| 115 | """ |
nothing calls this directly
no test coverage detected