
API Commands#
The INavigation Python command APIs are called from the omni.anim.navigation.core
module.
INavigation.get_navmesh_event_stream#
Returns the events stream for the asynchronous processing of NavMesh events, such as baking.
Example
import carb.events import omni.kit.app import omni.anim.navigation.core as nav inav = nav.acquire_interface() def on_event(e: carb.events.IEvent): print(e.type) navmesh_event_stream = inav.get_navmesh_event_stream() sub = navmesh_event_stream.create_subscription_to_pop(on_event, name="navmesh events", order=omni.kit.app.EVENT_ORDER_DEFAULT) inav.start_navmesh_baking()
INavigation.start_navmesh_baking#
Starts a task to asynchronously bake a NavMesh for currently opened stage. Use the event stream to subscribe for observing navmesh events.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking()
INavigation.start_navmesh_baking_and_wait#
Starts a task to bake a NavMesh for currently opened stage and waits for baking to complete.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait()
INavigation.cancel_navmesh_baking#
Cancels all pending NavMesh baking tasks.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.cancel_navmesh_baking()
INavigation.is_navmesh_baking#
Checks if the NavMesh is currently baking.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() baking = inav.is_navmesh_baking()
INavigation.get_navmesh#
Returns the currently baked NavMesh if available. The NavMesh is immutable.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh()
INavigation.create_area#
Creates a new area and returns the index of the new area, or -1 if the max area count was exceeded.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() area_index = inav.create_area()
INavigation.destroy_area#
Destroys the area at the specified index.
Arguments
area_index (int): The index of the area to be removed.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() area_index = inav.create_area() inav.destroy_area(area_index)
INavigation.get_area_count()#
Returns the number of navigation areas defined in the stage.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() area_count = inav.get_area_count()
INavigation.find_area#
Finds and returns area index of an area by name, or -1 if no area is found.
Arguments
area_name (str): The name of the area to find.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() not_walkable_area_index = inav.find_area("NotWalkable")
INavigation.get_area_name#
Returns the name of the area at the specified index.
Arguments
area_index (int): The index of the area to access. Should be between 0 andget_area_count()
- 1.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() area_name = inav.get_area_name(0)
INavigation.set_area_name#
Sets the name of the area at the specified index.
Arguments
area_index (int): The index of the area to access. Should be between 0 andget_area_count()
- 1. area_name (str): The new area name.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() new_area_index = inav.create_area() inav.set_area_name(new_area_index, "MyNewArea")
INavigation.get_area_color#
Returns the area color given an area index.
Arguments
area_index (int): The index of the area to access. Should be between 0 andget_area_count()
- 1.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() area_color = inav.get_area_color(0)
INavigation.set_area_color#
Sets the color of the area at the specified
area_index
toarea_color
for debug visualization.Arguments
area_index (int): The index of the area to access. Should be between 0 andget_area_count()
- 1. area_color (int): The color to set the area to for debug visualization.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() new_area_index = inav.create_area() inav.set_area_name(new_area_index, "MyNewArea") def rgb_to_int(red, green, blue): return (red << 16) + (green << 8) + blue inav.set_area_color(new_area_index, rgb_to_int(255, 255, 0))
INavigation.get_area_default_cost#
Returns the default cost of the area at the specified index.
Arguments
area_index (int): The index of the area to access. Should be between 0 andget_area_count()
- 1.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() area_color = inav.get_area_default_cost(0)
INavigation.set_area_default_cost#
Sets the default cost of the area at the specified index.
Arguments
area_index (int): The index of the area to access. Should be between 0 andget_area_count()
- 1. default_cost (float): The default cost to set the area to. Must be >= 0 or -1 to specify the area is inaccessible.Example
import omni.anim.navigation.core as nav new_area_index = inav.create_area() inav.set_area_name(new_area_index, "MyNewArea") inav.set_area_default_cost(new_area_index, 10.0)
INavigation.set_random_seed#
Sets the random seed to allow for deterministic random outputs.
Arguments
randomizer_id (str): Identifies a randomizer to set the seed for. This enables each consumer of randomness to return its own deterministic outcomes. seed (int): The seed to use for the randomizer.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() session = "robots" inav.set_random_seed(session, 12345) inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() random_point = navmesh.query_random_point(session)
INavigation.get_cache_dir#
Returns the directory that stores various cached Navigation files.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() cache_dir = inav.get_cache_dir()
INavigation.clear_cache_dir#
Clears the cached NavMesh files in the cache dir.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() area_count = inav.get_area_count()
The INavMesh Python command APIs are called from the omni.anim.navigation.core
module.
INavMesh.query_shortest_path#
Queries to find a shortest path on the NavMesh between a start and end position.
Arguments
start_pos (carb.Float3): The starting position of the path. end_pos (carb.Float3): The ending position of the path. area_costs (float[]): The optional overridden set of areas costs. This computes the shortest path from, or empty array to use default area costs. agent_radius (float): The optional radius of the agent. This navigates the path queried. agent_height (float): The optional height of the agent. This navigates the path queried. straighten (bool): True to optionally straighten the shorted path found for A* or false to not. prev_navmesh_path (bool): The optional previous path to use for A* pathfinding. This is used to avoid recomputing the full path again.Example
import carb import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() start = carb.Float3(-200.0, 0.0, -30.0) end = carb.Float3(250.0, 0.0, 150.0) navmesh_path = navmesh.query_shortest_path(start_pos=start, end_pos=end)
INavMesh.queryClosestPoint#
Queries to find the closest point on the NavMesh to the specified target. This returns a tuple (carb.Float3, int) that represents the closest point found, or None and island index for the found point.
The NavMesh can contain several islands for navigation. You can find the island indices and filter with them.
Arguments
target (carb.Float3): The target position to be closest to. area_indices (float[]): The optional an array of area indices to use for the closest point within or empty array to use all areas. agent_radius (float): The optional radius of the agent. This to navigates the path queried. agent_height (float): The optional height of the agent. This navigates the path queried. search_island_id (int): The id of the island to search for the closest point. If -1, to find the closest point on any island.Example
import carb import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() p = carb.Float3(-100.0, 0.0, -30.0) tuple_closest_point_and_island = navmesh.query_closest_point(target=p)
INavMesh.queryRandomPoint#
Queries to find a random point on the NavMesh.
Arguments
randomizer_id (str): Identifies a randomizer to set the seed for. area_probabilities (float[]): The optional indexed array of weighted probabilities to randomize for each area. agent_radius (float): The optional radius of the agent. This navigates the path queried. agent_height (float): The optional height of the agent. This navigates the path queried.
- Example
import omni.anim.navigation.core as nav
inav = nav.acquire_interface() session = “robots” inav.set_random_seed(session, 12345) inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() random_point = navmesh.query_random_point(session)
INavMesh.get_agent_min_height#
Returns the minimum height of the navigation agent for the baked NavMesh.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() agent_min_height = navmesh.get_agent_min_height()
INavMesh.get_agent_min_radius#
Returns the minimum radius of the navigation agent for the baked NavMesh.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() agent_min_radius = navmesh.get_agent_min_radius()
INavMesh.get_agent_max_radius#
Returns the maximum radius of the navigation agent for the baked NavMesh.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() agent_max_radius = navmesh.get_agent_max_radius()
INavMesh.get_agent_max_step_height#
Returns the maximum step height of the navigation agent for the baked NavMesh.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() agent_max_step_height = navmesh.get_agent_max_step_height()
INavMesh.get_agent_max_slope#
Returns the maximum slope angle of the navigation agent for the baked NavMesh.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() agent_max_slope_angle = navmesh.get_agent_max_slope()
INavMesh.get_agent_min_island_radius#
Returns the minimum radius of the island that the agent can navigate for the baked NavMesh.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() agent_min_island_radius = navmesh.get_agent_min_island_radius()
INavMesh.get_area_count#
Returns the number of areas defined in the baked NavMesh.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() area_count = navmesh.get_area_count()
INavMesh.get_area_name#
Get the name of the area at the sepecified index from the baked NavMesh.
Arguments
area_index (int): The index of the area to access. Should be between 0 andget_area_count()
- 1.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() area_name = navmesh.get_area_name(0)
INavMesh.get_draw_triangles#
Returns a list of mesh triangles(carb.Float3) for each point in the triangle needed to visualize the NavMesh surface for a given area index.
Recommended for debug drawing only.
Arguments
area_index (int): The index of the area to access. Should be between 0 andget_area_count()
- 1.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() triangles = navmesh.get_draw_triangles(0)
INavMesh.get_draw_lines#
Returns the lines points(carb.Float3) for each line point for visualization of the NavMesh outline.
Recommended for debug drawing only.
Arguments
border_only (bool): True if only the border lines be drawn; false if detailed edges.Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() line_points = navmesh.get_draw_lines()
INavMesh.get_mesh_signature#
Returns a signature to define and encode a hash representation of the mesh data that was baked.
Example
import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() signature = navmesh.get_mesh_signature()
The INavMeshPath Python command APIs are called from the omni.anim.navigation.core
module.
INavMeshPath.get_point_count#
Returns the number of points on the path.
Example
import carb import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() start = carb.Float3(-200.0, 0.0, -30.0) end = carb.Float3(250.0, 0.0, 150.0) navmesh_path = navmesh.query_shortest_path(start_pos=start, end_pos=end) count = navmesh_path.get_point_count()
INavMeshPath.get_points#
Returns an array of 2 or more points of type
carb.Float3
for the path points/waypoints.Example
import carb import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() start = carb.Float3(-200.0, 0.0, -30.0) end = carb.Float3(250.0, 0.0, 150.0) navmesh_path = navmesh.query_shortest_path(start_pos=start, end_pos=end) points = navmesh_path.get_points()
INavMeshPath.closest_distance#
Computes the distance along the path that is closest to the given reference position.
Arguments
position (carb.Float3): Position for which the closest point on the path should be calculated. out_path_position (carb.Float3): The position of the closest point on the path, ornullptr
if not needed. out_path_tangent (carb.Float3): The tangent of the closest point on the path, ornullptr
if not needed.Example
import carb import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() start = carb.Float3(-200.0, 0.0, -30.0) end = carb.Float3(250.0, 0.0, 150.0) navmesh_path = navmesh.query_shortest_path(start_pos=start, end_pos=end) target = carb.Float3(100.0, 0.0, 100.0) path_position = carb.Float3() path_tangent = carb.Float3() distance = navmesh_path.closest_distance( position=target, out_path_position=path_position out_path_tangent=path_tangent )
INavMeshPath.length#
Returns the total length of the path.
Example
import carb import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() start = carb.Float3(-200.0, 0.0, -30.0) end = carb.Float3(250.0, 0.0, 150.0) navmesh_path = navmesh.query_shortest_path(start_pos=start, end_pos=end) path_length = navmesh_path.length()
INavMeshPath.evaluate_position#
Evaluates the position that corresponds to the given distance along the path.
Arguments
distance (carb.Float3): Distance for which the corresponding position is to be evaluated.Example
import carb import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() start = carb.Float3(-200.0, 0.0, -30.0) end = carb.Float3(250.0, 0.0, 150.0) navmesh_path = navmesh.query_shortest_path(start_pos=start, end_pos=end) target = carb.Float3(100.0, 0.0, 100.0) path_position = carb.Float3() path_tangent = carb.Float3() distance = navmesh_path.closest_distance( position=target, out_path_position=path_position out_path_tangent=path_tangent ) position = navmesh_path.evaluate_position(distance)
INavMeshPath.evaluate_tangent#
Evaluates the tangent that corresponds to the given distance along the path.
Arguments
distance (carb.Float3): Distance for which the corresponding position is to be evaluated.Example
import carb import omni.anim.navigation.core as nav inav = nav.acquire_interface() inav.start_navmesh_baking_and_wait() navmesh = inav.get_navmesh() start = carb.Float3(-200.0, 0.0, -30.0) end = carb.Float3(250.0, 0.0, 150.0) navmesh_path = navmesh.query_shortest_path(start_pos=start, end_pos=end) target = carb.Float3(100.0, 0.0, 100.0) path_position = carb.Float3() path_tangent = carb.Float3() distance = navmesh_path.closest_distance( position=target, out_path_position=path_position out_path_tangent=path_tangent ) tangent = navmesh_path.evaluate_tangent(distance)
The authoring Python command APIs available from the omni.anim.navigation.core
module.
CreateNavMeshVolumeCommand#
Creates a NavMesh Volume prim of
include
orexclude
volume type.Arguments
parent_prim_path (str): The parent prim path in the stage where to add the NavMesh volume. volume_type (int): Use 0 forinclude
, and 1 forexclude
volume type. usd_context_name (str): The name of the usd context for this command. layer (str): The layer to create the NavMesh volume.Example
import omni.usd, omni.kit from pxr import Sdf omni.kit.commands.execute( "CreateNavMeshVolumeCommand", parent_prim_path=Sdf.Path("/World"), volume_type = 0, layer=stage.GetRootLayer() )