MJCF Import Extension [omni.isaac.mjcf]

MJCF Import Commands

The following commands can be used to simplify the import process. Below is a sample demonstrating how to import the Ant MJCF included with this extension

 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
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(True)
import_config.set_import_inertia_tensor(True)

# 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(9.81)

# add lighting
distantLight = UsdLux.DistantLight.Define(stage, Sdf.Path("/DistantLight"))
distantLight.CreateIntensityAttr(500)
class MJCFCreateAsset(mjcf_path: str = '', import_config=<omni.isaac.mjcf._mjcf.ImportConfig object>, prim_path: str = '')

This command parses and imports a given mjcf file.

Parameters
class MJCFCreateImportConfig

Returns an ImportConfig object that can be used while parsing and importing. Should be used with the MJCFCreateAsset command

Returns

Parsed MJCF stored in an internal structure.

Return type

omni.isaac.mjcf._mjcf.ImportConfig

This extension provides an interface to the MJCF importer.

Example

Setup the configuration parameters before importing. Files must be parsed before imported.

from omni.isaac.mjcf import _mjcf
mjcf_interface = _mjcf.acquire_mjcf_interface()

# setup config params
import_config = _mjcf.ImportConfig()
import_config.fix_base = True

# parse and import file
mjcf_interface.create_asset_mjcf(mjcf_path, prim_path, import_config)

Refer to the sample documentation for more examples and usage

class Mjcf
create_asset_mjcf(self: omni.isaac.mjcf._mjcf.Mjcf, arg0: str, arg1: str, arg2: omni.isaac.mjcf._mjcf.ImportConfig)None

Parse and import MJCF file.

Parameters
class ImportConfig
property convex_decomp

Decompose a convex mesh into smaller pieces for a closer fit

property create_body_for_fixed_joint

creates body for fixed joint

property create_physics_scene

add a physics scene to the stage on import

property default_drive_strength

default drive stiffness used for joints

property density

default density used for links

property distance_scale

Set the unit scaling factor, 1.0 means meters, 100.0 means cm

property fix_base

Create fix joint for base link

property import_inertia_tensor

Import inertia tensor from urdf, if not specified in urdf it will import as identity

property instanceable_usd_path

USD file to store instanceable mehses in

property make_default_prim

set imported robot as default prim

property make_instanceable

Creates an instanceable version of the asset. All meshes will be placed in a separate USD file

property merge_fixed_joints

Consolidating links that are connected by fixed joints

property override_com

whether to compute the center of mass from geometry and override values given in the original asset

property override_inertia_tensor

Whether to compute the inertia tensor from geometry and override values given in the original asset

property self_collision

Self collisions between links in the articulation

set_convex_decomp(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None
set_create_body_for_fixed_joint(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None
set_create_physics_scene(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None
set_default_drive_strength(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: float)None
set_density(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: float)None
set_distance_scale(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: float)None
set_fix_base(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None
set_import_inertia_tensor(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None
set_instanceable_usd_path(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: str)None
set_make_default_prim(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None
set_make_instanceable(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None
set_merge_fixed_joints(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None
set_override_com(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None
set_override_inertia(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None
set_self_collision(self: omni.isaac.mjcf._mjcf.ImportConfig, arg0: bool)None