Example #1
0
    def _initialize_actors(self, config):
        for actor in config.other_actors:
            new_actors = CarlaActorPool.request_new_batch_actors(actor.model,
                                                                 actor.amount,
                                                                 actor.transform,
                                                                 hero=False,
                                                                 autopilot=actor.autopilot,
                                                                 random_location=actor.random_location)
            if new_actors is None:
                raise Exception("Error: Unable to add actor {} at {}".format(actor.model, actor.transform))

            for _actor in new_actors:
                self.other_actors.append(_actor)
    def _initialize_actors(self, config):
        location = []

        infile = open('actor_config5', 'rb')
        location = pickle.load(infile)
        infile.close()
        for actor in config.other_actors:
            new_actors = []
            new_actors = CarlaActorPool.request_new_batch_actors(
                actor.model,
                actor.amount,
                actor.transform,
                hero=False,
                autopilot=actor.autopilot,
                random_location=actor.random_location)
            #Static obstacle for route based driving 2
            '''transform = carla.Transform(carla.Location(x=-77.3, y=108.4, z=0.0), carla.Rotation(pitch=360.5, yaw=269.8+90, roll=0.0))
            new_actors.append(CarlaActorPool.request_new_actor('static.prop.streetbarrier',
                                                                    transform,
                                                                    hero=False,
                                                                    autopilot=False,
                                                                    random_location=False))'''
            '''for i in range(len(location)):
                maploc = location[i]
                transform = carla.Transform(carla.Location(x=maploc['x'], y=maploc['y'], z=maploc['z']), carla.Rotation(pitch=maploc['pitch'], yaw=maploc['yaw'], roll=maploc['roll']))
                new_actors.append(CarlaActorPool.request_new_actor(maploc['vehicle'],
                                                                    transform,
                                                                    hero=False,
                                                                    autopilot=True,
                                                                    random_location=False))'''
            if new_actors is None:
                raise Exception("Error: Unable to add actor {} at {}".format(
                    actor.model, actor.transform))

            for _actor in new_actors:
                #print(f'actor_location======={_actor.type_id}')
                loc_dict = {
                    'vehicle': _actor.type_id,
                    'pitch': _actor.get_transform().rotation.pitch,
                    'yaw': _actor.get_transform().rotation.yaw,
                    'roll': _actor.get_transform().rotation.roll,
                    'x': _actor.get_location().x,
                    'y': _actor.get_location().y,
                    'z': _actor.get_location().z
                }
                location.append(loc_dict)
                self.other_actors.append(_actor)
        '''filename = 'actor_config2'
    def _initialize_actors(self, config):
        """
            This initialize actors for the background actitivy. The actors can be both \
            walkers (pedestrians) or vehicles (cars, bicycles, trucks ...)
            The pedestrian can have a cross factor, how often they cross the road.
        """

        for actor in config.other_actors:
            new_actors = CarlaActorPool.request_new_batch_actors(
                actor.model,
                actor.amount,
                actor.transform,
                hero=False,
                autopilot=actor.autopilot,
                random_location=actor.random_location,
                cross_factor=self.cross_factor)

            if new_actors is None:
                raise Exception("Error: Unable to add actor {} at {}".format(
                    actor.model, actor.transform))

            for _actor in new_actors:
                self.other_actors.append(_actor)