API Commands

All Navigation Mesh Python API commands are called from the omni.anim.navigation.core module.

start_navmesh_baking

Begins baking the NavMesh using current settings and utilizes the NavMesh cache if available. Return true if NavMesh baking is successfully requested. Return false if not (e.g. no suitable Mesh or NavMeshVolume in the stage).

Example

import omni.anim.navigation.core as nav
import omni.usd
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()
inav.start_navmesh_baking()

force_navmesh_baking

Returns true if NavMesh baking is successfully requested. Returns false if not (e.g. no suitable Mesh or NavMeshVolume in the stage).

Example

import omni.anim.navigation.core as nav
import omni.usd
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()
inav.force_navmesh_baking()

cancel_navmesh_baking

Cancel all NavMesh baking jobs.

Example

import omni.anim.navigation.core as nav
import omni.usd
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()
inav.cancel_navmesh_baking()

query_navmesh_path

Returns a path of valid points path points in between specified start and end points on the NavMesh. Path Points can be generated in and out of Play mode in Kit.

Arguments

  • start_pos (carb::float3): The starting point of the path to query.
  • end_pos (carb::float3): The end point of the path query.
  • half_extents (carb::float3): The search extents for NavMesh if the point is not exactly on the NavMesh.
  • overrideRayCastProportions (carb::float): Raycast is used to find potentially shortcuts on the path. Pass this optional parameter to config how long the raycast distance should be. The default value is 50 * agent radius.

Example

import omni.anim.navigation.core as nav
import omni.usd
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()

# Set the start and end points. If valid, new path points will be generated along the NavMesh.
path = inav.query_navmesh_path((24, 40, 63), (-960, 106, -258))
path_points = path.query_navmesh_path()
print(path_points.get_points())

validate_navmesh_point

Return true if the point is on the NavMesh. Returns false if no NavMesh is available or the point is not on the NavMesh.

Arguments

  • point (carb::float3): The point to query.
  • normal (carb::float3): The normal found.
  • half_extents (carb::float3)): The search extents for NavMesh if the point is not exactly on the NavMesh.

Example

import omni.anim.navigation.core as nav
import omni.usd
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()
is_point_valid = inav.validate_navmesh_point(point=(24, 40, 63))

closest_navmesh_point

Returns true if a nearby point on the NavMesh is found. Returns false if no NavMesh is available or the point is not reachable based on the Half Extents.

Arguments

  • target (carb::float3): The target position in the world to test against.
  • point (carb::float3): The nearest point on the NavMesh, if found.
  • normal (carb::float3): The normal found of the point on the NavMesh, if found.
  • half_extents (carb::float3): The search extents for NavMesh if the point is not exactly on the NavMesh.

Example

import omni.anim.navigation.core as nav
import omni.usd
import carb
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()
closest_point = carb.Float3(0, 0, 0)
result = inav.closest_navmesh_point(target=(0, 10, 0), point=closest_point, half_extents=(10,10,10))
print(result, closest_point)

random_navmesh_point

Returns a random point located on the NavMesh.

Example

import omni.anim.navigation.core as nav
import omni.usd
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()
random_point = inav.random_navmesh_point()

get_navmesh_event_stream

Returns the events stream for the NavMesh system.

Example

import omni.anim.navigation.core as nav
import omni.usd
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()
event_stream = inav.get_navmesh_event_stream()

is_supported_navmesh_prim

Returns true if specified prim supports NavMesh. Returns false if it is an unsupported prim type.

Arguments

  • primPath (str): The path to the prim to test.
  • includeExcludedPrims (bool): If true, include prims that have the NavMeshExcludeAPI.
  • includeRigidBodies (bool): If true, include rigid body prims even if the excludeRigidBodies setting is True.

Example

import omni.anim.navigation.core as nav
import omni.usd
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()
test_prim = inav.is_supported_navmesh_prim(
    primPath="/World/Cube",
    includeExcludedPrims=True,
    includeRigidBodies=False
)

get_navmesh_cache_dir

Returns the directory that stores the NavMesh Cache.

Example

import omni.anim.navigation.core as nav
import omni.usd
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()
cache_dir = inav.get_navmesh_cache_dir()

get_navmesh_volume_count


Returns the number of NavMesh volumes in the stage.

Example

import omni.anim.navigation.core as nav
import omni.usd
stage = omni.usd.get_context().get_stage()
inav = nav.acquire_interface()
volume_count = inav.get_navmesh_volume_count()

CreateNavMeshVolumeCommand


Creates a NavMesh Volume prim.

Arguments

  • parent_prim_path (str): The parent prim path in the stage where to add the NavMesh volume.
  • layer (str): The layer to create the NavMesh volume.

Example

import omni.usd, omni.kit
from pxr import Sdf
stage = omni.usd.get_context().get_stage()
omni.kit.commands.execute("CreateNavMeshVolumeCommand",
    parent_prim_path=Sdf.Path("/World"),
    layer=stage.GetRootLayer()
)

ApplyNavMeshObstacleSchema


Specialized command to apply NavMeshObstacleAPI that automatically infers size from prim(s)

Arguments

  • prim_path (str): The prim path in the stage on which to remove the API schema
  • usd_context_name (str): The USD context where this command should be used. Allows for this command to be used by multiple USD contexts simultaneously.

Example

import omni.kit
omni.kit.commands.execute("ApplyNavMeshObstacleSchema",
    prim_path="/World/MyCube",
)

RemoveNavMeshObstacleSchema


Removes the NavMeshObstacleAPI schema from prim(s).

Arguments

  • prim_path (str): The prim path in the stage on which to remove the API schema
  • usd_context_name (str): The USD context where this command should be used. Allows for this command to be used by multiple USD contexts simultaneously.

Example

import omni.kit
omni.kit.commands.execute("RemoveNavMeshObstacleSchema",
    prim_path="/World/MySphere",
)