facebookresearch / habitat-sim

A flexible, high-performance 3D simulator for Embodied AI research.
https://aihabitat.org/
MIT License
2.48k stars 406 forks source link

How to snap a point to the floor plane on the navmesh? #2344

Closed frank-gallagher closed 4 months ago

frank-gallagher commented 4 months ago

❓ Questions and Help

I'm trying to sample a navigable point by snapping the room centroid to the navmesh. However, I'm having issues with the point being snapped onto a bed, where it is possible for the agent to sit but is unable to navigate to/from other parts of the scene.

How can I snap the point to the floor plane and avoid it being snapped onto the bed or similar obstacles?

aclegg3 commented 4 months ago

Hey @frank-gallagher

What you want to do is restrict your navmesh snapping to a particular island. You'll notice that the snap_point API contains an option for island_id. The default value (-1) specifies the full navmesh. You can use get_island to check which island a particular point is closest to. You can also use our habitat-lab function (or borrow inspiration from it) to find the largest indoor navmesh island which most likely is the one you want to use.

In short, you'll want to compute the island you want the agent to use and then restrict all PathFinder API calls (snaps and sampling) to that island.