Delete prim from simulation and keep the simulation running

Isaac Sim Version

4.5.0
4.2.0
4.1.0
4.0.0
4.5.0
2023.1.1
2023.1.0-hotfix.1
Other (please specify):

Operating System

Ubuntu 22.04
Ubuntu 20.04
Windows 11
Windows 10
Other (please specify):

GPU Information

  • Model: RTX 3060TI
  • Driver Version: 550.78

Topic Description

Detailed Description

I want to delete a prim in running simulation process and have the simulation continue, but it seems that I can’t do it. The simulation view is invalidated after deleting the prim. What should I do?

Steps to Reproduce

  1. Add 2 Robot(like franka, here I use h1)
  2. Run sim steps
  3. Delete one of them
  4. Add another robot to this running sim process

Error Messages

 [Error] [omni.physx.tensors.plugin] Simulation view object is invalidated and cannot be used again to call getSharedMetatype
...
2025-03-31 06:35:19 [33,024ms] [Error] [omni.kit.app._impl] [py stderr]: Traceback (most recent call last):
...
...
  File "/isaac-sim/exts/isaacsim.core.api/isaacsim/core/api/robots/robot.py", line 73, in __init__
    SingleArticulation.__init__(
  File "/isaac-sim/exts/isaacsim.core.prims/isaacsim/core/prims/impl/single_articulation.py", line 99, in __init__
    self._articulation_view = Articulation(
  File "/isaac-sim/exts/isaacsim.core.prims/isaacsim/core/prims/impl/articulation.py", line 175, in __init__
    Articulation._on_physics_ready(self, None)
  File "/isaac-sim/exts/isaacsim.core.prims/isaacsim/core/prims/impl/articulation.py", line 5152, in _on_physics_ready
    self._body_names = self._metadata.link_names
AttributeError: 'NoneType' object has no attribute 'link_names'

Additional Information

What I’ve Tried

This may caused by Simulation view object is invalidated. And I read the source code, can not find how to avoid this error.

Maybe I need to know the internals of the simulation view (maybe a flowchart) but I can’t find it in the documentation. Could you please explain it and tell me if what I want to do is possible?

PLEASE!

Maybe some available APIs can also help

Hi @apx103, Thank you for your question. I will look into this issue shortly.

I am able to reproduce the error. For reference, here is a script that reproduces your error
repro_delete_prim.py (3.7 KB)
Looking into the cause

@apx103 the conclusion is that, unfortunately, it is not possible to delete objects on the fly. You will need to call stop on the simulation context (e.g. world.stop()), delete the prims, then start simulation again. The reason for this is that right now when deleting a prim it is not possible to fully synchronize the event with the physics engine. To protect against faulty behaviors, when deleting a prim the simulation context is invalidated.

1 Like

Well, I have a solution. After deleting the prim, I recreated the simulation view. At this time, I just need to set all the physical states in the scene back. As far as I know now, all I need to do is save all the states of rigidbody and articulation. I can now use methods such as robot._articulation_view._physics_view.get_dof_limits() to get the physical state of articulation. My question now is, is there any better way to directly get all the physical states in the entire simulation view?

1 Like

Saving the state of the simulation is definitely a way to do it. I will recommend an API to make this less of a manual process for the user. Thanks!

No, there is no API that I know of that will get the state of the physics context, save and load.