07 · オドメトリ、TF、RViz¶
目標: ロボットがどこにいるかとジョイントがどう動いているかを ROS が知るために必要なものを、すべてパブリッシュします。/odom、TF の変換 odom → base_footprint、そして /joint_states です。そのうえで、RViz で Lime が動く様子を見ます。

/joint_states で姿勢を決めています)、TF の座標軸、左旋回したときのオドメトリの矢印。考え方¶
TF は、ROS の座標フレームのツリーです。移動ロボットでは次のようになります。
flowchart LR
map([map]) -. "AMCL (tutorial 11)" .-> odom([odom])
odom -- "Isaac Sim<br/>/tf" --> bf([base_footprint])
bf -- "robot_state_publisher<br/>(URDF + /joint_states)" --> bl([base_link])
bl --> wheels([wheel_*_link])
bl --> scan([base_scan])
bl --> cam([camera_*_frame])
bl --> arm([link1 … link7 → end_effector_link])
odom → base_footprintは、ロボットが起動してからどれだけ走ったかを表します。これは Isaac Sim がパブリッシュします。Isaac Sim がロボットそのものだからです。base_footprintより下のすべては URDF から来ます。robot_state_publisher(ROS コンテナ内)が URDF と/joint_statesを読み、それらの変換をパブリッシュします。実機も同じ構成で、フレーム名とトピック名も同じです。
誰が何をパブリッシュするか
| トピック / 変換 | パブリッシャー |
|---|---|
/clock |
Isaac Sim |
/odom (nav_msgs/Odometry) |
Isaac Sim |
/tf odom → base_footprint |
Isaac Sim |
/joint_states |
Isaac Sim、10 個のジョイントすべて(チュートリアル 12 で ros2_control に引き継ぐまで) |
/tf base_footprint → …、/robot_description |
robot_state_publisher (ROS) |
グラフ¶
flowchart LR
tick([On Playback Tick])
time[Isaac Read Simulation Time]
odom[Isaac Compute Odometry Node<br/>chassisPrim = base_link]
podom[ROS2 Publish Odometry<br/><i>/odom</i> · odom → base_footprint]
ptf[ROS2 Publish Raw Transform Tree<br/><i>/tf</i> odom → base_footprint]
rjs[Isaac Read Joint State Node<br/>prim = base_link]
pjs[ROS2 Publish Joint State<br/><i>/joint_states</i>]
tick --> odom --> podom
odom --> ptf
tick --> rjs --> pjs
time --> podom & ptf & pjs
odom -- "position, orientation,<br/>linear/angular velocity" --> podom
odom -- "position → translation<br/>orientation → rotation" --> ptf
rjs -- "names, positions, velocities,<br/>efforts, dof types" --> pjs
チュートリアル 06 のクロックのグラフと /cmd_vel のグラフは、そのまま使います。
作ってみる¶
- チュートリアル 06 のステージ
my_stages/06_ros2_drive.usd(ロボット + クロック + 走行用のグラフ)を開きます。 -
新しい Action Graph を作り (Window ▸ Visual Scripting ▸ Action Graph ▸ New Action Graph)、上の図のノードを追加します。次のように設定します。
ノード 入力 値 Isaac Compute Odometry Node chassisPrim …/Geometry/base_footprint/base_linkROS2 Publish Odometry topicName / odomFrameId / chassisFrameId /odom/odom/base_footprintROS2 Publish Raw Transform Tree parentFrameId / childFrameId odom/base_footprintIsaac Read Joint State Node prim …/Geometry/base_footprint/base_linkROS2 Publish Joint State topicName /joint_states -
Isaac Read Joint State Node→ROS2 Publish Joint Stateを、ポートごとに接続します。jointNames、jointPositions、jointVelocities、jointEfforts、jointDofTypes、stageMetersPerUnit、そしてexecOut → execInです。 - Play を押します。終わったら Stop ■ を押し、File ▸ Save As で
my_stages/07_odom_tf.usdとして保存します。チュートリアル 12 はこのステージから続けます。

近道
Tools ▸ Robotics ▸ ROS 2 OmniGraphs ▸ Odometry Publisher と ▸ Joint States を使うと、フォームに入力するだけで同様のグラフを作れます。
なぜパブリッシャーの targetPrim ではなく Isaac Read Joint State を使うのか
Isaac Sim 6.x では、ROS2 Publish Joint State 自身の targetPrim 入力は非推奨です。サポートされている方法は、Isaac Read Joint State Node でジョイントを読み取り、その配列をパブリッシャーに渡すことです。
スクリプトはチュートリアル 06 のグラフを再利用し、新しいグラフを追加します。グラフを作る 3 つの関数は、すべて isaac/common/graphs.py にあります。
graphs.enable_ros2_realtime(simulation_app)
graphs.create_clock_graph() # /clock (06)
graphs.create_drive_graph(articulation_root) # /cmd_vel (06)
graphs.create_odom_tf_joint_states_graph(articulation_root) # /odom /tf /joint_states (new)
isaac/common/graphs.py の create_odom_tf_joint_states_graph()
def create_odom_tf_joint_states_graph(
articulation_root: str,
graph_path: str = "/World/ROS2_OdomTF",
joint_states_topic: str = "/joint_states",
):
import usdrt.Sdf
og = _og()
keys = og.Controller.Keys
og.Controller.edit(
{"graph_path": graph_path, "evaluator_name": "execution"},
{
keys.CREATE_NODES: [
("OnPlaybackTick", "omni.graph.action.OnPlaybackTick"),
("ReadSimTime", "isaacsim.core.nodes.IsaacReadSimulationTime"),
("ComputeOdometry", "isaacsim.core.nodes.IsaacComputeOdometry"),
("PublishOdometry", "isaacsim.ros2.bridge.ROS2PublishOdometry"),
("PublishOdomTF", "isaacsim.ros2.bridge.ROS2PublishRawTransformTree"),
("ReadJointState", "isaacsim.sensors.physics.IsaacReadJointState"),
("PublishJointState", "isaacsim.ros2.bridge.ROS2PublishJointState"),
],
keys.SET_VALUES: [
("ComputeOdometry.inputs:chassisPrim", [usdrt.Sdf.Path(articulation_root)]),
("PublishOdometry.inputs:topicName", "/odom"),
("PublishOdometry.inputs:odomFrameId", "odom"),
("PublishOdometry.inputs:chassisFrameId", "base_footprint"),
("PublishOdomTF.inputs:parentFrameId", "odom"),
("PublishOdomTF.inputs:childFrameId", "base_footprint"),
("ReadJointState.inputs:prim", [usdrt.Sdf.Path(articulation_root)]),
("PublishJointState.inputs:topicName", joint_states_topic),
],
keys.CONNECT: [
("OnPlaybackTick.outputs:tick", "ComputeOdometry.inputs:execIn"),
("ComputeOdometry.outputs:execOut", "PublishOdometry.inputs:execIn"),
("ComputeOdometry.outputs:execOut", "PublishOdomTF.inputs:execIn"),
("ReadSimTime.outputs:simulationTime", "PublishOdometry.inputs:timeStamp"),
("ReadSimTime.outputs:simulationTime", "PublishOdomTF.inputs:timeStamp"),
("ComputeOdometry.outputs:position", "PublishOdometry.inputs:position"),
("ComputeOdometry.outputs:orientation", "PublishOdometry.inputs:orientation"),
("ComputeOdometry.outputs:linearVelocity", "PublishOdometry.inputs:linearVelocity"),
("ComputeOdometry.outputs:angularVelocity", "PublishOdometry.inputs:angularVelocity"),
("ComputeOdometry.outputs:position", "PublishOdomTF.inputs:translation"),
("ComputeOdometry.outputs:orientation", "PublishOdomTF.inputs:rotation"),
("OnPlaybackTick.outputs:tick", "ReadJointState.inputs:execIn"),
("ReadJointState.outputs:execOut", "PublishJointState.inputs:execIn"),
("ReadSimTime.outputs:simulationTime", "PublishJointState.inputs:timeStamp"),
("ReadJointState.outputs:jointNames", "PublishJointState.inputs:jointNames"),
("ReadJointState.outputs:jointPositions", "PublishJointState.inputs:jointPositions"),
("ReadJointState.outputs:jointVelocities", "PublishJointState.inputs:jointVelocities"),
("ReadJointState.outputs:jointEfforts", "PublishJointState.inputs:jointEfforts"),
("ReadJointState.outputs:jointDofTypes", "PublishJointState.inputs:jointDofTypes"),
("ReadJointState.outputs:stageMetersPerUnit", "PublishJointState.inputs:stageMetersPerUnit"),
],
},
)
スクリプト全体:isaac/07_odom_tf.py
# SPDX-FileCopyrightText: 2026 An (an-robotics)
# SPDX-License-Identifier: Apache-2.0
"""Tutorial 07 - Odometry, TF and joint states: see TurtleBot3 Lime in RViz.
source scripts/isaac_env.sh
python isaac/07_odom_tf.py
# ROS 2 container: robot_state_publisher + RViz
./docker/run_ros.sh ros2 launch lime_isaac_bringup view_robot.launch.py
# and drive it
./docker/run_ros.sh ros2 run teleop_twist_keyboard teleop_twist_keyboard
New in this tutorial (graph "ROS2_OdomTF"):
On Playback Tick --> Isaac Compute Odometry (base_link) --+--> ROS2 Publish Odometry /odom
+--> ROS2 Publish Raw Transform /tf odom -> base_footprint
--> Isaac Read Joint State (robot) ------> ROS2 Publish Joint State /joint_states
robot_state_publisher (ROS side) turns /joint_states + the URDF into the rest of the TF tree:
base_footprint -> base_link -> wheels, arm links, base_scan, camera frames, ...
"""
import math
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 isaacsim.core.experimental.utils.app as app_utils
import isaacsim.core.experimental.utils.stage as stage_utils
import numpy as np
from common import graphs, 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
graphs.enable_ros2_realtime(simulation_app) # ROS 2 bridge + 60 Hz main loop (tutorial 06)
# --- 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)]):
Cube(f"/World/Landmark_{i}", sizes=0.2, positions=[x, y, 0.1], colors=[0.6, 0.85, 0.2])
articulation_root = lime.add_lime("/World/turtlebot3_lime")
# --- Graphs ------------------------------------------------------------------------------------------------
graphs.create_clock_graph() # /clock (tutorial 06)
graphs.create_drive_graph(articulation_root) # /cmd_vel -> wheels (tutorial 06)
graphs.create_odom_tf_joint_states_graph(articulation_root) # NEW: /odom, /tf, /joint_states (see common/graphs.py)
recorder = None
if args.record:
from common.recorder import Recorder
recorder = Recorder(args.record, eye=(2.0, -2.0, 1.5), target=(0.3, 0.3, 0.1), every_n=3, fps=20)
SimulationManager.setup_simulation(dt=1.0 / 60.0)
app_utils.play()
simulation_app.update()
robot = Articulation(articulation_root)
print("[07] ready: /odom, /tf (odom->base_footprint), /joint_states and /clock are published", flush=True)
def yaw_of(q_wxyz):
w, x, y, z = q_wxyz
return math.atan2(2 * (w * z + x * y), 1 - 2 * (y * y + z * z))
# --- Self-check (--test): drive a known twist and compare /odom with the commanded motion and the truth ---
if args.test or args.record:
import rclpy
from geometry_msgs.msg import Twist
from nav_msgs.msg import Odometry
from sensor_msgs.msg import JointState
from tf2_msgs.msg import TFMessage
rclpy.init()
node = rclpy.create_node("lime_tutorial07_check")
seen = {"odom": None, "joints": None, "tf": False}
node.create_subscription(Odometry, "/odom", lambda m: seen.__setitem__("odom", m), 10)
node.create_subscription(JointState, "/joint_states", lambda m: seen.__setitem__("joints", m), 10)
def on_tf(msg):
if any(t.header.frame_id == "odom" and t.child_frame_id == "base_footprint" for t in msg.transforms):
seen["tf"] = True
node.create_subscription(TFMessage, "/tf", on_tf, 10)
cmd_pub = node.create_publisher(Twist, "/cmd_vel", 10)
V, W = 0.2, 0.5 # commanded: 0.2 m/s forward, 0.5 rad/s counter-clockwise (left turn)
start_pose = robot.get_world_poses()
start_xy, start_yaw = start_pose[0].numpy()[0, :2].copy(), yaw_of(start_pose[1].numpy()[0])
steps = 0
while simulation_app.is_running():
if args.test or args.record:
if 60 <= steps < 60 + 4 * 60: # drive for 4 s
cmd = Twist()
cmd.linear.x, cmd.angular.z = V, W
cmd_pub.publish(cmd)
elif steps == 60 + 4 * 60:
cmd_pub.publish(Twist()) # stop
odom_while_driving = seen["odom"]
truth = robot.get_world_poses()
for _ in range(20): # handle every message that arrived (3 topics at 60 Hz), not just one
rclpy.spin_once(node, timeout_sec=0.0)
simulation_app.update()
if recorder:
recorder.capture()
steps += 1
if (args.test or args.record) and steps > 60 + 4 * 60 + 30:
break
ok = True
if args.test:
o = odom_while_driving
v_meas, w_meas = o.twist.twist.linear.x, o.twist.twist.angular.z
q = o.pose.pose.orientation
odom_yaw = yaw_of((q.w, q.x, q.y, q.z))
odom_xy = np.array([o.pose.pose.position.x, o.pose.pose.position.y])
true_xy = truth[0].numpy()[0, :2] - start_xy
true_yaw = yaw_of(truth[1].numpy()[0]) - start_yaw
names = set(seen["joints"].name) if seen["joints"] else set()
expected_joints = set(lime.WHEEL_JOINTS + lime.ARM_JOINTS + [lime.GRIPPER_JOINT, lime.GRIPPER_MIMIC_JOINT])
checks = {
f"odom twist v={v_meas:.3f} m/s (cmd {V})": abs(v_meas - V) < 0.15 * V,
f"odom twist w={w_meas:.3f} rad/s (cmd {W})": abs(w_meas - W) < 0.15 * W,
f"left turn -> yaw increased: odom yaw {math.degrees(odom_yaw):.1f} deg": odom_yaw > 0.5,
f"odom pose vs truth: |dxy|={np.linalg.norm(odom_xy - true_xy):.3f} m, dyaw={math.degrees(odom_yaw - true_yaw):.2f} deg": np.linalg.norm(odom_xy - true_xy) < 0.02 and abs(odom_yaw - true_yaw) < 0.02,
f"/joint_states has all {len(expected_joints)} joints": expected_joints <= names,
"TF odom -> base_footprint received": seen["tf"],
}
for text, passed in checks.items():
print(f"[07][check] {'ok ' if passed else 'FAIL'} {text}")
ok = all(checks.values())
print(f"[07][test] {'PASS' if ok else 'FAIL'}")
if args.test or args.record:
node.destroy_node()
rclpy.shutdown()
if recorder:
recorder.save()
app_utils.stop()
simulation_app.close(exit_code=0 if ok else 1)
sys.exit(0 if ok else 1)
RViz で見る¶
まず、ROS 2 のワークスペースを一度ビルドします。ワークスペースには、Lime のロボット記述(description)と、このプロジェクトの launch ファイルが入っています。
シミュレーションを再生した状態で、次を実行します。
これで robot_state_publisher(use_sim_time: true を指定)と RViz が起動します。RViz の設定は lime_isaac_bringup/rviz/view_robot.rviz で、固定フレームは odom、表示は RobotModel、TF、Odometry です。ここで teleop_twist_keyboard(チュートリアル 06)を使って走らせ、オドメトリの軌跡を見てください。
TF のチェーン全体を、コマンドラインで確認します。
At time 19.916666666
- Translation: [0.338, 0.604, 0.312]
- Rotation: in Quaternion (xyzw) [0.631, -0.429, -0.534, -0.364]
自動チェック¶
python isaac/07_odom_tf.py --headless --test は、自分で /cmd_vel をパブリッシュし、/odom に返ってくる値を、指令値およびシミュレーション内の実際の姿勢と比較します。
[07][check] ok odom twist v=0.199 m/s (cmd 0.2)
[07][check] ok odom twist w=0.505 rad/s (cmd 0.5)
[07][check] ok left turn -> yaw increased: odom yaw 106.6 deg
[07][check] ok odom pose vs truth: |dxy|=0.003 m, dyaw=-0.48 deg
[07][check] ok /joint_states has all 10 joints
[07][check] ok TF odom -> base_footprint received
[07][test] PASS
旋回速度が一致する理由
このチェックの最初のバージョンは失敗しました。ロボットは 0.5 rad/s ではなく 0.44 rad/s で旋回していたのです。タイヤのコライダーが URDF の幅の広い円柱で、旋回時に床を擦っていたためです。現在は、チュートリアル 03 で車輪に球のコライダーを与えています。これが、「動いたか?」だけを見るのではなく、シミュレーションのデータを指令値と比較する理由の 1 つです。
トラブルシューティング¶
| 症状 | 対処 |
|---|---|
| RViz: No transform from [base_link] to [odom] | シミュレーションは再生中ですか?robot_state_publisher は use_sim_time:=true で動いていますか? |
| RobotModel が灰色になる / アームの姿勢がおかしい | /joint_states が届いていません。ros2 topic hz /joint_states で確認してください。 |
| TF の時刻が飛ぶ / 「TF_OLD_DATA」の警告が出る | シミュレーションを再起動したためです。RViz を再起動してください(シミュレーション時間が 0 に戻っています)。 |