How to use USD files in Extensions

Hi everyone !

I downloaded Isaac Sim recently and completed the tutorials. My next objective was to reproduce the step number 6 of the Required Tutorials (Adding a Manipulator robot) and change it a bit to make the cube generated on an other cube. Therefore, the setup_scene function in the python script looks like this :

def setup_scene(self) :
      world = self.get_world()
      world.scene.add_default_ground_plane()
      world.scene.add(
            DynamicCuboid(
                  prim_path="/World/random_step",
                  name="fancy_step",
                  position=np.array([30, 30, 5.575]),
                  size=np.array([25, 35, 10]),
                  color=np.array([0, 1.0, 0]),
            )
      )
      world.scene.add(
            DynamicCuboid(
                  prim_path="/World/random_cube",
                  name="fancy_cube",
                  position=np.array([40, 40, 12]),
                  size=np.array([5, 5, 5])
                  color=np.array([0, 0, 1.0]),
            )
      )
      return

With this, the code works well. However, I would now like to replace the fancy_step with a USD file of a bin that I have. File is located at ‘/home/user/Documents/scene.usdc’. The purpose then is to generate scenes with bins from the USD with random sizes and random positions.
Do you know how can I do such a thing ?

I thank you in advance for taking the time to help me :)

Hi @yan.mtx

An approach could be to use the add_reference_to_stage method (Core [omni.isaac.core] — isaac_sim 2022.1.1-release.1 documentation) to add a .USD prim to the stage and play with the set_world_pose, set_local_pose and set_local_scale methods (from GeometryPrim or RigidPrim class)

Hey @toni.sm thanks for your answer !
I tried to use the add_reference_to_stage method and wrote it like this :

def setup_scene(self):
       world = self.get_world()
       world.scene.add_default_ground_plane()
       bin = world.scene.add(
             add_reference_to_stage(
                   usd_path= '/home/user/Documents/scene.usd',
                   prim_path= '/World/Bin',
             )
       )
       return

The problem now is that it says

‘Prim’ object has no attribute ‘name’

I assume it is due to the object generated by the add_reference_to_stage function that has not the attribute set up correctly but I can’t manage to fix this. I tried to follow the steps given by Nvidia to work with USD here but without success…

Do you think you can help me on this ?

Hi @yan.mtx

The world.scene.add method expects, as the only parameter, a XFormPrim object or derived objects such as RigidPrim, GeometryPrim, Robot or Articulation, for example… and the add_reference_to_stage method return a pxr.Usd.Prim