From 7b214401cb8135fcba874e7602bcd26abce0d7d8 Mon Sep 17 00:00:00 2001 From: lesh Date: Tue, 16 Sep 2025 14:01:56 -0700 Subject: [PATCH 1/4] zed local node --- dimos/hardware/test_webcam.py | 6 ++++-- dimos/hardware/webcam.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dimos/hardware/test_webcam.py b/dimos/hardware/test_webcam.py index d51cc41924..aa22b70194 100644 --- a/dimos/hardware/test_webcam.py +++ b/dimos/hardware/test_webcam.py @@ -43,14 +43,16 @@ def test_basic(): def test_module(): dimos = start(1) # Deploy ColorCameraModule, not Webcam directly - camera_module = dimos.deploy(ColorCameraModule) + camera_module = dimos.deploy( + ColorCameraModule, hardware=lambda: Webcam(camera_index=4, frequency=30, stereo_slice=1) + ) camera_module.image.transport = LCMTransport("/image", Image) camera_module.start() test_transport = LCMTransport("/image", Image) test_transport.subscribe(print) - time.sleep(2) + time.sleep(60) print("shutting down") camera_module.stop() diff --git a/dimos/hardware/webcam.py b/dimos/hardware/webcam.py index e733356a94..b46d74c5f3 100644 --- a/dimos/hardware/webcam.py +++ b/dimos/hardware/webcam.py @@ -62,6 +62,7 @@ class WebcamConfig(CameraConfig): frequency: int = 10 camera_info: CameraInfo = field(default_factory=CameraInfo) frame_id_prefix: Optional[str] = None + stereo_slice: Optional[int] = None # For stereo cameras, 1 for left, 2 for right class Webcam(ColorCameraHardware[WebcamConfig]): @@ -155,6 +156,15 @@ def capture_frame(self) -> Image: frame_id=self._frame("camera"), # Standard frame ID for camera images ts=time.time(), # Current timestamp ) + + if self.config.stereo_slice in (1, 2): + image.frame_id = self._frame(f"camera_stereo_{self.config.stereo_slice}") + half_width = image.width // 2 + if self.config.stereo_slice == 1: + image = image.crop(0, 0, half_width, image.height) + else: + image = image.crop(half_width, 0, half_width, image.height) + return image def _capture_loop(self): From 3f2399d79ddf068df42bd5428361890ae8542a12 Mon Sep 17 00:00:00 2001 From: leshy Date: Thu, 18 Sep 2025 02:55:41 +0300 Subject: [PATCH 2/4] Update dimos/hardware/webcam.py Co-authored-by: Paul Nechifor --- dimos/hardware/webcam.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dimos/hardware/webcam.py b/dimos/hardware/webcam.py index b46d74c5f3..df3d6220c4 100644 --- a/dimos/hardware/webcam.py +++ b/dimos/hardware/webcam.py @@ -62,7 +62,7 @@ class WebcamConfig(CameraConfig): frequency: int = 10 camera_info: CameraInfo = field(default_factory=CameraInfo) frame_id_prefix: Optional[str] = None - stereo_slice: Optional[int] = None # For stereo cameras, 1 for left, 2 for right + stereo_slice: Optional[Literal["left", "right"]] = None # For stereo cameras class Webcam(ColorCameraHardware[WebcamConfig]): From 005ecb521745b1053c398ad8b1c7d89bee310650 Mon Sep 17 00:00:00 2001 From: leshy Date: Thu, 18 Sep 2025 02:55:51 +0300 Subject: [PATCH 3/4] Update dimos/hardware/webcam.py Co-authored-by: Paul Nechifor --- dimos/hardware/webcam.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dimos/hardware/webcam.py b/dimos/hardware/webcam.py index df3d6220c4..b842f83be0 100644 --- a/dimos/hardware/webcam.py +++ b/dimos/hardware/webcam.py @@ -157,10 +157,10 @@ def capture_frame(self) -> Image: ts=time.time(), # Current timestamp ) - if self.config.stereo_slice in (1, 2): + if self.config.stereo_slice in ("left", "right"): image.frame_id = self._frame(f"camera_stereo_{self.config.stereo_slice}") half_width = image.width // 2 - if self.config.stereo_slice == 1: + if self.config.stereo_slice == "left": image = image.crop(0, 0, half_width, image.height) else: image = image.crop(half_width, 0, half_width, image.height) From 5d684f01bf08f6831947f076643fd78d363dd9c0 Mon Sep 17 00:00:00 2001 From: Paul Nechifor Date: Thu, 18 Sep 2025 03:22:09 +0300 Subject: [PATCH 4/4] fix missing import --- dimos/hardware/test_webcam.py | 3 ++- dimos/hardware/webcam.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dimos/hardware/test_webcam.py b/dimos/hardware/test_webcam.py index aa22b70194..e6d26d2b8d 100644 --- a/dimos/hardware/test_webcam.py +++ b/dimos/hardware/test_webcam.py @@ -44,7 +44,8 @@ def test_module(): dimos = start(1) # Deploy ColorCameraModule, not Webcam directly camera_module = dimos.deploy( - ColorCameraModule, hardware=lambda: Webcam(camera_index=4, frequency=30, stereo_slice=1) + ColorCameraModule, + hardware=lambda: Webcam(camera_index=4, frequency=30, stereo_slice="left"), ) camera_module.image.transport = LCMTransport("/image", Image) camera_module.start() diff --git a/dimos/hardware/webcam.py b/dimos/hardware/webcam.py index b842f83be0..c45cb59515 100644 --- a/dimos/hardware/webcam.py +++ b/dimos/hardware/webcam.py @@ -18,7 +18,7 @@ from abc import ABC, abstractmethod, abstractproperty from dataclasses import dataclass, field from functools import cache -from typing import Any, Callable, Generic, Optional, Protocol, TypeVar +from typing import Any, Callable, Generic, Optional, Protocol, TypeVar, Literal import cv2 import numpy as np