[Important]: Replicator : Orchestrator error

Error: Synchronous call to step cannot be made from within Kit. Please use an async function with step_async.

Receiving this error when i run my code with “rep.orchestrator.step()” but i still manage to save the data to the directory as required. But when i use “await omni.replicator.core.orchestrator.step_async()” the error goes away but the simulation dont play on each step and the replicator save the images at stand still simulation.

Any idea how to remove this error. Script is attache below:

async def _replicator_event_async(self):
color = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]

    def randomize_factory_lights():
        lights = rep.create.light(
            light_type="Sphere",
            temperature=rep.distribution.normal(6500, 2000),
            intensity=rep.distribution.normal(0, 150000),
            position=rep.distribution.uniform((0.25, 0.25, 2.0),
                                            (1, 1, 4.0)),
            scale=rep.distribution.uniform(0.5, 0.8),
            color=rep.distribution.choice(color),
            count=3,                
        )
        return lights.node
    
    rep.randomizer.register(randomize_factory_lights)

    camera_positions = [(-0.05, 0.02, 1.5), 
                        (-0.06, 0.1, 1.5), 
                        (-0.05, -0.07, 1.5),
                        (0.09, -0.15, 1.4)]
    camera = rep.create.camera(focal_length=21, clipping_range=(0.01, 1000000), name="BinCam")
    with rep.trigger.on_frame(num_frames=30):
        rep.randomizer.randomize_factory_lights()
        with camera:
            rep.modify.pose(
                position=rep.distribution.sequence(camera_positions),
                look_at="/bin",
            )

    # Setup the writer
    writer = rep.WriterRegistry.get("BasicWriter")
    os.getcwd()
    os.chdir('C:\\Users\\Student\\Lego')
    self._output_dir = os.getcwd() + "/_output_abc"
    print("Outputting synthetic data to: ", self._output_dir)
    writer.initialize(output_dir=self._output_dir, rgb=True, instance_segmentation=True, colorize_instance_segmentation=True)

    rp = rep.create.render_product("/Replicator/BinCam_Xform/BinCam", (512, 512))
    await writer.attach_async([rp])

    self._timeline.play()

    rep.orchestrator.run()
    rep.orchestrator.step()
    # await omni.replicator.core.orchestrator.step_async()
    rep.BackendDispatch.wait_until_done()
    rep.orchestrator.stop()
    self._timeline.pause()
    return

Hi there, there are multiple issues in your script, I would suggest you go over the tutorials and simpler scenarios.

I can point out some issues in the existing script:

  • with rep.trigger.on_frame(): will generate a graph which will be triggered every frame, therefore
    • you should remove the for loop on the num_frames
    • remove step_async, this should be called from outside after the graph has been created, it will basically trigger the randomization + data writing
    • remove get_data() and write_depth() these will only be called once, they do not trigger every frame because they are not part of the generated replicator graph
    • you can add the augmented depth data to the basic writer (see writer augmentation example:
  • calling run and then stop will probably only trigger one frame, you can use rep.orchestrator.run_until_complete(num_frames=10) or the async version run_until_complete_async

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