usd_utils
BoundingBoxAPI
Class containing class methods to facilitate bounding box handling
Source code in omnigibson/utils/usd_utils.py
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 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
|
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 omnigibson/utils/usd_utils.py
clear()
classmethod
Clears the internal state of this BoundingBoxAPI. This should occur at least once per sim step.
compute_aabb(prim)
classmethod
Computes the AABB (world-frame oriented) for @prim.
NOTE: If @prim is an EntityPrim (i.e.: owns multiple links), then the computed bounding box will be the subsequent aggregate over all the links.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim |
XFormPrim
|
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 omnigibson/utils/usd_utils.py
compute_center_extent(prim)
classmethod
Computes the AABB (world-frame oriented) for @prim, and convert it into the center and extent values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim |
XFormPrim
|
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 omnigibson/utils/usd_utils.py
CollisionAPI
Class containing class methods to facilitate collision handling, e.g. collision groups
Source code in omnigibson/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 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
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 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
|
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
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
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
|
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 |
np.ndarray or None
|
relative position of the joint frame to the parent frame (body0). |
None
|
joint_frame_in_parent_frame_quat |
np.ndarray or None
|
relative orientation of the joint frame to the parent frame (body0). |
None
|
joint_frame_in_child_frame_pos |
np.ndarray or None
|
relative position of the joint frame to the child frame (body1). |
None
|
joint_frame_in_child_frame_quat |
np.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
150 151 152 153 154 155 156 157 158 159 160 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 |
|
create_mesh_prim_with_default_xform(primitive_type, prim_path, 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 |
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 omnigibson/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 omnigibson/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 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 |
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 omnigibson/utils/usd_utils.py
get_semantic_objects_pose()
Get pose of all objects with a semantic label.
Source code in omnigibson/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 |