06 · ROS 2 で TurtleBot3 Lime を走らせる(/cmd_vel)¶
目標: シミュレーションのクロックをパブリッシュし、/cmd_vel の ROS 2 geometry_msgs/Twist メッセージを車輪の速度に変換する Action Graph を作ります。そのあと、ROS 2 コンテナからキーボードで Lime を運転します。
ros2 topic pub /cmd_vel … {linear: {x: 0.25}, angular: {z: 0.5}} を実行:Lime は円を描いて走ります。10 分でわかる ROS 2¶
このチュートリアル以降、Isaac Sim は ROS 2 システムの一部になります。以下は、各チュートリアルで使う ROS 2 の用語です。すでに知っている場合は、考え方まで飛ばしてください。
| 用語 | 意味 | チュートリアルでの例 |
|---|---|---|
| ノード(node) | 1 つの仕事を受け持ち、ほかのノードとやりとりする、実行中のプログラム(またはその一部) | RViz、Nav2 のプランナー、YOLO の検出器 |
| トピック(topic) | 名前の付いた通信路です。パブリッシャーがメッセージを送り、サブスクライバーがそれを受け取ります。どちらも相手を知る必要はありません | /cmd_vel(速度指令)、/odom、/scan、/clock |
| メッセージ型(message type) | トピックのデータ形式 | /cmd_vel は geometry_msgs/msg/Twist を運びます。中身は並進速度と角速度で、それぞれ 3 つの数値です |
| サービス(service) | 要求とその応答 | Nav2 のノードがアクティブかどうかの問い合わせ (/amcl/get_state)、コストマップのクリア(チュートリアル 15) |
| アクション(action) | 実行中にフィードバックを返し、最後に結果を返す、時間のかかる仕事です。途中でキャンセルもできます | NavigateToPose(Nav2、チュートリアル 11)、MoveGroup と GripperCommand(MoveIt 2、チュートリアル 12) |
| TF | 座標フレームのツリーです。ロボットの各部分がどこにあるかを表します | チュートリアル 07 |
| パッケージ(package) | ROS 2 のコード、設定、launch ファイルをまとめたフォルダー | ros2_ws/src/lime_isaac_bringup、lime_yolo、… |
| ワークスペース(workspace)、colcon | パッケージを収めるフォルダー (ros2_ws/) と、それらをビルドするツール |
./scripts/build_ws.sh がコンテナの中で colcon build を実行します |
| launch ファイル | 複数のノードを、それぞれの設定とともに一度に起動する Python ファイル | ros2 launch lime_isaac_bringup navigation.launch.py |
| パラメーター(parameter) | ノードの設定 | use_sim_time、nav2_params.yaml にある Nav2 の設定 |
/clock、use_sim_time |
Isaac Sim は、シミュレーション時間を /clock にパブリッシュします。use_sim_time: true で起動したノードは、PC の時計の代わりにこれを使います。そのため、シミュレーションが実時間より遅く動いていても、ノードの時刻はシミュレーションと一致します |
このプロジェクトの launch ファイルが自動で設定します |
2 種類のノード
Isaac Sim の Action Graph もノード、つまりグラフエディターの中の ROS2 Subscribe Twist のような箱でできています。これらは OmniGraph のノードです。このページで ROS 2 のノードを指すときは、そう明記します。
各チュートリアルの ROS 2 コマンドは、すべて ROS 2 コンテナの中で実行します。./docker/run_ros.sh ros2 … はコマンドを 1 つ実行し、./docker/run_ros.sh だけを実行するとコンテナの中でシェルが開きます。これらの考え方を、小さなサンプルプログラムを使って実際に手を動かしながら学ぶには、ROS 2 Jazzy の公式チュートリアルに取り組んでください。Beginner: CLI tools(ノード、トピック、サービス、パラメーター、アクション、launch)と Beginner: Client libraries(自作のパッケージとノード、colcon)です。コンテナには、これらの公式チュートリアルで使う turtlesim とサンプルノードが入っています。
考え方¶
OmniGraph / Action Graph: Isaac Sim は、ノードのグラフでシミュレーションと ROS 2 をつなぎます。Action Graph は、イベントが発生したときに実行されます。On Playback Tick は、シミュレーションの再生中にシミュレーションの 1 フレームごとに 1 回発生します。ROS 2 のトピックがパブリッシュ・受信されるのは、再生(Play)中だけです。
ROS 2 ブリッジ: 拡張機能 isaacsim.ros2.bridge は、ROS 2 とやりとりするグラフのノード(ROS2 Publish Clock、ROS2 Subscribe Twist、…)を提供します。この拡張機能は、Isaac Sim に同梱された Jazzy のライブラリで動きます(セットアップを参照)。
差動二輪駆動: Twist は、ロボットの前進速度 \(v\) と旋回の角速度 \(\omega\) を与えます。Differential Controller ノードは、これらを車輪の速度に変換します。
Lime の車輪の半径は \(r = 0.06\) m、車輪の間隔は \(L = 0.29425\) m です(URDF の値)。
グラフ¶
flowchart LR
tick([On Playback Tick])
time[Isaac Read<br/>Simulation Time]
clock[ROS2 Publish Clock<br/><i>/clock</i>]
twist[ROS2 Subscribe Twist<br/><i>/cmd_vel</i>]
bl[Break 3-Vector]
ba[Break 3-Vector]
diff[Differential Controller<br/>r = 0.06, L = 0.29425]
art[Articulation Controller<br/>wheel_left_joint, wheel_right_joint]
tick --> clock
time -- "simulationTime" --> clock
tick --> twist
tick --> art
twist -- "execOut" --> diff
twist -- "linearVelocity" --> bl -- "x" --> diff
twist -- "angularVelocity" --> ba -- "z" --> diff
diff -- "velocityCommand" --> art
作ってみる¶
- 調整済みのロボットを入れたステージを作ります。File ▸ New、Create ▸ Physics ▸ Ground Plane を選び、続いて File ▸ Add Reference で
assets/usd/turtlebot3_lime_tuned.usdaを追加します。(ロボットのファイル自体は開かないでください。それを保存してしまうと、以降のすべてのチュートリアルがその変更を読み込みます。) - Window ▸ Visual Scripting ▸ Action Graph を開き、New Action Graph を選びます。
- ノードライブラリ(左側)で各ノードを名前で検索し、グラフにドラッグします。追加するのは
On Playback Tick、Isaac Read Simulation Time、ROS2 Publish Clock、ROS2 Subscribe Twist、2×Break 3-Vector、Differential Controller、Articulation Controllerです。 - 上の図のとおりに接続します。
-
Property パネルで入力を設定します。
ノード 入力 値 ROS2 Subscribe Twist topicName /cmd_velDifferential Controller wheelRadius / wheelDistance / maxWheelSpeed 0.06/0.29425/8.063Articulation Controller targetPrim …/Geometry/base_footprint/base_link(アーティキュレーションのルート)Articulation Controller jointNames wheel_left_joint、wheel_right_joint -
Play ▶ を押します。
- 運転してみます(次の節)。終わったら Stop ■ を押し、File ▸ Save As でステージを
my_stages/06_ros2_drive.usdとして保存します。チュートリアル 07 はこのステージから続けます。
近道
Isaac Sim には、よく使う構成のグラフを作ってくれるツールがあります。Tools ▸ Robotics ▸ OmniGraph Controllers ▸ Differential Controller は、このグラフのうちコントローラーの半分を作ります。Tools ▸ Robotics ▸ ROS 2 OmniGraphs は、クロック、TF、オドメトリ、カメラ、LiDAR 用の ROS 2 グラフを作ります。これらの近道が何を作るのかを理解するには、このグラフを一度手で作ってみるのがいちばんです。

og.Controller.edit() は、1 回の呼び出しでノードを作り、値を設定し、ポートをつなぎます。これは、GUI で手作業で行う 3 つの手順と同じです。
og.Controller.edit(
{"graph_path": "/World/ROS2_Drive", "evaluator_name": "execution"},
{
keys.CREATE_NODES: [
("OnPlaybackTick", "omni.graph.action.OnPlaybackTick"),
("SubscribeTwist", "isaacsim.ros2.bridge.ROS2SubscribeTwist"),
("DiffController", "isaacsim.robot.wheeled_robots.DifferentialController"),
("ArticulationController", "isaacsim.core.nodes.IsaacArticulationController"),
# ...
],
keys.SET_VALUES: [("DiffController.inputs:wheelRadius", 0.06), ...],
keys.CONNECT: [("DiffController.outputs:velocityCommand",
"ArticulationController.inputs:velocityCommand"), ...],
},
)
スクリプトには、ほかにも 2 つのポイントがあります。
app_utils.enable_extension("isaacsim.ros2.bridge"):スタンドアロンのアプリは、ブリッジなしで起動するためです。- メインループは 60 Hz に制限しています (
/app/runLoops/main/rateLimitEnabled)。制限しないと、ヘッドレスのスクリプトは実時間より速く動きます。teleop、RViz、Nav2 などの ROS のツールは、ほぼ実時間で動くことを前提にしています。
スクリプト全体:isaac/06_ros2_drive.py
# SPDX-FileCopyrightText: 2026 An (an-robotics)
# SPDX-License-Identifier: Apache-2.0
"""Tutorial 06 - Drive TurtleBot3 Lime from ROS 2 (/cmd_vel) with an Action Graph.
source scripts/isaac_env.sh
python isaac/06_ros2_drive.py
# in another terminal (ROS 2 Jazzy container):
./docker/run_ros.sh ros2 run teleop_twist_keyboard teleop_twist_keyboard
The Action Graph built here:
On Playback Tick --+--> ROS2 Publish Clock <-- Isaac Read Simulation Time (/clock)
|
+--> ROS2 Subscribe Twist (/cmd_vel)
| |-- linear --> Break Vector3 --x--+
| |-- angular --> Break Vector3 --z--+--> Differential Controller
| | wheel velocities
+--> Articulation Controller <--------------------+
(wheel_left_joint, wheel_right_joint)
"""
import sys
from common.cli import parse_args
args = parse_args(__doc__.splitlines()[0])
from isaacsim import SimulationApp
simulation_app = SimulationApp({"headless": args.headless, "width": 1280, "height": 720})
import carb
import isaacsim.core.experimental.utils.app as app_utils
import isaacsim.core.experimental.utils.stage as stage_utils
import numpy as np
from common import lime
from isaacsim.core.experimental.objects import Cube, GroundPlane
from isaacsim.core.experimental.prims import Articulation
from isaacsim.core.simulation_manager import SimulationManager
from pxr import UsdLux
# --- 1. ROS 2 bridge + real-time pacing ------------------------------------------------------------
# The ROS 2 bridge is an extension. It uses Isaac Sim's bundled ROS 2 Jazzy libraries
# (scripts/isaac_env.sh puts them on LD_LIBRARY_PATH before Isaac Sim starts).
app_utils.enable_extension("isaacsim.ros2.bridge")
# Standalone scripts run "as fast as possible". ROS tools expect roughly real time, so cap the
# main loop at 60 Hz (= one 1/60 s physics step per frame).
settings = carb.settings.get_settings()
settings.set("/app/runLoops/main/rateLimitEnabled", True)
settings.set("/app/runLoops/main/rateLimitFrequency", 60)
simulation_app.update()
import omni.graph.core as og
import usdrt.Sdf
# --- 2. Scene -------------------------------------------------------------------------------------------
stage = stage_utils.create_new_stage(template="sunlight")
UsdLux.DomeLight.Define(stage, "/World/DomeLight").GetIntensityAttr().Set(500.0)
GroundPlane("/World/GroundPlane")
for i, (x, y) in enumerate([(1.5, 0.0), (0.0, 1.5), (-1.5, 0.0), (0.0, -1.5)]): # landmarks
Cube(f"/World/Landmark_{i}", sizes=0.2, positions=[x, y, 0.1], colors=[0.6, 0.85, 0.2])
robot_path = "/World/turtlebot3_lime"
articulation_root = lime.add_lime(robot_path)
# --- 3. The Action Graph ------------------------------------------------------------------------------
keys = og.Controller.Keys
og.Controller.edit(
{"graph_path": "/World/ROS2_Drive", "evaluator_name": "execution"},
{
keys.CREATE_NODES: [
("OnPlaybackTick", "omni.graph.action.OnPlaybackTick"),
("ReadSimTime", "isaacsim.core.nodes.IsaacReadSimulationTime"),
("PublishClock", "isaacsim.ros2.bridge.ROS2PublishClock"),
("SubscribeTwist", "isaacsim.ros2.bridge.ROS2SubscribeTwist"),
("BreakLinear", "omni.graph.nodes.BreakVector3"),
("BreakAngular", "omni.graph.nodes.BreakVector3"),
("DiffController", "isaacsim.robot.wheeled_robots.DifferentialController"),
("ArticulationController", "isaacsim.core.nodes.IsaacArticulationController"),
],
keys.SET_VALUES: [
("PublishClock.inputs:topicName", "/clock"),
("SubscribeTwist.inputs:topicName", "/cmd_vel"),
("DiffController.inputs:wheelRadius", lime.WHEEL_RADIUS),
("DiffController.inputs:wheelDistance", lime.WHEEL_BASE),
("DiffController.inputs:maxWheelSpeed", lime.MAX_WHEEL_SPEED),
("ArticulationController.inputs:targetPrim", [usdrt.Sdf.Path(articulation_root)]),
("ArticulationController.inputs:jointNames", lime.WHEEL_JOINTS),
],
keys.CONNECT: [
("OnPlaybackTick.outputs:tick", "PublishClock.inputs:execIn"),
("ReadSimTime.outputs:simulationTime", "PublishClock.inputs:timeStamp"),
("OnPlaybackTick.outputs:tick", "SubscribeTwist.inputs:execIn"),
("OnPlaybackTick.outputs:tick", "ArticulationController.inputs:execIn"),
("SubscribeTwist.outputs:execOut", "DiffController.inputs:execIn"),
("SubscribeTwist.outputs:linearVelocity", "BreakLinear.inputs:tuple"),
("BreakLinear.outputs:x", "DiffController.inputs:linearVelocity"),
("SubscribeTwist.outputs:angularVelocity", "BreakAngular.inputs:tuple"),
("BreakAngular.outputs:z", "DiffController.inputs:angularVelocity"),
("DiffController.outputs:velocityCommand", "ArticulationController.inputs:velocityCommand"),
],
},
)
recorder = None
if args.record:
from common.recorder import Recorder
recorder = Recorder(args.record, eye=(2.2, -2.2, 1.6), target=(0.0, 0.0, 0.1), every_n=3, fps=20)
# --- 4. Run -----------------------------------------------------------------------------------------------
SimulationManager.setup_simulation(dt=1.0 / 60.0)
app_utils.play()
simulation_app.update()
robot = Articulation(articulation_root)
start = robot.get_world_poses()[0].numpy()[0, :2].copy()
print("[06] ready: publish geometry_msgs/Twist on /cmd_vel to drive the robot", flush=True)
steps, moved, first_move_step = 0, 0.0, None
while simulation_app.is_running():
simulation_app.update()
steps += 1
if not (args.test or args.record):
continue # interactive: run until you close the window
# --test / --record: wait (max 60 s) for /cmd_vel commands, then watch the robot for 10 s
moved = float(np.linalg.norm(robot.get_world_poses()[0].numpy()[0, :2] - start))
if first_move_step is None and moved > 0.05:
first_move_step = steps
if first_move_step is None and steps > 60 * 60:
break # nobody published /cmd_vel
if first_move_step is not None:
if recorder:
recorder.capture()
if steps - first_move_step > 10 * 60:
break
ok = True
if args.test:
ok = moved > 0.3
print(f"[06][test] robot moved {moved:.2f} m after /cmd_vel commands -> {'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)
ROS 2 から走らせる¶
シミュレーションを再生したまま、2 つ目のターミナルを開きます。まず、ROS 2 から何が見えるかを確かめます。
./docker/run_ros.sh ros2 topic list # the topics that exist now
./docker/run_ros.sh ros2 topic info /cmd_vel # its message type, who publishes, who listens
./docker/run_ros.sh ros2 interface show geometry_msgs/msg/Twist # what a Twist message contains
/clock
/cmd_vel
/parameter_events
/rosout
Type: geometry_msgs/msg/Twist
Publisher count: 0
Subscription count: 1
# This expresses velocity in free space broken into its linear and angular parts.
Vector3 linear
float64 x
float64 y
float64 z
Vector3 angular
float64 x
float64 y
float64 z
Lime が使うのは linear.x(前進速度)と angular.z(旋回の角速度)です。1 つだけあるサブスクライバーは、Isaac Sim の中の ROS2 Subscribe Twist グラフノードです。/cmd_vel にはまだ誰もパブリッシュしていません。それをこれから行います。
クロックも確認します。
自動チェック
python isaac/06_ros2_drive.py --headless --test は /cmd_vel のメッセージを待ち、ロボットがスタート地点から 0.3 m を超えて動いたことをチェックします。上の topic pub コマンド(半径 0.5 m の円の上を 12 秒)では、robot moved 0.47 m … PASS と表示されます。

トラブルシューティング¶
| 症状 | 対処 |
|---|---|
/cmd_vel はパブリッシュされているのに、ロボットが動かない |
シミュレーションは再生中ですか?targetPrim はアーティキュレーションのルート (…/base_link) ですか? |
| ロボットが逆向きに曲がる、または後ろに走る | jointNames の順序を確認してください。左が先、右が後です |
| ロボットが遅い、またはガタつく | 調整済みのアセットを使っていないためです(03 を参照) |