How are people debugging their Replicator code?

I’m trying to get a reliable methodology to debug my Replicator Python code. The Script Editor in Code is insufficient, IMHO.

One method I’ve been using with some success is to create an extension from the template in the Extensions menu:

then add my replicator code and use the VS Code debugger to step through the Python. (I’ll be honest I forgot how I got VS Code to communicate with OV Code, I think it was all part of the prefab VS Code project created by the Extension Template) This works great… once, then Code crashes after a random number of times (1-3) of executing my extension. (I’ve upload dozen of crash logs, still waiting on a developer to investigate)

I’ve tried rearranging my code to release things after running, keeping an eye on memory on cpu and gpu but I’m not close to running out. I’ve tried replacing the assets with a basic cube.

Seems no matter what I do it crashes after a few runs.

My point is not for you to debug my code, my question is, how do YOU in the Replicator community debug your Python?

I have also created a duplicate headless mode script that does the same Replicator things and that works great but it’s not interactive and I haven’t tried to link VS Code with that python script, although I’m gathering it’s possible.

Again, my question is, how do you all debug your Replicator Python code?

Thanks in advance,

Hello @holdendp! I’ve shared your post with the dev team for further assistance.

1 Like

Now I remember I got the VS Code / OV Code integration working from Mati’s video

Update: It SEEMS to be stable as long as I create a new stage before each execution. If I can figure out how to do that programmatically I might have a band aid.

@holdendp Interesting discovery. Did you get this working reliably? I’m also trying to debug replicator in vs code and experience unpredictable weirdness and crashes. Would appreciate any solution you found.

As long as I create a new (I go for empty) stage before I start debugging it’s been stable. Haven’t had a crash in a long time. I was wondering if they’d fixed things with automatic updates but it sounds like your machine is still crashing, so maybe not.

Anyhow let me know if the “new stage” trick is working for you too.

Yes, it does seem to work. I haven’t quite figured out how to create a new stage in my code though.

1 Like

Me neither. If you figure it out let me know, it’d be appreciated.

I appear to have figured it out. For me, the following lines of code reset the stage and make the replicator work properly:

usd_context = omni.usd.get_context()

I wanted to add that, for me, replicator seems to work just fine unless I call randomizer.instantiate. At that point, Omniverse Code (as well as IsaacSim) has problems such as not running the code when expected, or only running it partially, or crashing. This workaround seems to fix that problem.

I doubt it’s a good idea to call new_stage frequently, so I’ll keep looking for a better workaround.

1 Like

Awesome can’t wait to try it out. Thanks.

On vacation till July 5, not ignoring.