Issues with applying rigid body properties to GeometryPrim

Hi,

I’m trying to set up a scene where objects are placed randomly on a table and moved around in Isaac Sim 2022.2.0. The pose of the table is randomized and the objects are also placed randomly on the table. After initially spawning the table and objects as GeometryPrims and adding rigid body properties with UsdPhysicsRigidBodyAPI, I randomize the tables pose and then the objects pose on the table. To this end, i call set_world_pose multiple times for the table and objects.

Unfortunately, when changing the pose with set_world_pose the objects visuals sometimes disappear, i.e the object is no longer visible (the prim is still in the scene). This only happens if I apply the UsdPhysicsRigidBodyAPI (i.e. apply rigid body properties) to the GeometryPrim. When using set_world_pose on a GeometryPrim without applying the UsdPhysicsRigidBodyAPI to it the objects remain visible.

Is this a known issue? What is the correct way to add rigid body properties (or apply the UsdPhysicsRigidBodyAPI) to a GeometryPrim and move them around in a scene?

This is how i spawn the objects:

def spawn_obstacle(name, prim_path, device):
    # Spawn Shapenet obstacle model from usd path

    object_usd_path = os.path.join(get_usd_path(),'Props','Shapenet',name,'models','model_normalized.usd')
    add_reference_to_stage(object_usd_path, prim_path + "/obstacle/" + name)

    obj = GeometryPrim(
        prim_path=prim_path + "/obstacle/" + name,
        name=name,
        position= torch.tensor([0.0, 0.0, 0.0], device=device),
        orientation= torch.tensor([0.707106, 0.707106, 0.0, 0.0], device=device), # Shapenet model may be downward facing. Rotate in X direction by 90 degrees,
        visible=True,
        scale=[0.01,0.01,0.01], # Has to be scaled down to metres. Default usd units for these objects is cms
        collision=True
    )
    # Attach rigid body and enable tight collision approximation
    rigid_api = UsdPhysics.RigidBodyAPI.Apply(get_current_stage().GetPrimAtPath(obj.prim_path))
    rigid_api.CreateRigidBodyEnabledAttr(True)
    obj.set_collision_approximation("convexDecomposition")

    return obj

In the picture below you can see that the visuals of the prim disappeared after setting the orientation with set_world_pose. Before setting the pose, the table was visible. The table is located at the depicted coordinate system.

This is how i update the orientation:

...
    tab_yaw = np.random.uniform(-np.pi,np.pi) # random yaw
    tab_orientation = Rotation.from_euler("xyz", [torch.pi/2,0,tab_yaw], degrees=False).as_quat()[np.array([3,0,1,2])] 
    obstacles[tab_index].set_world_pose(orientation=torch.tensor(tab_orientation,device=device))
...

After set_world_pose:

This is the correct way to set Rigidbody. What is the simulation setting saying? Is the update done through USD or Flatcache?

Hi @AlesBorovicka,

thank you very much for your reply.

The simulation setting is saying:

  • Rigid Body: Fabric
  • Soft Body: Fabric CPU
  • Particles: Fabric CPU
  • Reset Simulation on Stop: Enabled

Flatcache is enabled, so the update should be done through flatcache.
This is the simulation setting I am using: rlmmbp/TiagoDualMultiObjFetching.yaml at main · iROSA-lab/rlmmbp · GitHub
In general, I am using the setup from GitHub - NVIDIA-Omniverse/OmniIsaacGymEnvs: Reinforcement Learning Environments for Omniverse Isaac Gym

Best regards,
Sabin

Hmm I would guess that there is some synchronization mismatch between Flatcache and USD. Could you please for a test disable flatcache to see if the problem is gone?

With Flatcache disabled the problem is gone.

Is using Flatcache known to cause issues when moving GeometryPrims with rigid body properties around in a scene?

No not really, but with Flatcache enabled there is another representation of the prims in Flatcache with different transformation representation and thats what now is not synchronized. While rendered from Flatcache…

I kind of do wonder what could be wrong, let me try to repro. I am sure we can make this work, but forcing the synchronization to happen. Let me play with it a bit to see what could be wrong and how easily to fix it.

I am not having luck to reproduce this, one question is the object at the right position but extremely tiny not visible?
Guess you can try to change the scale in the property panel to see if the scale is not somehow incorrectly handled. My guess is that the scale was not correctly synced with Flatcache, however I cant prove it I am not able to reproduce atm.
I tried 104.2 kit based app, what version do you use please, (in Help->About) you should see what Kit version your app is based.