Exemple #1
0
 def relaunch(self):
     self.comm.close()
     self.comm = comm_unity.UnityCommunication(port=str(self.port_number),
                                               **self.executable_args)
Exemple #2
0
    def __init__(self,
                 num_agents=2,
                 max_episode_length=200,
                 observation_types=None,
                 use_editor=False,
                 base_port=8080,
                 port_id=0,
                 executable_args={},
                 recording_options={
                     'recording': False,
                     'output_folder': None,
                     'file_name_prefix': None,
                     'cameras': 'PERSON_FROM_BACK',
                     'modality': 'normal'
                 },
                 seed=123):

        self.seed = seed
        self.prev_reward = 0.
        self.rnd = random.Random(seed)
        np.random.seed(seed)

        self.steps = 0
        self.env_id = None
        self.max_ids = {}

        self.num_agents = num_agents
        self.max_episode_length = max_episode_length
        self.actions_available = [
            'turnleft', 'walkforward', 'turnright', 'walktowards', 'open',
            'close', 'put', 'grab', 'no_action'
        ]

        self.recording_options = recording_options
        self.base_port = base_port
        self.port_id = port_id
        self.executable_args = executable_args

        # Observation parameters
        self.num_camera_per_agent = 6
        self.CAMERA_NUM = 1  # 0 TOP, 1 FRONT, 2 LEFT..
        self.default_image_width = 300
        self.default_image_height = 300

        if observation_types is not None:
            self.observation_types = observation_types
        else:
            self.observation_types = ['partial' for _ in range(num_agents)]

        self.agent_info = {0: 'Chars/Female1', 1: 'Chars/Male1'}

        self.changed_graph = True
        self.rooms = None
        self.id2node = None
        self.num_static_cameras = None

        if use_editor:
            # Use Unity Editor
            self.port_number = 8080
            self.comm = comm_unity.UnityCommunication()
        else:
            # Launch the executable
            self.port_number = self.base_port + port_id
            # ipdb.set_trace()
            self.comm = comm_unity.UnityCommunication(port=str(
                self.port_number),
                                                      **self.executable_args)

        atexit.register(self.close)
        self.reset()