Example #1
0
File: cexp.py Project: PDillis/cexp
    def start(self, no_server=False, agent_name=None):
        """
        :param no_server:
        :param agent_name: the name of an agent to check for previous executions.
        :return:
        """
        # TODO: this setup is hardcoded for Batch_size == 1
        # TODO add here several server starts into a for
        # TODO for i in range(self._batch_size)
        logging.debug("Starting the CEXP System !")
        if agent_name is not None and not self.ignore_previous_execution:
            Environment.check_for_executions(agent_name,
                                             self._json['package_name'])
        if no_server:
            self._client_vec = []
        else:
            if self._port is None:
                # Starting the carla simulators
                for env in self._environment_batch:
                    free_port = find_free_port()
                    env.reset(port=free_port)
            else:
                # We convert it to integers
                self._port = int(self._port)
                if not check_test_server(self._port):
                    logging.debug("No Server online starting one !")
                    self._environment_batch[0].reset(port=self._port)
                free_port = self._port  # This is just a test mode where CARLA is already up.
            # setup world and client assuming that the CARLA server is up and running
            logging.debug(" Connecting to the free port client")
            self._client_vec = [carla.Client('localhost', free_port)]
            self._client_vec[0].set_timeout(self.client_timeout)

        # Create the configuration dictionary of the exp batch to pass to all environments
        env_params = {
            'batch_size':
            self._batch_size,
            'make_videos':
            self._params['make_videos'],
            'resize_images':
            self._params['resize_images'],
            'save_dataset':
            self._params['save_dataset'],
            'save_sensors':
            self._params['save_dataset'] and self._params['save_sensors'],
            'save_opponents':
            self._params['save_opponents'],
            'package_name':
            self._json['package_name'],
            'save_walkers':
            self._params['save_walkers'],
            'save_trajectories':
            self._params['save_trajectories'],
            'remove_wrong_data':
            self._params['remove_wrong_data'],
            'non_rendering_mode':
            self._params['non_rendering_mode'],
            'carla_recording':
            self._params['carla_recording'],
            'direct_read':
            self._params['direct_read'],
            'agent_name':
            agent_name,
            'trajectories_directory':
            self._params['trajectories_directory'],
            'debug':
            False  # DEBUG SHOULD BE SET
        }

        # We instantiate environments here using the recently connected client
        self._environments = {}
        parserd_exp_dict = parser.parse_exp_vec(
            self._jsonfile_path,
            collections.OrderedDict(
                sort_nicely_dict(self._json['envs'].items())))

        # For all the environments on the file.
        for env_name in self._json['envs'].keys():
            # We have the options to eliminate some events from execution.
            if env_name in self._eliminated_environments:
                continue
            # Instance an _environments.
            env = Environment(env_name, self._client_vec,
                              parserd_exp_dict[env_name], env_params)
            # add the additional sensors ( The ones not provided by the policy )
            self._environments.update({env_name: env})
Example #2
0


if __name__ == '__main__':

    description = ("CARLA AD Challenge evaluation: evaluate your Agent in CARLA scenarios\n")

    parser = argparse.ArgumentParser(description=description)

    parser.add_argument('-t', '--town', default='Town01', help='The town name to be used')

    parser.add_argument('-o', '--output', default='routes_test.xml', help='The outputfile route')

    arguments = parser.parse_args()


    port = find_free_port()
    print(port)

    #if not check_test_server(6666):
    #    start_test_server(6666)
    #    print (" WAITING FOR DOCKER TO BE STARTED")


    client = carla.Client('localhost', port)
    client.set_timeout(25.0)

    world = client.load_world(arguments.town)

    make_routes(arguments.output, world)