Inquiry about Customizing Box Randomization Algorithm in NVIDIA Replicator

Hi there,

I have been using the NVIDIA Replicator tool for my project,
and I’m interested in customizing the randomization algorithm used in the rep.create.cube function.

Specifically, I’d like to implement my own translation, rotation, and scale parameter generator to achieve two main goals:
maximizing the number of boxes within a specific range and ensuring that each box remains non-interfering with others.

I understand that the default randomization algorithm might not fully align with my requirements.
Therefore, I’m seeking guidance on where I can rewrite the algorithm in Replicator Code to achieve the following objectives:

  1. Bounding Range Optimization: I want to ensure that the boxes I create using my custom parameters stay within a predefined bounding range. This range is critical to my project’s context, and I need to make sure that no generated box exceeds these bounds.
  2. Non-interference Constraint: It’s essential that the boxes I place within the range do not interfere with each other. This means that they should not overlap or intersect, maintaining a minimum separation distance between them.

123

Thank you all!!

Hi @lily.chen ,

Thanks for your inquiry! Sorry it has taken a while to get to this . It looks like you are trying to pack / stack the boxes into an area as tightly as possible. Unfortunately, we don’t have functionality in replicator yet that does exactly this (but we are working on it).

Have you tried using the scatter nodes yet? I’m not sure if they will accomplish exactly what you are trying to do, but they should fulfill your two stated objectives of “Bounding range optimization” and “Non-interference constraint”. The scatter nodes sample uniformly in desired spaces (e.g. volumes or surfaces) but make no guarantees about how tightly the objects are packed.

For example, you can use the following replicator code to densely sample spheres on a plane (or as many surfaces as you want …):

    	#create a plane to sample on
         plane_samp = rep.create.plane(scale=3, rotation=(20, 0, 0), visible=True)

    	def randomize_spheres():

        	    #create small spheres to sample inside the plane
        	    spheres = rep.create.sphere(scale=0.4, count=48)
        	    with spheres:
        	        #randomize
                rep.randomizer.scatter_2d(plane_samp, check_for_collisions=True)
        	    return spheres.node

    	rep.randomizer.register(randomize_spheres)

As such the the “Non interference” constraint is satisfied by setting check_for_collisions to True. You can also ensure they stay within a specific range of the world volume by setting the min and max values like the following:

            rep.randomizer.scatter_2d(plane_samp, min_samp=(None, 0, None), max_samp=(None, None, None), check_for_collisions=True)

The above command ensures that nothing is sampled below y=0 but makes no other constraints - change any of them from None to a float value and it will constrain your sampling more.

There is also a scatter3d node if that is useful to you – so you can specify parts of the world you do and don’t want to sample in using the built in scatter3d voxel grid. In the case below small cones are sampled from an orange enclosure but excluded from the blue part of the enclosure.


Let me know!
-Henry