def _update_route(self, world, config, debug_mode): """ Update the input route, i.e. refine waypoint list, and extract possible scenario locations Parameters: - world: CARLA world - config: Scenario configuration (RouteConfiguration) """ # Transform the scenario file into a dictionary world_annotations = RouteParser.parse_annotations_file(config.scenario_file) # prepare route's trajectory (interpolate and add the GPS route) gps_route, route = interpolate_trajectory(config.trajectory) potential_scenarios_definitions, _ = RouteParser.scan_route_for_scenarios(config.town, route, world_annotations) self.route = route CarlaDataProvider.set_ego_vehicle_route(convert_transform_to_location(self.route)) if config.agent is not None: config.agent.set_global_plan(gps_route, self.route) # Sample the scenarios to be used for this route instance. self.sampled_scenarios_definitions = self._scenario_sampling(potential_scenarios_definitions) # Timeout of scenario in seconds self.timeout = self._estimate_route_timeout() # Print route in debug mode if debug_mode: self._draw_waypoints(world, self.route, vertical_shift=0.1, persistency=50000.0)
def _run_challenge(self, args): """ Run the challenge mode """ routes = args.route[0] scenario_file = args.route[1] single_route = None if args.route[2]: single_route = args.route[2] repetitions = 1 # retrieve routes route_descriptions_list = RouteParser.parse_routes_file( routes, single_route) # find and filter potential scenarios for each of the evaluated routes # For each of the routes and corresponding possible scenarios to be evaluated. # n_routes = len(route_descriptions_list) * repetitions for _, route_description in enumerate(route_descriptions_list): for _ in range(repetitions): config = RouteScenarioConfiguration(route_description, scenario_file) self._load_and_run_scenario(args, config) self._cleanup(ego=(not args.waitForEgo))
def _run_route(self): """ Run the route scenario """ result = False repetitions = self._args.repetitions if self._args.route: routes = self._args.route[0] scenario_file = self._args.route[1] single_route = None if len(self._args.route) > 2: single_route = self._args.route[2] # retrieve routes route_descriptions_list = RouteParser.parse_routes_file( routes, single_route) # find and filter potential scenarios for each of the evaluated routes # For each of the routes and corresponding possible scenarios to be evaluated. for _, route_description in enumerate(route_descriptions_list): for _ in range(repetitions): config = RouteScenarioConfiguration(route_description, scenario_file) result = self._load_and_run_scenario(config, -1, -1) self._cleanup() return result
def _update_route(self, world, config, debug_mode): """ Update the input route, i.e. refine waypoint list, and extract possible scenario locations Parameters: - world: CARLA world - config: Scenario configuration (RouteConfiguration) """ # retrieve worlds annotations world_annotations = RouteParser.parse_annotations_file( config.scenario_file) _route_description = copy.copy(config.route_description) # prepare route's trajectory gps_route, _route_description['trajectory'] = interpolate_trajectory( world, _route_description['trajectory']) potential_scenarios_definitions, _ = RouteParser.scan_route_for_scenarios( _route_description, world_annotations) self.route = _route_description['trajectory'] self.target = self.route[-1][0] CarlaDataProvider.set_ego_vehicle_route( convert_transform_to_location(self.route)) #Commenting this out because we want to run our own agent in pygame mode #config.agent.set_global_plan(gps_route, self.route) # Sample the scenarios to be used for this route instance. self.sampled_scenarios_definitions = self._scenario_sampling( potential_scenarios_definitions) # Timeout of scenario in seconds self.timeout = self._estimate_route_timeout() # Print route in debug mode if debug_mode: turn_positions_and_labels = clean_route(self.route) self._draw_waypoints(world, self.route, turn_positions_and_labels, vertical_shift=1.0, persistency=50000.0)
def _run_route(self): """ Run the route scenario """ result = False if self._args.route: routes = self._args.route[0] scenario_file = self._args.route[1] single_route = None if len(self._args.route) > 2: single_route = self._args.route[2] # retrieve routes route_configurations = RouteParser.parse_routes_file(routes, scenario_file, single_route) for config in route_configurations: for _ in range(self._args.repetitions): result = self._load_and_run_scenario(config) self._cleanup() return result
def _run_challenge(self): """ Run the challenge mode """ result = False phase_codename = os.getenv('CHALLENGE_PHASE_CODENAME', 'dev_track_3') phase = phase_codename.split("_")[0] repetitions = self._args.repetitions if self._args.challenge: weather_profiles = CarlaDataProvider.find_weather_presets() scenario_runner_root = os.getenv('ROOT_SCENARIO_RUNNER', "./") if phase == 'dev': routes = '{}/srunner/challenge/routes_devtest.xml'.format( scenario_runner_root) repetitions = 1 elif phase == 'validation': routes = '{}/srunner/challenge/routes_testprep.xml'.format( scenario_runner_root) repetitions = 3 elif phase == 'test': routes = '{}/srunner/challenge/routes_testchallenge.xml'.format( scenario_runner_root) repetitions = 3 else: # debug mode routes = '{}/srunner/challenge/routes_debug.xml'.format( scenario_runner_root) repetitions = 1 if self._args.route: routes = self._args.route[0] scenario_file = self._args.route[1] single_route = None if len(self._args.route) > 2: single_route = self._args.route[2] # retrieve routes route_descriptions_list = RouteParser.parse_routes_file( routes, single_route) # find and filter potential scenarios for each of the evaluated routes # For each of the routes and corresponding possible scenarios to be evaluated. if self._args.challenge: n_routes = len(route_descriptions_list) * repetitions ChallengeStatisticsManager.set_number_of_scenarios(n_routes) for _, route_description in enumerate(route_descriptions_list): for repetition in range(repetitions): if self._args.challenge and not self._within_available_time(): error_message = 'Not enough simulation time available to continue' print(error_message) ChallengeStatisticsManager.record_fatal_error( error_message) self._cleanup() return False config = RouteScenarioConfiguration(route_description, scenario_file) if self._args.challenge: profile = weather_profiles[repetition % len(weather_profiles)] config.weather = profile[0] config.weather.sun_azimuth_angle = -1 config.weather.sun_altitude_angle = -1 result = self._load_and_run_scenario(config) self._cleanup() return result