habitat_sim.nav.PathFinder class

Loads and/or builds a navigation mesh and then allows point sampling, path finding, collision, and island queries on that navmesh. See PathFinder C++ API docs for more details.

Methods

def build_navmesh_vertex_indices(self, island_index: int = -1) -> typing.List[int]
Returns an array of triangle index data for the triangulated NavMesh poly vertices returned by build_navmesh_vertices(). Optionally limit results to a specific island. Default (island_index==-1) queries all islands.
def build_navmesh_vertices(self, island_index: int = -1) -> typing.List[numpy.ndarray[numpy.float32[3, 1]]]
Returns an array of vertex data for the triangulated NavMesh polys. Optionally limit results to a specific island. Default (island_index==-1) queries all islands.
def closest_obstacle_surface_point(self, pt: numpy.ndarray[numpy.float32[3, 1]], max_search_radius: float = 2.0) -> HitRecord
Returns the hit_pos <HitRecord.hit_pos>, hit_normal <HitRecord.hit_normal>, and hit_dist <HitRecord.hit_dist> of the surface point on the closest obstacle.
def distance_to_closest_obstacle(self, pt: numpy.ndarray[numpy.float32[3, 1]], max_search_radius: float = 2.0) -> float
Returns the distance to the closest obstacle
def find_path(self, path: ShortestPath) -> bool
Finds the shortest path between two points on the navigation mesh using ShortestPath module. Path variable is filled if successful. Returns boolean success.
def find_path(self, path: MultiGoalShortestPath) -> bool
Finds the shortest path between a start point and the closest of a set of end points (in geodesic distance) on the navigation mesh using MultiGoalShortestPath module. Path variable is filled if successful. Returns boolean success.
def get_bounds(self, /) -> typing.Tuple[numpy.ndarray[numpy.float32[3, 1]], numpy.ndarray[numpy.float32[3, 1]]]
Get the axis aligned bounding box containing the navigation mesh.
def get_island(self, point: magnum.Vector3) -> int
Query the island closest to a point. Snaps the point to the NavMesh first, so check the snap distance also if unsure.
def get_island(self, point: numpy.ndarray[numpy.float32[3, 1]]) -> int
Query the island closest to a point. Snaps the point to the NavMesh first, so check the snap distance also if unsure.
def get_random_navigable_point(self, max_tries: int = 10, island_index: int = -1) -> numpy.ndarray[numpy.float32[3, 1]]
Samples a navigable point uniformly at random from the navmesh
def get_random_navigable_point_near(self, circle_center: numpy.ndarray[numpy.float32[3, 1]], radius: float, max_tries: int = 100, island_index: int = -1) -> numpy.ndarray[numpy.float32[3, 1]]
Returns a random navigable point within a specified radius about a given point. Optionally specify the island from which to sample the point. Default -1 queries the full navmesh.
def get_topdown_island_view(self, meters_per_pixel: float, height: float, eps: float = 0.5) -> numpy.ndarray[numpy.int32[m, n]]
Returns the topdown view of the PathFinder’s navmesh with island indices at each point or -1 for non-navigable cells for a given vertical slice with eps slack.
def get_topdown_view(self, meters_per_pixel: float, height: float, eps: float = 0.5) -> numpy.ndarray[bool[m, n]]
Returns the topdown view of the PathFinder’s navmesh at a given vertical slice with eps slack.
def is_navigable(self, pt: numpy.ndarray[numpy.float32[3, 1]], max_y_delta: float = 0.5) -> bool
Checks to see if the agent can stand at the specified point
def island_area(self, island_index: int = -1) -> float
The total area of all NavMesh polygons within the specified island.
def island_radius(self, pt: numpy.ndarray[numpy.float32[3, 1]]) -> float
Given a point, snaps to an islan and gets a heuristic of island size: the radius of a circle containing all NavMesh polygons within the specified island.
def island_radius(self, island_index: int) -> float
Given an island index, gets a heuristic of island size: the radius of a circle containing all NavMesh polygons within the specified island.
def load_nav_mesh(self, path: str) -> bool
Load a .navmesh file overriding this PathFinder instance.
def save_nav_mesh(self, path: str) -> bool
Serialize this PathFinder instance and current NavMesh settings to a .navmesh file.
def seed(self, arg0: int, /) -> None
Seed the pathfinder. Useful for get_random_navigable_point(). Seeds the global c rand function.
def snap_point(self, point: magnum.Vector3, island_index: int = -1) -> magnum.Vector3
Snaps a point to the closet navigable location
def snap_point(self, point: numpy.ndarray[numpy.float32[3, 1]], island_index: int = -1) -> numpy.ndarray[numpy.float32[3, 1]]
Snaps a point to the closet navigable location
def try_step(self, start: magnum.Vector3, end: magnum.Vector3) -> magnum.Vector3
Find a valid location for the agent to actually step to when it attempts to step between start and end
def try_step(self, start: numpy.ndarray[numpy.float32[3, 1]], end: numpy.ndarray[numpy.float32[3, 1]]) -> numpy.ndarray[numpy.float32[3, 1]]
Find a valid location for the agent to actually step to when it attempts to step between start and end
def try_step_no_sliding(self, start: magnum.Vector3, end: magnum.Vector3) -> magnum.Vector3
def try_step_no_sliding(self, start: numpy.ndarray[numpy.float32[3, 1]], end: numpy.ndarray[numpy.float32[3, 1]]) -> numpy.ndarray[numpy.float32[3, 1]]

Special methods

def __init__(self, /) -> None

Properties

is_loaded: bool get
Whether a valid navigation mesh is currently loaded or not.
The settings for the current NavMesh.
The total area of all NavMesh polygons.
num_islands: int get
The number of connected components making up the navmesh.

Method documentation

def habitat_sim.nav.PathFinder.closest_obstacle_surface_point(self, pt: numpy.ndarray[numpy.float32[3, 1]], max_search_radius: float = 2.0) -> HitRecord

Returns the hit_pos <HitRecord.hit_pos>, hit_normal <HitRecord.hit_normal>, and hit_dist <HitRecord.hit_dist> of the surface point on the closest obstacle.

If the returned hit_dist <HitRecord.hit_dist> is equal to max_search_radius, no obstacle was found.

def habitat_sim.nav.PathFinder.distance_to_closest_obstacle(self, pt: numpy.ndarray[numpy.float32[3, 1]], max_search_radius: float = 2.0) -> float

Returns the distance to the closest obstacle

If this distance is greater than max_search_radius, max_search_radius is returned instead.

def habitat_sim.nav.PathFinder.get_random_navigable_point(self, max_tries: int = 10, island_index: int = -1) -> numpy.ndarray[numpy.float32[3, 1]]

Samples a navigable point uniformly at random from the navmesh

This method can fail. If it does, the returned point will be {NAN, NAN, NAN}. Use is_navigable to check if the point is navigable.

param max_tries:
The maximum number of times to retry sampling if it fails and the navmesh seems fine. Setting this higher can sometimes be warranted, but needing to typically indicates an error with the navmesh.
param island_index:
Optionally specify the island from which to sample the point. Default -1 queries the full navmesh.
return:
A navigable point or {NAN, NAN, NAN} if this fails

def habitat_sim.nav.PathFinder.is_navigable(self, pt: numpy.ndarray[numpy.float32[3, 1]], max_y_delta: float = 0.5) -> bool

Checks to see if the agent can stand at the specified point

To check navigability, the point is snapped to the nearest polygon and then the snapped point is compared to the original point. Any amount of x-z translation indicates that the given point is not navigable. The amount of y-translation allowed is specified by max_y_delta to account for slight differences in floor height.

def habitat_sim.nav.PathFinder.snap_point(self, point: magnum.Vector3, island_index: int = -1) -> magnum.Vector3

Snaps a point to the closet navigable location

Will only search within a 4x8x4 cube centered around the point. If there is no navigable location within that cube, no navigable point will be found.

param point:
The starting location of the agent
param island_index:
Optionally specify the island from which to sample the point. Default -1 queries the full navmesh.
return:
The navigable point, if one exists, or {NAN, NAN, NAN}

def habitat_sim.nav.PathFinder.snap_point(self, point: numpy.ndarray[numpy.float32[3, 1]], island_index: int = -1) -> numpy.ndarray[numpy.float32[3, 1]]

Snaps a point to the closet navigable location

Will only search within a 4x8x4 cube centered around the point. If there is no navigable location within that cube, no navigable point will be found.

param point:
The starting location of the agent
param island_index:
Optionally specify the island from which to sample the point. Default -1 queries the full navmesh.
return:
The navigable point, if one exists, or {NAN, NAN, NAN}

def habitat_sim.nav.PathFinder.try_step(self, start: magnum.Vector3, end: magnum.Vector3) -> magnum.Vector3

Find a valid location for the agent to actually step to when it attempts to step between start and end

Attempts to move from start to end and returns the navigable point closest to end that is feasibly reachable from start.

param start:
The starting location of the agent
param end:
The desired end location
return:
The actual ending location, if such a location exists, or {NAN, NAN, NAN}

def habitat_sim.nav.PathFinder.try_step(self, start: numpy.ndarray[numpy.float32[3, 1]], end: numpy.ndarray[numpy.float32[3, 1]]) -> numpy.ndarray[numpy.float32[3, 1]]

Find a valid location for the agent to actually step to when it attempts to step between start and end

Attempts to move from start to end and returns the navigable point closest to end that is feasibly reachable from start.

param start:
The starting location of the agent
param end:
The desired end location
return:
The actual ending location, if such a location exists, or {NAN, NAN, NAN}