Ejemplo n.º 1
0
    def build_experiments(self):
        """
        Creates the whole set of experiment objects,
        The experiments created depend on the selected Town.


        """

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('CameraRGB')
        camera.set(FOV=100)
        camera.set_image_size(200, 88)
        camera.set_position(2.0, 0.0, 1.4)
        camera.set_rotation(-15.0, 0, 0)

        if self._city_name == 'Town01':
            poses_tasks = self._poses_town01()
            vehicles_tasks = [0, 0, 0, 20]
            pedestrians_tasks = [0, 0, 0, 50]
        else:
            poses_tasks = self._poses_town02()
            vehicles_tasks = [0, 0, 0, 15]
            pedestrians_tasks = [0, 0, 0, 50]

        experiments_vector = []

        for weather in self.weathers:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]

                #weather=14

                #poses = [[54, 60]]
                #poses=[[37,76]]
                #poses = [[80, 29]]
                #poses = [[50,43]]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                conditions = CarlaSettings()
                conditions.set(SendNonPlayerAgentsInfo=True,
                               NumberOfVehicles=vehicles,
                               NumberOfPedestrians=pedestrians,
                               WeatherId=weather)
                conditions.set(SynchronousMode=True)
                # Add all the cameras that were set for this experiments

                conditions.add_sensor(camera)

                experiment = Experiment()
                experiment.set(Conditions=conditions,
                               Poses=poses,
                               Task=iteration,
                               Repetitions=1)
                experiments_vector.append(experiment)

        return experiments_vector
Ejemplo n.º 2
0
    def build_experiments(self):
        """
            Creates the whole set of experiment objects,
            The experiments created depends on the selected Town.

        """

        # We check the town, based on that we define the town related parameters
        # The size of the vector is related to the number of tasks, inside each
        # task there is also multiple poses ( start end, positions )
        if self._city_name == 'Town01':
            poses_tasks = [[[7, 3]], [[138, 17]], [[140, 134]], [[140, 134]]]
            vehicles_tasks = [0, 0, 0, 20]
            pedestrians_tasks = [0, 0, 0, 50]
        else:
            poses_tasks = [[[4, 2]], [[37, 76]], [[19, 66]], [[19, 66]]]
            vehicles_tasks = [0, 0, 0, 15]
            pedestrians_tasks = [0, 0, 0, 50]

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('CameraRGB')
        camera.set(FOV=100)
        camera.set_image_size(800, 600)
        camera.set_position(2.0, 0.0, 1.4)
        camera.set_rotation(-15.0, 0, 0)

        # Based on the parameters, creates a vector with experiment objects.
        experiments_vector = []
        for weather in self.weathers:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                conditions = CarlaSettings()
                conditions.set(
                    SendNonPlayerAgentsInfo=True,
                    NumberOfVehicles=vehicles,
                    NumberOfPedestrians=pedestrians,
                    WeatherId=weather

                )
                # Add all the cameras that were set for this experiments
                conditions.add_sensor(camera)
                experiment = Experiment()
                experiment.set(
                    Conditions=conditions,
                    Poses=poses,
                    Task=iteration,
                    Repetitions=1
                )
                experiments_vector.append(experiment)

        return experiments_vector
    def build_experiments(self):
        """
            Creates the whole set of experiment objects,
            The experiments created depends on the selected Town.

        """

        # We check the town, based on that we define the town related parameters
        # The size of the vector is related to the number of tasks, inside each
        # task there is also multiple poses ( start end, positions )
        if self._city_name == 'Town01':
            poses_tasks = [[[7, 3]], [[138, 17]], [[140, 134]], [[140, 134]]]
            vehicles_tasks = [0, 0, 0, 20]
            pedestrians_tasks = [0, 0, 0, 50]
        else:
            poses_tasks = [[[4, 2]], [[37, 76]], [[19, 66]], [[19, 66]]]
            vehicles_tasks = [0, 0, 0, 15]
            pedestrians_tasks = [0, 0, 0, 50]

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('CameraRGB')
        camera.set(FOV=100)
        camera.set_image_size(800, 600)
        camera.set_position(2.0, 0.0, 1.4)
        camera.set_rotation(-15.0, 0, 0)

        # Based on the parameters, creates a vector with experiment objects.
        experiments_vector = []
        for weather in self.weathers:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                conditions = CarlaSettings()
                conditions.set(
                    SendNonPlayerAgentsInfo=True,
                    NumberOfVehicles=vehicles,
                    NumberOfPedestrians=pedestrians,
                    WeatherId=weather

                )
                # Add all the cameras that were set for this experiments
                conditions.add_sensor(camera)
                experiment = Experiment()
                experiment.set(
                    Conditions=conditions,
                    Poses=poses,
                    Task=iteration,
                    Repetitions=1
                )
                experiments_vector.append(experiment)

        return experiments_vector
Ejemplo n.º 4
0
    def build_experiments(self):
        """
        Creates the whole set of experiment objects,
        The experiments created depend on the selected Town.


        """

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('CameraRGB')
        camera.set(FOV=100)
        camera.set_image_size(800, 600)
        camera.set_position(2.0, 0.0, 1.4)
        camera.set_rotation(-15.0, 0, 0)

        if self._city_name == 'Town01':
            poses_tasks = self._poses_town01()
            vehicles_tasks = [0, 0, 0, 20]
            pedestrians_tasks = [0, 0, 0, 50]
        else:
            poses_tasks = self._poses_town02()
            vehicles_tasks = [0, 0, 0, 15]
            pedestrians_tasks = [0, 0, 0, 50]

        experiments_vector = []

        for weather in self.weathers:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                conditions = CarlaSettings()
                conditions.set(
                    SendNonPlayerAgentsInfo=True,
                    NumberOfVehicles=vehicles,
                    NumberOfPedestrians=pedestrians,
                    WeatherId=weather
                )
                # Add all the cameras that were set for this experiments

                conditions.add_sensor(camera)

                experiment = Experiment()
                experiment.set(
                    Conditions=conditions,
                    Poses=poses,
                    Task=iteration,
                    Repetitions=1
                )
                experiments_vector.append(experiment)

        return experiments_vector
Ejemplo n.º 5
0
    def build_experiments(self):
        """
        Creates the whole set of experiment objects,
        The experiments created depend on the selected Town.
        """

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('CameraRGB')
        camera.set(FOV=100)
        camera.set_image_size(800, 600)
        camera.set_position(2.0, 0.0, 1.4)
        camera.set_rotation(-15.0, 0, 0)

        if self._city_name == 'Town01':
            poses_tasks = self._poses_town01()
            vehicles_tasks = [25]
            pedestrians_tasks = [25]
        else:
            poses_tasks = self._poses_town02()
            vehicles_tasks = [0, 25]
            pedestrians_tasks = [0, 25]

        experiments_vector = []
        #weathers = [1,3,6,8]
        for weather in self.weathers:
            #prinst(weather , vehicles_tasks)
            for scenario in range(len(vehicles_tasks)):
                for iteration in range(len(poses_tasks)):
                    #print(f"interation : {iteration} , scenario:{scenario}")
                    poses = poses_tasks[iteration]
                    #print("poses re",poses)
                    vehicles = vehicles_tasks[scenario]
                    #print("Vehicles: ",vehicles)
                    pedestrians = pedestrians_tasks[scenario]
                    #print("pedestrians: ",pedestrians)

                    conditions = CarlaSettings()
                    conditions.set(SendNonPlayerAgentsInfo=True,
                                   NumberOfVehicles=vehicles,
                                   NumberOfPedestrians=pedestrians,
                                   WeatherId=weather)
                    # Add all the cameras that were set for this experiments

                    conditions.add_sensor(camera)

                    experiment = Experiment()
                    experiment.set(Conditions=conditions,
                                   Poses=poses,
                                   Task=iteration,
                                   Repetitions=1)
                    experiments_vector.append(experiment)

        return experiments_vector
Ejemplo n.º 6
0
    def build_experiments(self):
        """
        Creates the whole set of experiment objects,
        The experiments created depend on the selected Town.


        """

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('rgb')
        camera.set(FOV=90)
        camera.set_image_size(300, 300)
        camera.set_position(0.2, 0.0, 0.85)
        camera.set_rotation(-3.0, 0, 0)

        poses_tasks = self._poses()
        vehicles_tasks = [0, 0, 0, 15]
        pedestrians_tasks = [0, 0, 0, 50]



        experiments_vector = []

        for weather in self.weathers:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                conditions = CarlaSettings()
                conditions.set(
                    SendNonPlayerAgentsInfo=True,
                    NumberOfVehicles=vehicles,
                    NumberOfPedestrians=pedestrians,
                    WeatherId=weather,
                    QualityLevel='Epic'
                )
                # Add all the cameras that were set for this experiments

                conditions.add_sensor(camera)

                experiment = Experiment()
                experiment.set(
                    Conditions=conditions,
                    Poses=poses,
                    Task=iteration,
                    Repetitions=1
                )
                experiments_vector.append(experiment)

        return experiments_vector
    def build_experiments(self):
        """
        Creates the whole set of experiment objects,
        The experiments created depend on the selected Town.


        """

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('rgb')
        camera.set(FOV=100)
        camera.set_image_size(800, 600)
        camera.set_position(2.0, 0.0, 1.4)
        camera.set_rotation(-15.0, 0, 0)

        poses_tasks = self._poses()
        vehicles_tasks = [0, 15, 70]
        pedestrians_tasks = [0, 50, 150]

        task_names = ['empty', 'normal', 'cluttered']

        experiments_vector = []

        for weather in self.weathers:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                conditions = CarlaSettings()
                conditions.set(SendNonPlayerAgentsInfo=True,
                               NumberOfVehicles=vehicles,
                               NumberOfPedestrians=pedestrians,
                               WeatherId=weather)
                conditions.set(DisableTwoWheeledVehicles=True)
                # Add all the cameras that were set for this experiments

                conditions.add_sensor(camera)

                experiment = Experiment()
                experiment.set(Conditions=conditions,
                               Poses=poses,
                               Task=iteration,
                               TaskName=task_names[iteration],
                               Repetitions=1)
                experiments_vector.append(experiment)

        return experiments_vector
Ejemplo n.º 8
0
    def build_experiments(self):
        """
        Creates the whole set of experiment objects,
        The experiments created depend on the selected Town.


        """

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('CameraMiddle')
        camera.set(FOV=90)
        camera.set_image_size(768, 576)
        camera.set_position(1.5, 0.0, 1.6)
        camera.set_rotation(0, 0, 0)

        if self._city_name == 'Town01':
            poses_tasks = self._poses_town01()
            vehicles_tasks = [0, 0, 0, 100]
            pedestrians_tasks = [0, 0, 0, 300]
            n_samples = [0, 0, 30 // 4, 60 // 4]
            #n_samples = [3, 6, 6, 9]
        else:
            poses_tasks = self._poses_town02()
            vehicles_tasks = [0, 0, 0, 50]
            pedestrians_tasks = [0, 0, 0, 150]
            n_samples = [0, 0, 15, len(poses_tasks[-1])]
            #n_samples = [3, 6, 6, 9]

        experiments_vector = []

        random.seed(1)

        for weather in self.weathers:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                nsample = n_samples[iteration]
                if nsample == 0:
                    continue
                poses = random.sample(poses, nsample)

                conditions = CarlaSettings()
                conditions.set(SendNonPlayerAgentsInfo=True,
                               NumberOfVehicles=vehicles,
                               NumberOfPedestrians=pedestrians,
                               WeatherId=weather,
                               QualityLevel="Low")
                # Add all the cameras that were set for this experiments

                conditions.add_sensor(camera)

                experiment = Experiment()
                experiment.set(Conditions=conditions,
                               Poses=poses,
                               Task=iteration,
                               Repetitions=1)
                experiments_vector.append(experiment)

        return experiments_vector
Ejemplo n.º 9
0
    def build_experiments(self):
        """
        Creates the whole set of experiment objects,
        The experiments created depend on the selected Town.
        """

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('CameraRGB')
        camera.set(FOV=100)
        camera.set_image_size(800, 600)
        camera.set_position(2.0, 0.0, 1.4)
        camera.set_rotation(-15.0, 0, 0)

        if self._city_name == 'Town01':

            if self._subset == 'keep_lane':
                poses_tasks = [self._poses_town01()[0]]
                vehicles_tasks = [0]
                pedestrians_tasks = [0]

            elif self._subset == 'one_turn':
                poses_tasks = [self._poses_town01()[1]]
                vehicles_tasks = [0]
                pedestrians_tasks = [0]

            elif self._subset == 'keep_lane_one_turn':
                poses_tasks = self._poses_town01()[:2]
                vehicles_tasks = [0, 0]
                pedestrians_tasks = [0, 0]

            elif self._subset == 'no_dynamic_objects':
                poses_tasks = self._poses_town01()[:3]
                vehicles_tasks = [0, 0, 0]
                pedestrians_tasks = [0, 0, 0]

            elif self._subset is None:
                poses_tasks = self._poses_town01()
                vehicles_tasks = [0, 0, 0, 20]
                pedestrians_tasks = [0, 0, 0, 50]

            else:
                raise ValueError(
                    "experiments-subset must be keep_lane or keep_lane_one_turn or no_dynamic_objects or None"
                )

        else:
            raise ValueError("city must be Town01 for training")

        experiments_vector = []

        for i, iteration in enumerate(range(len(poses_tasks))):

            for weather in self.weathers:

                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                conditions = CarlaSettings()
                conditions.set(SendNonPlayerAgentsInfo=True,
                               NumberOfVehicles=vehicles,
                               NumberOfPedestrians=pedestrians,
                               WeatherId=weather)
                # Add all the cameras that were set for this experiments

                conditions.add_sensor(camera)

                experiment = Experiment()
                experiment.set(Conditions=conditions,
                               Poses=poses,
                               Task=iteration,
                               Repetitions=1)

                experiments_vector.append(experiment)

        return experiments_vector
    def build_experiments(self):
        """
        Creates the whole set of experiment objects,
        The experiments created depend on the selected Town.


        """

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('CameraRGB')
        camera.set(FOV=100)
        camera.set_image_size(800, 600)
        camera.set_position(2.0, 0.0, 1.4)
        camera.set_rotation(-15.0, 0, 0)
        if self._task == 'go-straight':
            task_select = 0
        elif self._task == 'turn-right':
            task_select = 1
        elif self._task == 'turn-left':
            task_select = 2
        elif self._task == 'go-straight-2':
            task_select = 3
        elif self._task == 'turn-right-2':
            task_select = 4
        elif self._task == 'turn-left-2':
            task_select = 5

        if self._city_name == 'Town01':
            poses_tasks = self._poses_town01()
            vehicles_tasks = [0, 0, 0, 20]
            pedestrians_tasks = [0, 0, 0, 50]
        elif self._city_name == 'Town02':
            poses_tasks = self._poses_town02()
            vehicles_tasks = [0, 0, 0, 20]
            pedestrians_tasks = [0, 0, 0, 50]
        elif self._city_name[:-1] == 'Town01_nemesis':
            poses_tasks = [self._poses_town01_nemesis()[task_select]]
            vehicles_tasks = [0, 0, 0, 0, 0, 0]
            pedestrians_tasks = [0, 0, 0, 0, 0, 0]
        elif self._city_name[:-1] == 'Town02_nemesis':
            poses_tasks = [self._poses_town02_nemesis()[task_select]]
            vehicles_tasks = [0, 0, 0, 0, 0, 0]
            pedestrians_tasks = [0, 0, 0, 0, 0, 0]

        experiments_vector = []
        """repeating experiment"""
        num_iters = self._iters
        weathers_iters = [self._weather] * num_iters

        # 0 - Default
        # 1 - ClearNoon
        # 2 - CloudyNoon
        # 3 - WetNoon
        # 4 - WetCloudyNoon
        # 5 - MidRainyNoon
        # 6 - HardRainNoon
        # 7 - SoftRainNoon
        # 8 - ClearSunset
        # 9 - CloudySunset
        # 10 - WetSunset
        # 11 - WetCloudySunset
        # 12 - MidRainSunset
        # 13 - HardRainSunset
        # 14 - SoftRainSunset

        for weather in weathers_iters:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                ## add here
                # random the scenario
                #weather_num_random = int(random.uniform(0,14))
                #vehicles_num_random = int(random.uniform(0,1000))
                #pedestrain_num_random = int(random.uniform(0,1000))
                #vehicles = vehicles_num_random
                #pedestrains = pedestrain_num_random
                #weather = weather_num_random
                vehicles = 400
                pedestrains = 400
                #weather =
                ##

                conditions = CarlaSettings()
                conditions.set(SendNonPlayerAgentsInfo=True,
                               NumberOfVehicles=vehicles,
                               NumberOfPedestrians=pedestrians,
                               WeatherId=weather)
                # Add all the cameras that were set for this experiments

                conditions.add_sensor(camera)

                experiment = Experiment()
                experiment.set(Conditions=conditions,
                               Poses=poses,
                               Task=iteration,
                               Repetitions=1)
                experiments_vector.append(experiment)

        return experiments_vector
Ejemplo n.º 11
0
    def build_experiments(self):
        """
            Creates the whole set of experiment objects,
            The experiments created depends on the selected Town.

        """

        # We check the town, based on that we define the town related parameters
        # The size of the vector is related to the number of tasks, inside each
        # task there is also multiple poses ( start end, positions )
        if self._city_name == 'Town01':
            #poses_tasks = [[[7, 3]], [[138, 17]], [[140, 134]], [[140, 134]]]
            poses_tasks = [[[138, 134]]]
            vehicles_tasks = [20]
            pedestrians_tasks = [10]
        else:
            right_curves = [[[1, 56], [65, 69], [78, 51], [44, 61], [40, 17],
                             [71, 16], [74, 38], [46, 12], [19, 18], [26, 74],
                             [37, 76], [11, 44], [20, 6], [10, 22], [28, 2],
                             [5, 15], [14, 33], [34, 8]]]
            left_curves = [[[57, 82], [72, 43], [52, 79], [70, 66], [43, 14],
                            [11, 47], [79, 32], [37, 75], [75, 16], [26, 73],
                            [39, 5], [2, 37], [34, 13], [6, 35], [10, 19],
                            [23, 6], [5, 30], [16, 2]]]
            special_test = [[[19, 66], [79, 14], [42, 13], [31, 71], [54, 30],
                             [10, 61], [66, 3], [27, 12], [2, 29], [16, 14],
                             [70, 73], [46, 67], [51, 81], [56, 65], [43, 54]]]
            corl_task2 = [[[19, 66], [79, 14], [19, 57], [23, 1], [53, 76],
                           [42, 13], [31, 71], [33, 5], [54, 30], [10, 61],
                           [66, 3], [27, 12], [79, 19], [2, 29], [16, 14],
                           [5, 57], [70, 73], [46, 67], [57, 50], [61, 49],
                           [21, 12], [51, 81], [77, 68], [56, 65], [43, 54]]]

            #poses_tasks = corl_task2
            poses_tasks = [[[10, 19]]]
            vehicles_tasks = [0]  #*len(poses_tasks[0])
            pedestrians_tasks = [0]  #*len(poses_tasks[0])

        # We set the camera
        # This single RGB camera is used on every experiment
        '''camera = Camera('CameraRGB')
        camera.set(FOV=90)
        camera.set_image_size(800, 600)
        camera.set_position(1.44, 0.0, 1.2)
        camera.set_rotation(0, 0, 0)'''

        camera0 = Camera('CameraRGB0')
        camera0.set(FOV=90)
        camera0.set_image_size(400, 300)
        camera0.set_position(1.7, 0.0, 1.3)
        camera0.set_rotation(0, 0, 0)

        camera1 = Camera('CameraRGB1')
        camera1.set(FOV=90)
        camera1.set_image_size(400, 300)
        camera1.set_position(1.7, 0.0, 1.3)
        camera1.set_rotation(0, -45, 0)

        camera2 = Camera('CameraRGB2')
        camera2.set(FOV=90)
        camera2.set_image_size(400, 300)
        camera2.set_position(1.7, 0.0, 1.3)
        camera2.set_rotation(0, +45, 0)

        # Based on the parameters, creates a vector with experiment objects.
        experiments_vector = []
        for weather in self.weathers:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                conditions = CarlaSettings()
                conditions.set(SendNonPlayerAgentsInfo=True,
                               NumberOfVehicles=vehicles,
                               NumberOfPedestrians=pedestrians,
                               WeatherId=weather)
                # Add all the cameras that were set for this experiments
                conditions.add_sensor(camera0)
                conditions.add_sensor(camera1)
                conditions.add_sensor(camera2)
                experiment = Experiment()
                experiment.set(Conditions=conditions,
                               Poses=poses,
                               Task=iteration,
                               Repetitions=1)
                experiments_vector.append(experiment)
            '''path0=os.listdir('CameraRGB0')
            path1=os.listdir('CameraRGB1')
            path2=os.listdir('CameraRGB2')
            os.mkdir('CameraRGB')

            width=400
            height=300

            total_width = width*3
            max_height = height

            i = 0
            images=[]
            images.append(Image.open('CameraRGB1/'+path1[i]))
            images.append(Image.open('CameraRGB0/'+path0[i]))
            images.append(Image.open('CameraRGB2/'+path2[i]))
            new_im = Image.new('RGB', (total_width, max_height))
            x_offset = 0
            for im in images:
                new_im.paste(im, (x_offset,0))
                x_offset += im.size[0]
                new_im.save('CameraRGB/'+path0[i])
            i = i+1'''

        return experiments_vector
Ejemplo n.º 12
0
    def build_experiments(self):
        """
        Creates the whole set of experiment objects,
        The experiments created depend on the selected Town.


        """

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('CameraRGB')
        camera.set(FOV=100)
        camera.set_image_size(800, 600)
        camera.set_position(2.0, 0.0, 1.4)
        camera.set_rotation(-15.0, 0, 0)

        if self._city_name == 'Town01':
            poses_tasks = self._poses_town01()
            vehicles_tasks = [0, 0, 0, 20]
            pedestrians_tasks = [0, 0, 0, 50]
        elif self._city_name == 'Town02':
            poses_tasks = self._poses_town02()
            vehicles_tasks = [0, 0, 0, 20]
            pedestrians_tasks = [0, 0, 0, 50]
        elif self._city_name == 'Town01_nemesis':
            poses_tasks = self._poses_town01_nemesis()
            vehicles_tasks = [0, 0, 0, 0]
            pedestrians_tasks = [0, 0, 0, 0]
        elif self._city_name == 'Town02_nemesis':
            poses_tasks = self._poses_town02_nemesis()
            vehicles_tasks = [0, 0, 0, 0]
            pedestrians_tasks = [0, 0, 0, 0]
        elif self._city_name == 'Town01_mini':
            poses_tasks = self._poses_town01_mini()
            vehicles_tasks = [0, 0, 0, 0]
            pedestrians_tasks = [0, 0, 0, 0]

        experiments_vector = []
        """repeating experiment"""
        num_iters = 171
        weathers_iters = [1] * num_iters

        for weather in weathers_iters:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                conditions = CarlaSettings()
                conditions.set(SendNonPlayerAgentsInfo=True,
                               NumberOfVehicles=vehicles,
                               NumberOfPedestrians=pedestrians,
                               WeatherId=weather)
                # Add all the cameras that were set for this experiments

                conditions.add_sensor(camera)

                experiment = Experiment()
                experiment.set(Conditions=conditions,
                               Poses=poses,
                               Task=iteration,
                               Repetitions=1)
                experiments_vector.append(experiment)

        return experiments_vector
Ejemplo n.º 13
0
    def build_experiments(self):
        """
            Creates the whole set of experiment objects,
            The experiments created depends on the selected Town.

        """

        # We check the town, based on that we define the town related parameters
        # The size of the vector is related to the number of tasks, inside each
        # task there is also multiple poses ( start end, positions )
        if self._city_name == 'Town01':
            poses_tasks = [[[7, 3]], [[138, 17]], [[140, 134]], [[140, 134]]]
            vehicles_tasks = [0, 0, 0, 20]
            pedestrians_tasks = [0, 0, 0, 50]
        else:
            right_curves =  [[[1,56],[65,69],[78,51],[44,61],[40,17],[71,16],[74,38],[46,12],
                              [19,18],[26,74],[37,76],[11,44],[20,6],[10,22],[28,2],[5,15],
                              [14,33],[34,8]]]      
            left_curves =  [[[57,82],[72,43],[52,79],[70,66],[43,14],[11,47],[79,32],[37,75],
                             [75,16],[26,73],[39,5],[2,37],[34,13],[6,35],[10,19],[23,6],
                             [5,30],[16,2]]] 
            special_test = [[[19, 66], [79, 14],[42, 13], [31, 71], 
                             [54, 30], [10, 61], [66, 3], [27, 12],
                             [2, 29], [16, 14],[70, 73], [46, 67],
                             [51, 81], [56, 65], [43, 54]]]
            corl_task2 = [[[19, 66], [79, 14], [19, 57], [23, 1],
                    [53, 76], [42, 13], [31, 71], [33, 5],
                    [54, 30], [10, 61], [66, 3], [27, 12],
                    [79, 19], [2, 29], [16, 14], [5, 57],
                    [70, 73], [46, 67], [57, 50], [61, 49], [21, 12],
                    [51, 81], [77, 68], [56, 65], [43, 54]]]

            poses_tasks = corl_task2
            vehicles_tasks = [0]*len(poses_tasks[0])
            pedestrians_tasks = [0]*len(poses_tasks[0])

        # We set the camera
        # This single RGB camera is used on every experiment

        camera = Camera('CameraRGB')
        camera.set(FOV=90)
        camera.set_image_size(800, 600)
        camera.set_position(1.44, 0.0, 1.2)
        camera.set_rotation(0, 0, 0)

        # Based on the parameters, creates a vector with experiment objects.
        experiments_vector = []
        for weather in self.weathers:

            for iteration in range(len(poses_tasks)):
                poses = poses_tasks[iteration]
                vehicles = vehicles_tasks[iteration]
                pedestrians = pedestrians_tasks[iteration]

                conditions = CarlaSettings()
                conditions.set(
                    SendNonPlayerAgentsInfo=True,
                    NumberOfVehicles=vehicles,
                    NumberOfPedestrians=pedestrians,
                    WeatherId=weather

                )
                # Add all the cameras that were set for this experiments
                conditions.add_sensor(camera)
                experiment = Experiment()
                experiment.set(
                    Conditions=conditions,
                    Poses=poses,
                    Task=iteration,
                    Repetitions=1
                )
                experiments_vector.append(experiment)

        return experiments_vector