What is the proper way to dynamically add and remove objects in Isaac Sim?

Hello, I am working in a simple application with Isaac Sim, ROS2 and Computer Vision that has the goal of replicating people detected by a real-world camera in the simulated environment. I have the ros topic working with the position and ID of each person detected, but I’m stumped in what the best or “proper” way of dynamically updating the objects would be. Currently I have created the models by hand and only update their position while making them visible or not visible, which works but I want to learn how to properly do this.
Thanks for any replies and code snippets/examples would be appreciated.

To dynamically remove objects in Isaac Sim, you can use the remove_object method from the Scene class. This method allows you to remove objects from the simulation environment programmatically.

What would be the difference between this method and delete_prim?

remove_object uses prim name.
delete_prim uses prim path.
Example:

import omni.isaac.core.utils.stage as stage_utils
from omni.isaac.core.scenes import Scene
import omni.isaac.core.utils.prims as prims_utils

# For remove_object
stage_utils.add_reference_to_stage("/test_path/cube.usd", "/World/Cube")
scene = Scene()
scene.remove_object("Cube")

# For delete_prim
stage_utils.add_reference_to_stage("/test_path/cube.usd", "/World/Cube")
prims_utils.delete_prim("/World/Cube")

You can call this dynamically by using Python REPL.
isaac_ros2_utils is my ROS 2 packages to spawn URDF or USD dynamically.

Thanks for the detailed reply, my last question would be about adding prims. Is loading the usd every time with “create_prim” the correct way to do it? Or would it be best to clone the already existing model to make more copies of the people on screen?

Loading the USD every time is simpler than loading the USD first and then cloning.
So in my opinion, Loading the USD every time is better way.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.