From 6032b12c59a0ada05ca6e3c0da10b531709d2234 Mon Sep 17 00:00:00 2001 From: Tangger Date: Fri, 3 Apr 2026 14:41:00 +0800 Subject: [PATCH] refactor: simplify camera init, document aperture warning as cosmetic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Camera.__init__() internally calls UsdGeom.Camera.Define() which resets aperture to defaults, making it impossible to pre-set values. The aperture mismatch warnings are cosmetic — IS auto-corrects them and our values are applied correctly after init. Co-Authored-By: Claude Opus 4.6 (1M context) --- workflows/simbox/core/cameras/custom_camera.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/workflows/simbox/core/cameras/custom_camera.py b/workflows/simbox/core/cameras/custom_camera.py index e427431..2b139d0 100644 --- a/workflows/simbox/core/cameras/custom_camera.py +++ b/workflows/simbox/core/cameras/custom_camera.py @@ -32,7 +32,7 @@ class CustomCamera(Camera): reference_path: Reference prim path for camera mounting name: Camera name """ - # ===== Pre-compute camera parameters ===== + # ===== From cfg ===== pixel_size = cfg["params"].get("pixel_size") f_number = cfg["params"].get("f_number") focus_distance = cfg["params"].get("focus_distance") @@ -47,18 +47,9 @@ class CustomCamera(Camera): focal_length_y = fy * pixel_size * 1e-3 focal_length = (focal_length_x + focal_length_y) / 2 / 10.0 - # Pre-set aperture on USD prim before Camera.__init__ to avoid mismatch warnings - from pxr import UsdGeom - import omni.usd - stage = omni.usd.get_context().get_stage() - cam_prim = stage.GetPrimAtPath(prim_path) - if cam_prim.IsValid(): - cam = UsdGeom.Camera(cam_prim) - cam.GetHorizontalApertureAttr().Set(horizontal_aperture * 10.0) # USD uses mm - cam.GetVerticalApertureAttr().Set(vertical_aperture * 10.0) - cam.GetFocalLengthAttr().Set(focal_length * 10.0) - # ===== Initialize camera ===== + # Note: Camera.__init__ triggers aperture consistency warnings with default USD values. + # These are cosmetic — IS auto-corrects, and we override with correct values below. super().__init__( prim_path=prim_path, name=name,