Randomizing between different parameter sets

Hello!

I would like to randomize between different sets of parameters. So for example, for each background I have a corresponding light settings I would like to use. Unfortunately I have not been able to achieve this since the distributions don’t support dictionaries and you can’t use generated indexes to access parameters.

Here is the pseudo code of what I am trying to achieve

import omni.replicator.core as rep

parameters = [
    {
        "texture": "map1",
        "temp_min": 3000,
        "temp_max": 6000,
    },
    {
        "texture": "map2",
        "temp_min": 7000,
        "temp_max": 10000,
    },
]

with rep.new_layer("test"):
    idx = rep.distribution.choice([0, 1])
    dome = rep.create.light(
        light_type="Dome",
        rotation=rep.distribution.uniform((0, 0, 0), (0, 360, 0)),
        exposure=13.3,
        temperature=rep.distribution.uniform(
            parameters[idx]["temp_min"], parameters[idx]["temp_max"]
        ),
        texture=parameters[idx]["texture"],
    )

Thanks!

Hi @lePoisson , I am having a similiar problem:

did you happen to find a way to randomly select an item from a list and retrieve its parameters with replicator?

Hello,

The way to do this is to pre-generate your list of parameters, and then use them later in a replicator distribution.

Example:

import omni.replicator.core as rep
import random  # Python random library

NUM_RANDOM = 10
random_list = [ random.randint(1, 10) for _ in range(NUM_RANDOM)]

with rep.trigger.on_frame(max_execs=10):
    sphere = rep.randomizer.instantiate(paths="omniverse://localhost/NVIDIA/Samples/Marbles/assets/standalone/A_marble/A_marble.usd",
                                        size=rep.distribution.sequence(random_list), 
                                        use_cache=False)

By using the pre-generated random_list in rep.distribution.sequence I can instantiate a “random” number of marbles each frame.

distribution.sequence and distribution.choice can both take pre-generated lists of values.

By using distribution.sequence you can “group” different lists of parameters, since it will iterate through each of them in sequence (like what you are doing with idx.

texture_list = ["map1", "map2"]
temp_min_list = [3000, 7000]
temp_max_list = [6000, 10000]

dome = rep.create.light(
        light_type="Dome",
        rotation=rep.distribution.uniform((0, 0, 0), (0, 360, 0)),
        exposure=13.3,
        temperature=rep.distribution.uniform(
            rep.distribution.sequence(temp_min_list), rep.distribution.sequence(temp_max_list)
        ),
        texture=rep.distribution.sequence(texture_list),

If you are looking to randomly pick from each list every frame, use distribution.choice instead

Regarding the last snippet, I tried something like this but saw no effect on the output but also got no errors, used Isaac Sim 4.2.0

import omni.replicator.core as rep

with rep.new_layer():
    cube = rep.create.cube()

    with rep.trigger.on_frame():
        with cube:
            rep.modify.pose(
                position_x=rep.distribution.uniform(
                    rep.distribution.sequence([-100, 0]),
                    rep.distribution.sequence([0, 100]),
                )
            )
        

Seems to be related to Combining replicator.distribution.choice with rep.distribution.uniform is not working