Using sequence distribution on multiple USD assets, to spawn 1 different object each frame

Randomizing appearance, placement and orientation of an existing 3D assets with a built-in writer — Omniverse Extensions latest documentation.
based on this example i am trying to use sequence distribution to spawn different variations of similar assets for every frame, just like spawning the worker object but a little bit different. For example, I have two similar USD files of truck models (target object) that I am trying to spawn in the scene at the same spot everytime. I have referenced the USD paths and put them in a list, but i can’t seem to use sequence distribution to spawn a different truck each frame. Is there guidance for this or if someone has tried this before?

I’m unsure if this is the correct or the most efficient way of doing this but using rep.modify.visibility() got working results in a similar case.

Basically, spawn all the models and just show one at a time.
Here’s a scalable version, of course with two models you can just alternate true and false.

paths = ['omniverse://localhost/assets/truck1',
         'omniverse://localhost/assets/truck2']

trucks = []
for x in paths:
    truck_usd = rep.create.from_usd(x, semantics=[('class', 'truck')])
    trucks.append(truck_usd)

viz_matrix = []
for x in range (len(trucks)):
    arr = [False] * len(trucks)
    arr[x] = True
    viz_matrix.append(arr)

with rep.trigger.on_frame(num_frames=10):
    for idx, truck in enumerate(trucks):
        with truck:
            rep.modify.visibility(rep.distribution.sequence(viz_matrix[idx]))

Context to above example, just dealing with tables not trucks: reference-SDGenerator/final_generator.py at main · jkuhno/reference-SDGenerator (github.com)

If I recall correct, there has been discussion of a similar case on this forum but I failed to find the post to include in this answer.

1 Like

I would use the randomizer.instantiate way of doing it.

1 Like

@j.kuhno - Your 2nd post is correct.

Loading multiple assets and hiding them is the more efficient solution.

Using instantiate or a similar method with create and destroy the objects each frame, which would likely be slower overall.

You could likely simplify it a little bit by not using a custom function and instead using 2 Replicator triggers.

See a code example of toggling visibility here: How to generate objects binary masks for synthetic data offline pose generation - Omniverse / Isaac Sim - NVIDIA Developer Forums

1 Like

If you have unlimited VRAM…