15. Import URDF

15.1. Learning Objectives

This tutorial shows how to import a urdf and convert it to a usd in Omniverse Isaac Sim. After this tutorial, you can use urdf files in your pipeline while using Omniverse Isaac Sim.

5-10 Minute Tutorial

15.2. Getting Started

Prerequisites

  • Review the Introductory Tutorial series prior to beginning this tutorial.

15.3. Using the URDF Importer Extension Window

Let’s begin by importing a Franka Panda URDF from the Built in URDF files that come with the extension.

  1. Load the URDF Importer extension, which should be automatically loaded when Omniverse Isaac Sim opens and can be accessed from the Isaac Utils -> Workflows -> URDF Importer menu. If not, go to Window-> Extensions and enable omni.isaac.urdf.

    User interface for URDF Importer
  2. Let’s specify the settings we want to import Franka with:

    • Check the box next to Fix Base Link, and Create Physics Scene only.

    • Set Stage Units Per Meters to 1.0, which means the asset will be imported in meters

    • Set the joint drive type to Position

    • Set Joint Drive Strength and Joint Position Drive Damping to 10000000.0 and 100000.0

    • Set the Output Directory to the place where you store your assets (nucleus or Local)

Note

You must have write access to the output directory used for import, it will default to the current open stage, change this as necessary.

  1. In the file selection dialog box, navigate to the desired folder, and select the desired URDF file. For this example, we will use the Franka panda_arm_hand.urdf file that is included in the Built in URDF Files that comes with this extension.

    Select URDF to Import
  2. Click the Import button to add the robot to the stage.

    Imported Franka
  3. Visualize the collision meshes, not all the rigid bodies need to have collision properties, and collision meshes are often a simplified mesh compared to the visual ones. Therefore you may want to visualize the collision mesh for inspection. To visualize collision in any viewport:

    • Select: the eyecon eye icon.

    • Select: Show by type.

    • Select: Physics.

    • Select: Colliders.

    • Check: All.

    ../_images/isaac_physics_visualize_collision.png

15.4. Importing URDF using Python

Let’s do the exact same things as we did before but with python scripting instead. We will then use the imported robot with one of the tasks defined under omni.isaac.franka extension to follow a target in the stage.

  1. Let’s begin by opening the Hello World example. Go to the top Menu Bar and Click Isaac Examples > Hello World.

  2. The window for the Hello World example extension should now be visible in the workspace.

  3. Click the Open Source Code button to launch the source code for editing in Visual Studio Code.

  4. Edit the hello_world.py file as shown below.

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    from omni.isaac.examples.base_sample import BaseSample
    from omni.isaac.core.utils.extensions import get_extension_path_from_name
    from omni.isaac.urdf import _urdf
    from omni.isaac.franka.controllers import RMPFlowController
    from omni.isaac.franka.tasks import FollowTarget
    import omni.kit.commands
    import omni.usd
    
    class HelloWorld(BaseSample):
        def __init__(self) -> None:
            super().__init__()
            return
    
        def setup_scene(self):
            world = self.get_world()
            world.scene.add_default_ground_plane()
            # Acquire the URDF extension interface
            urdf_interface = _urdf.acquire_urdf_interface()
            # Set the settings in the import config
            import_config = _urdf.ImportConfig()
            import_config.merge_fixed_joints = False
            import_config.convex_decomp = False
            import_config.import_inertia_tensor = True
            import_config.fix_base = True
            import_config.make_default_prim = True
            import_config.self_collision = False
            import_config.create_physics_scene = True
            import_config.import_inertia_tensor = False
            import_config.default_drive_strength = 1047.19751
            import_config.default_position_drive_damping = 52.35988
            import_config.default_drive_type = _urdf.UrdfJointTargetType.JOINT_DRIVE_POSITION
            import_config.distance_scale = 1
            import_config.density = 0.0
            # Get the urdf file path
            extension_path = get_extension_path_from_name("omni.isaac.urdf")
            root_path = extension_path + "/data/urdf/robots/franka_description/robots"
            file_name = "panda_arm_hand.urdf"
            # Finally import the robot
            result, prim_path = omni.kit.commands.execute( "URDFParseAndImportFile", urdf_path="{}/{}".format(root_path, file_name),
                                                          import_config=import_config,)
            # Optionally, you could also provide a `dest_path` parameter stage path to URDFParseAndImportFile,
            # which would import the robot on a new stage, in which case you'd need to add it to current stage as a reference:
            #   dest_path = "/path/to/dest.usd
            #   result, prim_path = omni.kit.commands.execute( "URDFParseAndImportFile", urdf_path="{}/{}".format(root_path, file_name),
            # import_config=import_config,dest_path = dest_path)
            #   prim_path = omni.usd.get_stage_next_free_path(
            #       self.world.scene.stage, str(current_stage.GetDefaultPrim().GetPath()) + prim_path, False
            #   )
            #   robot_prim = self.world.scene.stage.OverridePrim(prim_path)
            #   robot_prim.GetReferences().AddReference(dest_path)
            # This is required for robot assets that contain texture, otherwise texture won't be loaded.
    
            # Now lets use it with one of the tasks defined under omni.isaac.franka
            # Similar to what was covered in Tutorial 6 Adding a Manipulator in the Required Tutorials
            my_task = FollowTarget(name="follow_target_task", franka_prim_path=prim_path,
                                   franka_robot_name="fancy_franka", target_name="target")
            world.add_task(my_task)
            return
    
        async def setup_post_load(self):
            self._world = self.get_world()
            self._franka = self._world.scene.get_object("fancy_franka")
            self._controller = RMPFlowController(name="target_follower_controller", robot_articulation=self._franka)
            self._world.add_physics_callback("sim_step", callback_fn=self.physics_step)
            await self._world.play_async()
            return
    
        async def setup_post_reset(self):
            self._controller.reset()
            await self._world.play_async()
            return
    
        def physics_step(self, step_size):
            world = self.get_world()
            observations = world.get_observations()
            actions = self._controller.forward(
                target_end_effector_position=observations["target"]["position"],
                target_end_effector_orientation=observations["target"]["orientation"],
            )
            self._franka.apply_action(actions)
            return
    
  5. Press Ctrl+S to save the code and hot-reload Omniverse Isaac Sim.

  6. Click the File > New From Stage Template > Empty to create a new stage.

  7. Open the menu again and load the example.

  8. Click the LOAD button and move the target prim around

    ../_images/isaac_sim_import_urdf.gif

15.5. Summary

This tutorial covered the following topics:

  1. Importing URDF file using GUI

  2. Importing URDF file using Python

  3. Using the imported URDF in a Task

  4. Visualizing collision meshes

15.5.1. Further Learning

Checkout URDF Importer to learn more about the different configuration settings to import a urdf in Omniverse Isaac Sim.