Dear community,
I have a question how can I export a model (robot) to a USD file without additional hierarchy levels.
What I do:
Importing URDF model with the appropriate utility
this tool simultaneously saves the imported model in usd format
I open that usd file (UsD Composer/Isaac Sim) and make the changes
I export the model.
And in step 4 I get a problem, if I try to reopen the model it gets an extra hierarchy level.
Let’s say, before exporting it was like this:
After exporting (right click on “my_robot”, save) to the file husky_v2_1.usd the model opens as:
And now if I open this model with python API - no methods and classes will work with it, because they can’t “look” deeper and look for joints and other primitives only at first hierarchy level and are lost if I need to do 2 steps.
Maybe my question seems obvious, but I have not found any mention how I can export the model the same way I imported it (without husky_v2 as intermediary).
I just choose a model, right click and choose “Save Selected”.
As I mentioned, I want to import this model later via the Python API. And now I’m importing into the simulator just to edit the model and therefore it seems strange to save the whole scene - as it will save it together with the lighting, World primitive, etc. Whereas I only need the robot. So I do as I described.
Sorry, I just checked the scene save mechanism and it actually does not save World and lighting as I wrote above, but it still imports my model with the intermediate XForm primitive
Got it. I don’t have a good reason for why it should add an extra prim in that case. I moved this over to the Composer forum where someone will hopefully be able to speak more to that workflow.
The point is that the function “Save Selected” allows you to save the selected set of primitives in a separate file, and, accordingly, creates an intermediate primitive in which saves the selected ones. (So that when you import them, they are added as a single asset, not a disjointed “something”)
And it does not check how many primitives are selected. I adjusted the code, added such a check and made an alternative version of the save instructions in case only one primitive is saved.
For those who want to repeat this trick - the handler function is in the file isaac_sim-2022.2.1/kit/exts/omni.kit.widget.stage/omni/kit/widget/stage/export_utils.py line 42. My version of the file is attached.
Note: At the moment my patch can’t handle “external” dependencies relative to exported primitive - I just skipped this part of code (for example, if you use texture which is in your project, but it’s not part of exported primitive - it will just ignore it), but for my purposes it’s enough. export_utils.py (12.2 KB)