Skip to content

07 · Odometry, TF and RViz

⏱ 25 min · Level: beginner · Script: isaac/07_odom_tf.py · ROS: lime_isaac_bringup/view_robot.launch.py

Goal. Publish everything ROS needs to know where the robot is and what its joints are doing: /odom, the TF transform odom → base_footprint, and /joint_states. Then see the Lime move in RViz.

RViz showing the Lime model, its TF frames and the odometry trail

RViz in the ROS 2 container: the robot model (posed from Isaac Sim's /joint_states), TF axes, and the odometry arrows of a left turn.

Concepts

TF is ROS's tree of coordinate frames. For a mobile robot it looks like this:

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 is how far the robot has driven since it started. Isaac Sim publishes it, because Isaac Sim is the robot.
  • Everything below base_footprint comes from the URDF. robot_state_publisher (in the ROS container) reads the URDF and /joint_states and publishes those transforms. A real robot is organised the same way, with the same frame and topic names.

Who publishes what

Topic / transform Publisher
/clock Isaac Sim
/odom (nav_msgs/Odometry) Isaac Sim
/tf odom → base_footprint Isaac Sim
/joint_states Isaac Sim, for all 10 joints (until tutorial 12, where ros2_control takes over)
/tf base_footprint → …, /robot_description robot_state_publisher (ROS)

The graph

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

The clock and /cmd_vel graphs from tutorial 06 stay as they are.

Build it

  1. Open your stage from tutorial 06, my_stages/06_ros2_drive.usd (robot + clock + drive graph).
  2. Create a new Action Graph (Window ▸ Visual Scripting ▸ Action Graph ▸ New Action Graph) and add the nodes of the diagram above. Set:

    Node Input Value
    Isaac Compute Odometry Node chassisPrim …/Geometry/base_footprint/base_link
    ROS2 Publish Odometry topicName / odomFrameId / chassisFrameId /odom / odom / base_footprint
    ROS2 Publish Raw Transform Tree parentFrameId / childFrameId odom / base_footprint
    Isaac Read Joint State Node prim …/Geometry/base_footprint/base_link
    ROS2 Publish Joint State topicName /joint_states
  3. Connect Isaac Read Joint State Node → ROS2 Publish Joint State port by port: jointNames, jointPositions, jointVelocities, jointEfforts, jointDofTypes, stageMetersPerUnit, and execOut → execIn.

  4. Press Play. When you are done, press Stop ■ and save: File ▸ Save As my_stages/07_odom_tf.usd. Tutorial 12 continues from it.

The ROS2_OdomTF graph

Shortcut

Tools ▸ Robotics ▸ ROS 2 OmniGraphs ▸ Odometry Publisher and ▸ Joint States build similar graphs from a form.

Why Isaac Read Joint State and not targetPrim on the publisher?

In Isaac Sim 6.x, ROS2 Publish Joint State's own targetPrim input is deprecated. The supported way is to read the joints with Isaac Read Joint State Node and feed the arrays into the publisher.

source scripts/isaac_env.sh
python isaac/07_odom_tf.py

The script reuses the tutorial 06 graphs and adds the new one. All three graph builders are in 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)
create_odom_tf_joint_states_graph() in isaac/common/graphs.py
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"),
            ],
        },
    )
Full script: 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)

See it in RViz

First build the ROS 2 workspace once. It contains the Lime description and this project's launch files:

./scripts/build_ws.sh

With the simulation playing:

./docker/run_ros.sh ros2 launch lime_isaac_bringup view_robot.launch.py

This starts robot_state_publisher (with use_sim_time: true) and RViz with the config lime_isaac_bringup/rviz/view_robot.rviz: fixed frame odom, RobotModel, TF and Odometry displays. Now drive with teleop_twist_keyboard (tutorial 06) and watch the odometry trail.

Check the whole TF chain from the command line:

./docker/run_ros.sh ros2 run tf2_ros tf2_echo odom end_effector_link
At time 19.916666666
- Translation: [0.338, 0.604, 0.312]
- Rotation: in Quaternion (xyzw) [0.631, -0.429, -0.534, -0.364]
The self-check drives 0.2 m/s and 0.5 rad/s for 4 s.

Automatic check

python isaac/07_odom_tf.py --headless --test publishes /cmd_vel itself and compares what comes back on /odom with the command and with the true pose in the simulation:

[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

Why the turn rate matches

The first version of this check failed: the robot turned at 0.44 rad/s instead of 0.5. The tyre collider was the URDF's wide cylinder, which scrubs in turns. Tutorial 03 now gives the wheels sphere colliders. That is one reason to compare simulation data with the command, not only "did it move?".

Troubleshooting

Symptom Fix
RViz: No transform from [base_link] to [odom] Is the simulation playing? Is robot_state_publisher running with use_sim_time:=true?
RobotModel is grey / arm in the wrong pose /joint_states missing: check ros2 topic hz /joint_states.
TF time jumps / "TF_OLD_DATA" warnings You restarted the simulation; restart RViz (sim time went back to 0).

Next: 08 · Camera (RealSense D435)