mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-30 13:09:40 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6cd4f1839b | |||
| dc0570586b |
@@ -164,8 +164,8 @@ includes the range reported by the sensor. Requesting an unsupported control als
|
|||||||
Omitted controls leave the sensor's existing automatic or manual setting unchanged. These options
|
Omitted controls leave the sensor's existing automatic or manual setting unchanged. These options
|
||||||
require `use_rgb=True`.
|
require `use_rgb=True`.
|
||||||
|
|
||||||
On the RealSense D405, the color stream is provided by the Stereo Module, so changing manual
|
Manual color controls require a dedicated RGB module. Cameras without one, such as the RealSense
|
||||||
exposure or gain also affects the depth stream.
|
D405, do not support them and raise an error at connection time.
|
||||||
|
|
||||||
</hfoption>
|
</hfoption>
|
||||||
</hfoptions>
|
</hfoptions>
|
||||||
|
|||||||
@@ -365,11 +365,12 @@ class RealSenseCamera(Camera):
|
|||||||
return self._async_read(timeout_ms=10000, read_depth=read_depth)
|
return self._async_read(timeout_ms=10000, read_depth=read_depth)
|
||||||
|
|
||||||
def _get_color_sensor(self) -> "rs.sensor":
|
def _get_color_sensor(self) -> "rs.sensor":
|
||||||
"""Returns the sensor that controls the color stream.
|
"""Returns the dedicated "RGB Camera" sensor that controls the color stream.
|
||||||
|
|
||||||
Most RealSense cameras expose "RGB Camera" for color. The D405 has no
|
Manual color controls are only applied to a dedicated RGB module. Cameras
|
||||||
separate RGB module — its color stream comes from "Stereo Module".
|
without one (e.g. the D405, whose color stream comes from the shared
|
||||||
We try RGB Camera first, then fall back to Stereo Module.
|
"Stereo Module") are unsupported, so we never fall back to another sensor
|
||||||
|
to avoid altering the depth stream.
|
||||||
"""
|
"""
|
||||||
if self.rs_profile is None:
|
if self.rs_profile is None:
|
||||||
raise RuntimeError(f"{self}: rs_profile must be initialized before use.")
|
raise RuntimeError(f"{self}: rs_profile must be initialized before use.")
|
||||||
@@ -377,12 +378,14 @@ class RealSenseCamera(Camera):
|
|||||||
device = self.rs_profile.get_device()
|
device = self.rs_profile.get_device()
|
||||||
sensors = {s.get_info(rs.camera_info.name): s for s in device.query_sensors()}
|
sensors = {s.get_info(rs.camera_info.name): s for s in device.query_sensors()}
|
||||||
|
|
||||||
for name in ("RGB Camera", "Stereo Module"):
|
if "RGB Camera" in sensors:
|
||||||
if name in sensors:
|
return sensors["RGB Camera"]
|
||||||
return sensors[name]
|
|
||||||
|
|
||||||
available = list(sensors.keys())
|
available = list(sensors.keys())
|
||||||
raise RuntimeError(f"{self}: no color sensor found. Available sensors: {available}")
|
raise RuntimeError(
|
||||||
|
f"{self}: manual color controls require a dedicated 'RGB Camera' module, which this camera does not have. ",
|
||||||
|
f"Available sensors: {available}.",
|
||||||
|
)
|
||||||
|
|
||||||
def _set_sensor_option(self, sensor: "rs.sensor", option: "rs.option", value: float, label: str) -> None:
|
def _set_sensor_option(self, sensor: "rs.sensor", option: "rs.option", value: float, label: str) -> None:
|
||||||
"""Sets a sensor option, re-raising range errors with actionable diagnostics."""
|
"""Sets a sensor option, re-raising range errors with actionable diagnostics."""
|
||||||
|
|||||||
@@ -322,15 +322,16 @@ def test_get_color_sensor_prefers_rgb_camera():
|
|||||||
assert camera._get_color_sensor() is rgb
|
assert camera._get_color_sensor() is rgb
|
||||||
|
|
||||||
|
|
||||||
def test_get_color_sensor_falls_back_to_stereo_module():
|
def test_get_color_sensor_raises_without_dedicated_rgb_module():
|
||||||
"""D405 has no separate RGB module; color comes from Stereo Module."""
|
"""D405 has no separate RGB module; we refuse to touch the shared Stereo Module."""
|
||||||
config = RealSenseCameraConfig(serial_number_or_name="042")
|
config = RealSenseCameraConfig(serial_number_or_name="042")
|
||||||
camera = RealSenseCamera(config)
|
camera = RealSenseCamera(config)
|
||||||
|
|
||||||
stereo = _make_mock_sensor("Stereo Module")
|
stereo = _make_mock_sensor("Stereo Module")
|
||||||
_attach_mock_color_sensor(camera, stereo)
|
_attach_mock_color_sensor(camera, stereo)
|
||||||
|
|
||||||
assert camera._get_color_sensor() is stereo
|
with pytest.raises(RuntimeError, match="dedicated 'RGB Camera' module"):
|
||||||
|
camera._get_color_sensor()
|
||||||
|
|
||||||
|
|
||||||
def test_get_color_sensor_raises_with_available_sensors():
|
def test_get_color_sensor_raises_with_available_sensors():
|
||||||
|
|||||||
Reference in New Issue
Block a user