asw_component/__init__.py +3−0 View file@@ -0,0 +1,3 @@
1 +
from .component import execute 2 +
3 +
__all__ = ["execute"][참조 MVP] 작업 속도 제어 A-SW — 곡률, 작업 종류와 장애물 거리를 이용해 안전 목표 속도를 산정합니다.
https://git.agrithing.ai/kitech/speed-control-asw.git c105eba 5370f9c 8897104 ce13cd4 f7e21c8 5bb5e1a f7e21c80eec37a48917921236755f75e6be7238a asw_component/__init__.py +3−0 View filefrom .component import execute__all__ = ["execute"]asw_component/component.py +18−0 View filefrom __future__ import annotationsMODE_FACTOR = {"transport": 1.0, "seeding": 0.65, "tillage": 0.5, "spraying": 0.75}def execute(payload: dict) -> dict: maximum = float(payload["max_speed_mps"]) curvature = abs(float(payload.get("curvature", 0))) distance = float(payload.get("obstacle_distance_m", 999)) mode = payload.get("work_mode", "transport") if maximum <= 0: raise ValueError("max_speed_mps must be positive") target = maximum * MODE_FACTOR.get(mode, 0.6) / (1 + 3.5 * curvature) reason = "nominal" if distance < 2: target, reason = 0.0, "obstacle_stop" elif distance < 5: target, reason = min(target, maximum * 0.25), "obstacle_slowdown" return {"target_speed_mps": round(target, 3), "mode": mode, "limiting_reason": reason}examples/input.json +6−0 View file{ "max_speed_mps": 3, "curvature": 0.12, "work_mode": "seeding", "obstacle_distance_m": 7}pyproject.toml +8−0 View file[project]name = "speed_control_asw"version = "0.1.0"description = "곡률, 작업 종류와 장애물 거리를 이용해 안전 목표 속도를 산정합니다."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))