facebookresearch / habitat-sim

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

distance_to_closest_obstacle(pt, radius) cannot return properly while pt getting close to the ground #2351

Open Fanxing-LI opened 6 months ago

Fanxing-LI commented 6 months ago

Habitat-Sim version

v0.3.1

I have created a self-defined drone dynamics system using habitatsim as render. And I obtain the collision status by comparing the pathfinder.distance_to_closest_obstacle() to the radius of my ball-shape agent.

I have confirmed that the "collision_assert" (the same as render_assert) is included in configs/stages/**.stage_config.json, "is_collidable" is set as true. Besides, I've double check these settings after creating the Simulator.

the issue is that, the distance returned from pathfinder.distance_to_closest_obstacle(point, max_search_radius) is correct while the point is getting close to walls and objects, but wrong while getting close to ground/floor. It seems that the agents do not consider the ground as obstacles, assuming that robot always stands on the floor.

If I want to free the point in the room and make it aware of the closest distance in any direction (including ground), how could I do. I appreciate it very much if you can offer any help.

Thanks!

aclegg3 commented 6 months ago

Hey @Fanxing-LI

Interesting application. A few points of clarification about how the system works may help:

  1. The navmesh (PathFinder) is an abstraction of the navigable area in a scene representing the agent as a cylinder and computing a mesh based on a voxelization of the scene geometry.
  2. The distance_to_closest_obstacle function gives distance to the nearest mesh edge from the snapped point.
  3. Pathfinder does not use the collision proxy for the asset, it only uses the NavMeshSettings which by default is computed from the agent's height and radius config.
  4. The navmesh will not be a great representation if you want to the drone to be able to fly/hover over obstacles in addition to avoiding them.

It sounds like you have a clever way of using the navmesh for a drone to avoid walls and large obstacles, but you want vertical distance (e.g. to floor and maybe ceiling) in addition. One way to accomplish this is to setup some raycasts as sensors. For example, cast a ray from the center of your drone down the Y-axis and use the first hit distance (which isn't your drone). Similarly, you could setup rays in other directions for additional sensors.

Another option (if the world is mostly static, like scan scenes) would be to pre-compute a signed distance field in the space and then query from the cache for your drone's position.