ai2thor icon indicating copy to clipboard operation
ai2thor copied to clipboard

isCaught and LauncherPosition metadata missing

Open IdrissGo opened this issue 3 years ago • 5 comments

I am working with a drone agentMode and I need access to this data. However, although I find them in the code of DroneFPSAgentController.cs, when I try to access, say, metadata['agent']['launcherPosition'] I get a key error.

I have downloaded this project https://github.com/KuoHaoZeng/Visual_Reaction which uses ai2thor 2.4.0 and the fields are available with this version but I would like to work with the latest version of ai2thor.

Do I need to modify something in the python API or is it something I need to change in the unity backend?

IdrissGo avatar Feb 21 '22 12:02 IdrissGo

I believe I have found the issue, we have refactored the way our metadata is packaged a bit since version 2.4.0, and in part of that process some of the drone agent metadata was moved to a different class for the purposes of reorganization.

During this move, it seems that the drone metadata for luancher position got changed to be LauncherPosition with a capital "L" at the start, so that would be why your key is throwing an error.

In a future release we will update this key to be correctly camel cased to be in format with the others, but for now please try using LauncherPosition instead of launcherPosition until the update is live.

winthos avatar Feb 21 '22 19:02 winthos

Thanks for your reply. Actually when running metadata['agent'].keys() there are no key that refer to the launcher. Full code with ai2thor 4.2.0 from ai2thor.controller import Controller controller = Controller(agentMode='drone') controller.step(dict(action='SpawnDroneLauncher',position=dict(x=0,y=0,z=0))) print(controller.last_event.metadata['agent'])

this gives the output : {'cameraHorizon': -0.0, 'inHighFrictionArea': False, 'isStanding': None, 'name': 'drone', 'position': {'x': 0.0, 'y': 0.2010042667388916, 'z': -1.25}, 'rotation': {'x': -0.0, 'y': 90.0, 'z': 0.0}}

I also tried launching an object and look at metadata of said object and there is no field 'isCaught' It's like the specific metadata returned by the drone agent controller is not returned...

IdrissGo avatar Feb 21 '22 20:02 IdrissGo

We found that the drone specific metadata was having a serialization issue related to the way we use Msgpack to serialize our metadata out from Unity. We have a PR that fixes this (https://github.com/allenai/ai2thor/pull/989) which will be merged into the main build and will be included in the next pip release.

In the meantime, you can use the commit ID of this fix in the initialization of your controller as an additional parameter in order to use this fix without having to wait for the next release. The commit ID for the PR is: 00d171e440e0ad249108bba3a6f10d663372af81

You can initialize your controller to use the commit id by the following syntax

from ai2thor.controller import Controller

controller = Controller(commit_id="00d171e440e0ad249108bba3a6f10d663372af81")

winthos avatar Feb 24 '22 18:02 winthos

Thanks a lot for your quick reaction, how can I use it in headless mode though?

When I run controller = Controller(commit_id="00d171e440e0ad249108bba3a6f10d663372af81",platform=CloudRendering) I get the following error : ValueError: Invalid commit_id: 00d171e440e0ad249108bba3a6f10d663372af81 - no build exists for arch=Linux platforms=CloudRendering

IdrissGo avatar Feb 25 '22 09:02 IdrissGo

The fix for the drone metadata has been merged into main. This has yet to be released as a pip, but you can initialize the controller as follows to get the change:

controller = Controller(commit_id="f9fb7fa2123510ef3e60eabfa87b9be50374ce7c", platform=CloudRendering)

ekolve avatar Apr 06 '22 21:04 ekolve