-
Notifications
You must be signed in to change notification settings - Fork 368
feat(perception): add ORB-SLAM3 native module #1598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
ea78059
ba2124f
8afecb8
bb3d007
4f22d5d
64081da
b6a0279
b61ae93
a274e89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,7 @@ yolo11n.pt | |
|
|
||
| *mobileclip* | ||
| /results | ||
| **/cpp/result | ||
| **/result | ||
|
|
||
| CLAUDE.MD | ||
| /assets/teleop_certs/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,13 +12,13 @@ | |||||||||||
| # See the License for the specific language governing permissions and | ||||||||||||
| # limitations under the License. | ||||||||||||
|
|
||||||||||||
| from dataclasses import dataclass, field | ||||||||||||
| from functools import cache | ||||||||||||
| import threading | ||||||||||||
| import time | ||||||||||||
| from typing import Literal | ||||||||||||
|
|
||||||||||||
| import cv2 | ||||||||||||
| from pydantic import Field | ||||||||||||
| from reactivex import create | ||||||||||||
| from reactivex.observable import Observable | ||||||||||||
|
|
||||||||||||
|
|
@@ -28,13 +28,12 @@ | |||||||||||
| from dimos.utils.reactive import backpressure | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| @dataclass | ||||||||||||
| class WebcamConfig(CameraConfig): | ||||||||||||
| camera_index: int = 0 # /dev/videoN | ||||||||||||
| width: int = 640 | ||||||||||||
| height: int = 480 | ||||||||||||
| fps: float = 15.0 | ||||||||||||
| camera_info: CameraInfo = field(default_factory=CameraInfo) | ||||||||||||
| camera_info: CameraInfo = Field(default_factory=CameraInfo) | ||||||||||||
| frame_id_prefix: str | None = None | ||||||||||||
| stereo_slice: Literal["left", "right"] | None = None # For stereo cameras | ||||||||||||
|
|
||||||||||||
|
|
@@ -167,6 +166,10 @@ def _capture_loop(self) -> None: | |||||||||||
|
|
||||||||||||
| @property | ||||||||||||
| def camera_info(self) -> CameraInfo: | ||||||||||||
| return self.config.camera_info | ||||||||||||
| info = self.config.camera_info | ||||||||||||
| if info.width == 0 or info.height == 0: | ||||||||||||
| info.width = self.config.width | ||||||||||||
|
Comment on lines
+170
to
+171
|
||||||||||||
| if info.width == 0 or info.height == 0: | |
| info.width = self.config.width | |
| if info.width == 0: | |
| info.width = self.config.width | |
| if info.height == 0: |
leshy marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,9 @@ | ||||||
| # ORB-SLAM3 Native Module | ||||||
|
|
||||||
| Visual SLAM module wrapping [ORB-SLAM3](https://github.com/UZ-SLAMLab/ORB_SLAM3) as a native subprocess. | ||||||
|
|
||||||
| The C++ binary lives in a separate GPL-3.0 repo ([dimos-orb-slam3](https://github.com/dimensionalOS/dimos-orb-slam3)) and is pulled in at build time via Nix. | ||||||
|
|
||||||
| ## Known Issues | ||||||
|
|
||||||
| - **Transform / trajectory reconstruction mismatch**: The reconstructed trajectory does not match ground-truth poses. There is a suspected coordinate-frame or transform-composition issue causing output to diverge from base truth. Needs investigation. | ||||||
|
||||||
| - **Transform / trajectory reconstruction mismatch**: The reconstructed trajectory does not match ground-truth poses. There is a suspected coordinate-frame or transform-composition issue causing output to diverge from base truth. Needs investigation. | |
| - **Transform / trajectory reconstruction mismatch**: The reconstructed trajectory does not match ground-truth poses. There is a suspected coordinate-frame or transform-composition issue causing output to diverge from ground truth. Needs investigation. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||||||||||
| # Copyright 2026 Dimensional Inc. | ||||||||||||||||||
| # | ||||||||||||||||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||
| # you may not use this file except in compliance with the License. | ||||||||||||||||||
| # You may obtain a copy of the License at | ||||||||||||||||||
| # | ||||||||||||||||||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||
| # | ||||||||||||||||||
| # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||
| # See the License for the specific language governing permissions and | ||||||||||||||||||
| # limitations under the License. | ||||||||||||||||||
|
|
||||||||||||||||||
| from dimos.core.blueprints import autoconnect | ||||||||||||||||||
| from dimos.hardware.sensors.camera.module import CameraModule | ||||||||||||||||||
| from dimos.perception.slam.orbslam3.module import OrbSlam3 | ||||||||||||||||||
| from dimos.visualization.rerun.bridge import _resolve_viewer_mode, rerun_bridge | ||||||||||||||||||
|
|
||||||||||||||||||
| orbslam3_webcam = autoconnect( | ||||||||||||||||||
| rerun_bridge(viewer_mode=_resolve_viewer_mode()), | ||||||||||||||||||
|
Comment on lines
+18
to
+21
|
||||||||||||||||||
| from dimos.visualization.rerun.bridge import _resolve_viewer_mode, rerun_bridge | |
| orbslam3_webcam = autoconnect( | |
| rerun_bridge(viewer_mode=_resolve_viewer_mode()), | |
| from dimos.visualization.rerun.bridge import _resolve_viewer_mode, RerunBridgeModule | |
| orbslam3_webcam = autoconnect( | |
| RerunBridgeModule.blueprint(viewer_mode=_resolve_viewer_mode()), |
leshy marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,118 @@ | ||||||||||
| # Copyright 2026 Dimensional Inc. | ||||||||||
| # | ||||||||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| # you may not use this file except in compliance with the License. | ||||||||||
| # You may obtain a copy of the License at | ||||||||||
| # | ||||||||||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| # | ||||||||||
| # Unless required by applicable law or agreed to in writing, software | ||||||||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| # See the License for the specific language governing permissions and | ||||||||||
| # limitations under the License. | ||||||||||
|
|
||||||||||
| """Python NativeModule wrapper for ORB-SLAM3 visual SLAM. | ||||||||||
|
|
||||||||||
| Wraps ORB-SLAM3 as a native subprocess that receives camera images and | ||||||||||
| outputs camera pose estimates (odometry). | ||||||||||
|
|
||||||||||
| Usage:: | ||||||||||
|
|
||||||||||
| from dimos.perception.slam.orbslam3.module import OrbSlam3 | ||||||||||
| from dimos.core.blueprints import autoconnect | ||||||||||
|
|
||||||||||
| autoconnect( | ||||||||||
| OrbSlam3.blueprint(sensor_mode=SensorMode.MONOCULAR), | ||||||||||
| SomeConsumer.blueprint(), | ||||||||||
| ).build().loop() | ||||||||||
| """ | ||||||||||
|
|
||||||||||
| from __future__ import annotations | ||||||||||
|
|
||||||||||
| import enum | ||||||||||
| from pathlib import Path | ||||||||||
| from typing import TYPE_CHECKING | ||||||||||
|
|
||||||||||
| from dimos.core.native_module import NativeModule, NativeModuleConfig | ||||||||||
| from dimos.core.stream import In, Out | ||||||||||
| from dimos.msgs.nav_msgs.Odometry import Odometry | ||||||||||
| from dimos.msgs.nav_msgs.Path import Path as NavPath | ||||||||||
| from dimos.msgs.sensor_msgs.Image import Image | ||||||||||
| from dimos.msgs.sensor_msgs.PointCloud2 import PointCloud2 | ||||||||||
| from dimos.spec import perception | ||||||||||
|
|
||||||||||
| _MODULE_DIR = Path(__file__).parent | ||||||||||
|
|
||||||||||
|
|
||||||||||
| class SensorMode(enum.StrEnum): | ||||||||||
| MONOCULAR = "MONOCULAR" | ||||||||||
| STEREO = "STEREO" | ||||||||||
| RGBD = "RGBD" | ||||||||||
| IMU_MONOCULAR = "IMU_MONOCULAR" | ||||||||||
| IMU_STEREO = "IMU_STEREO" | ||||||||||
| IMU_RGBD = "IMU_RGBD" | ||||||||||
|
|
||||||||||
|
Comment on lines
+48
to
+55
|
||||||||||
|
|
||||||||||
| class OrbSlam3Config(NativeModuleConfig): | ||||||||||
| """Config for the ORB-SLAM3 visual SLAM native module.""" | ||||||||||
|
|
||||||||||
| cwd: str | None = str(_MODULE_DIR) | ||||||||||
| executable: str = "result/bin/orbslam3_native" | ||||||||||
| build_command: str | None = ( | ||||||||||
| "nix build github:dimensionalOS/dimos-orb-slam3/v0.2.0 --no-write-lock-file" | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| # ORB-SLAM3 sensor mode | ||||||||||
| sensor_mode: SensorMode = SensorMode.MONOCULAR | ||||||||||
|
|
||||||||||
| # Pangolin viewer (disable for headless) | ||||||||||
| use_viewer: bool = False | ||||||||||
|
|
||||||||||
| # Frame IDs for output messages | ||||||||||
| frame_id: str = "world" | ||||||||||
| child_frame_id: str = "camera_link" | ||||||||||
|
|
||||||||||
| # Camera settings YAML (absolute path, or override with your own calibration) | ||||||||||
| settings_path: str = str( | ||||||||||
| _MODULE_DIR / "result" / "share" / "orbslam3" / "config" / "RealSense_D435i.yaml" | ||||||||||
| ) | ||||||||||
|
Comment on lines
+77
to
+79
|
||||||||||
| settings_path: str = str( | |
| _MODULE_DIR / "result" / "share" / "orbslam3" / "config" / "RealSense_D435i.yaml" | |
| ) | |
| settings_path: str |
Uh oh!
There was an error while loading. Please reload this page.