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)) ...