How to use the ai2thor.controller.key_for_point function in ai2thor

To help you get started, we’ve selected a few ai2thor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github allenai / ai2thor / tests / test_controller.py View on Github external
def test_key_for_point():
    assert ai2thor.controller.key_for_point(2.567, -3.43) == "2.6 -3.4"
github allenai / ai2thor / ai2thor / offline_controller.py View on Github external
def find_position(self, x, z, rotation, camera_horizon):
        for p in self.positions[key_for_point(x, z)]:
            met = p['metadata']
            if abs(met['agent']['rotation']['y'] - rotation) < 1.0 and abs(met['agent']['cameraHorizon'] - camera_horizon) < 1.0:

                event = self.load_event(p)
                return event

        return None
github allenai / ai2thor / ai2thor / offline_controller.py View on Github external
def reset(self, scene_name):
        self.scene_name = scene_name
        self.positions = defaultdict(list)
        for g in glob.glob('%s/%s/metadata/*.json' % (self.base_dir,self.scene_name)):
            with open(g) as f:
                j = json.loads(f.read())
                pos = j['agent']['position']
                key = key_for_point(pos['x'], pos['z'])
                pos_id = os.path.splitext(os.path.basename(g))[0]
                event_path = os.path.join('%s/%s/events/%s.pickle' % (self.base_dir, self.scene_name, pos_id))
                self.positions[key].append({'event': event_path, 'metadata': j})

        p = self.positions[list(self.positions.keys())[50]][0]
        self.last_event = self.load_event(p)