diff --git a/dimos/hardware/sensors/camera/module.py b/dimos/hardware/sensors/camera/module.py index 6f51febfef..a6858f339c 100644 --- a/dimos/hardware/sensors/camera/module.py +++ b/dimos/hardware/sensors/camera/module.py @@ -19,10 +19,13 @@ import reactivex as rx from reactivex import operators as ops +import rerun as rr from dimos.agents import Output, Reducer, Stream, skill from dimos.core import Module, ModuleConfig, Out, rpc from dimos.core.blueprints import autoconnect +from dimos.core.global_config import GlobalConfig +from dimos.dashboard.rerun_init import connect_rerun from dimos.hardware.sensors.camera.spec import CameraHardware from dimos.hardware.sensors.camera.webcam import Webcam from dimos.msgs.geometry_msgs import Quaternion, Transform, Vector3 @@ -58,8 +61,9 @@ class CameraModule(Module[CameraModuleConfig], perception.Camera): config: CameraModuleConfig default_config = CameraModuleConfig - def __init__(self, *args: Any, **kwargs: Any) -> None: + def __init__(self, *args: Any, global_config: GlobalConfig, **kwargs: Any) -> None: super().__init__(*args, **kwargs) + self.global_config = global_config @rpc def start(self) -> None: @@ -73,8 +77,17 @@ def start(self) -> None: if self.config.frequency > 0: stream = stream.pipe(sharpness_barrier(self.config.frequency)) + # Connect this worker process to Rerun if it will log sensor data. + if self.global_config.viewer_backend.startswith("rerun"): + connect_rerun(global_config=self.global_config) + + def callback(image: Image) -> None: + self.color_image.publish(image) + if self.global_config.viewer_backend.startswith("rerun"): + rr.log("world/robot/camera/rgb", image.to_rerun()) + self._disposables.add( - stream.subscribe(self.color_image.publish), + stream.subscribe(callback), ) self._disposables.add(