コンテンツにスキップ

01 · Isaac Sim の基本と Hello World

⏱ 20 分 · レベル:はじめて · スクリプト:isaac/01_hello_world.py

目標: Isaac Sim のウィンドウの各部を把握し、はじめてのスタンドアロン Python スクリプトを書きます。題材は、TurtleBot3 Lime の隣で落ちる立方体です。

ウィンドウ

Lime を選択した状態の Isaac Sim 6.2 のウィンドウ

領域 役割
Viewport(中央) 3D ビューです。マウスの右ボタンを押しながら WASD で視点を動かし、F で選択中のものを画面に収め、スクロールでズームします。上のツールバーで、レンダラーとカメラを選びます。
Stage(右上) シーンをプリム(USD のオブジェクト)のツリーとして表示します:/World/GroundPlane、/World/turtlebot3_lime、…
Property(右下) 選択したプリムのすべての情報です:トランスフォーム、物理、マテリアル、バリアント。
Content / Console(下) NVIDIA のアセットライブラリと自分のファイル、そしてログです。
Play ▶ / Stop ■(左のツールバー) シミュレーションを開始・停止します。物理、センサー、ROS 2 は再生中にしか動きません。

1 段落でわかる USD

Isaac Sim のシーンは USD のステージです。ステージは、属性を持つプリムのツリーです。プリムはスキーマを適用することで振る舞いを持ちます。UsdPhysics.RigidBodyAPI を適用すると重力で動くようになり、CollisionAPI を適用するとほかの物体と接触するようになり、ArticulationRootAPI はリンクとジョイントのツリーをロボットにします。ステージは、ほかの USD ファイルをリファレンスできます。Lime は 1 つのファイル (assets/usd/turtlebot3_lime_tuned.usda) で、各シーンにリファレンスとして読み込まれます。

GUI で試してみる

  1. source scripts/isaac_env.sh && isaacsim を実行します。
  2. Create ▸ Physics ▸ Ground Plane を選びます。
  3. Create ▸ Shape ▸ Cube を選びます。Property ▸ Transform で Translate の z を 1 にします。
  4. 立方体を選択した状態で、Add ▸ Physics ▸ Rigid Body with Colliders Preset を選びます。
  5. Content ブラウザーから assets/usd/turtlebot3_lime_tuned.usda をビューポートにドラッグします。これでロボットがリファレンスとして追加されます。Content ブラウザーは、NVIDIA のアセットライブラリがある omniverse:// から始まります。自分のファイルを探すには、左側のリストを My Computer までスクロールし、リポジトリをクローンしたフォルダーを開きます。
  6. Play ▶ を押します。立方体が落ち、ロボットは車輪で立ちます。
  7. Stop ■ を押してから、File ▸ Save As で my_stages/01_hello_world.usd としてステージを保存します。リポジトリの my_stages/ フォルダーは自分のステージ用で、git はこのフォルダーを無視します。この後の GUI タブは、ここに保存したステージの続きから始まります。

Python で同じことをする

スタンドアロンスクリプトは Isaac Sim を自分で起動するので、ウィンドウなしでも実行できます。例えば、サーバー上やテストで実行できます。

source scripts/isaac_env.sh
python isaac/01_hello_world.py
python isaac/01_hello_world.py --headless --test

このプロジェクトのスクリプトは、どれも同じ 4 つのステップでできています。

from isaacsim import SimulationApp
simulation_app = SimulationApp({"headless": False})       # 1. start Isaac Sim - always first!

import isaacsim.core.experimental.utils.stage as stage_utils   # (imports only after SimulationApp)
stage = stage_utils.create_new_stage(template="sunlight") # 2. build a scene
GroundPlane("/World/GroundPlane")
cube = Cube("/World/LimeCube", sizes=0.2, positions=[0.6, 0.0, 1.0], colors=["limegreen"])
UsdPhysics.RigidBodyAPI.Apply(stage.GetPrimAtPath("/World/LimeCube"))
UsdPhysics.CollisionAPI.Apply(stage.GetPrimAtPath("/World/LimeCube"))

SimulationManager.setup_simulation(dt=1.0 / 60.0)       # 3. physics settings, then Play
app_utils.play()

while simulation_app.is_running():                      # 4. step: render + physics
    simulation_app.update()
[01] t = 0.5 s   cube height = 0.791 m
[01] t = 1.0 s   cube height = 0.100 m
[01][check] ok   cube landed on the floor (centre at 0.100 m = half its size)
[01][check] ok   robot stands on its wheels (base_link at 0.060 m = wheel radius)
[01][check] ok   robot has 10 joints that can move
[01][test] PASS

どの Python API を使えばよいか?

Isaac Sim 6.x では、isaacsim.core.experimental.* モジュール(prims、objects、utils)を SimulationManager と組み合わせて使うことが推奨されています。インターネット上の古いチュートリアルでは、isaacsim.core.api の World が使われています。これは 6.2 でもまだ動きますが、非推奨なので、このチュートリアルでは新しい API を使います。

スクリプト全体:isaac/01_hello_world.py
# SPDX-FileCopyrightText: 2026 An (an-robotics)
# SPDX-License-Identifier: Apache-2.0

"""Tutorial 01 - Isaac Sim basics: your first standalone script ("Hello World").

    source scripts/isaac_env.sh
    python isaac/01_hello_world.py              # with a window
    python isaac/01_hello_world.py --headless --test

Every standalone script follows the same four steps:
  1. start the simulator          SimulationApp(...)        <- must come first
  2. build a scene (a USD stage)  ground, light, objects, robot
  3. press Play                   SimulationManager + app_utils.play()
  4. step the simulation          simulation_app.update() in a loop, read and write the scene
"""

import sys

from common.cli import parse_args

args = parse_args(__doc__.splitlines()[0])

# --- 1. Start Isaac Sim. Import NOTHING from isaacsim / omni / pxr before this line. ------------------------
from isaacsim import SimulationApp

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

# Now the Isaac Sim / Omniverse / USD modules can be imported.
import isaacsim.core.experimental.utils.app as app_utils
import isaacsim.core.experimental.utils.stage as stage_utils
from common import lime
from isaacsim.core.experimental.objects import Cube, GroundPlane
from isaacsim.core.experimental.prims import Articulation, XformPrim
from isaacsim.core.simulation_manager import SimulationManager
from pxr import UsdLux, UsdPhysics

# --- 2. Build a scene ----------------------------------------------------------------------------------------
stage = stage_utils.create_new_stage(template="sunlight")  # a new, empty USD stage with a distant light
UsdLux.DomeLight.Define(stage, "/World/DomeLight").GetIntensityAttr().Set(500.0)  # soft light from the sky
GroundPlane("/World/GroundPlane")  # a floor with a collider

# A 20 cm cube, 1 m above the floor. A plain Cube only has geometry; the two USD *physics schemas* make it fall
# (RigidBodyAPI: it has mass and moves) and collide (CollisionAPI: it touches other colliders).
cube = Cube("/World/LimeCube", sizes=0.2, positions=[0.6, 0.0, 1.0], colors=["limegreen"])
UsdPhysics.RigidBodyAPI.Apply(stage.GetPrimAtPath("/World/LimeCube"))
UsdPhysics.CollisionAPI.Apply(stage.GetPrimAtPath("/World/LimeCube"))

# The robot of these tutorials (made in tutorials 02 + 03). It is a USD *reference* to another file.
articulation_root = lime.add_lime("/World/turtlebot3_lime")

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

    recorder = Recorder(args.record, eye=(1.4, -1.4, 0.9), target=(0.3, 0.0, 0.25))

# --- 3. Press Play ----------------------------------------------------------------------------------------------
SimulationManager.setup_simulation(dt=1.0 / 60.0)  # physics at 60 steps per second
app_utils.play()

# --- 4. Step and observe --------------------------------------------------------------------------------------------
robot = Articulation(articulation_root)
steps = 0
while simulation_app.is_running():
    simulation_app.update()  # renders one frame and advances physics by dt
    steps += 1
    if recorder:
        recorder.capture()
    if steps % 30 == 0 and steps <= 120:
        z = float(XformPrim("/World/LimeCube").get_world_poses()[0].numpy()[0, 2])
        print(f"[01] t = {steps / 60:.1f} s   cube height = {z:.3f} m", flush=True)
    if (args.test or args.record) and steps >= 150:
        break

ok = True
if args.test:
    cube_z = float(XformPrim("/World/LimeCube").get_world_poses()[0].numpy()[0, 2])
    robot_z = float(robot.get_world_poses()[0].numpy()[0, 2])
    checks = {
        f"cube landed on the floor (centre at {cube_z:.3f} m = half its size)": abs(cube_z - 0.1) < 0.01,
        f"robot stands on its wheels (base_link at {robot_z:.3f} m = wheel radius)": abs(robot_z - 0.06) < 0.01,
        f"robot has {robot.num_dofs} joints that can move": robot.num_dofs == 10,
    }
    for text, passed in checks.items():
        print(f"[01][check] {'ok  ' if passed else 'FAIL'} {text}")
    ok = all(checks.values())
    print(f"[01][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 · TurtleBot3 Lime のインポート。ロボットのファイルがどこから来るのかを説明します。