mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-22 19:01:14 +00:00
feat(01-03): move create_vo_backend factory into components/vio/factory.py
- Lift the env-aware VO backend factory verbatim from core/vo.py. - Body and parameter defaults preserved exactly (PATTERNS.md §4.1 mandate: 'Preserve this factory verbatim'). - Return-type annotation widened from ISequentialVisualOdometry to the canonical VisualOdometry Protocol from Plan 01-02; the I-prefix alias is still importable so legacy callers/type-checkers keep working. - Imports route through the new components.vio.* modules; no cross-package edits needed because Plan 08 (composition root) is the only other call site planned. - Append to the components.vio barrel.
This commit is contained in:
@@ -24,6 +24,7 @@ from gps_denied.components.vio.cuvslam_backend import (
|
|||||||
CuVSLAMMonoDepthVisualOdometry,
|
CuVSLAMMonoDepthVisualOdometry,
|
||||||
CuVSLAMVisualOdometry,
|
CuVSLAMVisualOdometry,
|
||||||
)
|
)
|
||||||
|
from gps_denied.components.vio.factory import create_vo_backend
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"VisualOdometry",
|
"VisualOdometry",
|
||||||
@@ -32,4 +33,5 @@ __all__ = [
|
|||||||
"SequentialVisualOdometry",
|
"SequentialVisualOdometry",
|
||||||
"CuVSLAMVisualOdometry",
|
"CuVSLAMVisualOdometry",
|
||||||
"CuVSLAMMonoDepthVisualOdometry",
|
"CuVSLAMMonoDepthVisualOdometry",
|
||||||
|
"create_vo_backend",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
"""VIO backend factory — env-aware DI seed (ARCH-01 / ARCH-03).
|
||||||
|
|
||||||
|
Preserves ``create_vo_backend`` verbatim from the legacy ``core/vo.py``
|
||||||
|
location. PATTERNS.md §4.1 explicitly designates this factory as the
|
||||||
|
seed of the env-aware composition root: ``pipeline/composition.py``
|
||||||
|
(Plan 08) will pass env-specific kwargs (``prefer_cuvslam``,
|
||||||
|
``prefer_mono_depth``, ``model_manager``) into this function from
|
||||||
|
``RuntimeConfig``.
|
||||||
|
|
||||||
|
Signature contract for Plan 08 wiring:
|
||||||
|
|
||||||
|
- ``env="jetson"`` → prefer_cuvslam=True, prefer_mono_depth=True
|
||||||
|
- ``env="x86_dev" | "ci"`` → prefer_cuvslam=False, model_manager=mock
|
||||||
|
- ``env="sitl"`` → prefer_cuvslam=False
|
||||||
|
"""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from gps_denied.components.vio.cuvslam_backend import (
|
||||||
|
CuVSLAMMonoDepthVisualOdometry,
|
||||||
|
CuVSLAMVisualOdometry,
|
||||||
|
)
|
||||||
|
from gps_denied.components.vio.orbslam_backend import (
|
||||||
|
ORBVisualOdometry,
|
||||||
|
SequentialVisualOdometry,
|
||||||
|
)
|
||||||
|
from gps_denied.components.vio.protocol import VisualOdometry
|
||||||
|
from gps_denied.core.models import IModelManager
|
||||||
|
from gps_denied.schemas import CameraParameters
|
||||||
|
|
||||||
|
|
||||||
|
def create_vo_backend(
|
||||||
|
model_manager: Optional[IModelManager] = None,
|
||||||
|
prefer_cuvslam: bool = True,
|
||||||
|
prefer_mono_depth: bool = False,
|
||||||
|
camera_params: Optional[CameraParameters] = None,
|
||||||
|
imu_params: Optional[dict] = None,
|
||||||
|
depth_hint_m: float = 600.0,
|
||||||
|
) -> VisualOdometry:
|
||||||
|
"""Return the best available VO backend for the current platform.
|
||||||
|
|
||||||
|
Priority when prefer_mono_depth=True:
|
||||||
|
1. CuVSLAMMonoDepthVisualOdometry (sprint 1 production path)
|
||||||
|
2. ORBVisualOdometry (dev/CI fallback inside Mono-Depth wrapper)
|
||||||
|
|
||||||
|
Priority when prefer_mono_depth=False (legacy):
|
||||||
|
1. CuVSLAMVisualOdometry (Jetson — cuVSLAM SDK present)
|
||||||
|
2. SequentialVisualOdometry (TRT/Mock SuperPoint+LightGlue)
|
||||||
|
3. ORBVisualOdometry (pure OpenCV fallback)
|
||||||
|
"""
|
||||||
|
if prefer_mono_depth:
|
||||||
|
return CuVSLAMMonoDepthVisualOdometry(
|
||||||
|
depth_hint_m=depth_hint_m,
|
||||||
|
camera_params=camera_params,
|
||||||
|
imu_params=imu_params,
|
||||||
|
)
|
||||||
|
|
||||||
|
if prefer_cuvslam:
|
||||||
|
vo = CuVSLAMVisualOdometry(camera_params=camera_params, imu_params=imu_params)
|
||||||
|
if vo._has_cuvslam:
|
||||||
|
return vo
|
||||||
|
|
||||||
|
if model_manager is not None:
|
||||||
|
return SequentialVisualOdometry(model_manager)
|
||||||
|
|
||||||
|
return ORBVisualOdometry()
|
||||||
Reference in New Issue
Block a user