The documentation for Omniverse Replicator has examples for getting annotator data when running headless in a Python script.
It is reproduced below for reference:
import omni.replicator.core as rep
async def test_ldr():
# Add Default Light
distance_light = rep.create.light(rotation=(315,0,0), intensity=3000, light_type="distant")
cone = rep.create.cone()
cam = rep.create.camera(position=(500,500,500), look_at=cone)
rp = rep.create.render_product(cam, (1024, 512))
ldr = rep.AnnotatorRegistry.get_annotator("LdrColor")
ldr.attach(rp)
await rep.orchestrator.step_async()
data = ldr.get_data()
print(data.shape, data.dtype) # ((512, 1024, 4), uint8)
import asyncio
asyncio.ensure_future(test_ldr())
When running Isaac Sim with a GUI and using custom OmniGraph nodes, however, how should annotators be initialized/released and then used to get data directly from within the node considering you cannot use the orchestrator functions in this context? For example, it is not valid to call rep.orchestrator.step_async()
from within the node so how can one make sure that the data is available for access when you need it?
By simply calling get_data()
in the compute function of the node I’ve run into various issues such as:
- The data is None indicating it is not yet available (it may become available at subsequent invocations but that data is likely from the previous timestep).
- The data is invalid or repeating upon subsequent plays.
I thought there could be some effect changing the pipeline stage, however, I think I should be using the simulation stage for my use case. It seems like the post-render pipeline stage is intended for scheduling after an offline rendering job since the graph does not run at all when I use it. The pre-render pipeline stage instead always runs, even if the simulation is stopped. The on-demand pipeline stage is not applicable for this which leaves just the simulation pipeline stage as the most appropriate.
Clarification on the correct initialization and cleanup procedure of annotators in custom OmniGraph nodes within the context of the asynchronous simulation architecture would be very helpful.