Exemplo n.º 1
0
    def step(self, action, object_id=None, receptacleObjectId=None, epsd_collector=None):
        assert object_id is not None
        object_id = PlanParser.map_legal_object_name_back(object_id)
        if action in ["PickupObject", "OpenObject", "DropObject"]:
            super().step(action=action, objectId=object_id)
        elif action == "PutObjectIntoReceptacle":
            assert receptacleObjectId is not None
            receptacleObjectId = PlanParser.map_legal_object_name_back(receptacleObjectId)
            super().step(action="PutObject", objectId=object_id, receptacleObjectId=receptacleObjectId)

        if epsd_collector:
            epsd_collector.add_experience(self.env.step_output, action)
Exemplo n.º 2
0
 def step(self,
          action,
          object_id=None,
          receptacleObjectId=None,
          from_playroom=None):
     assert object_id is not None
     object_id = PlanParser.map_legal_object_name_back(
         object_id, from_playroom)
     if action in [
             "PickupObject", "OpenObject", "DropObject", "CloseObject"
     ]:
         super().step(action=action, objectId=object_id)
     elif action == "PutObjectIntoReceptacle":
         assert receptacleObjectId is not None
         receptacleObjectId = PlanParser.map_legal_object_name_back(
             receptacleObjectId, from_playroom)
         super().step(action="PutObject",
                      objectId=object_id,
                      receptacleObjectId=receptacleObjectId)
                print(plan)
                break
            if result_plan[0]['action'] == "LookForObjectInReceptacle":
                new_config = deepcopy(metaController.env.scene_config)
                new_config['performerStart']['position'] = {
                    "x": metaController.env.step_output.position['x'],
                    "y": 0,
                    "z": metaController.env.step_output.position['z']
                }
                new_config['performerStart']['rotation'] = {
                    "y": metaController.env.step_output.rotation
                }
                new_config['goal'][
                    'category'] = 'searchObjectInReceptacleTraining'
                new_config['goal']['metadata'][
                    'targetReceptacleId'] = PlanParser.map_legal_object_name_back(
                        result_plan[0]['receptacleId'])

                file_name = new_config['name'].split(".")[0]
                file_path = os.path.join(
                    'interaction_scenes', 'searchObjectInReceptacleTraining',
                    "{}_{}.json".format(file_name, search_cnt))
                with open(file_path, 'w') as fp:
                    json.dump(new_config, fp, indent=4)
                search_cnt += 1
            success = metaController.step(result_plan[0])
            if not success:
                break
            if result_plan[0]['action'] == "End":
                break
            meta_stage += 1
        # time.sleep(2)