Isaac sim fail to import urdf

In Isaac sim, it allows us to import URDF of the robot. I can import urdf robot with UI. That is, I can do it with URDF importer. When I tried to run the following code
import carb
import os
import omni
from pxr import PhysicsSchema, Gf, PhysicsSchemaTools

# enable urdf importer extension
from omni.isaac.urdf import _urdf

# acquire urdf interface
_urdf = _urdf.acquire_urdf_interface()

# setting up import configuration:
import_config = _urdf.ImportConfig()
import_config.merge_fixed_joints = False
import_config.distance_scale = 10
import_config.enable_convex_decomp = False
import_config.force_z_up = True

# import URDF
path = "data/urdf/robots/carter/urdf/carter.urdf"
urdf_path = os.path.abspath(carb.tokens.get_tokens_interface().resolve("${app}/../" + path))
_urdf.import_urdf(urdf_path, import_config)

I will get the error,

File “”, line 10, in
_urdf = _urdf.acquire_urdf_interface()
RuntimeError: Failed to acquire interface: omni::isaac::urdf::Urdf (pluginName: nullptr)

I see this is from a while ago, so it’s probably resolved, but for future reference:

At time of writing, you CANNOT open the UI and then use the Python API to import a URDF. Instead, you need to do everything exclusively with the Python API. That is, write a Python script that starts up the simulator, followed by the code above in the same script. See isaac_sim/python_samples/simple/ for an example of starting up the simulator via Python.

1 Like