Skip to content

09 · LiDAR & IMU

⏱ 25 min · Level: beginner · Script: isaac/09_lidar_imu.py · ROS: lime_isaac_bringup/view_sensors.launch.py

Goal. Add the Lime's LDS-01 2D LiDAR as an RTX LiDAR, configured with the real sensor's numbers, and the IMU. Publish /scan and /imu, then look at everything in RViz.

RViz: robot, camera image and the LiDAR scan of the lime_room

RViz (view_sensors.launch.py): the camera image (top left) and /scan (red), outlining the walls, the three obstacles and the bottle. The bottle is the only object taller than the LiDAR's 16 cm scan plane.

Concepts

RTX LiDAR. Isaac Sim simulates LiDARs by ray tracing the scene on the GPU, with real scan patterns, timing and noise. Sensor models live in Isaac Sim's sensor library (Lidar.create(config=...)), and every parameter is a USD attribute on an OmniLidar prim.

Making it an LDS-01. The Lime's URDF says the LDS-01 measures 360 points per turn at 5 Hz, 0.12–3.5 m. We start from the single-beam RPLIDAR_S2E model and override its numbers:

Attribute Value Why
omni:sensor:Core:scanRateBaseHz, omni:sensor:tickRate 5 5 turns per second
omni:sensor:Core:patternFiringRateHz, reportRateBaseHz 1800 1800 shots/s ÷ 5 turns/s = 360 points per turn
omni:sensor:Core:nearRangeM / farRangeM 0.12 / 3.5 range limits; 0.12 m also ignores hits on the robot's own folded arm

The RPLIDAR housing mesh is hidden; the Lime's own LDS mesh is already there.

IMU. A physics sensor that reads the acceleration and angular velocity of the rigid body it is attached to. It must sit on a rigid body. imu_link is only a frame without mass, so the IMU goes on base_link, 33 mm up (where imu_link is). It publishes with frame_id = imu_link.

The graphs

flowchart LR
  tick([On Playback Tick]) --> rp[Isaac Create Render Product<br/>lds OmniLidar]
  rp -- renderProductPath --> scan[ROS2 RTX Lidar Helper<br/>type laser_scan · fullScan]
  scan --> t1["/scan · base_scan"]
  tick --> imu[Isaac Read IMU Node<br/>readGravity]
  imu -- linAcc, angVel, orientation --> pimu[ROS2 Publish Imu]
  pimu --> t2["/imu · imu_link"]

Build it

  1. Open your stage from tutorial 08, my_stages/08_camera.usd (lime_room + robot + camera).
  2. LiDAR: select …/base_link/base_scan, then Create ▸ Sensors ▸ RTX Lidar ▸ Slamtec ▸ RPLIDAR S2E. Select the created OmniLidar prim and set the attributes from the table above in Property ▸ Raw USD Properties.
  3. Tools ▸ Robotics ▸ ROS 2 OmniGraphs ▸ RTX Lidar: choose the LiDAR prim, type laser_scan, topic /scan, frame base_scan.
  4. IMU: select …/base_link, then Create ▸ Sensors ▸ Imu Sensor. Set its translation to (0, 0, 0.033).
  5. Build the IMU graph by hand (Action Graph editor): On Playback Tick → Isaac Read IMU Node (imuPrim = the IMU, readGravity ✓) → ROS2 Publish Imu (topicName /imu, frameId imu_link). Connect linAcc → linearAcceleration, angVel → angularVelocity, orientation → orientation, and the simulation time to timeStamp.
  6. To see the LiDAR in the viewport, tick showDebugView on the ROS2 RTX Lidar Helper node. Press Play:

    LiDAR hits drawn in the viewport (showDebugView)

    The dots sit on the walls, the obstacles and the bottle. The cup, bowl and banana are lower than the scan plane (16 cm), so the LiDAR cannot see them.

  7. Press Stop ■ and save: File ▸ Save As my_stages/09_lidar_imu.usd. Tutorial 14 continues from it.

source scripts/isaac_env.sh
python isaac/09_lidar_imu.py
lidar_path = sensors.add_lds_lidar(robot_path)   # RTX LiDAR at base_scan, LDS-01 numbers
graphs.create_lidar_graph(lidar_path, show_debug_view=not args.headless)   # -> /scan (+ dots in the viewport)
imu_path = sensors.add_imu(robot_path)           # physics IMU on base_link
graphs.create_imu_graph(imu_path)                # -> /imu
add_lds_lidar() and add_imu() in isaac/common/sensors.py

def add_lds_lidar(robot_path: str) -> str:
    """Create an RTX LiDAR at base_scan that behaves like the Lime's LDS-01. Returns the OmniLidar prim path."""
    from pxr import UsdGeom

    from isaacsim.sensors.experimental.rtx import Lidar

    firing_hz = LIDAR_HZ * LIDAR_SAMPLES  # one beam fired 1800 times/s while turning at 5 Hz -> 360 points/turn
    lidar = Lidar.create(
        f"{robot_path}/{lime.LIDAR_FRAME}/lds",
        config="RPLIDAR_S2E",  # a single-beam 2D spinning LiDAR from Isaac Sim's sensor library ...
        tick_rate=LIDAR_HZ,
        translations=[[0.0, 0.0, 0.0]],
        attributes={  # ... re-configured to the LDS-01's numbers
            "omni:sensor:Core:scanRateBaseHz": int(LIDAR_HZ),
            "omni:sensor:Core:patternFiringRateHz": int(firing_hz),
            "omni:sensor:Core:reportRateBaseHz": int(firing_hz),
            "omni:sensor:Core:nearRangeM": LIDAR_MIN,
            "omni:sensor:Core:farRangeM": LIDAR_MAX,
        },
    )
    # The Lime already has its own LDS mesh: hide the RPLIDAR housing meshes that come with the asset.
    from pxr import Usd

    from isaacsim.core.experimental.utils.stage import get_current_stage

    for prim in Usd.PrimRange(get_current_stage().GetPrimAtPath(f"{robot_path}/{lime.LIDAR_FRAME}/lds")):
        if prim.IsA(UsdGeom.Gprim):
            UsdGeom.Imageable(prim).MakeInvisible()
    return lidar.paths[0]
def add_imu(robot_path: str) -> str:
    """Create a physics IMU on base_link, at the position of imu_link. Returns its prim path."""
    from isaacsim.sensors.experimental.physics import IMU

    # The IMU must sit on a rigid body. imu_link is only a frame (no mass), so attach the sensor to
    # base_link and move it to where imu_link is.
    imu = IMU.create(f"{robot_path}/{lime.BASE_LINK}/imu", translations=[[0.0, 0.0, IMU_OFFSET_Z]])
    return imu.paths[0]

create_lidar_graph() and create_imu_graph() in isaac/common/graphs.py

def create_lidar_graph(
    lidar_path: str,
    graph_path: str = "/World/ROS2_Lidar",
    topic: str = "/scan",
    frame_id: str = "base_scan",
    show_debug_view: bool = False,
):
    """Tutorial 09: publish the RTX LiDAR as sensor_msgs/LaserScan."""
    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"),
                ("RenderProduct", "isaacsim.core.nodes.IsaacCreateRenderProduct"),
                ("PublishScan", "isaacsim.ros2.bridge.ROS2RtxLidarHelper"),
            ],
            keys.SET_VALUES: [
                ("RenderProduct.inputs:cameraPrim", [usdrt.Sdf.Path(lidar_path)]),
                ("PublishScan.inputs:type", "laser_scan"),
                ("PublishScan.inputs:topicName", topic),
                ("PublishScan.inputs:frameId", frame_id),
                ("PublishScan.inputs:fullScan", True),  # one message per full 360 deg revolution
                ("PublishScan.inputs:showDebugView", show_debug_view),  # draw the hits in the viewport (GUI only)
            ],
            keys.CONNECT: [
                ("OnPlaybackTick.outputs:tick", "RenderProduct.inputs:execIn"),
                ("RenderProduct.outputs:execOut", "PublishScan.inputs:execIn"),
                ("RenderProduct.outputs:renderProductPath", "PublishScan.inputs:renderProductPath"),
            ],
        },
    )
def create_imu_graph(imu_path: str, graph_path: str = "/World/ROS2_Imu", topic: str = "/imu", frame_id: str = "imu_link"):
    """Tutorial 09: publish the physics IMU as sensor_msgs/Imu."""
    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"),
                ("ReadIMU", "isaacsim.sensors.physics.IsaacReadIMU"),
                ("PublishImu", "isaacsim.ros2.bridge.ROS2PublishImu"),
            ],
            keys.SET_VALUES: [
                ("ReadIMU.inputs:imuPrim", [usdrt.Sdf.Path(imu_path)]),
                ("ReadIMU.inputs:readGravity", True),  # a real IMU measures gravity too (+9.81 m/s^2 on z at rest)
                ("PublishImu.inputs:topicName", topic),
                ("PublishImu.inputs:frameId", frame_id),
            ],
            keys.CONNECT: [
                ("OnPlaybackTick.outputs:tick", "ReadIMU.inputs:execIn"),
                ("ReadIMU.outputs:execOut", "PublishImu.inputs:execIn"),
                ("ReadSimTime.outputs:simulationTime", "PublishImu.inputs:timeStamp"),
                ("ReadIMU.outputs:linAcc", "PublishImu.inputs:linearAcceleration"),
                ("ReadIMU.outputs:angVel", "PublishImu.inputs:angularVelocity"),
                ("ReadIMU.outputs:orientation", "PublishImu.inputs:orientation"),
            ],
        },
    )

Full script: isaac/09_lidar_imu.py
# SPDX-FileCopyrightText: 2026 An (an-robotics)
# SPDX-License-Identifier: Apache-2.0

"""Tutorial 09 - 2D LiDAR (LDS-01) and IMU: /scan and /imu on ROS 2.

    source scripts/isaac_env.sh
    python isaac/09_lidar_imu.py

    # ROS 2 container: robot model + laser scan + camera in RViz
    ./docker/run_ros.sh ros2 launch lime_isaac_bringup view_sensors.launch.py

New in this tutorial:
  * an RTX LiDAR at base_scan, configured like the Lime's LDS-01 (360 points / turn, 5 Hz, 0.12 - 3.5 m)
      graph "ROS2_Lidar": On Playback Tick -> Isaac Create Render Product -> ROS2 RTX Lidar Helper (laser_scan)
      topic /scan  sensor_msgs/LaserScan  frame base_scan
  * a physics IMU on base_link (at imu_link)
      graph "ROS2_Imu": On Playback Tick -> Isaac Read IMU Node -> ROS2 Publish Imu
      topic /imu   sensor_msgs/Imu        frame imu_link
"""

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, sensors
from common.scene import build_lime_room
from isaacsim.core.simulation_manager import SimulationManager

graphs.enable_ros2_realtime(simulation_app)

stage = stage_utils.create_new_stage(template="empty")
build_lime_room(stage)
while stage_utils.is_stage_loading():
    simulation_app.update()
robot_path = "/World/turtlebot3_lime"
articulation_root = lime.add_lime(robot_path)

graphs.create_clock_graph()
graphs.create_drive_graph(articulation_root)
graphs.create_odom_tf_joint_states_graph(articulation_root)
graphs.create_camera_graph(sensors.add_d435_camera(robot_path))  # tutorial 08

# --- NEW: LiDAR + IMU and their ROS 2 graphs --------------------------------------------------------------
lidar_path = sensors.add_lds_lidar(robot_path)
# show_debug_view: with a window, the LiDAR helper also draws the hits as dots in the viewport
graphs.create_lidar_graph(lidar_path, show_debug_view=not args.headless)
imu_path = sensors.add_imu(robot_path)
graphs.create_imu_graph(imu_path)

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

    recorder = Recorder(args.record, eye=(-1.6, -1.8, 2.2), target=(0.4, 0.0, 0.0), every_n=3, fps=20)

SimulationManager.setup_simulation(dt=1.0 / 60.0)
app_utils.play()
simulation_app.update()
print("[09] ready: /scan and /imu published", flush=True)

if args.test or args.record:
    import rclpy
    from geometry_msgs.msg import Twist
    from sensor_msgs.msg import Imu, LaserScan

    rclpy.init()
    node = rclpy.create_node("lime_tutorial09_check")
    got = {"scans": [], "imu": None, "imu_turn": None}
    node.create_subscription(LaserScan, "/scan", lambda m: got["scans"].append(m), 10)
    node.create_subscription(Imu, "/imu", lambda m: got.__setitem__("imu", m), 10)
    cmd = node.create_publisher(Twist, "/cmd_vel", 10)

steps = 0
imu_rest = None
while simulation_app.is_running():
    simulation_app.update()
    steps += 1
    if recorder:
        recorder.capture()
    if args.test or args.record:
        for _ in range(10):
            rclpy.spin_once(node, timeout_sec=0.0)
        if steps == 3 * 60:  # t = 3 s, at rest: remember IMU + scan, then turn on the spot
            imu_rest, scan_rest = got["imu"], got["scans"][-1]
        if 3 * 60 < steps < 6 * 60:
            t = Twist()
            t.angular.z = 0.5
            cmd.publish(t)
        if steps == 5 * 60 + 30:
            got["imu_turn"] = got["imu"]
        if steps == 6 * 60:
            cmd.publish(Twist())
        if steps > 6 * 60 + 30:
            break

ok = True
if args.test or args.record:
    s = scan_rest
    ranges = np.array(s.ranges)
    angles = s.angle_min + np.arange(len(ranges)) * s.angle_increment

    def range_at(deg, window_deg=3.0):
        """Median of the valid beams within +-window_deg: the LiDAR model is noisy (~3 cm), like a real one."""
        diff = np.abs(np.angle(np.exp(1j * (angles - math.radians(deg)))))
        sel = ranges[(diff <= math.radians(window_deg)) & (ranges >= s.range_min) & (ranges <= s.range_max)]
        return float(np.median(sel)) if len(sel) else -1.0

    stamps = [m.header.stamp.sec + m.header.stamp.nanosec * 1e-9 for m in got["scans"]]
    rate = (len(stamps) - 1) / (stamps[-1] - stamps[0]) if len(stamps) > 2 else 0.0
    a, w = imu_rest.linear_acceleration, got["imu_turn"].angular_velocity
    checks = {
        f"scan: {len(ranges)} beams, {math.degrees(s.angle_increment):.2f} deg apart": 340 <= len(ranges) <= 380,
        f"scan range limits {s.range_min:.2f} .. {s.range_max:.2f} m": abs(s.range_min - 0.12) < 0.01 and abs(s.range_max - 3.5) < 0.01,
        f"scan rate {rate:.1f} Hz (sim time)": 4.0 < rate < 6.0,
        f"left wall  (+90 deg) {range_at(90):.2f} m (expected 2.50)": abs(range_at(90) - 2.50) < 0.06,
        f"right wall (-90 deg) {range_at(-90):.2f} m (expected 2.50)": abs(range_at(-90) - 2.50) < 0.06,
        f"back wall  (180 deg) {range_at(180):.2f} m (expected 2.03)": abs(range_at(180) - 2.03) < 0.06,
        f"front (0 deg): east wall at 3.97 m is beyond 3.5 m -> {range_at(0)}": not (0.12 <= range_at(0) <= 3.5),
        f"imu at rest: acc z = {a.z:.2f} m/s^2 (gravity 9.81)": abs(a.z - 9.81) < 0.3,
        f"imu turning: gyro z = {w.z:.2f} rad/s (commanded 0.50)": abs(w.z - 0.5) < 0.08,
        f"frames {s.header.frame_id} / {imu_rest.header.frame_id}": (s.header.frame_id, imu_rest.header.frame_id) == ("base_scan", "imu_link"),
    }
    for text, passed in checks.items():
        print(f"[09][check] {'ok  ' if passed else 'FAIL'} {text}")
    ok = all(checks.values())
    if args.test:
        print(f"[09][test] {'PASS' if ok else 'FAIL'}")
    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)

Look at it from ROS 2

./docker/run_ros.sh ros2 launch lime_isaac_bringup view_sensors.launch.py   # RViz: robot, TF, /scan, camera
./docker/run_ros.sh ros2 topic hz /scan                                     # ~5 Hz
./docker/run_ros.sh ros2 topic echo /imu --once
The self-check turns the robot on the spot at 0.5 rad/s to test the IMU's gyroscope.

Automatic check

The robot stands at the room's origin, so the expected distances are known: side walls at y = ±2.5 m, back wall at x = −2.0 m (from the LiDAR at x = 0.027 m that is 2.03 m), and the front wall at 3.97 m, beyond the 3.5 m range.

[09][check] ok   scan: 360 beams, 1.00 deg apart
[09][check] ok   scan range limits 0.12 .. 3.50 m
[09][check] ok   scan rate 5.0 Hz (sim time)
[09][check] ok   left wall  (+90 deg) 2.49 m (expected 2.50)
[09][check] ok   right wall (-90 deg) 2.53 m (expected 2.50)
[09][check] ok   back wall  (180 deg) 2.06 m (expected 2.03)
[09][check] ok   front (0 deg): east wall at 3.97 m is beyond 3.5 m -> -1.0
[09][check] ok   imu at rest: acc z = 9.81 m/s^2 (gravity 9.81)
[09][check] ok   imu turning: gyro z = 0.49 rad/s (commanded 0.50)
[09][check] ok   frames base_scan / imu_link
[09][test] PASS

−1 means “no return”

Isaac Sim writes −1.0 for a beam that hits nothing within range. ROS's convention is inf. AMCL and the Nav2 costmaps (tutorial 11) work with the −1, but slam_toolbox doesn't: tutorial 14 converts it.

The LiDAR is noisy, like a real one

Single beams scatter by a few centimetres (the sensor model's range accuracy is 3 cm). Around 180° one run read 1.97–2.10 m. The check therefore uses the median of the beams within ±3°, the same way you would test a real sensor.

At rest the IMU reads +9.81 m/s² upwards

An accelerometer measures specific force: standing still, the floor pushes the robot up against gravity. That is why readGravity is on; a real IMU behaves the same.

Next: 10 · Object detection with YOLO