# 11. Import MJCF¶

## 11.1. Learning Objectives¶

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

5-10 Minute Tutorial

## 11.2. Getting Started¶

Prerequisites

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

## 11.3. Using the MJCF Importer Extension Window¶

Let’s begin by importing an Ant MJCF from the Built in MJCF 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 -> MJCF Importer menu. If not, go to Window-> Extensions and enable omni.isaac.mjcf.

2. Let’s specify the settings we want to import Ant with:

• Uncheck the box next to Fix Base Link and Make Default Prim

• Check the box next to Create Physics Scene

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

3. Click on the SELECT AND IMPORT button since we are ready to import the robot.

4. In the file selection dialog box, navigate to the desired folder, and select the desired MJCF file. For this example, we will use the Ant nv_ant.xml file that is included in the Built in MJCF Files that comes with this extension.

5. Click the Import button to add the robot to the stage.

6. To add a ground plane, go to the Create -> Physics menu and click on Ground Plane. Drag the ground plane below the Ant.

## 11.4. Importing MJCF using Python¶

Let’s do the exact same things as we did before but with python scripting instead.

1. Let’s begin by opening the Script Editor. Go to the top Menu Bar and click Window -> Script Editor

2. The window for the Script Editor should now be visible in the workspace.

3. Copy the following code into the Script Editor window.

  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 import omni.kit.commands from pxr import UsdLux, Sdf, Gf, UsdPhysics, PhysicsSchemaTools # setting up import configuration: status, import_config = omni.kit.commands.execute("MJCFCreateImportConfig") import_config.set_fix_base(False) import_config.set_make_default_prim(False) # Get path to extension data: ext_manager = omni.kit.app.get_app().get_extension_manager() ext_id = ext_manager.get_enabled_extension_id("omni.isaac.mjcf") extension_path = ext_manager.get_extension_path(ext_id) # import MJCF omni.kit.commands.execute( "MJCFCreateAsset", mjcf_path=extension_path + "/data/mjcf/nv_ant.xml", import_config=import_config, prim_path="/ant" ) # get stage handle stage = omni.usd.get_context().get_stage() # enable physics scene = UsdPhysics.Scene.Define(stage, Sdf.Path("/physicsScene")) # set gravity scene.CreateGravityDirectionAttr().Set(Gf.Vec3f(0.0, 0.0, -1.0)) scene.CreateGravityMagnitudeAttr().Set(981.0) # add lighting distantLight = UsdLux.DistantLight.Define(stage, Sdf.Path("/DistantLight")) distantLight.CreateIntensityAttr(500) # add ground plane omni.kit.commands.execute( "AddGroundPlaneCommand", stage=stage, planePath="/groundPlane", axis="Z", size=1500.0, position=Gf.Vec3f(0, 0, -50), color=Gf.Vec3f(0.5), ) 
4. Click the Run (Ctrl + Enter) button to import the Ant robot.

## 11.5. Summary¶

This tutorial covered the following topics:

1. Importing MJCF file using GUI

2. Importing MJCF file using Python

3. Create a Ground Plane

### 11.5.1. Further Learning¶

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