leaderboard/leaderboard/scenarios/nocrash_eval_scenario.py
def _initialize_actors(self, config):
        """
        Set other_actors to the superset of all scenario actors
        """
        # Create the background activity of the route
        car_amounts = {
            'Town01': [0,20,100],
            'Town02': [0,15,70],
        }
        
        ped_amounts = {
            'Town01': [0,50,200],
            'Town02': [0,50,150],
        }

        car_amount = car_amounts[self.town_name][self.traffic_idx]
        ped_amount = ped_amounts[self.town_name][self.traffic_idx]

        new_actors = CarlaDataProvider.request_new_batch_actors('vehicle.*',
                                                                car_amount,
                                                                carla.Transform(),
                                                                autopilot=True,
                                                                random_location=True,
                                                                rolename='background')

        if new_actors is None:
            raise Exception("Error: Unable to add the background activity, all spawn points were occupied")

        blueprints = CarlaDataProvider._blueprint_library.filter('walker.pedestrian.*')
        spawn_points = []
        while len(spawn_points) < ped_amount:
            spawn_point = carla.Transform()
            loc = CarlaDataProvider.get_world().get_random_location_from_navigation()
            if (loc != None):
                spawn_point.location = loc
                spawn_points.append(spawn_point)

        batch = []
        for spawn_point in spawn_points:
            walker_bp = random.choice(blueprints)
            if walker_bp.has_attribute('is_invincible'):
                walker_bp.set_attribute('is_invincible', 'false')
            batch.append(carla.command.SpawnActor(walker_bp, spawn_point))
        
        pedestrians = CarlaDataProvider.handle_actor_batch(batch)
        
        batch = []
        walker_controller_bp = CarlaDataProvider._blueprint_library.find('controller.ai.walker')
        for pedestrian in pedestrians:
            batch.append(
                carla.command.SpawnActor(walker_controller_bp, carla.Transform(), pedestrian)
            )

        pedestrian_controllers = CarlaDataProvider.handle_actor_batch(batch)
        CarlaDataProvider.get_world().set_pedestrians_cross_factor(1.0)
        for controller in pedestrian_controllers:
            controller.start()
            controller.go_to_location(CarlaDataProvider.get_world().get_random_location_from_navigation())
            controller.set_max_speed(1.2 + random.random())
            
        for actor in itertools.chain(pedestrians, pedestrian_controllers):
            if actor is None:
                continue

            CarlaDataProvider._carla_actor_pool[actor.id] = actor
            CarlaDataProvider.register_actor(actor)

            self.other_actors.append(actor)

        Set other_actors to the superset of all scenario actors
        
Set other_actors to the superset of all scenario actors
Set other_actors to the superset of all scenario actors
def _initialize_actors(self, config):
        car_amounts = {
            'Town01': [0,20,100],
            'Town02': [0,15,70],
        }
        ped_amounts = {
            'Town01': [0,50,200],
            'Town02': [0,50,150],
        }
        car_amount = car_amounts[self.town_name][self.traffic_idx]
        ped_amount = ped_amounts[self.town_name][self.traffic_idx]
        new_actors = CarlaDataProvider.request_new_batch_actors('vehicle.*',
                                                                car_amount,
                                                                carla.Transform(),
                                                                autopilot=True,
                                                                random_location=True,
                                                                rolename='background')
        if new_actors is None:
            raise Exception("Error: Unable to add the background activity, all spawn points were occupied")
        blueprints = CarlaDataProvider._blueprint_library.filter('walker.pedestrian.*')
        spawn_points = []
        while len(spawn_points) < ped_amount:
            spawn_point = carla.Transform()
            loc = CarlaDataProvider.get_world().get_random_location_from_navigation()
            if (loc != None):
                spawn_point.location = loc
                spawn_points.append(spawn_point)
        batch = []
        for spawn_point in spawn_points:
            walker_bp = random.choice(blueprints)
            if walker_bp.has_attribute('is_invincible'):
                walker_bp.set_attribute('is_invincible', 'false')
            batch.append(carla.command.SpawnActor(walker_bp, spawn_point))
        pedestrians = CarlaDataProvider.handle_actor_batch(batch)
        batch = []
        walker_controller_bp = CarlaDataProvider._blueprint_library.find('controller.ai.walker')
        for pedestrian in pedestrians:
            batch.append(
                carla.command.SpawnActor(walker_controller_bp, carla.Transform(), pedestrian)
            )
        pedestrian_controllers = CarlaDataProvider.handle_actor_batch(batch)
        CarlaDataProvider.get_world().set_pedestrians_cross_factor(1.0)
        for controller in pedestrian_controllers:
            controller.start()
            controller.go_to_location(CarlaDataProvider.get_world().get_random_location_from_navigation())
            controller.set_max_speed(1.2 + random.random())
        for actor in itertools.chain(pedestrians, pedestrian_controllers):
            if actor is None:
                continue
            CarlaDataProvider._carla_actor_pool[actor.id] = actor
            CarlaDataProvider.register_actor(actor)
            self.other_actors.append(actor)
def _initialize_actors ( self , config ) : car_amounts = { 'Town01' : [ 0 , 20 , 100 ] , 'Town02' : [ 0 , 15 , 70 ] , } ped_amounts = { 'Town01' : [ 0 , 50 , 200 ] , 'Town02' : [ 0 , 50 , 150 ] , } car_amount = car_amounts [ self . town_name ] [ self . traffic_idx ] ped_amount = ped_amounts [ self . town_name ] [ self . traffic_idx ] new_actors = CarlaDataProvider . request_new_batch_actors ( 'vehicle.*' , car_amount , carla . Transform ( ) , autopilot = True , random_location = True , rolename = 'background' ) if new_actors is None : raise Exception ( "Error: Unable to add the background activity, all spawn points were occupied" ) blueprints = CarlaDataProvider . _blueprint_library . filter ( 'walker.pedestrian.*' ) spawn_points = [ ] while len ( spawn_points ) < ped_amount : spawn_point = carla . Transform ( ) loc = CarlaDataProvider . get_world ( ) . get_random_location_from_navigation ( ) if ( loc != None ) : spawn_point . location = loc spawn_points . append ( spawn_point ) batch = [ ] for spawn_point in spawn_points : walker_bp = random . choice ( blueprints ) if walker_bp . has_attribute ( 'is_invincible' ) : walker_bp . set_attribute ( 'is_invincible' , 'false' ) batch . append ( carla . command . SpawnActor ( walker_bp , spawn_point ) ) pedestrians = CarlaDataProvider . handle_actor_batch ( batch ) batch = [ ] walker_controller_bp = CarlaDataProvider . _blueprint_library . find ( 'controller.ai.walker' ) for pedestrian in pedestrians : batch . append ( carla . command . SpawnActor ( walker_controller_bp , carla . Transform ( ) , pedestrian ) ) pedestrian_controllers = CarlaDataProvider . handle_actor_batch ( batch ) CarlaDataProvider . get_world ( ) . set_pedestrians_cross_factor ( 1.0 ) for controller in pedestrian_controllers : controller . start ( ) controller . go_to_location ( CarlaDataProvider . get_world ( ) . get_random_location_from_navigation ( ) ) controller . set_max_speed ( 1.2 + random . random ( ) ) for actor in itertools . chain ( pedestrians , pedestrian_controllers ) : if actor is None : continue CarlaDataProvider . _carla_actor_pool [ actor . id ] = actor CarlaDataProvider . register_actor ( actor ) self . other_actors . append ( actor )
Set other_actors to the superset of all scenario actors
Set other_actors to the superset of all scenario actors
"""
        Set other_actors to the superset of all scenario actors
        """ # Create the background activity of the route
self
config