Replicator example from Documentation not running

Hello,

I am trying to run the sample code from “Instantiate multiple assets from a props folder” from your documentation.

and am getting this error:

OSError: [Errno 22] Invalid Argument

At
c:/users/ccc/appdata/local/ov/pkg/code-2022.1.1/kit/plugins/bindings-python\omni\kit\app\_init_.py(92): write
c:\users\ccc\appdata\local\ov\pkg\code-2022.1.1\extscache\omni.replicator.core-0.0.10+cp37\omni\repilcator\core\scripts\randomizer.py(54): register
executing: rendomize_tet1.py...(20): <module>

I am on Windows, running Code 2021.1.1 Beta.
Nucleus is running.

Here is the dump from the log file:

2022-05-31 12:23:02 [6,032,711ms] [Error] [carb.scripting-python.plugin] OSError: [Errno 22] Invalid argument

At:
  c:/users/ccc/appdata/local/ov/pkg/code-2022.1.1/kit/plugins/bindings-python\omni\kit\app\impl\__init__.py(92): write
  c:\users\ccc\appdata\local\ov\pkg\code-2022.1.1\extscache\omni.replicator.core-0.0.10+cp37\omni\replicator\core\scripts\randomizer.py(54): register
  executing: rendomize_test1.py...(20): <module>

2022-05-31 12:23:02 [6,032,711ms] [Error] [omni.kit.app.plugin] [py stderr]: OSError: [Errno 22] Invalid argument

At:
  c:/users/ccc/appdata/local/ov/pkg/code-2022.1.1/kit/plugins/bindings-python\omni\kit\app\impl\__init__.py(92): write
  c:\users\ccc\appdata\local\ov\pkg\code-2022.1.1\extscache\omni.replicator.core-0.0.10+cp37\omni\replicator\core\scripts\randomizer.py(54): register
  executing: rendomize_test1.py...(20): <module>

2022-05-31 12:23:02 [6,032,759ms] [Info] [omni.kit.manipulator.prim.model] Tf.Notice.Revoke in PrimTransformModel
2022-05-31 12:23:02 [6,032,759ms] [Info] [omni.kit.manipulator.prim.model] Tf.Notice.Register in PrimTransformModel

Any help is welcome.

Can you post the exact code you are executing? I tried the example (copy paste directly in the script editor) and it works. Judgin by the error, the registering of the custom randomizer function seems to be the issue

I copy-pasted the example code as well:

import omni.replicator.core as rep

with rep.new_layer():
    PROPS = 'omniverse://localhost/NVIDIA/Assets/Vegetation/Plant_Tropical/'
    plane = rep.create.plane(scale=10, visible=True)

    def get_props(size):
        instances = rep.randomizer.instantiate(rep.utils.get_usd_files(PROPS, recursive=True), size=size, mode='point_instance')
        with instances:
            rep.modify.pose(
                position=rep.distribution.uniform((-500, 0, -500), (500, 0, 500)),
                rotation=rep.distribution.uniform((-90, -180, 0), (-90, 180, 0)),
            )
        return instances.node

    rep.randomizer.register(get_props)

    # Setup randomization
    with rep.trigger.on_frame(num_frames=30):
        rep.randomizer.get_props(3)

Further,

I get EXACTLY the same error when I run this custom code:

import omni.replicator.core as rep

with rep.new_layer():
	render_product = rep.create.render_product('/World/Camera', (1024,1024))
		
	def create_random():
		bottle = rep.get.prims(path_pattern="/World/wine_bottle_1/default")
		with bottle:
			rep.modify.semantics([('class', 'wine_bottle')])
			rep.modify.pose(rotation=rep.distribution.uniform((0, 0, 0), (0, 0, 360)),
						position=rep.distribution.uniform( (-13.6, 84.6, -10.6), (79.6, 173.6, -10.6))
						)
		return bottle.node
		
	rep.randomizer.register(create_random)
	
	#writer = rep.WriterRegistry.get("BasicWriter")
	#writer.initialize( output_dir="d:/datasets/omniverse/content/tests/", rgb=True, bounding_box_2d_tight=True)
	#writer.attach([render_product])

	with rep.trigger.on_frame(num_frames=200):
		rep.randomizer.create_random()

NOTE: I am running this AFTER I manually create a scene.

Try closing code down, opening it again and run it in a new world. I had errors in the past, where I had to restart the program. Also make sure Nucleus is running with all services up

@simon.steinmann Restarting works! [facepalm]

1 Like

I had the exact same issue in the past. If you are able to recreate the error, please post it. For me it was something along the lines:

  1. Run a faulty script that throws an error
  2. Run a correct script after and it throws errors too
  3. Restart Code
  4. Run correct script again, now it works

Maybe you can try some things and see if you can get a reproducible error.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.