I have test that It’s caused by the code as follow
Run the follow code in the script editor, then create a new scene( File->New), and it‘s fail to create and crashe.
But if i commented the code “rep.create.render_product(camera, RESOLUTION)”, the application will not crashe, The same code doesn’t has this problem in version 2021.1.1, Is there a new usage in the new version?
import os.path
import omni.replicator.core as rep
from datetime import datetime
cameraInitpos = (435, 115, 105)
cameraInitrotation = (0, -0, 90)
#endregion
def run_orchestrator():
rep.orchestrator.run()
# Wait until started
while not rep.orchestrator.get_is_started():
kit.update()
# Wait until stopped
while rep.orchestrator.get_is_started():
kit.update()
rep.BackendDispatch.wait_until_done()
rep.orchestrator.stop()
print("stop")
def start(name):
with rep.new_layer():
camera=rep.create.camera(
position=cameraInitpos,
)
def get_CameraDR():
with camera:
rep.modify.pose(
position=rep.distribution.uniform((-1,-1,-1),(1,1,1)),
rotation=rep.distribution.uniform((-1,-1,-1),(1,1,1)))
return camera.node
rep.randomizer.register(get_CameraDR)
with rep.trigger.on_frame(num_frames=10):
rep.randomizer.get_CameraDR()
# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
output_directory = "C:/Users/robotkk/Desktop/writer/"
now = datetime.now()
timestr = now.strftime("%Y%m%d%H%M%S")
output_directory = output_directory + timestr
if os.path.exists(output_directory):
print("exist")
else:
os.makedirs(output_directory)
print("###################################Outputting data to ", output_directory)
writer.initialize(
output_dir=output_directory,
rgb=True,
bounding_box_2d_tight=True
)
RESOLUTION = (1024, 1024)
driver_rp = rep.create.render_product(camera, RESOLUTION)
writer.attach([driver_rp])
if __name__ == '__main__':
start('PyCharm')