asw_component/__init__.py +3−0 View file@@ -0,0 +1,3 @@
1 +
from .component import execute 2 +
3 +
__all__ = ["execute"][참조 MVP] A-SW ROS2 참조 Kit — ROS2 토픽과 유사한 메시지 봉투로 인지→계획→제어 연결 방법을 보여주는 참조 Kit입니다.
https://git.agrithing.ai/via/asw-reference-ros2-kit.git 277c3f0 d085d43 b7d2f98 17e12a8 0061666 9526ba0 006166654d45470e26cee1b898a8e6b2d55af0d9 asw_component/__init__.py +3−0 View filefrom .component import execute__all__ = ["execute"]asw_component/component.py +13−0 View filefrom __future__ import annotationsimport hashlibimport jsonREQUIRED_TOPICS = {"/vehicle/pose", "/planning/path", "/control/command"}def execute(payload: dict) -> dict: topic = payload.get("topic") if topic not in REQUIRED_TOPICS: raise ValueError(f"unsupported topic: {topic}") envelope = {"topic": topic, "timestamp_ms": int(payload["timestamp_ms"]), "frame_id": payload.get("frame_id", ""), "data": payload.get("data", {})} canonical = json.dumps(envelope, sort_keys=True, separators=(",", ":")).encode() return {"accepted": True, "envelope": envelope, "message_id": hashlib.sha256(canonical).hexdigest()[:16], "qos": {"reliability": "reliable", "depth": 10}}examples/input.json +10−0 View file{ "topic": "/vehicle/pose", "timestamp_ms": 1000, "frame_id": "field_local", "data": { "x": 1.2, "y": 3.4, "heading_rad": 0.1 }}pyproject.toml +8−0 View file[project]name = "asw_reference_ros2_kit"version = "0.1.0"description = "ROS2 토픽과 유사한 메시지 봉투로 인지→계획→제어 연결 방법을 보여주는 참조 Kit입니다."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))