コンテンツにスキップ

02 · TurtleBot3 Lime のインポート (URDF → USD)

⏱ 15 分 · レベル:初級 · スクリプト:isaac/02_import_urdf.py

目標: ROS が使うロボットの記述(URDF)を、Isaac Sim がシミュレーションする形式(USD)に変換し、インポーターが何を作るのかを理解します。

インポート直後は、アームが崩れ落ちます。ジョイントドライブにまだ剛性がないためです。これはチュートリアル 03 で直します。

考え方

URDF は、XML で書かれた ROS のロボット記述です。リンク(メッシュ、質量、慣性、衝突形状を持つ剛体の部品)をジョイント(fixed、revolute、continuous、prismatic)でつないで表します。Lime の URDF は ros2_ws/src/turtlebot3_lime/turtlebot3_lime_description/urdf/*.xacro にあります。

USD (Universal Scene Description) は、Omniverse と Isaac Sim のシーン形式です。USD のロボットはプリムのツリーです。物理は、RigidBodyAPI、ArticulationRootAPI、DriveAPI などのスキーマで追加します。

URDF インポーター (isaacsim.asset.importer.urdf) は、URDF を USD に変換します。

インポートするのは .xacro ではなく、生成済みの .urdf です

インポーターは xacro を読めません。scripts/gen_urdf.sh で xacro を一度展開し、ROS なしでも使えるようにメッシュのパスを書き換えてあります。その結果は assets/urdf/turtlebot3_lime.urdf としてコミットされています。このスクリプトを実行する必要があるのは、xacro ファイルを変更したときだけです。

6.2 のインポーターが作るもの

assets/usd/turtlebot3_lime/
├── turtlebot3_lime.usda          ← the file you open or reference ("interface" layer)
└── payloads/
    ├── base.usda                 ← the prim tree: Geometry/ (links) and Physics/ (joints)
    ├── geometries.usd            ← the meshes
    ├── materials.usda, instances.usda
    ├── robot.usda                ← Isaac robot schema (robot type, ordered links and joints)
    └── Physics/
        ├── physics.usda          ← engine-neutral USD Physics (bodies, joints, drives, masses)
        ├── physx.usda            ← PhysX-specific additions
        └── mujoco.usda           ← MuJoCo/Newton-specific additions

インターフェースのファイルには、none、physics、physx、mujoco の選択肢を持つ Physics という名前のバリアントセットがあります。デフォルトでは、どのバリアントも選択されていません。選択しないと、ロボットには物理がありません。宙に浮いたままになり、アーティキュレーションも見つかりません。Isaac Sim はデフォルトで PhysX を使ってシミュレーションするので、physx を選択します。

ロボットの中では、リンクは Geometry/ の下に URDF のツリーと同じ形で入れ子になっていて、ジョイントは Physics/ の下にあります。

/turtlebot3_lime
├── Geometry/base_footprint/base_link            ← articulation root
│   ├── wheel_left_link, wheel_right_link
│   ├── caster_back_left_link, caster_back_right_link
│   ├── base_scan, imu_link, camera_bottom_screw_frame/camera_link/...
│   └── link1/link2/.../link7/{gripper_left_link, gripper_right_link, end_effector_link}
└── Physics/wheel_left_joint, joint1 … joint6, gripper_left_joint, ...

インポート

  1. source scripts/isaac_env.sh && isaacsim で Isaac Sim を起動します。
  2. File ▸ Import を選び、assets/urdf/turtlebot3_lime.urdf を選択します。
  3. このファイルのオプションが、ダイアログの右側に表示されます。

    File ▸ Import のオプション

    セクション オプション 値 理由
    Model USD Output assets/usd インポーターがこの中に turtlebot3_lime/ フォルダーを作ります
    Colliders Collision From Visuals off URDF にはすでに単純な衝突形状があります
    Colliders Allow Self-Collision off
    Options Robot Type Mobile Manipulators
    Options Base Type Mobile 移動ロボットは、ワールドに固定(Fixed)してはいけません
    Options Add Reference to Stage on(デフォルト:off) 開いているステージにロボットを追加します。off の場合は、代わりにインポートしたファイルが開かれます
    Options Merge Mesh off
  4. Import をクリックします。29 MB ある台車のメッシュの変換に、数分かかります。

  5. Stage パネルでロボットのプリムを選択します。Property ▸ Variants で Physics = physx に設定します。

    Property ▸ Variants ▸ Physics = physx

  6. Create ▸ Physics ▸ Ground Plane で床を追加します。シーンが暗ければ、Create ▸ Light ▸ Dome Light でライトを追加します。

  7. Play ▶ を押します。ロボットが床に落ち、アームが折れ曲がって垂れ下がります。これは想定どおりです。
  8. Stop ■ を押してから、File ▸ Save As で my_stages/02_import.usd としてステージを保存します。チュートリアル 03 は、このステージから続けます。
source scripts/isaac_env.sh
python isaac/02_import_urdf.py            # with window
python isaac/02_import_urdf.py --headless --test

git status で geometries.usd が変更扱いになったら?

リポジトリにはこのインポート結果がすでに入っているので、このチュートリアルを飛ばしても以降のチュートリアルは動きます。スクリプトは assets/usd/turtlebot3_lime/ を削除してから、もう一度インポートします。結果は同じロボットですが、メッシュのファイル payloads/geometries.usd は数バイト異なることがあり、git pull は変更されたファイルの上書きを拒否します。pull する前に、コミット済みのファイルに戻してください。

git checkout assets/usd/turtlebot3_lime

主要な行は次のとおりです。

app_utils.enable_extension("isaacsim.asset.importer.urdf")   # (1)!
from isaacsim.asset.importer.urdf import URDFImporter, URDFImporterConfig

config = URDFImporterConfig(
    urdf_path=str(LIME_URDF),
    usd_path=str(USD_DIR),           # (2)!
    fix_base=False,                  # mobile robot
    merge_fixed_joints=False,        # (3)!
    collision_from_visuals=False,
    robot_type="Mobile Manipulators",
)
usd_path = URDFImporter(config).import_urdf()

stage_utils.add_reference_to_stage(
    usd_path, "/World/turtlebot3_lime", variants=[("Physics", "physx")]   # (4)!
)
  1. インポーターは拡張機能です。スタンドアロンアプリは、デフォルトではこれを読み込みません。
  2. これは出力先のフォルダーです。インポーターは上書きをしません。turtlebot3_lime/ がすでにあると、turtlebot3_lime_1/ に書き出します。そのため、スクリプトは先に古いフォルダーを削除します。
  3. センサーのフレーム(base_scan、imu_link、camera_*_optical_frame)が別々のプリムとして残るように、固定ジョイントを残します。以降のチュートリアルでは、これらにセンサーを取り付けます。
  4. PhysX の物理バリアントを選択します(上を参照)。
スクリプト全体:isaac/02_import_urdf.py
# SPDX-FileCopyrightText: 2026 An (an-robotics)
# SPDX-License-Identifier: Apache-2.0

"""Tutorial 02 - Import TurtleBot3 Lime from URDF into USD.

    python isaac/02_import_urdf.py              # import, then show the robot in the GUI
    python isaac/02_import_urdf.py --headless   # import only, no window

What it does
  1. Converts assets/urdf/turtlebot3_lime.urdf into a USD asset with the Isaac Sim 6.2
     URDF importer (``URDFImporter`` + ``URDFImporterConfig``).
  2. Opens a new stage, adds a ground plane + light, and references the new robot USD.
  3. Presses Play so you can watch the robot drop onto the ground.

The importer writes to assets/usd/turtlebot3_lime/ :
    turtlebot3_lime.usda      <- the file you open / reference (an "interface" layer)
    payloads/                 <- geometry, materials, physics (loaded through the interface layer)
"""

import shutil
import sys

from common.cli import parse_args

args = parse_args(
    __doc__.splitlines()[0],
    extra=lambda p: p.add_argument("--out", default=None, help="output folder (default: assets/usd)"),
)

# --- 1. Start Isaac Sim. Nothing from omni / isaacsim / pxr may be imported before this line. ---
from isaacsim import SimulationApp

simulation_app = SimulationApp({"headless": args.headless, "width": 1280, "height": 720})

import isaacsim.core.experimental.utils.app as app_utils
import isaacsim.core.experimental.utils.stage as stage_utils
from common.paths import LIME_IMPORTED_USD, LIME_URDF, USD_DIR
from isaacsim.core.experimental.objects import GroundPlane
from isaacsim.core.experimental.prims import Articulation
from isaacsim.core.simulation_manager import SimulationManager
from pxr import UsdLux

# The URDF importer is an extension; the default standalone app does not load it.
app_utils.enable_extension("isaacsim.asset.importer.urdf")
from isaacsim.asset.importer.urdf import URDFImporter, URDFImporterConfig

# --- 2. Convert URDF -> USD -----------------------------------------------------------------------
# The importer never overwrites: an existing folder would make it write "turtlebot3_lime_1".
# This tutorial re-creates the asset from scratch each time, so remove the previous output first.
from pathlib import Path

out_root = Path(args.out).resolve() if args.out else USD_DIR
out_dir = out_root / LIME_IMPORTED_USD.parent.name
if out_dir.exists():
    print(f"[02] removing previous import: {out_dir}")
    shutil.rmtree(out_dir)

config = URDFImporterConfig(
    urdf_path=str(LIME_URDF),
    usd_path=str(out_root),  # output *folder*; the importer adds a sub-folder named after the robot
    fix_base=False,  # a mobile robot must NOT be welded to the world
    merge_fixed_joints=False,  # keep sensor frames (base_scan, camera_*_optical_frame, imu_link) as prims
    collision_from_visuals=False,  # the URDF already has good collision shapes
    robot_type="Mobile Manipulators",
)
usd_path = URDFImporter(config).import_urdf()
print(f"[02] URDF imported -> {usd_path}")

# Housekeeping: the importer records the absolute path of its temporary files in a comment
# ("doc") of payloads/base.usda. Clear it so the asset does not depend on (or reveal) this machine.
from pxr import Sdf

base_layer = Sdf.Layer.FindOrOpen(str(out_dir / "payloads" / "base.usda"))
if base_layer is not None and base_layer.documentation:
    base_layer.documentation = ""
    base_layer.Save()

# --- 3. Build a small scene and add the robot -----------------------------------------------------
stage = stage_utils.create_new_stage(template="sunlight")
UsdLux.DomeLight.Define(stage, "/World/DomeLight").GetIntensityAttr().Set(500.0)
GroundPlane("/World/GroundPlane")
# The imported asset can carry physics for several engines. It has a "Physics" variant set
# (none / physics / physx / mujoco) and NO default selection - without a selection the robot has
# no physics at all. Isaac Sim simulates with PhysX by default, so pick "physx".
stage_utils.add_reference_to_stage(usd_path, "/World/turtlebot3_lime", variants=[("Physics", "physx")])

# Lift it 5 cm so it drops onto the ground when the simulation starts.
# reset_xform_op_properties=True gives the prim a standard translate/orient/scale transform first.
from isaacsim.core.experimental.prims import XformPrim

XformPrim("/World/turtlebot3_lime", reset_xform_op_properties=True).set_world_poses(positions=[0.0, 0.0, 0.05])

recorder = None
if args.record:
    from common.recorder import Recorder

    recorder = Recorder(args.record, eye=(0.9, -0.9, 0.6), target=(0.0, 0.0, 0.2))

# --- 4. Play ----------------------------------------------------------------------------------------
SimulationManager.setup_simulation(dt=1.0 / 60.0)
app_utils.play()
simulation_app.update()

# The importer marked the robot root as an articulation; find it and list its joints.
from pxr import UsdPhysics

root = next(
    p.GetPath().pathString
    for p in stage.Traverse()
    if p.HasAPI(UsdPhysics.ArticulationRootAPI) and p.GetPath().pathString.startswith("/World/turtlebot3_lime")
)
robot = Articulation(root)
print(f"[02] articulation root: {root}")
print(f"[02] {robot.num_dofs} degrees of freedom: {robot.dof_names}")

steps = 0
while simulation_app.is_running():
    simulation_app.update()
    if recorder:
        recorder.capture()
    steps += 1
    if (args.test or args.record) and steps >= 180:  # 3 s of simulated time
        break

ok = True
if args.test:
    expected = {"wheel_left_joint", "wheel_right_joint", *[f"joint{i}" for i in range(1, 7)], "gripper_left_joint"}
    missing = expected - set(robot.dof_names)
    z = float(robot.get_world_poses()[0].numpy()[0, 2])
    print(f"[02][test] missing joints: {missing or 'none'}; base height after 3 s: {z:.3f} m")
    ok = not missing and -0.02 < z < 0.2
    print(f"[02][test] {'PASS' if ok else 'FAIL'}")

if recorder:
    recorder.save()
app_utils.stop()
simulation_app.close(exit_code=0 if ok else 1)
sys.exit(0 if ok else 1)

結果を確かめる

スクリプトは、見つけたアーティキュレーションを表示します。

[02] articulation root: /World/turtlebot3_lime/Geometry/base_footprint/base_link
[02] 10 degrees of freedom: ['wheel_left_joint', 'wheel_right_joint', 'joint1', 'joint2', 'joint3',
     'joint4', 'joint5', 'joint6', 'gripper_left_joint', 'gripper_right_joint']
[02][test] missing joints: none; base height after 3 s: 0.060 m
[02][test] PASS
  • 10 DoF(自由度): 車輪 2 個 + アームのジョイント 6 個 + グリッパーの指 2 本です。固定ジョイント(キャスター、センサーの取り付け部)は DoF を増やしません。
  • 0.060 m: base_link は、床からちょうど車輪の半径 1 つ分の高さにあります。ロボットを支えているのは車輪です。

インポートしたロボット

わざと残してある問題点

見えること 原因 修正するチュートリアル
アームが崩れ落ちる ジョイントドライブは maxForce 付きでインポートされましたが、剛性 = 減衰 = 0 です 03
車輪を駆動できない 同じ原因です。速度ドライブには減衰 > 0 が必要です 03
右のグリッパーの指 mimic ジョイント(URDF の <mimic> タグから作られた NewtonMimicAPI)によって、左の指に追従します すでに動作します
ロボットが灰色 URDF はすべてのリンクに単色を 1 つ付けています。実機の Lime は黒とライムグリーンです 03

次へ: 03 · ロボットの調整