How to can I add children to Xform while simulating using Python standalone workflow?

I wanted to create a Xform prim containing an existing 4 wheeled robot and keep adding different children to it throughout the simulation, using python standalone application or python extension workflow. How can I achieve this?

Hi @s.w.isaac.sim - In Isaac Sim, you can add children to an Xform using the create_child method of the omni.usd API. Here’s a basic example:

import omni.usd

stage = omni.usd.get_context().get_stage()
xform = stage.DefinePrim("/MyXform", "Xform")
child = stage.DefinePrim("/MyXform/MyChild", "Sphere")

In this example, a new Xform is created at the path “/MyXform”, and then a child Sphere is added to that Xform at the path “/MyXform/MyChild”.

However, if you’re trying to do this while a simulation is running, you may run into issues. The simulation might not immediately recognize the new child, or there might be conflicts between the simulation and the changes you’re making to the stage.

To avoid these issues, you can pause the simulation before making changes to the stage, and then resume the simulation after you’re done. You can use the omni.isaac.dynamic_control API to control the simulation:

import omni.isaac.dynamic_control

dc = omni.isaac.dynamic_control.acquire_dynamic_control_interface()
# Make changes to the stage here...

Remember to release the dynamic control interface when you’re done with it:


I hope this helps!