fix: stable target IDs, hardware.py null checks, remove unused crcmod
Agent-Logs-Url: https://github.com/NawfalMotii79/PLFM_RADAR/sessions/39ac635f-c79b-438f-8764-8db7361e4d50 Co-authored-by: JJassonn69 <83615043+JJassonn69@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
bbaf1e3436
commit
ce61b71cf4
@@ -32,10 +32,23 @@ def _load_radar_protocol():
|
||||
if mod_name in sys.modules:
|
||||
return sys.modules[mod_name]
|
||||
proto_path = pathlib.Path(__file__).resolve().parent.parent / "radar_protocol.py"
|
||||
if not proto_path.is_file():
|
||||
raise FileNotFoundError(
|
||||
f"radar_protocol.py not found at expected location: {proto_path}"
|
||||
)
|
||||
spec = importlib.util.spec_from_file_location(mod_name, proto_path)
|
||||
if spec is None or spec.loader is None:
|
||||
raise ImportError(
|
||||
f"Cannot create module spec for radar_protocol.py at {proto_path}"
|
||||
)
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
# Register before exec so cyclic imports resolve correctly, but remove on failure
|
||||
sys.modules[mod_name] = mod
|
||||
spec.loader.exec_module(mod) # type: ignore[union-attr]
|
||||
try:
|
||||
spec.loader.exec_module(mod)
|
||||
except Exception:
|
||||
sys.modules.pop(mod_name, None)
|
||||
raise
|
||||
return mod
|
||||
|
||||
|
||||
|
||||
@@ -131,6 +131,10 @@ class RadarDataWorker(QThread):
|
||||
self._byte_count = 0
|
||||
self._error_count = 0
|
||||
|
||||
# Monotonically increasing target ID — persisted across frames so map
|
||||
# JS can key markers/trails by a stable ID.
|
||||
self._next_target_id = 0
|
||||
|
||||
def stop(self):
|
||||
self._running = False
|
||||
if self._acquisition:
|
||||
@@ -244,7 +248,7 @@ class RadarDataWorker(QThread):
|
||||
)
|
||||
|
||||
target = RadarTarget(
|
||||
id=len(targets),
|
||||
id=self._next_target_id,
|
||||
range=range_m,
|
||||
velocity=velocity_ms,
|
||||
azimuth=azimuth,
|
||||
@@ -254,6 +258,7 @@ class RadarDataWorker(QThread):
|
||||
snr=snr,
|
||||
timestamp=frame.timestamp,
|
||||
)
|
||||
self._next_target_id += 1
|
||||
targets.append(target)
|
||||
|
||||
# DBSCAN clustering
|
||||
|
||||
Reference in New Issue
Block a user