Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snapToGrid affects GetReachablePositions #1208

Open
garfieldnate opened this issue Apr 18, 2024 · 0 comments
Open

snapToGrid affects GetReachablePositions #1208

garfieldnate opened this issue Apr 18, 2024 · 0 comments

Comments

@garfieldnate
Copy link

If you set snapToGrid to False, GetReachablePositions may or may not return positions that are directly on the grid points. Here's an example:

from ai2thor.controller import Controller

# Spawn in FloorPlan1 with snapToGrid disabled
controller = Controller(snapToGrid=False)

# reachable floor XZ coordinates are multiples of .25, the default gridSize parameter
event = controller.step("GetReachablePositions")
print(event.metadata["actionReturn"])

# Walk to the left and around the kitchen island
controller.step("RotateLeft")
for i in range(12):
    controller.step("MoveAhead")
controller.step("RotateLeft")
for i in range(11):
    controller.step("MoveAhead")

# reachable floor XZ coordinates are no longer multiples of .25!
event = controller.step("GetReachablePositions")
print(event.metadata["actionReturn"])

The output will look like this:

[{'x': 0.0, 'y': 0.9009992480278015, 'z': -1.25}, {'x': 0.25, 'y': 0.9009992480278015, 'z': -1.25},...
[{'x': -2.750000238418579, 'y': 0.9009992480278015, 'z': 1.75}, {'x': -2.500000238418579, 'y': 0.9009992480278015, 'z': 1.75},...

Notice that the first reachable positions printed have the XZ coordinates rounded to .25 (the gridSize), and the second ones do not. The extra digits always seem to occur at the 7th decimal point, which is around where 32-bit precision lies, so it makes me wonder a 32-bit float is being used where a 64-bit one should be on the unity side somewhere.

This was an issue for us because we were doing exact matching over the coordinate values while looking for a path through the scene. There's a method in Controller.py called key_for_point (also used for path finding of some sort), and it seems to account for this discrepancy by always rounding to 3 decimal places (although, of course, if gridSize is very small this will not work). For now I'm using the same workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant