BBoxCache computation is wrong during Pose Randomization


Following Situation:
I am importing usd objects into my simulation and want to change the pose of them using my own implemented OgnPerAxisPose node. In this node I am trying to get the bbox size of the object and do some overlap test like here Frequently Used Python Snippets — isaacsim latest documentation (without line 10, since it is not possible during randomization).

The problem starts with the size of the bbox, because the results are not stable.

For example:

(0.6530528665575275, 0.7136309560278187, 0.5500675907560046)
(0.6870291550008039, 0.6052032736056401, 0.5500475141172724)
(0.7263889617847499, 0.6848893498133128, 0.550064940423661)

Since I want to change the pose of all objects and avoid overlaps with other objects, this is not really working for me.

The following function is used for computation of the bbox:

def compute_bbox_with_cache(prim: Usd.Prim) -> Gf.Range3d:
    bbox_cache = UsdGeom.BBoxCache(Usd.TimeCode.Default(), includedPurposes=[UsdGeom.Tokens.default_])
    bound = bbox_cache.ComputeWorldBound(prim)
    return bound.GetRange().GetSize()

During the very first randomization, the size of the bbox seems to be good:

(0.6499999921768904, 0.5499999944120646, 0.5499999944120646)
(0.6499999921768904, 0.5499999944120646, 0.5499999944120646)
(0.6499999921768904, 0.5499999944120646, 0.5499999944120646)

Any recommendations for getting stable and correct results of the bbox size?

Thanks in advance!

Best Regards,

Hi there,

afaik, after the object has moved you will need to use ComputeAlignedRange()bboxcache.ComputeWorldBound(prim).ComputeAlignedRange() to recompute the AABB. This will apply the current transformation of the prim to the default (origin-based) AABB.


the computation is still wrong. Any further ideas?

I mean, it is just necessary to get the dimensions of the object. Is there any alternative way to do so?

Not sure what else could be wrong since they are default USD function calls.

Do you need the dimension in AABB (axis-aligned) or OBB(oriented)? USD gives them in AABB.

If however your mesh is already rotated in the origin, it will not give you the dimensions of the mesh, it will return you the area it occupies in AABB.

For example: if you have a cube of size 1 where its vertices are not aligned with the frame axis by default (e.g. rotated 45 deg with the rotation value still 0,0,0). The bounding box size will then not be 1x1x1. If you want to calculate this (the oriented smallest volume box) of the mesh you will need to iterate all the vertices, get their locations and calculate this from this information.

See for example the Graham Scan algorithm or the Jarvis March (Gift Wrapping) algorithms:

  • Rotating Calipers: