mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-22 00:11:13 +00:00
[AZ-243] Integrate production native VIO runtime
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
"""Loader for installed BASALT-compatible VIO runtime packages."""
|
||||
|
||||
from collections.abc import Mapping
|
||||
from importlib import import_module
|
||||
from typing import Any
|
||||
|
||||
from vio_adapter.interfaces import NativeVioRunner, VioBackendError
|
||||
from vio_adapter.types import VioBackendEstimate
|
||||
|
||||
|
||||
class BasaltNativeRunner:
|
||||
"""Adapts an installed BASALT binding to the VIO runner protocol."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
module_name: str = "basalt_vio",
|
||||
factory_name: str = "create_runner",
|
||||
config: Mapping[str, object] | None = None,
|
||||
) -> None:
|
||||
self._module_name = module_name
|
||||
self._factory_name = factory_name
|
||||
self._config = dict(config or {})
|
||||
self._runner: NativeVioRunner | None = None
|
||||
|
||||
def initialize(self) -> None:
|
||||
try:
|
||||
module = import_module(self._module_name)
|
||||
factory = getattr(module, self._factory_name)
|
||||
runner = factory(**self._config)
|
||||
except Exception as exc:
|
||||
raise VioBackendError(
|
||||
f"unable to load BASALT runtime {self._module_name}:{self._factory_name}"
|
||||
) from exc
|
||||
|
||||
if not isinstance(runner, NativeVioRunner):
|
||||
raise VioBackendError(
|
||||
f"BASALT runtime {self._module_name}:{self._factory_name} "
|
||||
"does not implement NativeVioRunner"
|
||||
)
|
||||
|
||||
self._runner = runner
|
||||
self._runner.initialize()
|
||||
|
||||
def estimate(self, frame: Any, telemetry_window: tuple[Any, ...]) -> VioBackendEstimate:
|
||||
if self._runner is None:
|
||||
raise VioBackendError("BASALT runtime is not initialized")
|
||||
return self._runner.estimate(frame, telemetry_window)
|
||||
Reference in New Issue
Block a user