usd_utils
CollisionAPI
Class containing class methods to facilitate collision handling, e.g. collision groups
Source code in omnigibson/utils/usd_utils.py
add_group_filter(col_group, filter_group)
classmethod
Adds a new group filter for group @col_group, filtering all collision with group @filter_group Args: col_group (str): Name of the collision group which will have a new filter group added filter_group (str): Name of the group that should be filtered
Source code in omnigibson/utils/usd_utils.py
add_to_collision_group(col_group, prim_path)
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. Args: col_group (str): Name of the collision group to assign the prim at @prim_path to prim_path (str): Prim (and all nested prims) to assign to this @col_group
Source code in omnigibson/utils/usd_utils.py
clear()
classmethod
create_collision_group(col_group, filter_self_collisions=False)
classmethod
Creates a new collision group with name @col_group
Parameters:
Name | Type | Description | Default |
---|---|---|---|
col_group |
str
|
Name of the collision group to create |
required |
filter_self_collisions |
bool
|
Whether to ignore self-collisions within the group. Default is False |
False
|
Source code in omnigibson/utils/usd_utils.py
FlatcacheAPI
Monolithic class for leveraging functionality meant to be used EXCLUSIVELY with flatcache.
Source code in omnigibson/utils/usd_utils.py
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
|
reset()
classmethod
Resets the internal state of this FlatcacheAPI.This should only occur when the simulator is stopped
Source code in omnigibson/utils/usd_utils.py
reset_raw_object_transforms_in_usd(prim)
classmethod
Manually resets the per-link local raw transforms and per-joint raw states from entity prim @prim to be zero.
NOTE: This slightly abuses the dynamic control - usd integration, and should ONLY be used if flatcache is active, since the USD is not R/W at runtime and so we can write directly to child link poses on the USD without breaking the simulation!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim |
EntityPrim
|
prim whose owned links and joints should have their local values reset to be zero |
required |
Source code in omnigibson/utils/usd_utils.py
sync_raw_object_transforms_in_usd(prim)
classmethod
Manually synchronizes the per-link local raw transforms per-joint raw states from entity prim @prim using dynamic control interface as the ground truth.
NOTE: This slightly abuses the dynamic control - usd integration, and should ONLY be used if flatcache is active, since the USD is not R/W at runtime and so we can write directly to child link poses on the USD without breaking the simulation!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim |
EntityPrim
|
prim whose owned links and joints should have their raw local states updated to match the "true" values found from the dynamic control interface |
required |
Source code in omnigibson/utils/usd_utils.py
PoseAPI
This is a singleton class for getting world poses. Whenever we directly set the pose of a prim, we should call PoseAPI.invalidate(). After that, if we need to access the pose of a prim without stepping physics, this class will refresh the poses by syncing across USD-fabric-PhysX depending on the flatcache setting.
Source code in omnigibson/utils/usd_utils.py
get_world_pose_with_scale(prim_path)
classmethod
This is used when information about the prim's global scale is needed, e.g. when converting points in the prim frame to the world frame.
Source code in omnigibson/utils/usd_utils.py
RigidContactAPI
Class containing class methods to aggregate rigid body contacts across all rigid bodies in the simulator
Source code in omnigibson/utils/usd_utils.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 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 |
|
clear()
classmethod
get_all_impulses()
classmethod
Grab all impulses at the current timestep
Returns:
Type | Description |
---|---|
n-array: (N, M, 3) impulse array defining current impulses between all N contact-sensor enabled rigid bodies in the simulator and M tracked rigid bodies |
Source code in omnigibson/utils/usd_utils.py
get_body_col_idx(prim_path)
classmethod
Returns:
Name | Type | Description |
---|---|---|
int |
col idx assigned to the rigid body defined by @prim_path |
get_body_row_idx(prim_path)
classmethod
Returns:
Name | Type | Description |
---|---|---|
int |
row idx assigned to the rigid body defined by @prim_path |
get_col_idx_prim_path(idx)
classmethod
Returns:
Name | Type | Description |
---|---|---|
str |
@prim_path corresponding to the column idx @idx in the contact matrix |
get_impulses(prim_paths_a, prim_paths_b)
classmethod
Grabs the matrix representing all impulse forces between rigid prims from @prim_paths_a and rigid prims from @prim_paths_b
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim_paths_a |
list of str
|
Rigid body prim path(s) with which to grab contact impulses against any of the rigid body prim path(s) defined by @prim_paths_b |
required |
prim_paths_b |
list of str
|
Rigid body prim path(s) with which to grab contact impulses against any of the rigid body prim path(s) defined by @prim_paths_a |
required |
Returns:
Type | Description |
---|---|
n-array: (N, M, 3) impulse array defining current impulses between N bodies from @prim_paths_a and M bodies from @prim_paths_b |
Source code in omnigibson/utils/usd_utils.py
get_row_idx_prim_path(idx)
classmethod
Returns:
Name | Type | Description |
---|---|---|
str |
@prim_path corresponding to the row idx @idx in the contact matrix |
in_contact(prim_paths_a, prim_paths_b)
classmethod
Check if any rigid prim from @prim_paths_a is in contact with any rigid prim from @prim_paths_b
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim_paths_a |
list of str
|
Rigid body prim path(s) with which to check contact against any of the rigid body prim path(s) defined by @prim_paths_b |
required |
prim_paths_b |
list of str
|
Rigid body prim path(s) with which to check contact against any of the rigid body prim path(s) defined by @prim_paths_a |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether any body from @prim_paths_a is in contact with any body from @prim_paths_b |
Source code in omnigibson/utils/usd_utils.py
initialize_view()
classmethod
Initializes the rigid contact view. Note: Can only be done when sim is playing!
Source code in omnigibson/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 omnigibson/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 omnigibson/utils/usd_utils.py
check_extent_radius_ratio(mesh_prim)
Checks if the min extent in world frame and the extent radius ratio in local frame of @mesh_prim is within the acceptable range for PhysX GPU acceleration (not too thin, and not too oblong)
Ref: https://github.com/NVIDIA-Omniverse/PhysX/blob/561a0df858d7e48879cdf7eeb54cfe208f660f18/physx/source/geomutils/src/convex/GuConvexMeshData.h#L183-L190
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_prim |
Prim
|
Mesh prim to check |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
True if the min extent (world) and the extent radius ratio (local frame) is acceptable, False otherwise |
Source code in omnigibson/utils/usd_utils.py
clear()
create_joint(prim_path, joint_type, body0=None, body1=None, enabled=True, joint_frame_in_parent_frame_pos=None, joint_frame_in_parent_frame_quat=None, joint_frame_in_child_frame_pos=None, joint_frame_in_child_frame_quat=None, break_force=None, break_torque=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 or JointType
|
type of joint to create. Valid options are: "FixedJoint", "Joint", "PrismaticJoint", "RevoluteJoint", "SphericalJoint" (equivalently, one of JointType) |
required |
body0 |
str or None
|
absolute path to the first body's prim. At least @body0 or @body1 must be specified. |
None
|
body1 |
str or None
|
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
|
joint_frame_in_parent_frame_pos |
ndarray or None
|
relative position of the joint frame to the parent frame (body0). |
None
|
joint_frame_in_parent_frame_quat |
ndarray or None
|
relative orientation of the joint frame to the parent frame (body0). |
None
|
joint_frame_in_child_frame_pos |
ndarray or None
|
relative position of the joint frame to the child frame (body1). |
None
|
joint_frame_in_child_frame_quat |
ndarray or None
|
relative orientation of the joint frame to the child frame (body1). |
None
|
break_force |
float or None
|
break force for linear dofs, unit is Newton. |
None
|
break_torque |
float or None
|
break torque for angular dofs, unit is Newton-meter. |
None
|
Returns:
Type | Description |
---|---|
Usd.Prim: Created joint prim |
Source code in omnigibson/utils/usd_utils.py
create_mesh_prim_with_default_xform(primitive_type, prim_path, u_patches=None, v_patches=None, stage=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 |
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
|
stage |
None or Stage
|
If specified, stage on which the primitive mesh should be generated. If None, will use og.sim.stage |
None
|
Source code in omnigibson/utils/usd_utils.py
create_primitive_mesh(prim_path, primitive_type, extents=1.0, u_patches=None, v_patches=None, stage=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
|
stage |
None or Stage
|
If specified, stage on which the primitive mesh should be generated. If None, will use og.sim.stage |
None
|
Returns:
Type | Description |
---|---|
UsdGeom.Mesh: Generated primitive mesh as a prim on the active stage |
Source code in omnigibson/utils/usd_utils.py
get_mesh_volume_and_com(mesh_prim, world_frame=False)
Computes the volume and center of mass for @mesh_prim
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_prim |
Prim
|
Mesh prim to compute volume and center of mass for |
required |
world_frame |
bool
|
Whether to return the volume and CoM in the world frame |
False
|
Returns:
Type | Description |
---|---|
Tuple[float, np.array]: Tuple containing the (volume, center_of_mass) in the mesh frame or the world frame |
Source code in omnigibson/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 |
Prim
|
root prim from which to search for nested children prims |
required |
Returns:
Type | Description |
---|---|
list of Usd.Prim: nested prims |
Source code in omnigibson/utils/usd_utils.py
get_world_prim()
mesh_prim_mesh_to_trimesh_mesh(mesh_prim, include_normals=True, include_texcoord=True)
Generates trimesh mesh from @mesh_prim if mesh_type is "Mesh"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_prim |
Prim
|
Mesh prim to convert into trimesh mesh |
required |
include_normals |
bool
|
Whether to include the normals in the resulting trimesh or not |
True
|
include_texcoord |
bool
|
Whether to include the corresponding 2D-texture coordinates in the resulting trimesh or not |
True
|
Returns:
Type | Description |
---|---|
trimesh.Trimesh: Generated trimesh mesh |
Source code in omnigibson/utils/usd_utils.py
mesh_prim_shape_to_trimesh_mesh(mesh_prim)
Generates trimesh mesh from @mesh_prim if mesh_type is "Sphere", "Cube", "Cone" or "Cylinder"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_prim |
Prim
|
Mesh prim to convert into trimesh mesh |
required |
Returns:
Type | Description |
---|---|
trimesh.Trimesh: Generated trimesh mesh |
Source code in omnigibson/utils/usd_utils.py
mesh_prim_to_trimesh_mesh(mesh_prim, include_normals=True, include_texcoord=True, world_frame=False)
Generates trimesh mesh from @mesh_prim
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_prim |
Prim
|
Mesh prim to convert into trimesh mesh |
required |
include_normals |
bool
|
Whether to include the normals in the resulting trimesh or not |
True
|
include_texcoord |
bool
|
Whether to include the corresponding 2D-texture coordinates in the resulting trimesh or not |
True
|
world_frame |
bool
|
Whether to convert the mesh to the world frame or not |
False
|
Returns:
Type | Description |
---|---|
trimesh.Trimesh: Generated trimesh mesh |
Source code in omnigibson/utils/usd_utils.py
sample_mesh_keypoints(mesh_prim, n_keypoints, n_keyfaces, seed=None)
Samples keypoints and keyfaces for mesh @mesh_prim
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_prim |
Prim
|
Mesh prim to be sampled from |
required |
n_keypoints |
int
|
number of (unique) keypoints to randomly sample from @mesh_prim |
required |
n_keyfaces |
int
|
number of (unique) keyfaces to randomly sample from @mesh_prim |
required |
seed |
None or int
|
If set, sets the random seed for deterministic results |
None
|
Returns:
Type | Description |
---|---|
2-tuple: - n-array: (n,) 1D int array representing the randomly sampled point idxs from @mesh_prim. Note that since this is without replacement, the total length of the array may be less than @n_keypoints - None or n-array: 1D int array representing the randomly sampled face idxs from @mesh_prim. Note that since this is without replacement, the total length of the array may be less than @n_keyfaces |