I have the following code:
from omni.isaac.kit import SimulationApp
OBJECTS_PATH = ["path/to/myusd1", "path/to/myusd2"]
N_OBJS = 30
OUTPUT = "outputs"
simulation_app = SimulationApp(launch_config={"renderer": "RayTracedLighting", "headless": True})
import random
import carb
import omni.replicator.core as rep
from omni.isaac.core import World
from omni.isaac.core.utils import prims
from omni.isaac.core.utils.stage import get_current_stage
from omni.physx.scripts import utils
from omni.replicator.core.scripts.get import mesh
from pxr import Gf, UsdGeom
# Starts replicator and waits until all data was successfully written
def run_orchestrator():
rep.orchestrator.run()
# Wait until started
while not rep.orchestrator.get_is_started():
simulation_app.update()
# Wait until stopped
while rep.orchestrator.get_is_started():
simulation_app.update()
rep.BackendDispatch.wait_until_done()
rep.orchestrator.stop()
def main():
rep.create.light(position=(0.0, 0.0, 1.0))
# load objects
objs_path = []
objs_prim = []
objs_rep = []
types = []
for idx in range(N_OBJS):
random_idx = random.randint(0, len(OBJECTS_PATH) - 1)
obj_path = OBJECTS_PATH[random_idx]
path = f"/Objects/mesh_{str(idx).zfill(3)}"
obj_prim = prims.create_prim(prim_path=path, usd_path=obj_path)
objs_path.append(path)
utils.setRigidBody(obj_prim, "convexHull", False)
objs_prim.append(obj_prim)
obj_rep = mesh(str(obj_prim.GetPrimPath()))
objs_rep.append(obj_rep)
types.append(random_idx)
# place objects
for obj_rep in objs_rep:
with obj_rep:
rep.modify.pose(
position=rep.distribution.uniform((-0.3, -0.3, 0.3), (0.3, 0.3, 0.5)),
rotation=rep.distribution.uniform((0.0, 0.0, 0.0), (360.0, 360.0, 360.0)),
)
# place camera
camera_path = "/Camera"
camera = get_current_stage().DefinePrim(camera_path, "Camera")
camera.GetAttribute("clippingRange").Set(Gf.Vec2f(0.001, 100.0))
camera.GetAttribute("focalLength").Set(30)
UsdGeom.Xformable(camera).AddTranslateOp().Set((0.0, 0.0, 1.0))
UsdGeom.Xformable(camera).AddRotateXYZOp().Set((0.0, 0.0, 0.0))
# render
basic_writer = rep.WriterRegistry.get("BasicWriter")
basic_writer.initialize(output_dir=OUTPUT, rgb=True)
render_product = rep.create.render_product(camera_path, (512, 512))
basic_writer.attach(render_product)
# world = World(
# physics_dt=1.0 / 200.0,
# rendering_dt=1.0 / 200.0,
# stage_units_in_meters=1.0,
# )
# world.reset()
with rep.trigger.on_frame(num_frames=100, interval=1):
# for obj_rep in objs_rep:
# with obj_rep:
# pass
pass
run_orchestrator()
simulation_app.update()
if __name__ == "__main__":
try:
main()
except Exception as e:
carb.log_error(f"Exception: {e}")
import traceback
traceback.print_exc()
finally:
simulation_app.close()
It works correctly.
If I uncomment only the following lines it works:
# world = World(
# physics_dt=1.0 / 200.0,
# rendering_dt=1.0 / 200.0,
# stage_units_in_meters=1.0,
# )
# world.reset()
If I uncomment only the following lines (so the “world” lines remain commented) it works:
# for obj_rep in objs_rep:
# with obj_rep:
# pass
But I uncomment both blocks the code throws thousand of warnings (more than 18000 warnings):
2023-04-21 16:48:19 [14,730ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719268 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,731ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719268 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,731ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719268 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,731ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719430 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,731ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719430 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,731ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719430 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,748ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719268 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,748ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719268 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,748ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719268 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,748ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719430 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,748ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719430 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,748ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719430 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,766ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719268 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,766ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719268 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,766ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719268 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,766ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719430 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,766ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719430 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
2023-04-21 16:48:19 [14,766ms] [Warning] [omni.graph.core.plugin] No source has valid data array=0x1e719430 usdValid=0 cpuValid=0 gpuValid=0 gpuAllocedWithCuda=0
...
In fact if I also try to add a randomization step in with rep.trigger.on_frame(num_frames=100, interval=1):
for the objects poses like:
for obj_rep in objs_rep:
with obj_rep:
rep.modify.pose(position=(0.0, 0.0, 0.5), rotation=(0.0, 0.0, 0.0))
or
for obj_rep in objs_rep:
with obj_rep:
rep.modify.pose(
position=rep.distribution.uniform((-0.3, -0.3, 2.0), (0.3, 0.3, 2.0)),
rotation=rep.distribution.uniform((0.0, 0.0, 0.0), (360.0, 360.0, 360.0)),
)
it raises the same warnings and the poses are not changed but follow only the physics simulation.