asw_component/__init__.py +3−0 View file@@ -0,0 +1,3 @@
1 +
from .component import execute 2 +
3 +
__all__ = ["execute"][참조 MVP] 센서융합 측위 A-SW — GNSS와 주행 추정값을 품질 가중치로 융합해 연속적인 위치를 제공합니다.
https://git.agrithing.ai/jbnu/sensor-fusion-localization.git c15cf86 b287380 67952cf 79dc9fc dd56d7b 7d05c47 dd56d7bedac1176e8de89b9a394f11e774b9a8a5 asw_component/__init__.py +3−0 View filefrom .component import execute__all__ = ["execute"]asw_component/component.py +11−0 View filefrom __future__ import annotationsdef execute(payload: dict) -> dict: gnss, odom = payload["gnss"], payload["odometry"] wg, wo = max(0.0, float(gnss.get("quality", 0))), max(0.0, float(odom.get("quality", 0))) total = wg + wo if total == 0: raise ValueError("at least one sensor must have quality") x = (float(gnss["x"]) * wg + float(odom["x"]) * wo) / total y = (float(gnss["y"]) * wg + float(odom["y"]) * wo) / total return {"pose": {"x": round(x, 4), "y": round(y, 4)}, "confidence": round(min(1.0, total / 2), 3), "sources": ["gnss", "odometry"]}examples/input.json +12−0 View file{ "gnss": { "x": 10.2, "y": 4.9, "quality": 0.9 }, "odometry": { "x": 9.8, "y": 5.1, "quality": 0.7 }}pyproject.toml +8−0 View file[project]name = "sensor_fusion_localization"version = "0.1.0"description = "GNSS와 주행 추정값을 품질 가중치로 융합해 연속적인 위치를 제공합니다."requires-python = ">=3.11"[tool.unittest]test-path = "tests"run.py +10−0 View filefrom __future__ import annotationsimport jsonimport sysfrom asw_component import executeif __name__ == "__main__": path = sys.argv[1] if len(sys.argv) > 1 else None with open(path, encoding="utf-8") if path else sys.stdin as source: payload = json.load(source) print(json.dumps(execute(payload), ensure_ascii=False, indent=2))