Hello,
Sorry the documentation for trigger.on_frame
is not clear.
Without a custom Writer
, Replicator will always write an image for every frame. What trigger.on_frame
does is control when randomizations happen.
For example:
spheres = rep.create.sphere(semantics=[("class", "sphere")], position=(0, 0, 100), count=6)
with rep.trigger.on_frame(num_frames=10,interval=5):
with spheres:
rep.modify.pose(
position=rep.distribution.uniform((-300, 0, -300), (300, 0, 300)),
scale=rep.distribution.uniform(0.1, 2),
)
Will generate 50 frames total (10*5
) and randomize the position and scale of the spheres every 5th frame.
I can combine this with a separate trigger that performs another randomization
with rep.trigger.on_frame(num_frames=50):
with spheres:
rep.randomizer.color(colors=rep.distribution.normal((0.1, 0.1, 0.1), (1.0, 1.0, 1.0)))
Which will randomize the color of my spheres every frame.
With the two above, I will produce 50 frames, every frame the spheres will change colors, and every 5th frame they will change position and scale.
import omni.replicator.core as rep
with rep.new_layer():
camera = rep.create.camera(position=(0, 500, 1000), look_at=(0, 0, 0))
# Create simple shapes to manipulate
plane = rep.create.plane(semantics=[("class", "plane")], position=(0, -100, 0), scale=(100, 1, 100))
spheres = rep.create.sphere(semantics=[("class", "sphere")], position=(0, 0, 100), count=6)
with rep.trigger.on_frame(num_frames=10,interval=5):
with spheres:
rep.modify.pose(
position=rep.distribution.uniform((-300, 0, -300), (300, 0, 300)),
scale=rep.distribution.uniform(0.1, 2),
)
with rep.trigger.on_frame(num_frames=50):
with spheres:
rep.randomizer.color(colors=rep.distribution.normal((0.1, 0.1, 0.1), (1.0, 1.0, 1.0)))
render_product = rep.create.render_product(camera, (512, 512))
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(
output_dir="trigger_intervals",
rgb=True,
)
writer.attach([render_product])
We will try to update the documentation ASAP as well as providing examples, and will try to make the API parameters more clear in a future update.
You might also want to look at trigger.on_time
to see if it works for your use-case.