allenai / allenai/ai2thor

snapToGrid affects GetReachablePositions

Đang mở
#1,208 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C#
Star
1.8k
Fork
296
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

```py
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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.