Replies: 4 comments
-
Thank you for posting this. Here's an example and summary of things to consider for rescaling meshes without adding/deleting objects, using the World API properly: Rescaling Meshes - Using World APIfrom omni.isaac.core import World
from pxr import UsdGeom
def rescale_meshes(prim_paths, new_scales):
# Get the current world instance
world = World.instance()
# Pause physics before modifications
if world.is_playing():
world.stop()
# Process scaling operations
stage = world.stage
for prim_path, new_scale in zip(prim_paths, new_scales):
prim = stage.GetPrimAtPath(prim_path)
if prim.IsValid():
xform = UsdGeom.Xformable(prim)
xform.ClearXformOpOrder()
scale_op = xform.AddScaleOp()
scale_op.Set(new_scale)
# Restart physics after modifications
world.start()
world.reset() # Critical for physics state update
# Usage in RL environment reset:
def on_reset(self):
prim_paths = ["/World/Object1", "/World/Object2"]
new_scales = [(1.5, 1.5, 1.5), (0.8, 0.8, 0.8)]
rescale_meshes(prim_paths, new_scales)
# ... rest of reset logic Key Implementation Notes:
Alternative Methods Considered:
# Initialize objects at multiple scales
scaled_objects = {
0.5: world.scene.add(DynamicCuboid(scale=(0.5, 0.5, 0.5)),
1.0: world.scene.add(DynamicCuboid(scale=(1.0, 1.0, 1.0)),
2.0: world.scene.add(DynamicCuboid(scale=(2.0, 2.0, 2.0))
}
# At reset: Hide unused scales
def set_scale(scale_factor):
for scale, obj in scaled_objects.items():
obj.visible = (scale == scale_factor) Critical Best Practices:
physx_collision_api = PhysxSchema.PhysxCollisionAPI.Get(prim)
physx_collision_api.GetContactOffsetAttr().Set(new_contact_offset) This implementation resolves the "invalidated simulation view" error by properly managing the simulation state during rescaling operations. The World API approach provides real-time scaling capability without memory overhead of pre-spawned objects 512. References Footnotes
|
Beta Was this translation helpful? Give feedback.
-
Thank you for the response. I just tried this out and my training was still not starting. I tried to use the debugging option in VScode to get some more details and this is what I found. I had a breakpoint at |
Beta Was this translation helpful? Give feedback.
-
@RandomOakForest , any updates on how to use the world instance properly would be really helpful. Thanks! |
Beta Was this translation helpful? Give feedback.
-
That's interesting. I'll move this to our Discussions for the team to follow up. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question is very similar to #2524 in my case I have a manager based RL environment and I am not deleting/adding any objects on reset, but rescaling some of the meshes I already have. As per the discussion in the linked issue, the solution seems to be using the Isaacsim core World api to start and stop simulation before rescaling the meshes.
[Error] [omni.physx.tensors.plugin] Simulation view object is invalidated and cannot be used again to call setDofActuationForces
I was getting a similar error as mentioned above when I tried to rescale without using world start and stop. After adding the below lines in my events function, I am not getting any errors but the training does not begin. I am using skrl to train and made some custom changes to the reach environment provided.
As of now, these are the options I am aware of as a workaround
It would be very helpful if you could provide an example of how to use the world api to do this or suggest any better alternative methods. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions