Hello,
I want to position one object in one of 3 areas randomly.
For the implementation, I combined rep.distribution.uniform() and rep.distribution.choice(). But the program just stops without an error message.
To reproduce that issue, I created the following example:
import omni.replicator.core as rep
import omni.usd
with rep.new_layer():
camera = rep.create.camera(position=(1000, 1000, 1000), look_at=(0,0,0))
render_product = rep.create.render_product(camera, (1024, 1024))
torus = rep.create.torus(semantics=[('class', 'torus')] , position=(0, -200 , 100),count=3)
plane = rep.create.plane(scale=10, visible=True)
def get_shapes():
shape = rep.get.prims(semantics=[('class', 'torus')])
with shape:
position1 = rep.distribution.uniform((0, 0, 0), (1, 1, 1))
position2 = rep.distribution.uniform((1, 1, 1), (2, 2, 2))
position3 = rep.distribution.uniform((2, 2, 2), (3, 3, 3))
positions = rep.distribution.choice(choices=[position1, position2, position3])
rep.modify.pose(
rotation=rep.distribution.uniform((0, 0, -180), (0, 0, 180)),
position=positions)
rep.randomizer.color(colors=rep.distribution.uniform((0, 0, 0), (1, 1, 1)))
return shape.node
rep.randomizer.register(get_shapes)
with rep.trigger.on_frame(num_frames=10,rt_subframes=10):
rep.randomizer.get_shapes()
# Initialize and attach writer
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir=f"/path/to/Data", rgb=True, bounding_box_2d_tight=False, bounding_box_2d_loose=True, semantic_segmentation=False)
writer.attach([render_product])
Using the scatter function is not an option, as the objects rotatation won’t vary.
Happy about any information.