allenai / ai2thor

An open-source platform for Visual AI.
http://ai2thor.allenai.org
Apache License 2.0
1.12k stars 215 forks source link

is it possible to get the shortest path for drone? #1078

Open Tom-Huang opened 1 year ago

Tom-Huang commented 1 year ago

Dear developers of AI2THOR, thank you very much for providing this tool to the community. It is really helpful in embodied AI research.

I have a problem regarding the get_shortest_path_to_point function. I want to get the shortest path for the drone to navigate between positions, ignoring obstacles on the ground and navigating at a certain height level. However, I found that the generated shortest path always has "y" value close to 0 even when the initial_position and the target_position have values around 1.7. Also, the generated shortest path always circumvent objects on the ground like sofa, tables and so on.

I want to ask if you know whether I can get the shortest path at a certain height level? Thank you in advance!

the code to reproduce the results are:

from ai2thor.controller import Controller

kitchens = [f"FloorPlan{i}" for i in range(1, 31)]
living_rooms = [f"FloorPlan{200 + i}" for i in range(1, 31)]
bedrooms = [f"FloorPlan{300 + i}" for i in range(1, 31)]
bathrooms = [f"FloorPlan{400 + i}" for i in range(1, 31)]

scenes = kitchens + living_rooms + bedrooms + bathrooms

controller = Controller(
    agentMode="drone",
    visibilityDistance=1.5,
    scene="FloorPlan1",
    gridSize=0.1,
    snapToGrid=False,
    movementGaussianSigma=0,
    rotateStepDegrees=15,
    rotateGaussianSigma=0,
    renderDepthImage=True,
    renderClassImage=True,
    renderInstanceSegmentation=True,
    width=1080,
    height=720,
    fieldOfView=90
)

positions = controller.step(
    action="GetReachablePositions"
).metadata["actionReturn"]

# set the drone to certain height
tmp = positions[0]
new_pos = dict(x=tmp['x'], y=tmp['y'] + 1.5, z=tmp['z']) 
event = controller.step(
    action="Teleport",
    position=new_pos,
    rotation=dict(x=0, y=0, z=0),
    horizon=0
)

from ai2thor.util.metrics import (
    get_shortest_path_to_point
)
position = controller.last_event.metadata["agent"]["position"]

target_position = dict(x=position["x"]+0.25, y=position["y"], z=position["z"]+0.25)
path = get_shortest_path_to_point(controller=controller, initial_position=position, target_position=target_position)

print(path)

you can see that all positions in path have "y" values around zero.

zhaowei-wang-nlp commented 4 months ago

I also get this problem. Is there any update?