# 创建SensorCamera
from omni.isaac.sensor import Camera

# 在 /World 下新建一个 Isaac Sensor Camera prim
sensor_cam = Camera(
    prim_path="/World/MySensorCamera",   # 新的相机路径
    frequency=60,                        # 刷新频率
    resolution=(1280, 720),               # 分辨率
    position=(0, 0, 1.6),                 # 初始位置
    orientation=(0, 0, 0, 1)              # 朝向四元数
)
sensor_cam.initialize()

print("✅ Added Sensor Camera at /World/MySensorCamera")





# 调整焦距
from pxr import UsdGeom
stage = omni.usd.get_context().get_stage()
cam_prim = stage.GetPrimAtPath("/World/MySensorCamera")
usd_cam = UsdGeom.Camera(cam_prim)

# 例如设置成 Camera_01 一样的焦距（假设 Camera_01 是 35mm）
usd_cam.GetFocalLengthAttr().Set(30.0)  # 越小越广