For the generation of synthetic images for bin picking, I want to drop an object into the bin, then capture several photos with different camera poses, and then drop another object into the bin. With the current code, 30 photos are taken while the object is falling into the bin.
- How can I suppress this image generation while the object is falling and only capture photos with different camera poses after the object is in the bin?
- Once the first object is in the bin → How can I spawn a second object of the same class above the bin and let it fall into the bin as well? (for-loop for approximately 20 objects)
- As you can see from the code, I manually specify the size of the bin in the first few lines. Is there a function that outputs the size of the 3D bounding box of a .usd file?
Love greetings Alexander
import omni.replicator.core as rep
rep.settings.set_stage_meters_per_unit(1.0)
rep.settings.set_stage_up_axis("Z")
with rep.new_layer():
#bin
BIN_USD = 'omniverse://localhost/Projects/synthetic_data_cad_files/Kiste/Kiste_final.usd'
bin_lengh=0.400
bin_width=0.600
bin_height=0.150
bin_rotations = (90,0,90)
bin_size = (bin_lengh, bin_width, bin_height)
bin_transform = (-bin_size[0]/2, -bin_size[1]/2, 0)
#Object
PART1_USD = "omniverse://localhost/Projects/synthetic_data_cad_files/Part/morobot-s_Achse-1A/morobot-s_Achse-1A.usd"
#Camera
camera = rep.create.camera()
with camera:
rep.modify.pose(
position=rep.distribution.uniform((-bin_size[0]/2, -bin_size[1]/2, 1.500), (bin_size[0]/2, bin_size[1]/2, 1.500)),
look_at=(0, 0, 0)
)
def rand_camera():
with camera:
rep.modify.pose(
position=rep.distribution.uniform((-bin_size[0]/2, -bin_size[1]/2, 1.500), (bin_size[0]/2, bin_size[1]/2, 1.500)),
look_at=(0, 0, 0)
)
rep.randomizer.register(rand_camera)
sphere_light = rep.create.light(
light_type="Sphere",
temperature=rep.distribution.normal(6500, 500),
intensity=rep.distribution.normal(1000, 50),
position=rep.distribution.uniform((-0.300, -0.300, bin_size[2]+0.100), (0.300, 0.300, 1.000)),
scale=rep.distribution.uniform(0.050, 1),
count=2 #2 light sources
)
#plane
plane = rep.create.plane(semantics=[("class", "plane")], position=(0, 0, 0), scale=(2, 2, 1))
with plane:
rep.physics.collider()
#import bin
bin = rep.create.from_usd(BIN_USD)
with bin:
rep.modify.semantics([('class', 'bin')])
rep.physics.collider(approximation_shape="convexDecomposition")
rep.modify.pose(
rotation=(bin_rotations[0], bin_rotations[1], bin_rotations[2]),
position=bin_transform,
scale=(0.001, 0.001, 0.001)
)
#import Object
part1 = rep.create.from_usd(PART1_USD)
with part1:
rep.modify.semantics([('class', 'part1')])
rep.physics.rigid_body()
rep.physics.collider(approximation_shape="convexDecomposition")
rep.modify.pose(
position=rep.distribution.uniform((-bin_size[0]/2, -bin_size[1]/2, bin_size[2]+0.150), (bin_size[0]/2, bin_size[1]/2, bin_size[2]+0.150)),
rotation=rep.distribution.uniform((-180,-180, -180), (180, 180, 180)),
scale=(0.001, 0.001, 0.001)
)
with rep.trigger.on_frame(num_frames=30):
rep.randomizer.rand_camera()
writer = rep.WriterRegistry.get("BasicWriter")
writer.initialize(output_dir="_output", rgb=True)
render_product = rep.create.render_product(camera, (1920, 1080))
writer.attach([render_product])
rep.orchestrator.run()