Пример #1
0
def create_ai2thor_env(x_display=constants.X_DISPLAY,
                       quality='MediumCloseFitShadows',
                       player_screen_height=constants.SCREEN_HEIGHT,
                       player_screen_width=constants.SCREEN_WIDTH):
    print('Creating env')

    if platform.system() == "Linux":
        unity_app_file_path = unity_app_file_path_linux
    elif platform.system() == "Darwin":
        unity_app_file_path = unity_app_file_path_mac
    else:
        app = None
    #unity_app_file_path = "/Users/rajesh/Rajesh/Subjects/Research/aiThor/mcs_playroom_old/algorithms/a3c/gym_ai2thor/MCSai2thor.app/Contents/MacOS/MCSai2thor"

    env = controller.Controller(
        quality='Medium',
        fullscreen=False,
        # The headless flag does not work for me
        headless=False,
        local_executable_path=unity_app_file_path,
        width=player_screen_width,
        height=player_screen_height,
        # Set the name of our Scene in our Unity app
        scene='MCS',
        logs=True,
        #quiality=quality,
        # This constructor always initializes a scene, so add a scene config to ensure it doesn't error
        sceneConfig={"objects": []})

    return env
Пример #2
0
def create_env(x_display=constants.X_DISPLAY,
               quality='MediumCloseFitShadows',
               player_screen_height=constants.SCREEN_HEIGHT,
               player_screen_width=constants.SCREEN_WIDTH):
    print('Creating env')

    if platform.system() == "Linux":
        unity_app_file_path = unity_app_file_path_linux
    elif platform.system() == "Darwin":
        unity_app_file_path = unity_app_file_path_mac
    else:
        app = None

    if RUN_MCS != 1:
        env = controller.Controller(quality=quality)
        env.start(x_display=x_display,
                  player_screen_height=player_screen_height,
                  player_screen_width=player_screen_width)

    else:
        #unity_app_file_path = "/home/rajesh/rajesh/mcs_data/MCS-AI2-THOR-Unity-App-v0.0.6.x86_64"
        #unity_app_file_path = "/Users/rajesh/Rajesh/Subjects/Research/aiThor/mcs_playroom_old/algorithms/a3c/gym_ai2thor/MCSai2thor.app/Contents/MacOS/MCSai2thor"
        '''
        env = controller.Controller(
                quality='Medium',
                fullscreen=False,
                # The headless flag does not work for me
                headless=False,
                local_executable_path=unity_app_file_path,
                width=player_screen_width,
                height=player_screen_height,
                # Set the name of our Scene in our Unity app
                scene='MCS',
                logs=True,
                #quiality=quality,
                # This constructor always initializes a scene, so add a scene config to ensure it doesn't error
                sceneConfig={
                    "objects": []
                }
            )
        '''
        #env = machine_common_sense.MCS_Controller_AI2THOR(
        env = machine_common_sense.MCS_Controller_AI2THOR(unity_app_file_path)

        #                 "/Users/rajesh/Rajesh/Subjects/Research/aiThor/mcs_playroom_old/algorithms/a3c/gym_ai2thor/MCSai2thor.app/Contents/MacOS/MCSai2thor")
    #env.start(x_display=x_display)

    print(
        'Starting env, if this takes more than a few seconds (except for downloading the build), the display is not set correctly'
    )

    print('Done starting env')
    print("type of env", type(env))
    return env
Пример #3
0
def create_env(x_display=constants.X_DISPLAY,
               quality='MediumCloseFitShadows',
               player_screen_height=constants.SCREEN_HEIGHT,
               player_screen_width=constants.SCREEN_WIDTH):
    print('Creating env')
    env = controller.Controller(quality=quality)
    print('Starting env, if this takes more than a few seconds (except for downloading the build), the display is not set correctly')
    env.start(x_display=x_display,
              player_screen_height=player_screen_height,
              player_screen_width=player_screen_width)
    print('Done starting env')
    return env
Пример #4
0
"""
Runs the AI2THOR controller, and stores a list of all the objects present.

Returns
thor_v1_objects.txt - the file containing the list of all objects in iThor
"""

from ai2thor import controller
controller = controller.Controller()
controller.start()

rooms = [['Kitchen', 0], ['Living_Room', 200], ['Bedroom', 300],
         ['Bathroom', 400]]
obj_ls = []
for k in range(len(rooms)):  #len(rooms)
    room = rooms[k][0]
    room_ind = rooms[k][1]
    for i in range(30):  #for each scene
        controller.reset('FloorPlan' + str(1 + i + room_ind))
        event = controller.step(dict(action='Initialize'))
        n = len(event.metadata["objects"])
        lst = []
        for j in range(n):  #for each object
            obj = event.metadata["objects"][j]['objectType']
            if obj not in obj_ls:
                obj_ls.append(obj)

f = open("kg_prep/kg_data/thor_v1_objects.txt", "w+")
for i in range(len(obj_ls) - 1):
    f.write(sorted(obj_ls)[i] + '\n')
f.write(sorted(obj_ls)[-1])