08 · Camera (RealSense D435)¶
Goal. Give the Lime its RealSense D435 camera, at the exact frame from the URDF. Publish RGB images,
depth images and the camera intrinsics on ROS 2, using the topic names the real robot's realsense2_camera
driver uses.


Left: /camera/camera/color/image_raw. Right: /camera/camera/aligned_depth_to_color/image_raw (32-bit float metres),
coloured for display. The robot stands in the "lime_room", in front of a cup, a bowl, a banana and a bottle.
Concepts¶
The lime_room. From this tutorial on, the robot lives in a small room (isaac/common/scene.py): 6 × 5 m,
0.6 m walls, three orange obstacles, and four everyday objects from NVIDIA's asset library on the floor. The
same file can save the room as assets/scenes/lime_room.usda for the GUI (python isaac/common/scene.py).
Where the camera is. The URDF already contains the D435's frames. We put a USD camera at
camera_color_optical_frame, which is 5.8 cm above the floor, at the front of the base, looking forward.
Optical frames vs. USD cameras
A ROS optical frame looks along +Z with +Y down (image rows grow downwards). A USD camera looks
along −Z with +Y up. A 180° rotation about X turns one into the other, so the camera prim sits
under camera_color_optical_frame with rotateX = 180.
Matching the real camera. The URDF says 640 × 480 and a horizontal field of view of 1.211 rad (69.4°).
A USD camera uses a pinhole model: focal length \(f\) and aperture width \(w\) (in mm) give the field of view
\(\text{FOV} = 2\arctan\frac{w}{2f}\). With the default \(w = 20.955\) mm that is \(f = 15.1\) mm. The published
camera_info then has \(f_x = 640 / (2\tan(1.211/2)) = 462.3\) px.
Render product. A camera produces images only through a render product (camera + resolution).
Isaac Create Render Product makes one. The ROS helpers read RGB, depth and intrinsics from it.
The graph¶
flowchart LR
tick([On Playback Tick]) --> rp[Isaac Create Render Product<br/>d435_color · 640 × 480]
rp -- renderProductPath --> rgb[ROS2 Camera Helper<br/>type rgb]
rp -- renderProductPath --> dep[ROS2 Camera Helper<br/>type depth]
rp -- renderProductPath --> info[ROS2 Camera Info Helper]
rgb --> t1["/camera/camera/color/image_raw"]
dep --> t2["/camera/camera/aligned_depth_to_color/image_raw"]
info --> t3["/camera/camera/color/camera_info"]
All three use frameId = camera_color_optical_frame, so RViz and other ROS tools place the image correctly.
Build it¶
- Open the room and add the robot: File ▸ Open
assets/scenes/lime_room.usda(create it once withpython isaac/common/scene.py), then File ▸ Add Referenceassets/usd/turtlebot3_lime_tuned.usdaat/World/turtlebot3_lime. - Select
…/camera_color_frame/camera_color_optical_frame, right-click and choose Create ▸ Camera. Name itd435_color. In Property set: Transform ▸ Rotate = (180, 0, 0), Focal Length = 15.1, Horizontal Aperture = 20.955, Vertical Aperture = 15.716, Clipping Range = (0.05, 20). -
Look through it: viewport camera menu (Perspective ▾) ▸
d435_color.
-
Tools ▸ Robotics ▸ ROS 2 OmniGraphs ▸ Camera builds the graph above from a form. Its defaults (Camera Prim
/OmniverseKit_Persp, Frame IDsim_camera, topics/rgband/depth) are placeholders: set the camera prim tod435_color, the frame ID tocamera_color_optical_frame, the RGB and depth topics from the diagram, then OK. The form has no field for the camera_info topic (it usescamera_info): open the created graph and set theROS2 Camera Info Helpernode's topicName to/camera/camera/color/camera_info.
-
Press Play. When you are done, press Stop ■ and save: File ▸ Save As
my_stages/08_camera.usd(not overlime_room.usda). Tutorial 09 continues from it.
camera_path = sensors.add_d435_camera(robot_path) # USD camera at camera_color_optical_frame
graphs.create_camera_graph(camera_path, 640, 480) # RGB + depth + camera_info
add_d435_camera() in isaac/common/sensors.py
def add_d435_camera(robot_path: str) -> str:
"""Create a USD camera at camera_color_optical_frame. Returns its prim path."""
from pxr import Gf, UsdGeom
import isaacsim.core.experimental.utils.stage as stage_utils
stage = stage_utils.get_current_stage()
path = f"{robot_path}/{lime.CAMERA_COLOR_OPTICAL_FRAME}/d435_color"
camera = UsdGeom.Camera.Define(stage, path)
# A USD camera looks along its -Z axis with +Y up. A ROS *optical* frame looks along +Z with +Y down.
# Rotating 180 deg about X turns one into the other.
UsdGeom.Xformable(camera.GetPrim()).AddRotateXOp().Set(180.0)
# Pinhole model: focal length / aperture (in mm) give the field of view.
h_aperture = 20.955 # mm (default USD camera aperture)
camera.CreateHorizontalApertureAttr(h_aperture)
camera.CreateVerticalApertureAttr(h_aperture * CAMERA_HEIGHT / CAMERA_WIDTH)
camera.CreateFocalLengthAttr(h_aperture / (2.0 * math.tan(CAMERA_HFOV / 2.0))) # = 15.1 mm
camera.CreateClippingRangeAttr(Gf.Vec2f(0.05, 20.0))
return path
create_camera_graph() in isaac/common/graphs.py
def create_camera_graph(
camera_path: str,
width: int = 640,
height: int = 480,
graph_path: str = "/World/ROS2_Camera",
namespace: str = "/camera/camera", # the topic names realsense2_camera uses on the real robot
frame_id: str = "camera_color_optical_frame",
):
"""Tutorial 08: RGB image, depth image (aligned to RGB) and camera_info of one camera."""
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"),
("PublishRGB", "isaacsim.ros2.bridge.ROS2CameraHelper"),
("PublishDepth", "isaacsim.ros2.bridge.ROS2CameraHelper"),
("PublishInfo", "isaacsim.ros2.bridge.ROS2CameraInfoHelper"),
],
keys.SET_VALUES: [
("RenderProduct.inputs:cameraPrim", [usdrt.Sdf.Path(camera_path)]),
("RenderProduct.inputs:width", width),
("RenderProduct.inputs:height", height),
("PublishRGB.inputs:type", "rgb"),
("PublishRGB.inputs:topicName", f"{namespace}/color/image_raw"),
("PublishRGB.inputs:frameId", frame_id),
("PublishDepth.inputs:type", "depth"), # float32 metres (32FC1)
("PublishDepth.inputs:topicName", f"{namespace}/aligned_depth_to_color/image_raw"),
("PublishDepth.inputs:frameId", frame_id),
("PublishInfo.inputs:topicName", f"{namespace}/color/camera_info"),
("PublishInfo.inputs:frameId", frame_id),
],
keys.CONNECT: [
("OnPlaybackTick.outputs:tick", "RenderProduct.inputs:execIn"),
("RenderProduct.outputs:execOut", "PublishRGB.inputs:execIn"),
("RenderProduct.outputs:execOut", "PublishDepth.inputs:execIn"),
("RenderProduct.outputs:execOut", "PublishInfo.inputs:execIn"),
("RenderProduct.outputs:renderProductPath", "PublishRGB.inputs:renderProductPath"),
("RenderProduct.outputs:renderProductPath", "PublishDepth.inputs:renderProductPath"),
("RenderProduct.outputs:renderProductPath", "PublishInfo.inputs:renderProductPath"),
],
},
)
Full script: isaac/08_camera.py
# SPDX-FileCopyrightText: 2026 An (an-robotics)
# SPDX-License-Identifier: Apache-2.0
"""Tutorial 08 - RealSense D435 camera: RGB, depth and camera_info on ROS 2.
source scripts/isaac_env.sh
python isaac/08_camera.py
# ROS 2 container: look at the images
./docker/run_ros.sh ros2 run rqt_image_view rqt_image_view /camera/camera/color/image_raw
The robot stands in the "lime_room" (isaac/common/scene.py) in front of a cup, a banana, a bowl and a
bottle - the objects tutorial 10 will detect with YOLO.
New in this tutorial:
* a USD camera at the URDF frame camera_color_optical_frame (640 x 480, 69.4 deg FOV, like the D435)
* graph "ROS2_Camera": On Playback Tick -> Isaac Create Render Product -> ROS2 Camera Helper (rgb)
-> ROS2 Camera Helper (depth)
-> ROS2 Camera Info Helper
topics (same names as realsense2_camera on the real robot):
/camera/camera/color/image_raw sensor_msgs/Image (rgb8)
/camera/camera/aligned_depth_to_color/image_raw sensor_msgs/Image (32FC1, metres)
/camera/camera/color/camera_info sensor_msgs/CameraInfo
"""
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(): # the objects are downloaded from NVIDIA's asset server
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)
# --- NEW: camera + its ROS 2 graph ---------------------------------------------------------------------
camera_path = sensors.add_d435_camera(robot_path)
graphs.create_camera_graph(camera_path, sensors.CAMERA_WIDTH, sensors.CAMERA_HEIGHT)
recorder = None
if args.record:
from common.recorder import Recorder
recorder = Recorder(args.record, eye=(-0.9, -1.0, 0.8), target=(0.7, 0.0, 0.05), every_n=3, fps=20)
SimulationManager.setup_simulation(dt=1.0 / 60.0)
app_utils.play()
simulation_app.update()
print("[08] ready: camera topics on /camera/camera/...", flush=True)
if args.test or args.record:
import rclpy
from sensor_msgs.msg import CameraInfo, Image
rclpy.init()
node = rclpy.create_node("lime_tutorial08_check")
got = {"rgb": [], "depth": None, "info": None}
node.create_subscription(Image, "/camera/camera/color/image_raw", lambda m: got["rgb"].append(m), 10)
node.create_subscription(Image, "/camera/camera/aligned_depth_to_color/image_raw", lambda m: got.__setitem__("depth", m), 10)
node.create_subscription(CameraInfo, "/camera/camera/color/camera_info", lambda m: got.__setitem__("info", m), 10)
steps = 0
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 > 5 * 60: # 5 s
break
ok = True
if args.test or args.record:
rgb, depth, info = got["rgb"][-1], got["depth"], got["info"]
stamps = [m.header.stamp.sec + m.header.stamp.nanosec * 1e-9 for m in got["rgb"]]
rate = (len(stamps) - 1) / (stamps[-1] - stamps[0]) if len(stamps) > 2 and stamps[-1] > stamps[0] else 0.0
image = np.frombuffer(rgb.data, dtype=np.uint8).reshape(rgb.height, rgb.width, 3)
d = np.frombuffer(depth.data, dtype=np.float32).reshape(depth.height, depth.width)
center = d[depth.height // 2 - 20 : depth.height // 2 + 20, depth.width // 2 - 20 : depth.width // 2 + 20]
center_m = float(np.nanmedian(center[np.isfinite(center)]))
fx_expected = sensors.CAMERA_WIDTH / (2 * math.tan(sensors.CAMERA_HFOV / 2))
checks = {
f"rgb {rgb.width}x{rgb.height} {rgb.encoding}": (rgb.width, rgb.height, rgb.encoding) == (640, 480, "rgb8"),
f"rgb rate {rate:.1f} Hz (sim time)": rate > 10,
f"depth {depth.encoding}, centre distance {center_m:.2f} m": depth.encoding == "32FC1" and 0.2 < center_m < 6.0,
f"camera_info fx={info.k[0]:.1f} (expected {fx_expected:.1f} from the 69.4 deg FOV)": abs(info.k[0] - fx_expected) < 2.0,
f"frame_id {rgb.header.frame_id}": rgb.header.frame_id == "camera_color_optical_frame",
}
for text, passed in checks.items():
print(f"[08][check] {'ok ' if passed else 'FAIL'} {text}")
ok = all(checks.values())
if args.test:
print(f"[08][test] {'PASS' if ok else 'FAIL'}")
if args.record: # what the robot sees -> docs
import imageio.v2 as imageio
from common.paths import IMG_DIR
imageio.imwrite(IMG_DIR / f"{args.record}_rgb.png", image)
import matplotlib
valid = np.isfinite(d) & (d > 0) # no surface hit (the "sky") -> black
vis = np.clip(np.where(valid, d, 0.0) / 4.0, 0.0, 1.0) # 0 .. 4 m
colored = (matplotlib.colormaps["turbo"](vis)[..., :3] * 255 * valid[..., None]).astype(np.uint8)
imageio.imwrite(IMG_DIR / f"{args.record}_depth.png", colored)
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 run rqt_image_view rqt_image_view /camera/camera/color/image_raw
./docker/run_ros.sh ros2 topic hz /camera/camera/color/image_raw
./docker/run_ros.sh ros2 topic echo /camera/camera/color/camera_info --once
Or use RViz with the camera panel: ros2 launch lime_isaac_bringup view_sensors.launch.py (see tutorial 09).
Automatic check¶
python isaac/08_camera.py --headless --test subscribes to its own topics:
[08][check] ok rgb 640x480 rgb8
[08][check] ok rgb rate 60.0 Hz (sim time)
[08][check] ok depth 32FC1, centre distance 3.94 m
[08][check] ok camera_info fx=462.3 (expected 462.3 from the 69.4 deg FOV)
[08][check] ok frame_id camera_color_optical_frame
[08][test] PASS
The 3.94 m centre distance is the far wall: x = 4.0 m, minus the camera's own x position of 0.059 m.
Publish rate
Camera helpers publish every rendered frame (here 60 Hz). In Isaac Sim 6.x the per-sensor rate is set by the
omni:sensor:tickRate attribute; frameSkipCount on the helper nodes is deprecated.
Next: 09 · LiDAR & IMU