diff --git a/ai2thor/build.py b/ai2thor/build.py index 7f33219977..bbd2f1ab39 100644 --- a/ai2thor/build.py +++ b/ai2thor/build.py @@ -22,7 +22,7 @@ TEST_OUTPUT_DIRECTORY = "../../images-debug" LOCAL_BUILD_COMMIT_ID = "local" -AUTO_BUILD_PLATFORMS = [CloudRendering, Linux64, OSXIntel64] +AUTO_BUILD_PLATFORMS = [CloudRendering, OSXIntel64] COMMIT_ID = None try: diff --git a/ai2thor/controller.py b/ai2thor/controller.py index 4daeea2fe0..8f64bc7b71 100644 --- a/ai2thor/controller.py +++ b/ai2thor/controller.py @@ -1460,7 +1460,7 @@ def find_platform_builds( commit_build = ai2thor.build.Build( plat, commit_id, self.include_private_scenes, releases_dir ) - + print(f"commit_build base_dir: {commit_build.base_dir}") try: if os.path.isdir(commit_build.base_dir) or ( not local_build and commit_build.exists() diff --git a/ai2thor/hooks/procedural_asset_hook.py b/ai2thor/hooks/procedural_asset_hook.py index f5006bbbb3..6aee37f609 100644 --- a/ai2thor/hooks/procedural_asset_hook.py +++ b/ai2thor/hooks/procedural_asset_hook.py @@ -9,12 +9,27 @@ import logging import os import warnings +import pathlib + from typing import Dict, Any, List -from objathor.asset_conversion.util import create_asset, get_existing_thor_asset_file_path +from objathor.asset_conversion.util import ( + get_existing_thor_asset_file_path, + create_runtime_asset_file, + get_existing_thor_asset_file_path, + change_asset_paths, + add_default_annotations, + load_existing_thor_asset_file +) logger = logging.getLogger(__name__) +EXTENSIONS_LOADABLE_IN_UNITY = { + ".json", + ".json.gz", + ".msgpack", + ".msgpack.gz", +} def get_all_asset_ids_recursively( objects: List[Dict[str, Any]], asset_ids: List[str] @@ -31,6 +46,143 @@ def get_all_asset_ids_recursively( assets_set.remove("") return list(assets_set) +def create_asset( + thor_controller, + asset_id, + asset_directory, + copy_to_dir=None, + verbose=False, + load_file_in_unity=False, + extension=None, + raise_for_failure=True, + fail_if_not_unity_loadable=False +): + return create_assets( + thor_controller=thor_controller, + asset_ids=[asset_id], + assets_dir=asset_directory, + copy_to_dir=copy_to_dir, + verbose=verbose, + load_file_in_unity=load_file_in_unity, + extension=extension, + fail_if_not_unity_loadable=fail_if_not_unity_loadable, + raise_for_failure=raise_for_failure, + ) + +def create_assets( + thor_controller: Any, + asset_ids: List[str], + assets_dir: str, + copy_to_dir=None, + verbose=False, + load_file_in_unity=False, + extension=None, + fail_if_not_unity_loadable=False, + raise_for_failure=True, +): + copy_to_dir = ( + os.path.join(thor_controller._build.base_dir) + if copy_to_dir is None + else copy_to_dir + ) + + multi_create_unity_loadable = dict( + action="CreateRuntimeAssets", + assets=[], + dir=copy_to_dir, + raise_for_failure=raise_for_failure, + ) + + create_with_data_actions = [] + errors = [] + + for asset_id in asset_ids: + asset_dir = os.path.join(assets_dir, asset_id) + # Verifies the file exists + asset_path = get_existing_thor_asset_file_path( + out_dir=asset_dir, asset_id=asset_id, force_extension=extension + ) + file_extension = ( + "".join(pathlib.Path(asset_path).suffixes) if extension is None else extension + ) + load_asset_in_unity = load_file_in_unity + + if file_extension not in EXTENSIONS_LOADABLE_IN_UNITY: + load_asset_in_unity = False + if fail_if_not_unity_loadable: + errors.append(asset_path) + continue + + # save_dir = os.path.join(controller._build.base_dir, "processed_models") + os.makedirs(copy_to_dir, exist_ok=True) + + if verbose: + logger.info(f"Copying asset to THOR build dir: {copy_to_dir}.") + + asset = create_runtime_asset_file( + asset_directory=asset_dir, + save_dir=copy_to_dir, + asset_id=asset_id, + load_file_in_unity=load_asset_in_unity, + verbose=verbose + ) + + if not load_asset_in_unity: + # TODO refactor to this when objathor changes + # asset = load_existing_thor_asset_file( + # out_dir=asset_target_dir, object_name=asset_id, force_extension=file_extension + # ) + asset = change_asset_paths(asset=asset, save_dir=copy_to_dir) + asset = add_default_annotations( + asset=asset, asset_directory=asset_dir, verbose=verbose + ) + create_prefab_action = { + "action": "CreateRuntimeAsset", + "asset": asset, + "raise_for_failure": raise_for_failure, + } + create_with_data_actions.append(create_prefab_action) + else: + asset_args = { + "id": asset_id, + "extension": file_extension, + } + asset_args = add_default_annotations( + asset=asset_args, asset_directory=asset_dir, verbose=verbose + ) + multi_create_unity_loadable["assets"].append( + asset_args + ) + + if fail_if_not_unity_loadable: + error_strs = ', '.join(errors) + extensions = ', '.join(EXTENSIONS_LOADABLE_IN_UNITY) + raise RuntimeError(f"Set to fail if files are not loadable in unity. Invalid extension of files `{error_strs}` must be of any of extensions {extensions}") + + events = [] + # Slow pass asset data to pipe + if len(create_with_data_actions): + for create_asset_action in create_with_data_actions: + evt = thor_controller.step(**create_asset_action) + events.append(evt) + if verbose: + logger.info(f"Last Action: {thor_controller.last_action['action']}") + + if len(multi_create_unity_loadable): + evt = thor_controller.step(**multi_create_unity_loadable) + events.append(evt) + if verbose: + logger.debug(f"Last Action: {thor_controller.last_action['action']}") + + for evt in events: + if not evt.metadata["lastActionSuccess"]: + logger.error( + f'Error: {evt.metadata["errorMessage"]}' + f"\nLast Action: {thor_controller.last_action['action']}" + f"\nAction success: {evt.metadata['lastActionSuccess']}" + ) + return events + def create_assets_if_not_exist( controller, @@ -43,6 +195,7 @@ def create_assets_if_not_exist( extension=None, verbose=False, raise_for_failure=True, + fail_if_not_unity_loadable=False ): evt = controller.step( action="AssetsInDatabase", assetIds=asset_ids, updateProceduralLRUCache=True @@ -52,27 +205,50 @@ def create_assets_if_not_exist( assets_not_created = [ asset_id for (asset_id, in_db) in asset_in_db.items() if not in_db ] - for asset_id in assets_not_created: - asset_dir = os.path.abspath(os.path.join(asset_directory, asset_id)) - # print(f"Create {asset_id}") - evt = create_asset( - thor_controller=controller, - asset_id=asset_id, - asset_directory=asset_dir, - copy_to_dir=copy_to_dir, - verbose=verbose, - load_file_in_unity=load_file_in_unity, - extension=None, - # raise_for_failure=raise_for_failure, - ) + + events = create_assets( + thor_controller=controller, + asset_ids=assets_not_created, + assets_dir=asset_directory, + copy_to_dir=copy_to_dir, + verbose=verbose, + load_file_in_unity=load_file_in_unity, + extension=extension, + fail_if_not_unity_loadable=fail_if_not_unity_loadable + ) + for (evt, i) in zip(events, range(len(events))) : if not evt.metadata["lastActionSuccess"]: + # TODO do a better matching of asset_ids and event + asset_id = assets_not_created[i] if i < len(events) else None + asset_path = get_existing_thor_asset_file_path(out_dir=asset_directory, asset_id=asset_id) if asset_id is not None else "" warnings.warn( - f"Could not create asset `{get_existing_thor_asset_file_path(out_dir=asset_dir, asset_id=asset_id)}`." + f"Could not create asset `{asset_path}`." f"\nError: {evt.metadata['errorMessage']}" ) - if stop_if_fail: - return evt - return evt + return events[-1] + + # slower + # for asset_id in assets_not_created: + # asset_dir = os.path.abspath(os.path.join(asset_directory, asset_id)) + # # print(f"Create {asset_id}") + # evt = create_asset( + # thor_controller=controller, + # asset_id=asset_id, + # asset_directory=asset_dir, + # copy_to_dir=copy_to_dir, + # verbose=verbose, + # load_file_in_unity=load_file_in_unity, + # extension=None, + # # raise_for_failure=raise_for_failure, + # ) + # if not evt.metadata["lastActionSuccess"]: + # warnings.warn( + # f"Could not create asset `{get_existing_thor_asset_file_path(out_dir=asset_dir, asset_id=asset_id)}`." + # f"\nError: {evt.metadata['errorMessage']}" + # ) + # if stop_if_fail: + # return evt + class ProceduralAssetHookRunner: diff --git a/ai2thor/platform.py b/ai2thor/platform.py index 6cf55bc7f8..8794423e13 100644 --- a/ai2thor/platform.py +++ b/ai2thor/platform.py @@ -226,7 +226,7 @@ def executable_path(cls, base_dir, name): def select_platforms(request): candidates = [] - system_platform_map = dict(Linux=(Linux64,), Darwin=(OSXIntel64,), Windows=(StandaloneWindows64,)) + system_platform_map = dict(Linux=(Linux64,CloudRendering), Darwin=(OSXIntel64,), Windows=(StandaloneWindows64,)) for p in system_platform_map.get(request.system, ()): if not p.enabled: continue diff --git a/ai2thor/tests/build_controller.py b/ai2thor/tests/build_controller.py index d1aa1184b3..2e410adc22 100644 --- a/ai2thor/tests/build_controller.py +++ b/ai2thor/tests/build_controller.py @@ -1,17 +1,31 @@ import warnings +import os from ai2thor.controller import Controller class TestController(Controller): + def __init__(self, **kwargs): + self.force_opengl = os.environ.get("FORCE_OPENGL", False) + if type(self.force_opengl) != bool or self.force_opengl != False: + self.force_opengl = self.force_opengl.lower() in ("true", "1", "t") + super().__init__(**kwargs) + def unity_command(self, width, height, headless): command = super().unity_command(width, height, headless) # force OpenGLCore to get used so that the tests run in a consistent way # With low power graphics cards (such as those in the test environment) # Metal behaves in inconsistent ways causing test failures - command.append("-force-glcore") + + # This is not needed for cloudrendering + if self.force_opengl: + command.append("-force-glcore") return command def build_controller(**args): - default_args = dict(local_build=True) + platform = os.environ.get("TEST_PLATFORM") + if platform: + default_args = dict(platform=platform) + else: + default_args = dict(local_build=True) default_args.update(args) # during a ci-build we will get a warning that we are using a commit_id for the diff --git a/ai2thor/tests/data/arm/new/pickup_object.json b/ai2thor/tests/data/arm/new/pickup_object.json new file mode 100644 index 0000000000..e908990158 --- /dev/null +++ b/ai2thor/tests/data/arm/new/pickup_object.json @@ -0,0 +1,184 @@ +[ + {"action": "TeleportFull", "standing": true, "x": 12.5, "y": 0.9009921550750732, "z": 2.5, "rotation": {"x": 0, "y": {"x": -0.0, "y": 90.0, "z": 0.0}, "z": 0}, "horizon": 20}, + {"action": "RotateAgent", "degrees": -30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": 30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveAgent", "ahead": 0.2, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -30, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -6.0, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -6.0, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateAgent", "degrees": -6.0, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.1500000238418579, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.20000003576278685, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.2500000476837158, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.30000005960464476, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.3500000715255737, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.4000000834465027, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.45000009536743163, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.5000001072883606, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.5500001192092896, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.6000001311302186, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.6500001430511475, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.7000001549720765, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.7500001668930054, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.8000001192092896, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.8500000715255738, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.900000023841858, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.8999999761581421, "z": 0.04993938207626343}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.19316303730011e-05, "y": 0.8999999761581421, "z": 0.09987889528274536}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.212534546852112e-05, "y": 0.8999999761581421, "z": 0.14981855750083922}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.228180766105652e-05, "y": 0.8999999761581421, "z": 0.1997581899166107}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.196888327598572e-05, "y": 0.8999999761581421, "z": 0.24969773292541503}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.216259837150574e-05, "y": 0.8999999761581421, "z": 0.29963727593421935}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.183477282524109e-05, "y": 0.8999999761581421, "z": 0.34957690834999083}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.201358675956726e-05, "y": 0.8999999761581421, "z": 0.3995166003704071}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.216259837150574e-05, "y": 0.8999999761581421, "z": 0.4494561731815338}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.183477282524109e-05, "y": 0.8999999761581421, "z": 0.4993958055973053}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.204338908195496e-05, "y": 0.8999999761581421, "z": 0.5493356168270112}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.210299372673035e-05, "y": 0.8999999761581421, "z": 0.5992755174636841}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.216259837150574e-05, "y": 0.8999999761581421, "z": 0.6492153882980347}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.198378443717957e-05, "y": 0.8999999761581421, "z": 0.6991552591323853}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.204338908195496e-05, "y": 0.8999999761581421, "z": 0.749095368385315}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.210299372673035e-05, "y": 0.8999999761581421, "z": 0.7990354776382447}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 0.8999999761581421, "z": 0.8489755868911744}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.8999999761581421, "z": 0.8564396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 0.849999976158142, "z": 0.8064396381378174}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.219240069389343e-05, "y": 0.8000000238418579, "z": 0.8063795566558838}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 0.7500000715255737, "z": 0.8063197135925293}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "PickupObject"}, + {"action": "MoveArm", "position": {"x": -7.207319140434265e-05, "y": 0.8000001192092896, "z": 0.8062597513198853}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.219240069389343e-05, "y": 0.8500000715255738, "z": 0.8061997890472412}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 0.900000023841858, "z": 0.8061399459838867}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.207319140434265e-05, "y": 0.9499999761581421, "z": 0.8060799837112427}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.219240069389343e-05, "y": 0.9999999284744263, "z": 0.8060200214385986}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.219240069389343e-05, "y": 1.0499998807907105, "z": 0.805959939956665}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 1.0949999570846558, "z": 0.8058998584747314}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 1.0949999570846558, "z": 0.8058398962020874}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.201358675956726e-05, "y": 1.0949999570846558, "z": 0.8057800531387329}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 1.0949999570846558, "z": 0.8057200908660889}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.201358675956726e-05, "y": 1.0949999570846558, "z": 0.8056603670120239}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 1.0949999570846558, "z": 0.8056005239486694}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 1.0949999570846558, "z": 0.8055405616760254}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 1.0949999570846558, "z": 0.8054807186126709}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 1.0949999570846558, "z": 0.8054207563400269}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.207319140434265e-05, "y": 1.0949999570846558, "z": 0.8053606748580933}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.207319140434265e-05, "y": 1.0949999570846558, "z": 0.8053005933761597}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.225200533866882e-05, "y": 1.0949999570846558, "z": 0.8052407503128052}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.219240069389343e-05, "y": 1.0949999570846558, "z": 0.805180549621582}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 1.0949999570846558, "z": 0.8051207065582275}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.207319140434265e-05, "y": 1.0449999570846558, "z": 0.7550607442855835}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.213279604911804e-05, "y": 1.0449999570846558, "z": 0.7050009489059448}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.216259837150574e-05, "y": 1.0449999570846558, "z": 0.6549410343170166}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.201358675956726e-05, "y": 1.0449999570846558, "z": 0.6048810005187988}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.231160998344421e-05, "y": 1.0449999570846558, "z": 0.5548210859298706}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "MoveArm", "position": {"x": -7.216259837150574e-05, "y": 1.0449999570846558, "z": 0.5047609329223632}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1} +] diff --git a/ai2thor/tests/data/arm/pickup_object.json b/ai2thor/tests/data/arm/pickup_object.json index 1bd0e90bb0..2936b99cc3 100644 --- a/ai2thor/tests/data/arm/pickup_object.json +++ b/ai2thor/tests/data/arm/pickup_object.json @@ -107,24 +107,24 @@ {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.8000001192092896, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.8500000715255738, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.900000023841858, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.8999999761581421, "z": 0.04993938207626343}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.19316303730011e-05, "y": 0.8999999761581421, "z": 0.09987889528274536}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.212534546852112e-05, "y": 0.8999999761581421, "z": 0.14981855750083922}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, diff --git a/ai2thor/tests/data/arm/pickup_plate_before_intersect.json b/ai2thor/tests/data/arm/pickup_plate_before_intersect.json index c953779dcd..83c665b069 100644 --- a/ai2thor/tests/data/arm/pickup_plate_before_intersect.json +++ b/ai2thor/tests/data/arm/pickup_plate_before_intersect.json @@ -107,24 +107,24 @@ {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.8000001192092896, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.8500000715255738, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.900000023841858, "z": -6.0617923736572266e-05}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 0.8999999761581421, "z": 0.04993938207626343}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.19316303730011e-05, "y": 0.8999999761581421, "z": 0.09987889528274536}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.212534546852112e-05, "y": 0.8999999761581421, "z": 0.14981855750083922}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, @@ -199,20 +199,20 @@ {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 1.0449999570846558, "z": -0.050060617923736575}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 1.0449999570846558, "z": -0.050060617923736575}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, {"action": "MoveArm", "position": {"x": -7.222592830657959e-05, "y": 1.0449999570846558, "z": -0.050060617923736575}, "physicsSimulationParams": {"autoSimulation": false}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, - {"action": "RotateWristRelative", "yaw": 10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1} + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1}, + {"action": "RotateWristRelative", "yaw": -10, "physicsSimulationParams": {"autoSimulation": true}, "returnToStart": true, "speed": 1} ] diff --git a/ai2thor/tests/test_arm.py b/ai2thor/tests/test_arm.py index 19db1def62..4137f02fa2 100644 --- a/ai2thor/tests/test_arm.py +++ b/ai2thor/tests/test_arm.py @@ -130,17 +130,27 @@ def test_arm_body_object_intersect(controller_args): prev_event = run(controller, "pickup_plate_before_intersect.json") + assert evt.metadata["lastActionSuccess"] + evt = controller.step(** {"action": "RotateWristRelative", - "yaw": 10, + "yaw": -10, "physicsSimulationParams": {"autoSimulation": False}, "returnToStart": True, "speed": 1 } ) + print( + "Action success {0}, message {1}".format( + evt.metadata["lastActionSuccess"], evt.metadata["errorMessage"] + ) + ) + assert not evt.metadata["lastActionSuccess"] + assert "Collided with static structure" in evt.metadata["errorMessage"] + controller.stop() diff = DeepDiff(evt.metadata['arm'], prev_event.metadata['arm'], significant_digits=2, ignore_numeric_type_changes=True) diff --git a/ai2thor/tests/test_unity.py b/ai2thor/tests/test_unity.py index eb4bfddce9..2fdad8ac8f 100644 --- a/ai2thor/tests/test_unity.py +++ b/ai2thor/tests/test_unity.py @@ -26,6 +26,8 @@ import functools import ctypes +from .build_controller import build_controller + # Defining const classes to lessen the possibility of a misspelled key class Actions: AddThirdPartyCamera = "AddThirdPartyCamera" @@ -41,33 +43,8 @@ class ThirdPartyCameraMetadata: rotation = "rotation" fieldOfView = "fieldOfView" - -class TestController(Controller): - def unity_command(self, width, height, headless): - command = super().unity_command(width, height, headless) - # force OpenGLCore to get used so that the tests run in a consistent way - # With low power graphics cards (such as those in the test environment) - # Metal behaves in inconsistent ways causing test failures - command.append("-force-glcore") - return command - -def build_controller(**args): - default_args = dict(scene=TEST_SCENE, local_build=True) - default_args.update(args) - # during a ci-build we will get a warning that we are using a commit_id for the - # build instead of 'local' - with warnings.catch_warnings(): - warnings.simplefilter("ignore") - print("args test controller") - print(default_args) - c = TestController(**default_args) - - # used for resetting - c._original_initialization_parameters = c.initialization_parameters - return c - -_wsgi_controller = build_controller(server_class=WsgiServer) -_fifo_controller = build_controller(server_class=FifoServer) +_wsgi_controller = build_controller(server_class=WsgiServer, scene=TEST_SCENE) +_fifo_controller = build_controller(server_class=FifoServer, scene=TEST_SCENE) def skip_reset(controller): @@ -2374,7 +2351,7 @@ def test_settle_physics(): diffs = [] last_objs = {o['objectId']: o for o in fifo_controller.last_event.metadata["objects"]} for object_id, object_metadata in first_objs.items(): - for d in (diff(object_metadata, last_objs.get(object_id, {}), tolerance=0.00001, ignore=set(["receptacleObjectIds"]))): + for d in (diff(object_metadata, last_objs.get(object_id, {}), absolute_tolerance=0.001, ignore=set(["receptacleObjectIds"]))): diffs.append((object_id, d)) assert diffs == [] diff --git a/scripts/test_controllers.py b/scripts/test_controllers.py deleted file mode 100755 index df5abed05a..0000000000 --- a/scripts/test_controllers.py +++ /dev/null @@ -1,33 +0,0 @@ -import ai2thor.controller -import ai2thor.robot_controller -import random -import time -import numpy as np -from pprint import pprint - -fps = ["FloorPlan311"] - -runs = [ - {"id": "unity", "port": 8200, "controller": ai2thor.controller.Controller()}, - {"id": "robot", "port": 9200, "controller": ai2thor.robot_controller.Controller()} - # {'id': 'robot', 'port': 9000, 'controller': ai2thor.robot_controller.Controller()} -] - -for run_config in runs: - port = run_config["port"] - controller = run_config["controller"] - event = controller.start(start_unity=False, host="127.0.0.1", port=port) - # event = controller.step({'action': 'ChangeQuality', 'quality': 'High'}) - # event = controller.step({"action": "ChangeResolution", "x": 300, "y": 300}) - - for fp in fps: - print(fp) - for i in range(1): - event = controller.reset(fp) - # event = controller.step(dict(action='Initialize', gridSize=0.25, fieldOfView=90, renderInstanceSegmentation=True)) - # event = controller.step(dict(action='InitialRandomSpawn', forceVisible=True, maxNumRepeats=10, randomSeed=1)) - # event = controller.step(dict(action='MoveAhead', noise=0.02)) - event = controller.step(dict(action="RotateLeft")) - print("event for '{}':".format(run_config["id"])) - pprint(event.metadata) - time.sleep(1) diff --git a/scripts/test_msg.py b/scripts/test_msg.py deleted file mode 100644 index 2de963408b..0000000000 --- a/scripts/test_msg.py +++ /dev/null @@ -1,33 +0,0 @@ -import json -import msgpack -import gzip -import os - -root_dir = "./objaverse" - -id = "b8d24c146a6844788c0ba6f7b135e99e" - -path = os.path.join(root_dir, id, id + '.json') -out_p = os.path.join(root_dir, id, id + '.msgpack') -out_msg_gz = f"{out_p}.gz" - - -with open(path, "r") as f: - obj = json.load(f) - v = obj['vertices'][0]['x'] - print(f"v0: {v} type:{type(v)}") - - packed = msgpack.packb(obj) - - # Write msgpack file - with gzip.open(out_msg_gz, "wb") as outfile: - outfile.write(packed) - - - -with gzip.open(out_msg_gz, 'rb') as f: - unp = msgpack.unpackb(f.read()) - out_copy = os.path.join(root_dir, id, f"{id}_copy.json") - with open(out_copy, 'w') as f_out: - # f_out.write(unp) - json.dump(unp, f_out) \ No newline at end of file diff --git a/scripts/test_thor_msg.py b/scripts/test_thor_msg.py deleted file mode 100644 index 94c376b876..0000000000 --- a/scripts/test_thor_msg.py +++ /dev/null @@ -1,226 +0,0 @@ -import glob -import json -import os -import sys -import time - -from objathor.asset_conversion.util import ( - save_thor_asset_file, - add_default_annotations, - change_asset_paths, - load_existing_thor_asset_file, - create_runtime_asset_file, -) - -import ai2thor.controller -import ai2thor.wsgi_server - - -def make_single_object_house( - asset_id, - house_path, - instance_id="asset_0", - skybox_color=(0, 0, 0), -): - with open(house_path, "r") as f: - house = json.load(f) - - house["objects"] = [ - { - "assetId": asset_id, - "id": instance_id, - "kinematic": True, - "position": {"x": 0, "y": 0, "z": 0}, - "rotation": {"x": 0, "y": 0, "z": 0}, - "layer": "Procedural2", - "material": None, - } - ] - return house - - -def view_asset_in_thor( - asset_id, - controller, - output_dir, - house_path, - rotations=[], - instance_id="asset_0", - skybox_color=(0, 0, 0), -): - from PIL import Image - - house = make_single_object_house( - asset_id=asset_id, house_path=house_path, instance_id=instance_id, skybox_color=skybox_color - ) - - start = time.perf_counter() - evt = controller.step(action="CreateHouse", house=house) - end = time.perf_counter() - - if not evt.metadata["lastActionSuccess"]: - print(f"Action success: {evt.metadata['lastActionSuccess']}") - print(f'Error: {evt.metadata["errorMessage"]}') - return evt - evt = controller.step(action="LookAtObjectCenter", objectId=instance_id) - - evt = controller.step( - action="SetSkybox", - color={ - "r": skybox_color[0], - "g": skybox_color[1], - "b": skybox_color[2], - }, - ) - - if not evt.metadata["lastActionSuccess"]: - print(f"Action success: {evt.metadata['lastActionSuccess']}") - print(f'Error: {evt.metadata["errorMessage"]}') - - if evt.frame is not None: - im = Image.fromarray(evt.frame) - # os.makedirs(output_dir, exist_ok=True) - - if not os.path.exists(output_dir): - os.makedirs(output_dir) - for rotation in rotations: - evt = controller.step( - action="RotateObject", - angleAxisRotation={ - "axis": { - "x": rotation[0], - "y": rotation[1], - "z": rotation[2], - }, - "degrees": rotation[3], - }, - ) - im = Image.fromarray(evt.frame) - im.save( - os.path.join( - output_dir, f"{rotation[0]}_{rotation[1]}_{rotation[2]}_{rotation[3]}.jpg" - ) - ) - return evt, (end - start) - - -if __name__ == "__main__": - width = 300 - height = 300 - output_dir = "./images" - empty_house = "empty_house.json" - - extension = sys.argv[1] if len(sys.argv) > 1 else ".json" - - asset_id = "Apple_1" - - extensions = [".json", ".msgpack", ".msgpack.gz", "gz", ".pkl.gz", ""] - - controller = ai2thor.controller.Controller( - port=8200, - start_unity=False, - server_class=ai2thor.wsgi_server.WsgiServer, - # start_unity=True, local_build=True, server_class=ai2thor.fifo_server.FifoServer, - scene="Procedural", - gridSize=0.25, - width=width, - height=height, - ) - objsverse_root = "./objaverse" - ids = [] - - dirs = glob.glob(f"{objsverse_root}/*") - dirs = dirs[:1] - - extensions = [".pkl.gz"] - # extensions = extensions[:1] - - for g in dirs: - asset_id = os.path.basename(g) - ids.append(asset_id) - evt = controller.step(action="GetPersistentDataPath") - print(f"return : {evt.metadata['actionReturn']}") - print(f"success: {evt.metadata['lastActionSuccess']}") - print(evt.metadata["errorMessage"]) - - # copy_to_dir = os.path.join(controller._build.base_dir, "processed_models") - copy_to_dir = evt.metadata["actionReturn"] - build_target_dir = os.path.join(copy_to_dir, asset_id) - asset_dir = os.path.abspath(os.path.join(objsverse_root, asset_id)) - for extension in extensions: - print(f"---- extension {extension}") - extension = extension if extension != "" else ".json" - load_file_in_unity = extension != "" and extension != ".pkl.gz" - print( - f"---- running {asset_id} wit extension {extension}, load_in_unity {load_file_in_unity}" - ) - - create_runtime_asset_file( - asset_id=asset_id, - asset_directory=asset_dir, - save_dir=copy_to_dir, - verbose=True, - load_file_in_unity=load_file_in_unity, - use_extension=extension, - ) - - asset = load_existing_thor_asset_file( - build_target_dir, asset_id, force_extension=".pkl.gz" - ) - asset = add_default_annotations( - asset=asset, asset_directory=build_target_dir, verbose=True - ) - asset = change_asset_paths(asset=asset, save_dir=build_target_dir) - print(f" -- saving asset dir {build_target_dir} name {asset_id}{extension}") - save_thor_asset_file(asset, os.path.join(build_target_dir, f"{asset_id}{extension}")) - - args = {} - if load_file_in_unity: - args = dict( - action="CreateRuntimeAsset", id=asset_id, dir=copy_to_dir, extension=extension - ) - else: - args = asset - - start = time.perf_counter() - print(args) - evt = controller.step(**args) - end = time.perf_counter() - frame_time = end - start - print(f"return : {controller.last_action}") - print(f"return : {evt.metadata['actionReturn']}") - print(f"success: {evt.metadata['lastActionSuccess']}") - print(evt.metadata["errorMessage"]) - - angle_increment = 45 - angles = [n * angle_increment for n in range(0, round(360 / angle_increment))] - axes = [(0, 1, 0), (1, 0, 0)] - rotations = [(x, y, z, degrees) for degrees in angles for (x, y, z) in axes] - - evt, time_create_H = view_asset_in_thor( - asset_id=asset_id, - controller=controller, - house_path="empty_house.json", - rotations=rotations, - output_dir="./out_msg", - ) - - print(f"return : {evt.metadata['actionReturn']}") - print(f"success: {evt.metadata['lastActionSuccess']}") - print(evt.metadata["errorMessage"]) - - print(f"{asset_id}: time Create Prefab: {frame_time} create_hoyse {time_create_H}") - print("---reset") - # controller.reset() - - break - break - - input() - # evt = controller.step(action="CreateRuntimeAsset", - # filepath="/Users/alvaroh/ai2/ai2thor/objaverse/b8d24c146a6844788c0ba6f7b135e99e/b8d24c146a6844788c0ba6f7b135e99e.msgpack.gz", - # outpath="/Users/alvaroh/ai2/ai2thor/objaverse/b8d24c146a6844788c0ba6f7b135e99e/out" - # ) - - # print(f"error: {evt.metadata['lastActionSuccess']}") - # print(evt.metadata["errorMessage"]) diff --git a/tasks.py b/tasks.py index 524604bc90..8dcfeeb348 100644 --- a/tasks.py +++ b/tasks.py @@ -67,7 +67,9 @@ def add_files(zipf, start_dir, exclude_ext=()): continue arcname = os.path.relpath(fn, start_dir) - if arcname.split("/")[0].endswith("_BackUpThisFolder_ButDontShipItWithYourGame"): + if arcname.split("/")[0].endswith( + "_BackUpThisFolder_ButDontShipItWithYourGame" + ): # print("skipping %s" % arcname) continue # print("adding %s" % arcname) @@ -104,17 +106,19 @@ def push_build(build_archive_name, zip_data, include_private_scenes): ChecksumSHA256=b64encode(sha.digest()).decode("ascii"), ) logger.info("pushing sha256 %s" % (sha256_key,)) - s3.Object(bucket, sha256_key).put(Body=sha.hexdigest(), ACL=acl, ContentType="text/plain") - except botocore.exceptions.ClientError: - logger.error( - "caught error uploading archive %s: %s" % (build_archive_name, traceback.format_exc()) + s3.Object(bucket, sha256_key).put( + Body=sha.hexdigest(), ACL=acl, ContentType="text/plain" ) + except botocore.exceptions.ClientError: + logger.error("caught error uploading archive %s: %s" % (build_archive_name, traceback.format_exc())) logger.info("pushed build %s to %s" % (bucket, build_archive_name)) def _webgl_local_build_path(prefix, source_dir="builds"): - return os.path.join(os.getcwd(), "unity/{}/thor-{}-WebGL/".format(source_dir, prefix)) + return os.path.join( + os.getcwd(), "unity/{}/thor-{}-WebGL/".format(source_dir, prefix) + ) def _unity_version(): @@ -131,10 +135,18 @@ def _unity_playback_engines_path(): standalone_path = None if sys.platform.startswith("darwin"): - unity_hub_path = "/Applications/Unity/Hub/Editor/{}/PlaybackEngines".format(unity_version) + unity_hub_path = ( + "/Applications/Unity/Hub/Editor/{}/PlaybackEngines".format( + unity_version + ) + ) # /Applications/Unity/2019.4.20f1/Unity.app/Contents/MacOS - standalone_path = "/Applications/Unity/{}/PlaybackEngines".format(unity_version) + standalone_path = ( + "/Applications/Unity/{}/PlaybackEngines".format( + unity_version + ) + ) elif "win" in sys.platform: raise ValueError("Windows not supported yet, verify PlaybackEnginesPath") unity_hub_path = "C:/PROGRA~1/Unity/Hub/Editor/{}/Editor/Data/PlaybackEngines".format( @@ -154,19 +166,22 @@ def _unity_playback_engines_path(): return unity_path - def _unity_path(): unity_version = _unity_version() standalone_path = None if sys.platform.startswith("darwin"): - unity_hub_path = "/Applications/Unity/Hub/Editor/{}/Unity.app/Contents/MacOS/Unity".format( - unity_version + unity_hub_path = ( + "/Applications/Unity/Hub/Editor/{}/Unity.app/Contents/MacOS/Unity".format( + unity_version + ) ) # /Applications/Unity/2019.4.20f1/Unity.app/Contents/MacOS - standalone_path = "/Applications/Unity/{}/Unity.app/Contents/MacOS/Unity".format( - unity_version + standalone_path = ( + "/Applications/Unity/{}/Unity.app/Contents/MacOS/Unity".format( + unity_version + ) ) # standalone_path = ( # "/Applications/Unity-{}/Unity.app/Contents/MacOS/Unity".format( @@ -174,7 +189,9 @@ def _unity_path(): # ) # ) elif "win" in sys.platform: - unity_hub_path = "C:/PROGRA~1/Unity/Hub/Editor/{}/Editor/Unity.exe".format(unity_version) + unity_hub_path = "C:/PROGRA~1/Unity/Hub/Editor/{}/Editor/Unity.exe".format( + unity_version + ) # TODO: Verify windows unity standalone path standalone_path = "C:/PROGRA~1/{}/Editor/Unity.exe".format(unity_version) elif sys.platform.startswith("linux"): @@ -231,7 +248,9 @@ def _build( elapsed = time.time() - start if elapsed > timeout: - logger.error(f"Timeout occurred when running command:\n{command}\nKilling the process.") + logger.error( + f"Timeout occurred when running command:\n{command}\nKilling the process." + ) os.kill(process.pid, signal.SIGKILL) os.waitpid(-1, os.WNOHANG) return False @@ -297,7 +316,9 @@ def class_dataset_images_for_scene(scene_name): for o in event.metadata["objects"]: if o["receptacle"] and o["receptacleObjectIds"] and o["openable"]: print("opening %s" % o["objectId"]) - env.step(dict(action="OpenObject", objectId=o["objectId"], forceAction=True)) + env.step( + dict(action="OpenObject", objectId=o["objectId"], forceAction=True) + ) event = env.step(dict(action="GetReachablePositions", gridSize=0.25)) @@ -316,7 +337,9 @@ def class_dataset_images_for_scene(scene_name): ) ) exclude_colors.update( - set(map(tuple, np.unique(event.instance_segmentation_frame[-1], axis=0))) + set( + map(tuple, np.unique(event.instance_segmentation_frame[-1], axis=0)) + ) ) exclude_colors.update( set( @@ -393,7 +416,9 @@ def class_dataset_images_for_scene(scene_name): for o in event.metadata["objects"]: if o["receptacle"] and o["receptacleObjectIds"] and o["openable"]: print("opening %s" % o["objectId"]) - env.step(dict(action="OpenObject", objectId=o["objectId"], forceAction=True)) + env.step( + dict(action="OpenObject", objectId=o["objectId"], forceAction=True) + ) for vol in visible_object_locations: point = vol["point"] @@ -437,7 +462,9 @@ def class_dataset_images_for_scene(scene_name): # print("start x %s start_y %s end_x %s end y %s" % (start_x, start_y, end_x, end_y)) print("storing %s " % object_id) img = event.cv2img[start_y:end_y, start_x:end_x, :] - dst = cv2.resize(img, (target_size, target_size), interpolation=cv2.INTER_LANCZOS4) + dst = cv2.resize( + img, (target_size, target_size), interpolation=cv2.INTER_LANCZOS4 + ) object_type = object_id.split("|")[0].lower() target_dir = os.path.join("images", scene_name, object_type) @@ -486,14 +513,14 @@ def local_build_test(context, prefix="local", arch="OSXIntel64"): @task(iterable=["scenes"]) -def local_build(context, prefix="local", arch="OSXIntel64", scenes=None, scripts_only=False): +def local_build( + context, prefix="local", arch="OSXIntel64", scenes=None, scripts_only=False +): import ai2thor.controller build = ai2thor.build.Build(arch, prefix, False) env = dict() - if os.path.isdir("unity/Assets/Private/Scenes") or os.path.isdir( - "Assets/Resources/ai2thor-objaverse/NoveltyTHOR_Assets/Scenes" - ): + if os.path.isdir("unity/Assets/Private/Scenes") or os.path.isdir("Assets/Resources/ai2thor-objaverse/NoveltyTHOR_Assets/Scenes"): env["INCLUDE_PRIVATE_SCENES"] = "true" build_dir = os.path.join("builds", build.name) @@ -501,7 +528,9 @@ def local_build(context, prefix="local", arch="OSXIntel64", scenes=None, scripts env["BUILD_SCRIPTS_ONLY"] = "true" if scenes: - env["BUILD_SCENES"] = ",".join(map(ai2thor.controller.Controller.normalize_scene, scenes)) + env["BUILD_SCENES"] = ",".join( + map(ai2thor.controller.Controller.normalize_scene, scenes) + ) if _build("unity", arch, build_dir, build.name, env=env): print("Build Successful") @@ -643,7 +672,9 @@ class YamlUnity3dTag(yaml.SafeLoader): def let_through(self, node): return self.construct_mapping(node) - YamlUnity3dTag.add_constructor("tag:unity3d.com,2011:47", YamlUnity3dTag.let_through) + YamlUnity3dTag.add_constructor( + "tag:unity3d.com,2011:47", YamlUnity3dTag.let_through + ) qs = yaml.load( open("unity/ProjectSettings/QualitySettings.asset").read(), @@ -664,14 +695,20 @@ def let_through(self, node): def git_commit_comment(): - comment = subprocess.check_output("git log -n 1 --format=%B", shell=True).decode("utf8").strip() + comment = ( + subprocess.check_output("git log -n 1 --format=%B", shell=True) + .decode("utf8") + .strip() + ) return comment def git_commit_id(): commit_id = ( - subprocess.check_output("git log -n 1 --format=%H", shell=True).decode("ascii").strip() + subprocess.check_output("git log -n 1 --format=%H", shell=True) + .decode("ascii") + .strip() ) return commit_id @@ -695,9 +732,9 @@ def push_pip_commit(context): pip_name = os.path.basename(g) logger.info("pushing pip file %s" % g) with open(g, "rb") as f: - s3.Object(ai2thor.build.PYPI_S3_BUCKET, os.path.join("ai2thor", pip_name)).put( - Body=f, ACL=acl - ) + s3.Object( + ai2thor.build.PYPI_S3_BUCKET, os.path.join("ai2thor", pip_name) + ).put(Body=f, ACL=acl) @task @@ -773,7 +810,11 @@ def build_pip(context, version): if ( (next_maj == current_maj + 1) or (next_maj == current_maj and next_min == current_min + 1) - or (next_maj == current_maj and next_min == current_min and next_sub >= current_sub + 1) + or ( + next_maj == current_maj + and next_min == current_min + and next_sub >= current_sub + 1 + ) ): if os.path.isdir("dist"): shutil.rmtree("dist") @@ -790,7 +831,9 @@ def build_pip(context, version): fi.write("__version__ = '%s'\n" % (version)) subprocess.check_call("python setup.py clean --all", shell=True) - subprocess.check_call("python setup.py sdist bdist_wheel --universal", shell=True) + subprocess.check_call( + "python setup.py sdist bdist_wheel --universal", shell=True + ) else: raise Exception( @@ -830,7 +873,9 @@ def build_log_push(build_info, include_private_scenes): bucket = ai2thor.build.PRIVATE_S3_BUCKET acl = "private" - s3.Object(bucket, build_log_key).put(Body=build_log, ACL=acl, ContentType="text/plain") + s3.Object(bucket, build_log_key).put( + Body=build_log, ACL=acl, ContentType="text/plain" + ) def archive_push(unity_path, build_path, build_dir, build_info, include_private_scenes): @@ -920,7 +965,14 @@ def link_build_cache(root_dir, arch, branch): os.makedirs(os.path.dirname(branch_cache_dir), exist_ok=True) # -c uses MacOS clonefile - subprocess.check_call("cp -a -c %s %s" % (main_cache_dir, branch_cache_dir), shell=True) + if sys.platform.startswith("darwin"): + subprocess.check_call( + "cp -a -c %s %s" % (main_cache_dir, branch_cache_dir), shell=True + ) + else: + subprocess.check_call( + "cp -a %s %s" % (main_cache_dir, branch_cache_dir), shell=True + ) logger.info("copying main cache complete for %s" % encoded_branch) branch_library_cache_dir = os.path.join(branch_cache_dir, "Library") @@ -1021,7 +1073,9 @@ def ci_merge_push_pytest_results(context, commit_id): s3_obj.bucket_name, s3_obj.key, ) - logger.info("ci_merge_push_pytest_results pytest before url check code change logging works") + logger.info( + "ci_merge_push_pytest_results pytest before url check code change logging works" + ) logger.info("pytest url %s" % s3_pytest_url) logger.info("s3 obj is valid: {}".format(s3_obj)) @@ -1050,7 +1104,9 @@ def ci_pytest(branch, commit_id): start_time = time.time() - proc = subprocess.run("pytest", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + proc = subprocess.run( + "pytest", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE + ) result = dict( success=proc.returncode == 0, @@ -1065,17 +1121,16 @@ def ci_pytest(branch, commit_id): f"finished pytest for {branch} {commit_id} in {time.time() - start_time:.2f} seconds" ) - -# Type hints break build server's invoke version +# Type hints break build server's invoke version @task def ci_build( context, - commit_id=None, # Optional[str] - branch=None, # Optional[str] - skip_pip=False, # bool - novelty_thor_scenes=False, - skip_delete_tmp_dir=False, # bool - cloudrendering_first=False, + commit_id = None, # Optional[str] + branch = None, # Optional[str] + skip_pip = False, # bool + novelty_thor_scenes = False, + skip_delete_tmp_dir = False, # bool + cloudrendering_first = False ): assert (commit_id is None) == ( branch is None @@ -1091,11 +1146,12 @@ def ci_build( if is_travis_build: # a deploy key is used on the build server and an .ssh/config entry has been added # to point to the deploy key caclled ai2thor-private-github - private_url = "git@ai2thor-private-github:allenai/ai2thor-private.git" + private_url = "git@ai2thor-private-github:allenai/ai2thor-private.git" novelty_thor_url = "git@ai2thor-objaverse-github:allenai/ai2thor-objaverse.git" else: private_url = "https://github.com/allenai/ai2thor-private" - novelty_thor_url = "https://github.com/allenai/ai2thor-objaverse" + novelty_thor_url ="https://github.com/allenai/ai2thor-objaverse" + private_repos = [ scripts.update_private.Repo( @@ -1113,17 +1169,17 @@ def ci_build( if novelty_thor_scenes: logger.info("Including a NoveltyThor scenes and making it a private build") - private_repos.append(novelty_thor_repo) + private_repos.append( + novelty_thor_repo + ) else: # Needs to be here so we overwrite any existing NoveltyTHOR repo private_repos.append( scripts.update_private.Repo( url=novelty_thor_url, - target_dir=os.path.join( - base_dir, "unity", "Assets", "Resources", "ai2thor-objaverse" - ), + target_dir=os.path.join(base_dir, "unity", "Assets", "Resources", "ai2thor-objaverse"), delete_before_checkout=is_travis_build, - commit_id="066485f29d7021ac732bed57758dea4b9d481c40", # Initial commit, empty repo. + commit_id="066485f29d7021ac732bed57758dea4b9d481c40", # Initial commit, empty repo. ) ) @@ -1143,7 +1199,9 @@ def ci_build( novelty_thor_add_branches = ["new_cam_adjust"] if is_travis_build and build and build["branch"] in novelty_thor_add_branches: novelty_thor_scenes = True - private_repos.append(novelty_thor_repo) + private_repos.append( + novelty_thor_repo + ) skip_branches = ["vids", "video", "erick/cloudrendering", "it_vr"] if build and build["branch"] not in skip_branches: @@ -1152,13 +1210,17 @@ def ci_build( logger.info(f"pending build for {build['branch']} {build['commit_id']}") clean(private_repos=private_repos) subprocess.check_call("git fetch", shell=True) - subprocess.check_call("git checkout %s --" % build["branch"], shell=True) + subprocess.check_call( + "git checkout %s --" % build["branch"], shell=True + ) logger.info(f" After checkout") - subprocess.check_call("git checkout -qf %s" % build["commit_id"], shell=True) + subprocess.check_call( + "git checkout -qf %s" % build["commit_id"], shell=True + ) private_scene_options = [novelty_thor_scenes] - build_archs = ["OSXIntel64"] # , "Linux64"] + build_archs = ["OSXIntel64"] #, "Linux64"] # CloudRendering only supported with 2020.3.25 # should change this in the future to automatically install @@ -1172,7 +1234,9 @@ def ci_build( has_any_build_failed = False for include_private_scenes in private_scene_options: for arch in build_archs: - logger.info(f"processing {arch} {build['branch']} {build['commit_id']}") + logger.info( + f"processing {arch} {build['branch']} {build['commit_id']}" + ) temp_dir = arch_temp_dirs[arch] = os.path.join( os.environ["HOME"], "tmp/unity-%s-%s-%s-%s" @@ -1199,18 +1263,24 @@ def ci_build( releases_dir=rdir, ) if commit_build.exists(): - logger.info(f"found build for commit {build['commit_id']} {arch}") + logger.info( + f"found build for commit {build['commit_id']} {arch}" + ) # download the build so that we can run the tests if sys.platform.startswith("darwin"): if arch == "OSXIntel64": commit_build.download() else: - if arch == "CloudRendering": + + if arch in ["CloudRendering", "OSXIntel64"]: + # In Linux the OSX build cache is used for Unity Tests as cloud rendering fails commit_build.download() else: # this is done here so that when a tag build request arrives and the commit_id has already # been built, we avoid bootstrapping the cache since we short circuited on the line above - link_build_cache(root_dir=temp_dir, arch=arch, branch=build["branch"]) + link_build_cache( + root_dir=temp_dir, arch=arch, branch=build["branch"] + ) build_success = ci_build_arch( root_dir=temp_dir, @@ -1218,11 +1288,13 @@ def ci_build( commit_id=build["commit_id"], include_private_scenes=include_private_scenes, immediately_fail_and_push_log=has_any_build_failed, - timeout=60 * 60, + timeout=60 * 60 # Don't bother trying another build if one has already failed ) - has_any_build_failed = has_any_build_failed or not build_success + has_any_build_failed = ( + has_any_build_failed or not build_success + ) if build_success: logger.info( f"Build success detected for {arch} {build['commit_id']}" @@ -1234,7 +1306,9 @@ def ci_build( # the project and we can run the unit tests # waiting for all builds to complete before starting tests for arch in build_archs: - lock_file_path = os.path.join(arch_temp_dirs[arch], "unity/Temp/UnityLockfile") + lock_file_path = os.path.join( + arch_temp_dirs[arch], "unity/Temp/UnityLockfile" + ) if os.path.isfile(lock_file_path): logger.info(f"attempting to lock {lock_file_path}") lock_file = os.open(lock_file_path, os.O_RDWR) @@ -1249,14 +1323,22 @@ def ci_build( if build["tag"] is None: # its possible that the cache doesn't get linked if the builds # succeeded during an earlier run - link_build_cache(arch_temp_dirs["OSXIntel64"], "OSXIntel64", build["branch"]) + + pytest_platform = "OSXIntel64" if sys.platform.startswith("darwin") else "CloudRendering" + # Weirdly even in Linux you can run utf tests using OSX build cache, but not CloudRendering + utf_test_platform = "OSXIntel64" + + link_build_cache( + arch_temp_dirs[utf_test_platform], utf_test_platform, build["branch"] + ) # link builds directory so pytest can run logger.info("current directory pre-symlink %s" % os.getcwd()) os.symlink( - os.path.join(arch_temp_dirs["OSXIntel64"], "unity/builds"), + os.path.join(arch_temp_dirs[pytest_platform], "unity/builds"), "unity/builds", ) + print(f"Symlink from `unity/builds` to `{os.path.join(arch_temp_dirs[pytest_platform], 'unity/builds')}`") os.makedirs("tmp", exist_ok=True) # using threading here instead of multiprocessing since we must use the start_method of spawn, which # causes the tasks.py to get reloaded, which may be different on a branch from main @@ -1265,7 +1347,7 @@ def ci_build( args=( build["branch"], build["commit_id"], - arch_temp_dirs["OSXIntel64"], + arch_temp_dirs[utf_test_platform], ), ) utf_proc.start() @@ -1287,7 +1369,8 @@ def ci_build( for p in procs: if p: logger.info( - "joining proc %s for %s %s" % (p, build["branch"], build["commit_id"]) + "joining proc %s for %s %s" + % (p, build["branch"], build["commit_id"]) ) p.join() @@ -1307,13 +1390,17 @@ def ci_build( if is_travis_build: for i in range(12): b = travis_build(build["id"]) - logger.info("build state for %s: %s" % (build["id"], b["state"])) + logger.info( + "build state for %s: %s" % (build["id"], b["state"]) + ) if b["state"] != "started": break time.sleep(10) - logger.info("build complete %s %s" % (build["branch"], build["commit_id"])) + logger.info( + "build complete %s %s" % (build["branch"], build["commit_id"]) + ) fcntl.flock(lock_f, fcntl.LOCK_UN) @@ -1340,9 +1427,13 @@ def install_cloudrendering_engine(context, force=False): if os.path.isdir(full_dir): if force: shutil.rmtree(full_dir) - logger.info("CloudRendering engine already installed - removing due to force") + logger.info( + "CloudRendering engine already installed - removing due to force" + ) else: - logger.info("skipping installation - CloudRendering engine already installed") + logger.info( + "skipping installation - CloudRendering engine already installed" + ) return print("packages/CloudRendering-%s.zip" % _unity_version()) @@ -1365,28 +1456,34 @@ def ci_build_webgl(context, commit_id): arch = "WebGL" set_gi_cache_folder(arch) link_build_cache(os.getcwd(), arch, branch) - webgl_build_deploy_demo(context, verbose=True, content_addressable=False, force=True) + webgl_build_deploy_demo( + context, verbose=True, content_addressable=False, force=True + ) logger.info("finished webgl build deploy %s %s" % (branch, commit_id)) update_webgl_autodeploy_commit_id(commit_id) def set_gi_cache_folder(arch): gi_cache_folder = os.path.join(os.environ["HOME"], "GICache/%s" % arch) - plist_path = os.path.join( - os.environ["HOME"], "Library/Preferences/com.unity3d.UnityEditor5.x.plist" - ) - # done to avoid race conditions when modifying GICache from more than one build - subprocess.check_call( - "plutil -replace GICacheEnableCustomPath -bool TRUE %s" % plist_path, shell=True - ) - subprocess.check_call( - "plutil -replace GICacheFolder -string '%s' %s" % (gi_cache_folder, plist_path), - shell=True, - ) - subprocess.check_call( - "plutil -replace GICacheMaximumSizeGB -integer 100 %s" % (plist_path,), - shell=True, - ) + + if sys.platform.startswith("darwin"): + plist_path = os.path.join( + os.environ["HOME"], "Library/Preferences/com.unity3d.UnityEditor5.x.plist" + ) + # done to avoid race conditions when modifying GICache from more than one build + subprocess.check_call( + "plutil -replace GICacheEnableCustomPath -bool TRUE %s" % plist_path, shell=True + ) + subprocess.check_call( + "plutil -replace GICacheFolder -string '%s' %s" % (gi_cache_folder, plist_path), + shell=True, + ) + subprocess.check_call( + "plutil -replace GICacheMaximumSizeGB -integer 100 %s" % (plist_path,), + shell=True, + ) + else: + logger.warn("Unchanged GI Cache directory. Only supported in OSX.") def ci_build_arch( @@ -1465,7 +1562,9 @@ def poll_ci_build(context): start_datetime = datetime.datetime.utcnow() hours_before_timeout = 2 - print(f"WAITING FOR BUILDS TO COMPLETE ({hours_before_timeout} hours before timeout)") + print( + f"WAITING FOR BUILDS TO COMPLETE ({hours_before_timeout} hours before timeout)" + ) start_time = time.time() last_emit_time = 0 for i in range(360 * hours_before_timeout): @@ -1517,7 +1616,9 @@ def poll_ci_build(context): f"\nBuild DOES NOT exist for arch {plat}, expected log url: {commit_build.log_url}" ) else: - print(f"\nBuild DOES exist for arch {plat}, log url: {commit_build.log_url}") + print( + f"\nBuild DOES exist for arch {plat}, log url: {commit_build.log_url}" + ) if any_failures: print(f"\nERROR: BUILD FAILURES DETECTED") @@ -1575,7 +1676,9 @@ def build(context, local=False): if include_private_scenes: env["INCLUDE_PRIVATE_SCENES"] = "true" unity_path = "unity" - build_name = ai2thor.build.build_name(plat.name(), version, include_private_scenes) + build_name = ai2thor.build.build_name( + plat.name(), version, include_private_scenes + ) build_dir = os.path.join("builds", build_name) build_path = build_dir + ".zip" build_info = builds[plat.name()] = {} @@ -1730,7 +1833,9 @@ def get_depth( save_image_per_frame=True, ) else: - env = ai2thor.controller.Controller(width=600, height=600, local_build=local_build) + env = ai2thor.controller.Controller( + width=600, height=600, local_build=local_build + ) if scene is not None: env.reset(scene) @@ -1752,7 +1857,9 @@ def get_depth( from ai2thor.interact import InteractiveControllerPrompt if scene is not None: - teleport_arg = dict(action="TeleportFull", y=0.9010001, rotation=dict(x=0, y=rotation, z=0)) + teleport_arg = dict( + action="TeleportFull", y=0.9010001, rotation=dict(x=0, y=rotation, z=0) + ) if teleport is not None: teleport = [float(pos) for pos in teleport.split(",")] @@ -1808,7 +1915,9 @@ def get_depth( @task -def inspect_depth(ctx, directory, all=False, indices=None, jet=False, under_score=False): +def inspect_depth( + ctx, directory, all=False, indices=None, jet=False, under_score=False +): import numpy as np import cv2 import glob @@ -1850,11 +1959,15 @@ def sort_key_function(name): mn = np.min(raw_depth) mx = np.max(raw_depth) print("min depth value: {}, max depth: {}".format(mn, mx)) - norm = (((raw_depth - mn).astype(np.float32) / (mx - mn)) * 255.0).astype(np.uint8) + norm = (((raw_depth - mn).astype(np.float32) / (mx - mn)) * 255.0).astype( + np.uint8 + ) img = cv2.applyColorMap(norm, cv2.COLORMAP_JET) else: - grayscale = (255.0 / raw_depth.max() * (raw_depth - raw_depth.min())).astype(np.uint8) + grayscale = ( + 255.0 / raw_depth.max() * (raw_depth - raw_depth.min()) + ).astype(np.uint8) print("max {} min {}".format(raw_depth.max(), raw_depth.min())) img = grayscale @@ -1873,7 +1986,9 @@ def inspect_pixel(event, x, y, flags, param): @task -def real_2_sim(ctx, source_dir, index, scene, output_dir, rotation=0, local_build=False, jet=False): +def real_2_sim( + ctx, source_dir, index, scene, output_dir, rotation=0, local_build=False, jet=False +): import cv2 from ai2thor.util.transforms import transform_real_2_sim @@ -1961,7 +2076,9 @@ def imshow_components(labels): indices_top_left = np.where(labels == labels[0][0]) indices_top_right = np.where(labels == labels[0][img_size[1] - 1]) indices_bottom_left = np.where(labels == labels[img_size[0] - 1][0]) - indices_bottom_right = np.where(labels == labels[img_size[0] - 1][img_size[1] - 1]) + indices_bottom_right = np.where( + labels == labels[img_size[0] - 1][img_size[1] - 1] + ) indices = [ indices_top_left, @@ -2038,7 +2155,10 @@ def check_visible_objects_closed_receptacles(ctx, start_scene, end_scene): ) ) - if visibility_object_id is None and obj["objectType"] in visibility_object_types: + if ( + visibility_object_id is None + and obj["objectType"] in visibility_object_types + ): visibility_object_id = obj["objectId"] if visibility_object_id is None: @@ -2068,7 +2188,9 @@ def check_visible_objects_closed_receptacles(ctx, start_scene, end_scene): ) ) - replace_success = controller.last_event.metadata["lastActionSuccess"] + replace_success = controller.last_event.metadata[ + "lastActionSuccess" + ] if replace_success: if ( @@ -2096,7 +2218,9 @@ def list_objects_with_metadata(bucket): continuation_token = None while True: if continuation_token: - objects = s3c.list_objects_v2(Bucket=bucket, ContinuationToken=continuation_token) + objects = s3c.list_objects_v2( + Bucket=bucket, ContinuationToken=continuation_token + ) else: objects = s3c.list_objects_v2(Bucket=bucket) @@ -2167,7 +2291,11 @@ def upload_file(f_path, key): if ext in content_encoding: kwargs["ContentEncoding"] = content_encoding[ext] - if not force and key in current_objects and etag == current_objects[key]["ETag"]: + if ( + not force + and key in current_objects + and etag == current_objects[key]["ETag"] + ): if verbose: print("ETag match - skipping %s" % key) return @@ -2243,7 +2371,9 @@ def webgl_build_deploy_demo(ctx, verbose=False, force=False, content_addressable content_addressable=content_addressable, ) - webgl_deploy(ctx, source_dir="builds/demo", target_dir="demo", verbose=verbose, force=force) + webgl_deploy( + ctx, source_dir="builds/demo", target_dir="demo", verbose=verbose, force=force + ) if verbose: print("Deployed selected scenes to bucket's 'demo' directory") @@ -2253,9 +2383,13 @@ def webgl_build_deploy_demo(ctx, verbose=False, force=False, content_addressable living_rooms = [f"FloorPlan{200 + i}_physics" for i in range(1, 31)] bedrooms = [f"FloorPlan{300 + i}_physics" for i in range(1, 31)] bathrooms = [f"FloorPlan{400 + i}_physics" for i in range(1, 31)] - robothor_train = [f"FloorPlan_Train{i}_{j}" for i in range(1, 13) for j in range(1, 6)] + robothor_train = [ + f"FloorPlan_Train{i}_{j}" for i in range(1, 13) for j in range(1, 6) + ] robothor_val = [f"FloorPlan_Val{i}_{j}" for i in range(1, 4) for j in range(1, 6)] - scenes = kitchens + living_rooms + bedrooms + bathrooms + robothor_train + robothor_val + scenes = ( + kitchens + living_rooms + bedrooms + bathrooms + robothor_train + robothor_val + ) webgl_build( ctx, @@ -2311,7 +2445,9 @@ def webgl_deploy_all(ctx, verbose=False, individual_rooms=False): build_dir = "builds/{}".format(target_s3_dir) webgl_build(ctx, scenes=floorPlanName, directory=build_dir) - webgl_deploy(ctx, source_dir=build_dir, target_dir=target_s3_dir, verbose=verbose) + webgl_deploy( + ctx, source_dir=build_dir, target_dir=target_s3_dir, verbose=verbose + ) else: webgl_build(ctx, room_ranges=range_str, directory=build_dir) @@ -2343,7 +2479,10 @@ def webgl_s3_deploy( if all: flatten = lambda l: [item for sublist in l for item in sublist] room_numbers = flatten( - [[i for i in range(room_range[0], room_range[1])] for key, room_range in rooms.items()] + [ + [i for i in range(room_range[0], room_range[1])] + for key, room_range in rooms.items() + ] ) else: room_numbers = [s.strip() for s in scenes.split(",")] @@ -2358,7 +2497,9 @@ def webgl_s3_deploy( target_s3_dir = "{}/{}".format(target_dir, floor_plan_name) build_dir = "builds/{}".format(target_s3_dir) - webgl_build(ctx, scenes=floor_plan_name, directory=build_dir, crowdsource_build=True) + webgl_build( + ctx, scenes=floor_plan_name, directory=build_dir, crowdsource_build=True + ) if verbose: print("Deploying room '{}'...".format(floor_plan_name)) if not deploy_skip: @@ -2392,7 +2533,9 @@ def webgl_site_deploy( shutil.rmtree(output_dir) # os.mkdir(output_dir) - ignore_func = lambda d, files: [f for f in files if isfile(join(d, f)) and f.endswith(".meta")] + ignore_func = lambda d, files: [ + f for f in files if isfile(join(d, f)) and f.endswith(".meta") + ] if unity_build_dir != "": shutil.copytree(unity_build_dir, output_dir, ignore=ignore_func) @@ -2419,7 +2562,9 @@ def mock_client_request(context): import requests import cv2 - r = requests.post("http://127.0.0.1:9200/step", json=dict(action="MoveAhead", sequenceId=1)) + r = requests.post( + "http://127.0.0.1:9200/step", json=dict(action="MoveAhead", sequenceId=1) + ) payload = msgpack.unpackb(r.content, raw=False) metadata = payload["metadata"]["agents"][0] image = np.frombuffer(payload["frames"][0], dtype=np.uint8).reshape( @@ -2535,7 +2680,9 @@ def get_points(contoller, object_type, scene): print("Getting points in scene: '{}'...: ".format(scene)) controller.reset(scene) event = controller.step( - dict(action="ObjectTypeToObjectIds", objectType=object_type.replace(" ", "")) + dict( + action="ObjectTypeToObjectIds", objectType=object_type.replace(" ", "") + ) ) object_ids = event.metadata["actionReturn"] @@ -2546,11 +2693,13 @@ def get_points(contoller, object_type, scene): objects_types_in_scene.add(object_type) object_id = object_ids[0] - event_reachable = controller.step(dict(action="GetReachablePositions", gridSize=0.25)) + event_reachable = controller.step( + dict(action="GetReachablePositions", gridSize=0.25) + ) - target_position = controller.step(action="GetObjectPosition", objectId=object_id).metadata[ - "actionReturn" - ] + target_position = controller.step( + action="GetObjectPosition", objectId=object_id + ).metadata["actionReturn"] reachable_positions = event_reachable.metadata["actionReturn"] @@ -2571,7 +2720,8 @@ def filter_points(selected_points, point_set, minimum_distance): [ p for p in point_set - if sqr_dist(p, selected) <= minimum_distance * minimum_distance + if sqr_dist(p, selected) + <= minimum_distance * minimum_distance ] ) point_set = point_set.difference(remove_set) @@ -2698,7 +2848,8 @@ def key_sort_func(scene_name): objects = [] for objectType in targets: if filter_file is None or ( - objectType in scene_object_filter and scene in scene_object_filter[objectType] + objectType in scene_object_filter + and scene in scene_object_filter[objectType] ): dataset[scene][objectType] = [] obj = get_points(controller, objectType, scene) @@ -2707,7 +2858,9 @@ def key_sort_func(scene_name): dataset_flat = dataset_flat + objects if intermediate_directory != ".": - with open(os.path.join(intermediate_directory, "{}.json".format(scene)), "w") as f: + with open( + os.path.join(intermediate_directory, "{}.json".format(scene)), "w" + ) as f: json.dump(objects, f, indent=4) with open(os.path.join(intermediate_directory, output), "w") as f: @@ -2758,7 +2911,9 @@ def shortest_path_to_object( agentMode="bot", visibilityDistance=visibility_distance, ) - path = metrics.get_shortest_path_to_object_type(controller, object, p, {"x": 0, "y": 0, "z": 0}) + path = metrics.get_shortest_path_to_object_type( + controller, object, p, {"x": 0, "y": 0, "z": 0} + ) minimum_path_length = metrics.path_distance(path) print("Path: {}".format(path)) @@ -2845,7 +3000,9 @@ def filter_dataset(ctx, filename, output_filename, ids=False): @task -def fix_dataset_object_types(ctx, input_file, output_file, editor_mode=False, local_build=False): +def fix_dataset_object_types( + ctx, input_file, output_file, editor_mode=False, local_build=False +): import ai2thor.controller with open(input_file, "r") as f: @@ -2891,7 +3048,9 @@ def fix_dataset_object_types(ctx, input_file, output_file, editor_mode=False, lo @task -def test_dataset(ctx, filename, scenes=None, objects=None, editor_mode=False, local_build=False): +def test_dataset( + ctx, filename, scenes=None, objects=None, editor_mode=False, local_build=False +): import ai2thor.controller import ai2thor.util.metrics as metrics @@ -2921,7 +3080,9 @@ def test_dataset(ctx, filename, scenes=None, objects=None, editor_mode=False, lo if objects is not None: object_set = set(objects.split(",")) print("Filtering {}".format(object_set)) - filtered_dataset = [d for d in filtered_dataset if d["object_type"] in object_set] + filtered_dataset = [ + d for d in filtered_dataset if d["object_type"] in object_set + ] current_scene = None current_object = None point_counter = 0 @@ -3009,7 +3170,9 @@ def visualize_shortest_paths( dataset_filtered = [d for d in dataset if d["scene"] in scene_f_set] if object_types is not None: object_f_set = set(object_types.split(",")) - dataset_filtered = [d for d in dataset_filtered if d["object_type"] in object_f_set] + dataset_filtered = [ + d for d in dataset_filtered if d["object_type"] in object_f_set + ] print("Running for {} points...".format(len(dataset_filtered))) index = 0 @@ -3023,7 +3186,8 @@ def visualize_shortest_paths( previous_index = index controller.reset(current_scene) while ( - current_scene == datapoint["scene"] and current_object == datapoint["object_type"] + current_scene == datapoint["scene"] + and current_object == datapoint["object_type"] ): index += 1 if index > len(dataset_filtered) - 1: @@ -3037,7 +3201,9 @@ def visualize_shortest_paths( failed[key] = [] - print("Points for '{}' in scene '{}'...".format(current_object, current_scene)) + print( + "Points for '{}' in scene '{}'...".format(current_object, current_scene) + ) evt = controller.step( action="AddThirdPartyCamera", rotation=dict(x=90, y=0, z=0), @@ -3048,7 +3214,9 @@ def visualize_shortest_paths( sc = dataset_filtered[previous_index]["scene"] obj_type = dataset_filtered[previous_index]["object_type"] - positions = [d["initial_position"] for d in dataset_filtered[previous_index:index]] + positions = [ + d["initial_position"] for d in dataset_filtered[previous_index:index] + ] # print("{} : {} : {}".format(sc, obj_type, positions)) evt = controller.step( action="VisualizeShortestPaths", @@ -3147,7 +3315,9 @@ def key_sort_func(scene_name): for datapoint in filter_dataset: missing_datapoints_by_scene[datapoint["scene"]].append(datapoint) - partial_dataset_filenames = sorted(glob.glob("{}/FloorPlan_*.png".format(dataset_dir))) + partial_dataset_filenames = sorted( + glob.glob("{}/FloorPlan_*.png".format(dataset_dir)) + ) print("Datas") difficulty_order_map = {"easy": 0, "medium": 1, "hard": 2} @@ -3160,8 +3330,12 @@ def key_sort_func(scene_name): final_dataset = [] for scene in scenes: for object_type in targets: - arr = [p for p in partial_dataset[scene] if p["object_type"] == object_type] + [ - p for p in missing_datapoints_by_scene[scene] if p["object_type"] == object_type + arr = [ + p for p in partial_dataset[scene] if p["object_type"] == object_type + ] + [ + p + for p in missing_datapoints_by_scene[scene] + if p["object_type"] == object_type ] final_dataset = final_dataset + sorted( arr, @@ -3223,7 +3397,10 @@ def resort_dataset(ctx, dataset_path, output_path, editor_mode=False, local_buil new_dataset = [] while index < len(dataset): previous_index = index - while current_scene == datapoint["scene"] and current_object == datapoint["object_type"]: + while ( + current_scene == datapoint["scene"] + and current_object == datapoint["object_type"] + ): index += 1 if index > len(dataset) - 1: break @@ -3381,7 +3558,9 @@ def reachable_pos(ctx, scene, editor_mode=False, local_build=False): @task -def get_physics_determinism(ctx, scene="FloorPlan1_physics", agent_mode="arm", n=100, samples=100): +def get_physics_determinism( + ctx, scene="FloorPlan1_physics", agent_mode="arm", n=100, samples=100 +): import ai2thor.controller import random @@ -3428,7 +3607,11 @@ def act(controller, actions, n): controller, num_trials, ObjectPositionVarianceAverage() ): act(controller, actions, n) - print(" actions: '{}', object_position_variance_average: {} ".format(action_name, metric)) + print( + " actions: '{}', object_position_variance_average: {} ".format( + action_name, metric + ) + ) @task @@ -3467,7 +3650,8 @@ def generate_pypi_index(context): def ci_test_utf(branch, commit_id, base_dir): logger.info( - "running Unity Test framework testRunner for %s %s %s" % (branch, commit_id, base_dir) + "running Unity Test framework testRunner for %s %s %s" + % (branch, commit_id, base_dir) ) results_path, results_logfile = test_utf(base_dir) @@ -3601,14 +3785,18 @@ def format_py(context): @task -def install_unity_hub(context, target_dir=os.path.join(os.path.expanduser("~"), "local/bin")): +def install_unity_hub( + context, target_dir=os.path.join(os.path.expanduser("~"), "local/bin") +): import stat import requests if not sys.platform.startswith("linux"): raise Exception("Installation only support for Linux") - res = requests.get("https://public-cdn.cloud.unity3d.com/hub/prod/UnityHub.AppImage") + res = requests.get( + "https://public-cdn.cloud.unity3d.com/hub/prod/UnityHub.AppImage" + ) res.raise_for_status() os.makedirs(target_dir, exist_ok=True) @@ -3636,7 +3824,9 @@ def install_unity_editor(context, version=None, changeset=None): unity_hub_path = None if sys.platform.startswith("linux"): - unity_hub_path = os.path.join(os.path.expanduser("~"), "local/bin/UnityHub.AppImage") + unity_hub_path = os.path.join( + os.path.expanduser("~"), "local/bin/UnityHub.AppImage" + ) elif sys.platform.startswith("darwin"): unity_hub_path = "/Applications/Unity\ Hub.app/Contents/MacOS/Unity\ Hub --" else: @@ -3676,17 +3866,24 @@ def generate_unity_alf(context): # with manual activation https://docs.unity3d.com/Manual/ManualActivationGuide.html alf_path = "Unity_v%s.alf" % _unity_version() - subprocess.run("%s -batchmode -createManualActivationFile" % _unity_path(), shell=True) + subprocess.run( + "%s -batchmode -createManualActivationFile" % _unity_path(), shell=True + ) assert os.path.isfile(alf_path), "ALF not found at %s" % alf_path - print("ALF created at %s. Activate license at: https://license.unity3d.com/manual" % alf_path) + print( + "ALF created at %s. Activate license at: https://license.unity3d.com/manual" + % alf_path + ) @task def activate_unity_license(context, ulf_path): assert os.path.isfile(ulf_path), "License file '%s' not found" % ulf_path - subprocess.run('%s -batchmode -manualLicenseFile "%s"' % (_unity_path(), ulf_path), shell=True) + subprocess.run( + '%s -batchmode -manualLicenseFile "%s"' % (_unity_path(), ulf_path), shell=True + ) def test_utf(base_dir=None): @@ -3766,7 +3963,9 @@ def test_{methodname}(self): test_record_data = " pass" if test_records: test_record_data = "\n".join(test_records) - encoded_class_name = re.sub(r"[^a-zA-Z0-9_]", "_", re.sub("_", "__", class_name)) + encoded_class_name = re.sub( + r"[^a-zA-Z0-9_]", "_", re.sub("_", "__", class_name) + ) class_data.append( f""" class {encoded_class_name}: @@ -3969,7 +4168,9 @@ def test_render(ctx, editor_mode=False, local_build=False): if img is not None: print(f"img r {img[0][0][0]} g {img[0][0][1]} b {img[0][0][2]}") - print(f"evt frame r {evt.cv2img[0][0][0]} g {evt.cv2img[0][0][1]} b {evt.cv2img[0][0][2]}") + print( + f"evt frame r {evt.cv2img[0][0][0]} g {evt.cv2img[0][0][1]} b {evt.cv2img[0][0][2]}" + ) cv2.namedWindow("image") @@ -4072,7 +4273,9 @@ def walls_to_floor_poly(walls): "empty": wall["empty"] if "empty" in wall else False, "polygon": wall_to_poly(wall), } - for (wall, wall_indx) in zip(room["walls"], range(0, len(room["walls"]))) + for (wall, wall_indx) in zip( + room["walls"], range(0, len(room["walls"])) + ) ] for (room, room_i) in zip(obj["rooms"], range(len(obj["rooms"]))) ] @@ -4253,7 +4456,8 @@ def get_benchmark_title(benchmark, default_title=""): benchmarks = [load_benchmark_filename(filename) for filename in benchmark_filenames] benchmark_titles = [ - get_benchmark_title(b, "") for (i, b) in zip(range(0, len(benchmarks)), benchmarks) + get_benchmark_title(b, "") + for (i, b) in zip(range(0, len(benchmarks)), benchmarks) ] if plot_titles is not None: @@ -4279,7 +4483,10 @@ def get_benchmark_title(benchmark, default_title=""): ) all_data = reduce( list.__add__, - [[(x, [y[action] for y in b]) for action in all_data[0][1][0]] for (x, b) in all_data], + [ + [(x, [y[action] for y in b]) for action in all_data[0][1][0]] + for (x, b) in all_data + ], ) keys = [k for (k, y) in all_data] @@ -4456,7 +4663,9 @@ def run_benchmark_from_s3_config(ctx): client = boto3.client("s3") - response = client.list_objects_v2(Bucket=BENCHMARKING_S3_BUCKET, Prefix="benchmark_jobs/") + response = client.list_objects_v2( + Bucket=BENCHMARKING_S3_BUCKET, Prefix="benchmark_jobs/" + ) s3 = boto3.resource("s3", region_name="us-west-2") benchmark_runs = [] @@ -4474,7 +4683,9 @@ def run_benchmark_from_s3_config(ctx): BENCHMARKING_S3_BUCKET, f"procedural_houses/{procedural_house}", ) - house_json = json.loads(house_obj.get()["Body"].read().decode("utf-8")) + house_json = json.loads( + house_obj.get()["Body"].read().decode("utf-8") + ) if "id" not in house_json: house_json["id"] = procedural_house.split(".")[0] procedural_houses_transformed.append(house_json) @@ -4535,7 +4746,9 @@ def run_benchmark_from_local_config( if house_from_s3: client = boto3.client("s3") - response = client.list_objects_v2(Bucket=BENCHMARKING_S3_BUCKET, Prefix="benchmark_jobs/") + response = client.list_objects_v2( + Bucket=BENCHMARKING_S3_BUCKET, Prefix="benchmark_jobs/" + ) s3 = boto3.resource("s3", region_name="us-west-2") benchmark_runs = [] key = config_path @@ -4562,7 +4775,9 @@ def run_benchmark_from_local_config( BENCHMARKING_S3_BUCKET, f"procedural_houses/{procedural_house}", ) - house_json = json.loads(house_obj.get()["Body"].read().decode("utf-8")) + house_json = json.loads( + house_obj.get()["Body"].read().decode("utf-8") + ) if "id" not in house_json: house_json["id"] = procedural_house.split(".")[0] procedural_houses_transformed.append(house_json) @@ -4577,12 +4792,15 @@ def run_benchmark_from_local_config( benchmark_run_config["init_params"]["commit_id"] = None benchmark_run_config["init_params"]["local_build"] = True del benchmark_run_config["init_params"]["platform"] - + + # benchmark_run_config['verbose'] = True action_groups = copy.deepcopy(benchmark_run_config["action_groups"]) del benchmark_run_config["action_groups"] - benchmark_runs.append((UnityActionBenchmarkRunner(**benchmark_run_config), action_groups)) + benchmark_runs.append( + (UnityActionBenchmarkRunner(**benchmark_run_config), action_groups) + ) benchmark_results = [] for benchmark_runner, action_group in benchmark_runs: benchmark_result = benchmark_runner.benchmark(action_group) @@ -4620,12 +4838,16 @@ def add_daily_benchmark_config(ctx, benchmark_config_filename): # validate(benchmark_config, schema=benchmarking_config_schema) try: logger.info(f"Pushing benchmark config '{benchmark_config_basename}'") - s3.Object(BENCHMARKING_S3_BUCKET, f"benchmark_jobs/{benchmark_config_basename}").put( + s3.Object( + BENCHMARKING_S3_BUCKET, f"benchmark_jobs/{benchmark_config_basename}" + ).put( Body=json.dumps(benchmark_config, indent=4), ContentType="application/json", ) except botocore.exceptions.ClientError as e: - logger.error(f"Caught error uploading archive '{benchmark_config_basename}': {e}") + logger.error( + f"Caught error uploading archive '{benchmark_config_basename}': {e}" + ) @task diff --git a/unity/Assets/Scripts/ActionDispatcher.cs b/unity/Assets/Scripts/ActionDispatcher.cs index fc1bc826b8..38763c4efa 100644 --- a/unity/Assets/Scripts/ActionDispatcher.cs +++ b/unity/Assets/Scripts/ActionDispatcher.cs @@ -20,6 +20,16 @@ public class ActionFinished { public bool isDummy; public ActionFinished() {} + + public ActionFinished(bool success = true, object actionReturn = null, string errorMessage = "", bool toEmitState = false, ServerActionErrorCode errorCode = 0, bool isDummy = false) { + this.success = success; + this.actionReturn = actionReturn; + this.errorMessage = errorMessage; + this.toEmitState = toEmitState; + this.errorCode = errorCode; + this.isDummy = isDummy; + } + public ActionFinished(ActionFinished toCopy) { this.success = toCopy.success; this.actionReturn = toCopy.actionReturn; diff --git a/unity/Assets/Scripts/AgentManager.cs b/unity/Assets/Scripts/AgentManager.cs index 0156400089..3112fbc101 100644 --- a/unity/Assets/Scripts/AgentManager.cs +++ b/unity/Assets/Scripts/AgentManager.cs @@ -1229,7 +1229,6 @@ public IEnumerator EmitFrame() { ThirdPartyCameraMetadata[] cameraMetadata = new ThirdPartyCameraMetadata[this.thirdPartyCameras.Count]; List> renderPayload = new List>(); createPayload(multiMeta, cameraMetadata, renderPayload, shouldRender, shouldRenderImageSynthesis); - Debug.Log("------ payload"); #if UNITY_WEBGL JavaScriptInterface jsInterface = this.primaryAgent.GetComponent(); if (jsInterface != null) { diff --git a/unity/Assets/Scripts/ArmCollisionResolver.cs b/unity/Assets/Scripts/ArmCollisionResolver.cs index 7a50d3b7c0..8e6b377e24 100644 --- a/unity/Assets/Scripts/ArmCollisionResolver.cs +++ b/unity/Assets/Scripts/ArmCollisionResolver.cs @@ -15,7 +15,6 @@ public class ArmCollisionResolver : CollisionEventResolver { base.Start(); arm = this.GetComponent(); var collisionListener = this.GetComponentInParent(); - Debug.Log("-------- ArmCollisionResolver Start"); } public override StaticCollision resolveToStaticCollision(Collider externalCollider, HashSet internalColliders) { diff --git a/unity/Assets/Scripts/BaseFPSAgentController.cs b/unity/Assets/Scripts/BaseFPSAgentController.cs index c454c87bfa..28eaae048f 100644 --- a/unity/Assets/Scripts/BaseFPSAgentController.cs +++ b/unity/Assets/Scripts/BaseFPSAgentController.cs @@ -2365,7 +2365,6 @@ public virtual MetadataPatch generateMetadataPatch() { } public virtual MetadataWrapper generateMetadataWrapper() { - Debug.Log("calling generateMetadataWrapper"); // AGENT METADATA AgentMetadata agentMeta = new AgentMetadata(); agentMeta.name = "agent"; @@ -6796,7 +6795,33 @@ public void CreateRuntimeAsset(ProceduralAsset asset) { actionFinished(success: true, actionReturn: assetData); } - public void CreateRuntimeAsset( + public class UnityLoadableAsset { + public string id; + public string dir; + public string extension = ".msgpack.gz"; + + public ObjectAnnotations annotations = null; + } + + public ActionFinished CreateRuntimeAssets( + List assets, + string dir = null + ) { + foreach (var asset in assets) { + var actionFinished = CreateRuntimeAsset( + id: asset.id, + dir: dir ?? asset.dir, + extension: asset.extension, + annotations: asset.annotations + ); + if (!actionFinished.success) { + return actionFinished; + } + } + return ActionFinished.Success; + } + + public ActionFinished CreateRuntimeAsset( string id, string dir, string extension = ".msgpack.gz", @@ -6809,18 +6834,16 @@ public void CreateRuntimeAsset( var supportedExtensions = new HashSet(){ ".gz", ".msgpack", ".msgpack.gz", ".json" }; - Debug.Log($"------- CreateRuntimeAsset for '{id}' extension: = {extension}"); + extension = !extension.StartsWith(".") ? $".{extension}" : extension; extension = extension.Trim(); if (!supportedExtensions.Contains(extension)) { - actionFinished(success: false, errorMessage: $"Unsupported extension `{extension}`. Only supported: {string.Join(", ", supportedExtensions)}", actionReturn: null); - return; + return new ActionFinished(success: false, errorMessage: $"Unsupported extension `{extension}`. Only supported: {string.Join(", ", supportedExtensions)}", actionReturn: null); } var filename = $"{id}{extension}"; var filepath = Path.Combine(dir, id, filename); if (!File.Exists(filepath)) { - actionFinished(success: false, actionReturn: null, errorMessage: $"Asset fiile '{filepath}' does not exist."); - return; + return new ActionFinished(success: false, actionReturn: null, errorMessage: $"Asset fiile '{filepath}' does not exist."); } // to support different @@ -6828,7 +6851,6 @@ public void CreateRuntimeAsset( using FileStream rawFileStream = File.Open(filepath, FileMode.Open); using var resultStream = new MemoryStream(); - Debug.Log($"------- raw file read at for '{filepath}'"); var stageIndex = 0; if ("gz" == presentStages[stageIndex]) { using var decompressor = new GZipStream(rawFileStream, CompressionMode.Decompress); @@ -6840,10 +6862,8 @@ public void CreateRuntimeAsset( ProceduralAsset procAsset = null; var debug = stageIndex < presentStages.Length ? presentStages[stageIndex] : "null"; - Debug.Log($"presentStages {presentStages}, at index {stageIndex}: {debug} , {debug == "msgpack"}, {presentStages.Length} "); if (stageIndex < presentStages.Length && presentStages[stageIndex] == "msgpack") { - Debug.Log("Deserialize raw json"); procAsset = MessagePack.MessagePackSerializer.Deserialize( resultStream.ToArray(), MessagePack.Resolvers.ThorContractlessStandardResolver.Options @@ -6859,19 +6879,12 @@ public void CreateRuntimeAsset( ObjectCreationHandling = ObjectCreationHandling.Replace }; var json = reader.ReadToEnd(); - Debug.Log($"Deserialize raw json at {filepath}: str {json}"); // procAsset = Newtonsoft.Json.JsonConvert.DeserializeObject(reader.ReadToEnd(), serializer); procAsset = JsonConvert.DeserializeObject(json); } else { - actionFinished(success: false, errorMessage: $"Unexpected error with extension `{extension}`. Only supported: {string.Join(", ", supportedExtensions)}", actionReturn: null); - return; + return new ActionFinished(success: false, errorMessage: $"Unexpected error with extension `{extension}`. Only supported: {string.Join(", ", supportedExtensions)}", actionReturn: null); } - - - Debug.Log($"procAsset is null? {procAsset == null} - {procAsset}, albedo rooted? {!Path.IsPathRooted(procAsset.albedoTexturePath)} {procAsset.albedoTexturePath}"); - procAsset.parentTexturesDir = Path.Combine(dir, id); - Debug.Log($" albedo after fix? {procAsset.albedoTexturePath}"); var assetData = ProceduralTools.CreateAsset( procAsset.vertices, @@ -6894,9 +6907,7 @@ public void CreateRuntimeAsset( addAnotationComponent: false, parentTexturesDir: procAsset.parentTexturesDir ); - - // Debug.Log($"root is null? {parent == null} - {parent}"); - actionFinished(success: true, actionReturn: assetData); + return new ActionFinished(success: true, actionReturn: assetData); } public void GetStreamingAssetsPath() { diff --git a/unity/Assets/Scripts/ProceduralTools.cs b/unity/Assets/Scripts/ProceduralTools.cs index dfbb1c1ad4..8998290c3e 100644 --- a/unity/Assets/Scripts/ProceduralTools.cs +++ b/unity/Assets/Scripts/ProceduralTools.cs @@ -1158,7 +1158,6 @@ public static (int, int, int) parseHouseVersion(string version) { } else { var versionSplit = version.Split('.'); - Debug.Log(string.Join(", ", versionSplit)); var versionResult = new int[] {0, 0, 0 }.Select((x, i) => { if (versionSplit.Length > i) { int outVersion; @@ -1504,13 +1503,11 @@ public static GameObject CreateHouse( // buildNavMesh(floorGameObject, house.proceduralParameters.navmeshVoxelSize); // Debug.Log($"Navmeshes {string.Join(", ", house.metadata.navMeshes.Select(n => $"{n.agentTypeID} radius {n.agentRadius}"))}"); - Debug.Log($"schema {house.metadata.schema}"); buildNavMeshes(floorGameObject, house.metadata.navMeshes); if (string.IsNullOrEmpty(house.proceduralParameters.skyboxId) || !materialDb.ContainsKey(house.proceduralParameters.skyboxId)) { var mat = new Material(Shader.Find("Standard")); - Debug.Log("--------- Working"); mat.color = house.proceduralParameters.skyboxColor.toUnityColor(); RenderSettings.skybox = mat; @@ -1640,7 +1637,6 @@ public static GameObject buildNavMeshSurface(NavMeshBuildSettings buildSettings, navMeshSurface.voxelSize = buildSettings.voxelSize; navMeshSurface.overrideVoxelSize = buildSettings.overrideVoxelSize; navMeshSurface.BuildNavMesh(buildSettings); - Debug.Log($"Created navmesh w agentType id {navMeshSurface.agentTypeID}"); return go; } @@ -1654,7 +1650,6 @@ public static GameObject buildNavMeshSurface(NavMeshConfig navMeshConfig, int in navMeshSurface.voxelSize = buildSettings.voxelSize; navMeshSurface.overrideVoxelSize = buildSettings.overrideVoxelSize; navMeshSurface.BuildNavMesh(buildSettings); - Debug.Log($"Created navmesh w agentType id {navMeshSurface.agentTypeID}"); return go; } @@ -2410,7 +2405,6 @@ public static Dictionary CreateAsset( foreach (Transform t in go.GetComponentsInChildren()) { if (t.parent == go.transform) { - Debug.Log($"Moving transform of {t.gameObject.name}"); t.parent = newGo.transform; } } diff --git a/unity/Assets/Scripts/RuntimePrefab.cs b/unity/Assets/Scripts/RuntimePrefab.cs index 9d9c6309fa..10bdd8f45c 100644 --- a/unity/Assets/Scripts/RuntimePrefab.cs +++ b/unity/Assets/Scripts/RuntimePrefab.cs @@ -48,7 +48,7 @@ Texture2D SwapChannelsRGBAtoRRRB(Texture2D originalTexture) { private void reloadtextures() { GameObject mesh = transform.Find("mesh").gameObject; // load the texture from disk - if (albedoTexturePath != null) { + if (!string.IsNullOrEmpty(albedoTexturePath)) { if (sharedMaterial.mainTexture == null) { Debug.Log("adding texture!!!"); byte[] imageBytes = File.ReadAllBytes(albedoTexturePath); @@ -58,7 +58,7 @@ private void reloadtextures() { } } - if (metallicSmoothnessTexturePath != null) { + if (!string.IsNullOrEmpty(metallicSmoothnessTexturePath)) { sharedMaterial.EnableKeyword("_METALLICGLOSSMAP"); byte[] imageBytes = File.ReadAllBytes(metallicSmoothnessTexturePath); Texture2D tex = new Texture2D(2, 2); @@ -69,7 +69,7 @@ private void reloadtextures() { sharedMaterial.SetTexture("_MetallicGlossMap", tex); } - if (normalTexturePath != null) { + if (!string.IsNullOrEmpty(normalTexturePath)) { sharedMaterial.EnableKeyword("_NORMALMAP"); byte[] imageBytes = File.ReadAllBytes(normalTexturePath); Texture2D tex = new Texture2D(2, 2); @@ -77,7 +77,7 @@ private void reloadtextures() { sharedMaterial.SetTexture("_BumpMap", tex); } - if (emissionTexturePath != null) { + if (!string.IsNullOrEmpty(emissionTexturePath)) { sharedMaterial.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive; sharedMaterial.EnableKeyword("_EMISSION"); byte[] imageBytes = File.ReadAllBytes(emissionTexturePath); diff --git a/unity/Assets/Scripts/Stretch_Robot_Arm_Controller.cs b/unity/Assets/Scripts/Stretch_Robot_Arm_Controller.cs index 09032f765d..24af6c7439 100644 --- a/unity/Assets/Scripts/Stretch_Robot_Arm_Controller.cs +++ b/unity/Assets/Scripts/Stretch_Robot_Arm_Controller.cs @@ -46,7 +46,7 @@ public override void ContinuousUpdate(float fixedDeltaTime) { private bool DeadZoneCheck() { if (deadZoneCheck) { - float currentYaw = armTarget.rotation.eulerAngles.y; + float currentYaw = armTarget.localRotation.eulerAngles.y; float cLimit = wristClockwiseLocalRotationLimit; float ccLimit = wristCounterClockwiseLocalRotationLimit;