Rework radar system
This commit is contained in:
@@ -9,7 +9,7 @@ import numpy as np
|
||||
|
||||
from python_app.hardware_full.librevna_driver.models import SweepResult
|
||||
from python_app.models.dataset_model import ComboKey, SweepCollection, TraceData
|
||||
from python_app.models.run_config_model import RadarSweepModel, RunConfigModel
|
||||
from python_app.models.run_config_schema import RadarSweepModel, RunConfigModel
|
||||
|
||||
_WAVE_SPEED_M_S = 3e8
|
||||
_FRAME_PERIOD_S = 0.05
|
||||
@@ -46,9 +46,6 @@ class PointTargetMockService:
|
||||
def close(self) -> None:
|
||||
"""Mock acquisition owns no hardware resources."""
|
||||
|
||||
def recover(self) -> None:
|
||||
"""Mock acquisition has no hardware connection to recover."""
|
||||
|
||||
def read_device_limits(self) -> dict[str, float | int]:
|
||||
raise RuntimeError("Mock radar has no hardware device limits")
|
||||
|
||||
@@ -56,7 +53,7 @@ class PointTargetMockService:
|
||||
self._frequency_hz = np.linspace(sweep.start_hz, sweep.stop_hz, sweep.points, dtype=np.float32)
|
||||
self._phase_per_m = -2j * np.pi * self._frequency_hz.astype(np.float64) / _WAVE_SPEED_M_S
|
||||
|
||||
def set_active_combo(self, combo: ComboKey) -> None:
|
||||
def prepare_combo(self, combo: ComboKey) -> None:
|
||||
if not (0 <= combo.input < self.config.input_switch.positions
|
||||
and 0 <= combo.output < self.config.output_switch.positions):
|
||||
raise ValueError(f"Mock combo is outside the antenna matrix: {combo}")
|
||||
@@ -66,18 +63,14 @@ class PointTargetMockService:
|
||||
collection = self._capture((self._active_combo,), 1)
|
||||
trace = collection.traces[0]
|
||||
return SweepResult(
|
||||
x=trace.frequency_hz, traces={"s11": trace.s11, "s21": trace.s21},
|
||||
x=trace.frequency_hz, traces={"s21": trace.s21},
|
||||
capture_start_ns=trace.capture_start_ns, capture_end_ns=trace.capture_end_ns,
|
||||
)
|
||||
|
||||
def acquire_collection(self, collection_id: int = 1) -> SweepCollection:
|
||||
return self._capture(self._combos, collection_id)
|
||||
|
||||
def acquire_combo_collection(
|
||||
self, *, input_pos: int, output_pos: int, collection_id: int = 1,
|
||||
) -> SweepCollection:
|
||||
self.set_active_combo(ComboKey(input_pos, output_pos))
|
||||
return self._capture((self._active_combo,), collection_id)
|
||||
def acquire_collection(self, collection_id: int = 1, *, combo: ComboKey | None = None) -> SweepCollection:
|
||||
if combo is not None:
|
||||
self.prepare_combo(combo)
|
||||
return self._capture(self._combos if combo is None else (combo,), collection_id)
|
||||
|
||||
def _target_position(
|
||||
self, sample_ns: int,
|
||||
@@ -107,7 +100,6 @@ class PointTargetMockService:
|
||||
r_rx = float(np.linalg.norm(target - rx.get(combo.input, (0.0, 0.0, 0.0))))
|
||||
traces.append(TraceData(
|
||||
combo=combo, frequency_hz=self._frequency_hz,
|
||||
s11=np.asarray(0.5 / max(1.0, r_tx * r_tx) * np.exp(self._phase_per_m * 2 * r_tx), dtype=np.complex64),
|
||||
s21=np.asarray(0.5 / max(1.0, r_tx * r_rx) * np.exp(self._phase_per_m * (r_tx + r_rx)), dtype=np.complex64),
|
||||
capture_start_ns=capture_start_ns,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user