newton.utils.parse_usd#

newton.utils.parse_usd(source, builder, xform=None, only_load_enabled_rigid_bodies=False, only_load_enabled_joints=True, joint_drive_gains_scaling=1.0, invert_rotations=False, verbose=wp.config.verbose, ignore_paths=None, cloned_env=None, collapse_fixed_joints=False, enable_self_collisions=True, apply_up_axis_from_stage=False, root_path='/', joint_ordering='dfs', bodies_follow_joint_ordering=True, skip_mesh_approximation=False, load_non_physics_prims=True)[source]#

Parses a Universal Scene Description (USD) stage containing UsdPhysics schema definitions for rigid-body articulations and adds the bodies, shapes and joints to the given ModelBuilder.

The USD description has to be either a path (file name or URL), or an existing USD stage instance that implements the Stage interface.

Parameters:
  • source (str | pxr.Usd.Stage) – The file path to the USD file, or an existing USD stage instance.

  • builder (ModelBuilder) – The ModelBuilder to add the bodies and joints to.

  • xform (Transform) – The transform to apply to the entire scene.

  • default_density (float) – The default density to use for bodies without a density attribute.

  • only_load_enabled_rigid_bodies (bool) – If True, only rigid bodies which do not have physics:rigidBodyEnabled set to False are loaded.

  • only_load_enabled_joints (bool) – If True, only joints which do not have physics:jointEnabled set to False are loaded.

  • joint_drive_gains_scaling (float) – The default scaling of the PD control gains (stiffness and damping), if not set in the PhysicsScene with as “warp:joint_drive_gains_scaling”.

  • invert_rotations (bool) – If True, inverts any rotations defined in the shape transforms.

  • verbose (bool) – If True, print additional information about the parsed USD file.

  • ignore_paths (List[str]) – A list of regular expressions matching prim paths to ignore.

  • cloned_env (str) – The prim path of an environment which is cloned within this USD file. Siblings of this environment prim will not be parsed but instead be replicated via ModelBuilder.add_builder(builder, xform) to speed up the loading of many instantiated environments.

  • collapse_fixed_joints (bool) – If True, fixed joints are removed and the respective bodies are merged. Only considered if not set on the PhysicsScene with as “warp:collapse_fixed_joints”.

  • enable_self_collisions (bool) – Determines the default behavior of whether self-collisions are enabled for all shapes. If a shape has the attribute physxArticulation:enabledSelfCollisions defined, this attribute takes precedence.

  • apply_up_axis_from_stage (bool) – If True, the up axis of the stage will be used to set newton.ModelBuilder.up_axis. Otherwise, the stage will be rotated such that its up axis aligns with the builder’s up axis. Default is False.

  • root_path (str) – The USD path to import, defaults to “/”.

  • joint_ordering (str) – The ordering of the joints in the simulation. Can be either “bfs” or “dfs” for breadth-first or depth-first search, or None to keep joints in the order in which they appear in the USD. Default is “dfs”.

  • bodies_follow_joint_ordering (bool) – If True, the bodies are added to the builder in the same order as the joints (parent then child body). Otherwise, bodies are added in the order they appear in the USD. Default is True.

  • skip_mesh_approximation (bool) – If True, mesh approximation is skipped. Otherwise, meshes are approximated according to the physics:approximation attribute defined on the UsdPhysicsMeshCollisionAPI (if it is defined). Default is False.

  • load_non_physics_prims (bool) – If True, prims that are children of a rigid body that do not have a UsdPhysics schema applied are loaded as visual shapes in a separate pass (may slow down the loading process). Otherwise, non-physics prims are ignored. Default is True.

Returns:

Dictionary with the following entries:

”fps”

USD stage frames per second

”duration”

Difference between end time code and start time code of the USD stage

”up_axis”

Axis representing the stage’s up axis (“X”, “Y”, or “Z”)

”path_shape_map”

Mapping from prim path (str) of the UsdGeom to the respective shape index in ModelBuilder

”path_body_map”

Mapping from prim path (str) of a rigid body prim (e.g. that implements the PhysicsRigidBodyAPI) to the respective body index in ModelBuilder

”path_shape_scale”

Mapping from prim path (str) of the UsdGeom to its respective 3D world scale

”mass_unit”

The stage’s Kilograms Per Unit (KGPU) definition (1.0 by default)

”linear_unit”

The stage’s Meters Per Unit (MPU) definition (1.0 by default)

”scene_attributes”

Dictionary of all attributes applied to the PhysicsScene prim

”collapse_results”

Dictionary returned by \(ModelBuilder.collapse_fixed_joints()\) if collapse_fixed_joints is True, otherwise None.

Return type:

dict