Attaching RealSense D455 Camera to Go1 via Python

Isaac Sim Version

  • 4.5.0
  • 4.2.0
  • 4.1.0
  • 4.0.0
  • 2023.1.1
  • 2023.1.0-hotfix.1
  • Other (please specify):

Operating System

  • Ubuntu 22.04
  • Ubuntu 20.04
  • Windows 11
  • Windows 10
  • Other (please specify):

Attaching RealSense D455 Camera to Go1 via Python

Hello all,

I’m currently working on attaching an Intel RealSense D455 camera to a Go1 robot using Python in Isaac Sim.

I followed these steps below and the camera seems to be working. However, I’m not sure if I’m doing this the correct way, and I have a few questions:

  1. Is it enough to simply add the camera USD to the world and parent it to the correct prim under the robot?
  2. The Go1 USD I’m using already includes joints for the camera. So if I place the camera under /trunk/camera_face, do I still need to manually set its transform (position/orientation)? Or does Isaac Sim automatically treat it as attached to the joint?
  3. Is modifying the transform from Python recommended when the camera is already “linked” through USD structure?

Here’s a cleaned version of my code for review:

Python Code
from isaacsim import SimulationApp
simulation_app = SimulationApp({"headless": False})

import numpy as np
import matplotlib.pyplot as plt
from isaacsim.core.api import World
from isaacsim.core.prims import Articulation
from isaacsim.core.utils.stage import add_reference_to_stage, get_stage_units
from pxr import UsdPhysics, Sdf
from isaacsim.sensors.camera import Camera
import isaacsim.core.utils.numpy.rotations as rot_utils
from omni.isaac.dynamic_control import _dynamic_control
import omni

my_world = World(stage_units_in_meters=1.0)
my_world.scene.add_default_ground_plane()

add_reference_to_stage("/home/marwah/isaacsim/standalone_examples/tutorials/go1.usd", "/World/go1")
go1_robot = Articulation("/World/go1")
go1_robot.set_world_poses(positions=np.array([[0.0, 0, 0.5]]) / get_stage_units())
my_world.reset()

add_reference_to_stage("/home/marwah/isaacsim/standalone_examples/tutorials/stairs.usd", "/World/Stairs")
my_world.reset()

go1_robot = my_world.scene.add(Articulation("/World/go1"))
stage = omni.usd.get_context().get_stage()

realsense_usd_path = "/home/marwah/isaacsim/standalone_examples/tutorials/IntelCam2ndTry.usd"
realsense_prim_path = "/World/go1/trunk/camera_face"
add_reference_to_stage(realsense_usd_path, realsense_prim_path)
my_world.reset()

joint_target_positions = np.deg2rad([
    0.0, 0.0, 0.0, 0.0,
    45.0, 45.0, 45.0, 45.0,
    -95.0, -95.0, -95.0, -95.0
])
go1_robot.set_joint_positions(joint_target_positions)

color_camera_path = f"{realsense_prim_path}/rsd455/RSD455/Camera_OmniVision_OV9782_Color"
left_ir_camera_path = f"{realsense_prim_path}/rsd455/RSD455/Camera_OmniVision_OV9782_Left"
right_ir_camera_path = f"{realsense_prim_path}/rsd455/RSD455/Camera_OmniVision_OV9782_Right"
depth_camera_path = f"{realsense_prim_path}/rsd455/RSD455/Camera_Pseudo_Depth"

print("Color camera path:", color_camera_path)
print("Depth camera path:", depth_camera_path)
print("Left IR camera path:", left_ir_camera_path)
print("Right IR camera path:", right_ir_camera_path)

print("Color camera exists:", stage.GetPrimAtPath(color_camera_path).IsValid())
print("Depth camera exists:", stage.GetPrimAtPath(depth_camera_path).IsValid())
print("Left IR camera exists:", stage.GetPrimAtPath(left_ir_camera_path).IsValid())
print("Right IR camera exists:", stage.GetPrimAtPath(right_ir_camera_path).IsValid())

rgb_camera = None
depth_camera = None
left_ir_camera = None
right_ir_camera = None
cameras_initialized = False

def initialize_cameras():
    global rgb_camera, depth_camera, left_ir_camera, right_ir_camera, cameras_initialized
    try:
        rgb_camera = Camera(color_camera_path, [0.0, 0.0, 0.0], rot_utils.euler_angles_to_quats([0, 0, 0], degrees=True), 30, (1280, 720))
        depth_camera = Camera(depth_camera_path, [0.0, 0.0, 0.0], rot_utils.euler_angles_to_quats([0, 0, 0], degrees=True), 30, (1280, 720))
        left_ir_camera = Camera(left_ir_camera_path, [0.0, 0.0, 0.0], rot_utils.euler_angles_to_quats([0, 0, 0], degrees=True), 30, (1280, 720))
        right_ir_camera = Camera(right_ir_camera_path, [0.0, 0.0, 0.0], rot_utils.euler_angles_to_quats([0, 0, 0], degrees=True), 30, (1280, 720))

        for cam in [rgb_camera, depth_camera, left_ir_camera, right_ir_camera]:
            cam.initialize()
            cam.add_motion_vectors_to_frame()

        cameras_initialized = True
        print("All cameras initialized successfully")
        return True
    except Exception as e:
        cameras_initialized = False
        print("Camera init error:", e)
        return False

for prim in stage.TraverseAll():
    prim_type = prim.GetTypeName()
    if prim_type == "PhysicsRevoluteJoint":
        drive = UsdPhysics.DriveAPI.Get(prim, "angular")
        dc = _dynamic_control.acquire_dynamic_control_interface()
        articulation = dc.get_articulation("/World/go1")
        dc.wake_up_articulation(articulation)
        drive.GetStiffnessAttr().Set(80)
        drive.GetDampingAttr().Set(20)

initialize_cameras()

for _ in range(500):
    my_world.step(render=True)

simulation_app.close()

Console Output

Color camera path: /World/go1/trunk/camera_face/rsd455/RSD455/Camera_OmniVision_OV9782_Color  
Depth camera path: /World/go1/trunk/camera_face/rsd455/RSD455/Camera_Pseudo_Depth  
Left IR camera path: /World/go1/trunk/camera_face/rsd455/RSD455/Camera_OmniVision_OV9782_Left  
Right IR camera path: /World/go1/trunk/camera_face/rsd455/RSD455/Camera_OmniVision_OV9782_Right  
Color camera exists: True  
Depth camera exists: True  
Left IR camera exists: True  
Right IR camera exists: True  
All cameras initialized successfully  

Any suggestions or confirmation would be really appreciated!
Thanks 🙏

Hi @Marwah_Al_Sakkaf! Please check out our tutorial Add Camera and Sensors — Isaac Sim Documentation

Attach the camera to the robot’s body by dragging the prim under body . The camera moves together with the body.

As for your second question do I still need to manually set its transform (position/orientation)?
It depends on what you plan to do with the camera. If you plan to do something like vision based localization, a precise camera extrinsic would be important.

What are you doing in the python script is fine.