Closed XiaoLiSean closed 3 years ago
Hi @XiaoLiSean,
The following minimal example should allow the agent to navigate such that it is not snapped to the grid:
from ai2thor.controller import Controller
controller = Controller(snapToGrid=False, gridSize=0.25)
print(controller.last_event.metadata["agent"}["position"])
controller.step(action="MoveAhead", moveMagnitude=0.15)
print(controller.last_event.metadata["agent"}["position"])
Thanks for your help. I have a follow-up issue regarding the teleport
attributes. Basically, I have the following code which teleports the agent to a position:
controller = Controller(scene='FloorPlan26', snapToGrid=False, applyActionNoise=False, renderObjectImage=True) event = controller.step(action='Teleport', position=dict(x=-2.0, y=0.9, z=3.75), rotation=dict(x=0.0, y=180, z=0.0)) print(event.metadata['agent']) exit()
However, the result robot position end up at {'x': 0.0, 'y': -39.24, 'z': 0.0}
which is out of the scene bound. Could you point me to the right way of coding so that I can teleport the agent to the desired position? Thanks in advance.
Hi, I suspect this has to due with an out of bounds or clipping issue.
The normal way to teleport is with GetReachablePositions
:
import random
from ai2thor.controller import Controller
controller = Controller(snapToGrid=False)
positions = controller.step(action="GetReachablePositions").metadata["actionReturn"]
position = random.choice(positions)
controller.step(
action="Teleport",
position=position
)
If you are certain that x=-2
and z=3.75
exists in the scene, I suspect that the y
location of the agent is off. Instead of setting it to 0.9
, set it exactly to the current y
coordinate of the agent: y=controller.last_event.metadata["agent"]["position"]["y"]
.
Just to clarify, the point at x=-2
and z=3.75
exists in the scene and is in the list of "ReachablePositions". I just replace the y coordinates as controller.last_event.metadata["agent"]["position"]["y"]
. Same phenomenon occurred.
Hmm... I just tried running it in the latest version and it looks like it works for me.
from ai2thor.controller import Controller
controller = Controller(scene="FloorPlan26", snapToGrid=False)
event = controller.step(action="Teleport", position=dict(x=-2.0, y=0.9015910625457764, z=3.75, rotation=dict(x=0, y=180, z=0))
print(event.metadata["agent"]["position"])
Can you check which version of AI2-THOR you're using; e.g.,
import ai2thor
print(ai2thor.__version__)
my ai2thor is version 2.4.22.
Are you able to upgrade your version? I believe this bug might have been fixed fairly somewhat recently.
Sure. I just updated to the lastest version and everything works just fine. Thanks!
I'd like to inquire if the continuous action is deprecated in some latest versions (i.e. ai2thor=2.4.22 from conda forge). I tried the command mentioned in this issue #40 :
controller = Controller() controller.reset('FloorPlan1') event = controller.step(dict(action='Initialize', continuous=True)) print(event.metadata['agent']) event = controller.step(action='RotateLeft', degrees=45.0) print(event.metadata['agent']) exit()
However, the returned robot position still snapped to the grid (default grid size 0.25). I'm wondering if my code leads to this problem or the continuous functionality is deprecated.