facebookresearch / habitat-lab

A modular high-level library to train embodied AI agents across a variety of tasks and environments.
https://aihabitat.org/
MIT License
1.93k stars 483 forks source link

shortest path to the object goal #419

Closed yimengli46 closed 4 years ago

yimengli46 commented 4 years ago

❓ Questions and Help

Hi, I was wondering if there is a direct way to get the shortest distance to the target object. I tried the shortest path follower with one of the target object view but it doesn't seem to work.

erikwijmans commented 4 years ago

You can see how the distance to goal measure works here: https://github.com/facebookresearch/habitat-api/blob/master/habitat/tasks/nav/nav.py#L953. The "VIEW_POINTS" mode is used for objectnav.

yimengli46 commented 4 years ago

Thanks for the answer. I have a follow-up question, not sure if it's solvable. So this goal measure will tell the distance from agent current state to one of the goal view. Is there a way to get the geodesic distance after taking each action? Because calling env.step(action) you can compute the distance for only one action, not all the actions. In the DD-PPO baseline, the reward computing is only for the taken action, not all the actions.

erikwijmans commented 4 years ago

This is not something that is neatly wrapped up into an existing functionality, but is completely doable. While it is in cpp, it may be useful to look at the primitive selection part of the local planner/shortest path follower -- here: https://github.com/facebookresearch/habitat-sim/blob/master/src/esp/nav/GreedyFollower.cpp#L81 (maybe also be useful to look at the python code that drives it: https://github.com/facebookresearch/habitat-sim/blob/master/habitat_sim/nav/greedy_geodesic_follower.py) -- as all the necessary parts are bound to python.

yimengli46 commented 4 years ago

Thanks.

yimengli46 commented 4 years ago

Hi Erik, sorry to bother you again. I looked at the code you suggested me carefully. I would like to know if there is a way to call greedy_geodesic_follower for the objectnav task? It seems to me that greedy_geodesic_follower is designed for a single goal location. However, objectnav has multiple viewpoints for one target object.

erikwijmans commented 4 years ago

No, there isn't. This is done on purpose as the multi-goal geodesic distance computation is considerably slower than single goal. You can get the closest point by first running a multi-goal geodesic distance computation/path find, the .points field is the list of way points to the closest goal point, with .points[-1] being the closest goal. You can then give that point to the follower.

yimengli46 commented 4 years ago

Thanks, it's very helpful.