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 _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)