As topic.
Thank you!
As topic.
Thank you!
Hi,
its possible to query local AABB and volume for a given rigid body collider. You can use this script to get the information:
import omni.usd
from omni.physx import get_physx_property_query_interface, get_physx_cooking_interface
from pxr import Usd, Gf, UsdGeom, UsdPhysics, UsdUtils, PhysicsSchemaTools, PhysxSchema, Sdf, UsdUtils
from omni.physx.bindings._physx import PhysxPropertyQueryRigidBodyResponse, PhysxPropertyQueryColliderResponse, PhysxPropertyQueryResult, PhysxPropertyQueryMode
import asyncio
async def main():
usd_context = omni.usd.get_context()
stage = usd_context.get_stage()
selection = usd_context.get_selection()
paths = list(selection.get_selected_prim_paths())
stage_id = UsdUtils.StageCache.Get().Insert(stage).ToLongInt()
def report_collider(collider_info : PhysxPropertyQueryColliderResponse):
print("Volume for prim: " + str(PhysicsSchemaTools.intToSdfPath(collider_info.path_id)) + " is: " + str(collider_info.volume))
print("aabb local min: " + str(collider_info.aabb_local_min)
print("aabb local max: " + str(collider_info.aabb_local_max)
for p in paths:
prim_id = PhysicsSchemaTools.sdfPathToInt(p)
get_physx_property_query_interface().query_prim(stage_id , prim_id,
query_mode = PhysxPropertyQueryMode.QUERY_RIGID_BODY_WITH_COLLIDERS,
collider_fn = report_collider)
await omni.kit.app.get_app().next_update_async()
print("Done")
asyncio.ensure_future(main())
Select a rigid body and run the script in the script editor.
Regards,
Ales
I tried it, but the aabb local min and local max seem unchanged even if I change the dimension.
aabb local min: (-0.5, -0.5, -0.5)
aabb local max: (0.5, 0.5, 0.5)
may I know why?
The scale should not be part of it, so if you just scaled the object the aabb wont change.
I see. May I know how should I check the scaled object dimension?
You get the scale and muliply the provided aabb dimensions. You can get the scale of the prim like this:
tf = Gf.Transform(xformable.ComputeLocalToWorldTransform(Usd.TimeCode.Default()))
scale = Gf.Vec3d(tf.GetScale())
Thank you so much! May I know if we have any method that can check the object size not in the interactive script editor and Python script?
Where would you like to check the size? You can also use OVD:
https://docs.omniverse.nvidia.com/extensions/latest/ext_omnipvd.html
Capturing the simulation state and checking the created objects in PhysX SDK.
Oh, I want to check the object size in Issac Sim/Orbit in python script.
This python code can be run anywhere even as part of Sim/Orbit. If simulation already started you can just run the query, it should return the results instantly.