snapToGrid affects GetReachablePositions
- Vorherrschende Sprache
- C#
- Sterne
- 1.8k
- Forks
- 297
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.