From 10a8ea13777b8a31fc72318e809fa0ecfc1492a2 Mon Sep 17 00:00:00 2001 From: Lev Kozlov Date: Thu, 26 Mar 2026 14:34:22 +0900 Subject: [PATCH] fix: support D405 stereo module for sensor options D405 exposes color stream via "Stereo Module", not "RGB Camera". Fall back to Stereo Module when RGB Camera is not found. --- .../cameras/realsense/camera_realsense.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/lerobot/cameras/realsense/camera_realsense.py b/src/lerobot/cameras/realsense/camera_realsense.py index cb76f93b3..d58799217 100644 --- a/src/lerobot/cameras/realsense/camera_realsense.py +++ b/src/lerobot/cameras/realsense/camera_realsense.py @@ -341,15 +341,24 @@ class RealSenseCamera(Camera): return self._async_read(timeout_ms=10000, read_depth=read_depth) def _get_color_sensor(self) -> "rs.sensor": - """Returns the color sensor from the active pipeline profile.""" + """Returns the sensor that controls the color stream. + + Most RealSense cameras expose "RGB Camera" for color. The D405 has no + separate RGB module — its color stream comes from "Stereo Module". + We try RGB Camera first, then fall back to Stereo Module. + """ if self.rs_profile is None: raise RuntimeError(f"{self}: rs_profile must be initialized before use.") device = self.rs_profile.get_device() - for sensor in device.query_sensors(): - if sensor.get_info(rs.camera_info.name) == "RGB Camera": - return sensor - raise RuntimeError(f"{self}: no RGB Camera sensor found on device.") + sensors = {s.get_info(rs.camera_info.name): s for s in device.query_sensors()} + + for name in ("RGB Camera", "Stereo Module"): + if name in sensors: + return sensors[name] + + available = list(sensors.keys()) + raise RuntimeError(f"{self}: no color sensor found. Available sensors: {available}") def _configure_sensor_options(self) -> None: """Applies manual sensor options (exposure, gain, white balance) to the color sensor.