8. Import URDF

8.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.

10-15 Minute Tutorial

8.2. Getting Started

Prerequisites

  • Please review the Required Tutorial series, prior to beginning this tutorial.

8.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.

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

    User interface for URDF Importer
  • 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 100.0 which means the asset will be imported in cms

    • 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)

  • Click on the SELECT AND IMPORT button, since we are ready to import the robot urdf.

  • 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 come with this extension.

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

    Imported Franka
  • Visualize the collision meshes, not all the rigid bodies need to have collision properties, and collision meshes are often a simplified mesh comparing 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

8.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 stage.

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

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

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

  • 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
    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
    
    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 = 10000000.0
            import_config.default_position_drive_damping = 100000.0
            import_config.default_drive_type = _urdf.UrdfJointTargetType.JOINT_DRIVE_POSITION
            import_config.distance_scale = 100
            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
            imported_robot = urdf_interface.parse_urdf(root_path, file_name, import_config)
            prim_path = urdf_interface.import_robot(root_path, file_name, imported_robot, import_config)
            # 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_prim_path=self._franka.prim_path)
            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
    
  • Press Ctrl+S to save the code and hot-reload Omniverse Isaac Sim.

  • Open the menu again

  • Click CLEAR button and move the target prim around

  • Click LOAD button and move the target prim around

    ../_images/isaac_sim_import_urdf.gif

8.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.

8.5.1. Further Learning

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