usd_utils
BoundingBoxAPI
Class containing class methods to facilitate bounding box handling
Source code in utils/usd_utils.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
|
aabb_contains_point(point, container)
classmethod
Returns true if the point is contained in the container AABB
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point |
tuple
|
(x,y,z) position in world-coordinates |
required |
container |
tuple
|
|
required |
Returns:
Name | Type | Description |
---|---|---|
bool | True if AABB contains @point, otherwise False |
Source code in utils/usd_utils.py
clear()
classmethod
compute_aabb(prim_path)
classmethod
Computes the AABB (world-frame oriented) for the prim specified at @prim_path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim_path |
str
|
Path to the prim to calculate AABB for |
required |
Returns:
Type | Description |
---|---|
2-tuple: - 3-array: start (x,y,z) corner of world-coordinate frame aligned bounding box - 3-array: end (x,y,z) corner of world-coordinate frame aligned bounding box |
Source code in utils/usd_utils.py
compute_center_extent(prim_path)
classmethod
Computes the AABB (world-frame oriented) for the prim specified at @prim_path, and convert it into the center and extent values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim_path |
str
|
Path to the prim to calculate AABB for |
required |
Returns:
Type | Description |
---|---|
2-tuple: - 3-array: center position (x,y,z) of world-coordinate frame aligned bounding box - 3-array: end-to-end extent size (x,y,z) of world-coordinate frame aligned bounding box |
Source code in utils/usd_utils.py
union(prim_paths)
classmethod
Computes the union of AABBs (world-frame oriented) for the prims specified at @prim_paths
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim_paths |
str
|
Paths to the prims to calculate union AABB for |
required |
Returns:
Type | Description |
---|---|
2-tuple: - 3-array: start (x,y,z) corner of world-coordinate frame aligned bounding box - 3-array: end (x,y,z) corner of world-coordinate frame aligned bounding box |
Source code in utils/usd_utils.py
CollisionAPI
Class containing class methods to facilitate collision handling, e.g. collision groups
Source code in utils/usd_utils.py
add_to_collision_group(col_group, prim_path, create_if_not_exist=False)
classmethod
Adds the prim and all nested prims specified by @prim_path to the global collision group @col_group. If @col_group does not exist, then it will either be created if @create_if_not_exist is True, otherwise will raise an Error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
col_group |
str
|
Name of the collision group to assign the prim at @prim_path to |
required |
prim_path |
str
|
Prim (and all nested prims) to assign to this @col_group |
required |
create_if_not_exist |
bool
|
True if @col_group should be created if it does not already exist, otherwise an error will be raised |
False
|
Source code in utils/usd_utils.py
add_asset_to_stage(asset_path, prim_path)
Adds asset file (either USD or OBJ) at @asset_path at the location @prim_path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
asset_path |
str
|
Absolute or relative path to the asset file to load |
required |
prim_path |
str
|
Where loaded asset should exist on the stage |
required |
Returns:
Type | Description |
---|---|
Usd.Prim: Loaded prim as a USD prim |
Source code in utils/usd_utils.py
array_to_vtarray(arr, element_type)
Converts array @arr into a Vt-typed array, where each individual element of type @element_type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arr |
n-array
|
An array of values. Can be, e.g., a list, or numpy array |
required |
element_type |
type
|
Per-element type to convert the elements from @arr into. Valid options are keys of GF_TO_VT_MAPPING |
required |
Returns:
Type | Description |
---|---|
Vt.Array: Vt-typed array, of specified type corresponding to @element_type |
Source code in utils/usd_utils.py
clear()
create_joint(prim_path, joint_type, body0=None, body1=None, enabled=True, stage=None)
Creates a joint between @body0 and @body1 of specified type @joint_type
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim_path |
str
|
absolute path to where the joint will be created |
required |
joint_type |
str
|
type of joint to create. Valid options are: "FixedJoint", "Joint", "PrismaticJoint", "RevoluteJoint", "SphericalJoint" (equivalently, one of JointType) |
required |
body0 |
str
|
absolute path to the first body's prim. At least @body0 or @body1 must be specified. |
None
|
body1 |
str
|
absolute path to the second body's prim. At least @body0 or @body1 must be specified. |
None
|
enabled |
bool
|
whether to enable this joint or not |
True
|
stage |
Usd.Stage
|
if specified, should be specific stage to be used to load the joint. Otherwise, the current active stage will be used. |
None
|
Returns:
Type | Description |
---|---|
Usd.Prim: Created joint prim |
Source code in utils/usd_utils.py
create_mesh_prim_with_default_xform(primitive_type, prim_path, stage=None, u_patches=None, v_patches=None)
Creates a mesh prim of the specified @primitive_type at the specified @prim_path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
primitive_type |
str
|
Primitive mesh type, should be one of PRIMITIVE_MESH_TYPES to be valid |
required |
prim_path |
str
|
Destination prim path to store the mesh prim |
required |
stage |
Usd.Stage or None
|
If specified, should be specific stage to be used to load the mesh prim. Otherwise, the current active stage will be used. |
None
|
u_patches |
int or None
|
If specified, should be an integer that represents how many segments to create in the u-direction. E.g. 10 means 10 segments (and therefore 11 vertices) will be created. |
None
|
v_patches |
int or None
|
If specified, should be an integer that represents how many segments to create in the v-direction. E.g. 10 means 10 segments (and therefore 11 vertices) will be created. Both u_patches and v_patches need to be specified for them to be effective. |
None
|
Source code in utils/usd_utils.py
create_primitive_mesh(prim_path, primitive_type, extents=1.0, u_patches=None, v_patches=None)
Helper function that generates a UsdGeom.Mesh prim at specified @prim_path of type @primitive_type.
NOTE: Generated mesh prim will, by default, have extents equaling [1, 1, 1]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim_path |
str
|
Where the loaded mesh should exist on the stage |
required |
primitive_type |
str
|
Type of primitive mesh to create. Should be one of: |
required |
extents |
float or 3-array
|
Specifies the extents of the generated mesh. Default is 1.0, i.e.: generated mesh will be in be contained in a [1,1,1] sized bounding box |
1.0
|
u_patches |
int or None
|
If specified, should be an integer that represents how many segments to create in the u-direction. E.g. 10 means 10 segments (and therefore 11 vertices) will be created. |
None
|
v_patches |
int or None
|
If specified, should be an integer that represents how many segments to create in the v-direction. E.g. 10 means 10 segments (and therefore 11 vertices) will be created. Both u_patches and v_patches need to be specified for them to be effective. |
None
|
Returns:
Type | Description |
---|---|
UsdGeom.Mesh: Generated primitive mesh as a prim on the active stage |
Source code in utils/usd_utils.py
get_camera_params(viewport)
Get active camera intrinsic and extrinsic parameters.
Returns:
Name | Type | Description |
---|---|---|
dict | Keyword-mapped values of the active camera's parameters: pose (numpy.ndarray): camera position in world coordinates, fov (float): horizontal field of view in radians focal_length (float) horizontal_aperture (float) view_projection_matrix (numpy.ndarray(dtype=float64, shape=(4, 4))) resolution (dict): resolution as a dict with 'width' and 'height'. clipping_range (tuple(float, float)): Near and Far clipping values. |
Source code in utils/usd_utils.py
get_prim_nested_children(prim)
Grabs all nested prims starting from root @prim via depth-first-search
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim |
Usd.Prim
|
root prim from which to search for nested children prims |
required |
Returns:
Type | Description |
---|---|
list of Usd.Prim: nested prims |
Source code in utils/usd_utils.py
get_semantic_objects_pose()
Get pose of all objects with a semantic label.
Source code in utils/usd_utils.py
get_world_prim()
mesh_prim_to_trimesh_mesh(mesh_prim)
Generates trimesh mesh from @mesh_prim
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_prim |
Usd.Prim
|
Mesh prim to convert into trimesh mesh |
required |
Returns:
Type | Description |
---|---|
trimesh.Trimesh: Generated trimesh mesh |