Hi @felipe.cunha1 - Yes, you can create and destroy prims during runtime in Isaac Sim.
To create a prim, you can use the
create_prim function from the
omni.usd module. Here is an example of how to create a cube:
from omni.usd import Usd, UsdGeom
stage = Usd.Stage.CreateNew('path/to/your.usda')
prim = stage.DefinePrim('/Cube', 'Xform')
cube = UsdGeom.Cube.Define(stage, '/Cube/cube')
In this example, a new stage is created, a new Xform prim is defined at the path ‘/Cube’, and then a cube is defined as a child of that Xform.
To delete a prim, you can use the
RemovePrim function. Here is an example:
In this example, the prim at the path ‘/Cube’ is removed from the stage.
To create boxes with random rotations, you can use the
UsdGeom.XformCommonAPI to set the rotation of the Xform prim. Here is an example:
from omni.usd import UsdGeom
xformAPI = UsdGeom.XformCommonAPI(prim)
rotation = (random.uniform(0, 360), random.uniform(0, 360), random.uniform(0, 360))
In this example, a
UsdGeom.XformCommonAPI is created for the prim, and then its rotation is set to a random value.
To destroy prims based on whether they are in the field of view of the camera, you would need to implement a check that determines whether the prim is in the camera’s field of view. If it is not, you can then call
RemovePrim to remove it. The specifics of this check would depend on the details of your camera and scene setup.