From 487bf785a06c4cc2aef42f0d65e5dfc5bd8ba4fd Mon Sep 17 00:00:00 2001 From: Musung Kim <70582218+Musung1@users.noreply.github.com> Date: Thu, 19 Nov 2026 16:56:38 +0900 Subject: [PATCH] =?UTF-8?q?feat(acs/v1):=20EVCS=20fbs=20=EA=B3=B5=EC=9C=A0?= =?UTF-8?q?=20=E2=80=94=20contract.fbs(ACS=20=E2=86=94=20EVCS=20zenoh=20?= =?UTF-8?q?=EA=B3=84=EC=95=BD)=20=C2=B7=20evcs=5Fplugin.fbs(EVCS=20?= =?UTF-8?q?=E2=86=94=20Muscat=20=ED=94=8C=EB=9F=AC=EA=B7=B8=EC=9D=B8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- acs/v1/contract.fbs | 195 +++++++++++++++++++++++++++++++++++++++++ acs/v1/evcs_plugin.fbs | 191 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 386 insertions(+) create mode 100644 acs/v1/contract.fbs create mode 100644 acs/v1/evcs_plugin.fbs diff --git a/acs/v1/contract.fbs b/acs/v1/contract.fbs new file mode 100644 index 00000000..8fc1556f --- /dev/null +++ b/acs/v1/contract.fbs @@ -0,0 +1,195 @@ +// schemas/acs/v1/contract.fbs — ACS ↔ EVCS zenoh 메시지. 원본은 이 파일 하나. +// +// 메시지 하나 = 루트 테이블 하나. 이름은 키에서 바로 나온다: +// building//evcs//cmd/ EvcsRequest · EvcsResponse +// building//evcs//evt/ EvcsEvent +// building//evcs/config/… Config… +// 주소와 규칙은 contract/README.md. 이 파일은 모양만 정한다. +// +// 약속: +// - 요청 = 인자만. 응답 = {ok, error | data}. 이벤트 = status 하나 (1초마다, 지금 상태 통째로). +// - EVCS 는 사실만 알린다. 사람을 부를지 · 언제 다시 알릴지는 ACS 가 정한다. +// - 이유(reason)는 문자열 코드다 — 목록은 README. 모르는 코드는 그대로 보여 준다. +// - 모르는 칸은 무시한다 (새 칸은 끝에 붙인다). +// - enum 은 모두 ubyte, 값은 0 부터 차례로. JSON 표기에서는 이름 문자열이다. +// - 테이블만 쓴다 (struct · union 없음). JSON 표기(flatc --json)가 곧 문서·예제의 모양이다. +// - 건물 맵·층 토포는 그 자체가 문서(해시가 바이트에 걸린다)라 JSON 문자열로 싣는다. +namespace contract; + +// ── 공통 ──────────────────────────────────────────────────────────────────── + +enum ErrorCode : ubyte { + not_at_pickup, // 로봇이 출발 자리(B)에 없다 + dropoff_occupied, // 도착 자리(C)에 다른 로봇이 있다 + busy, // 지금은 못 받는다 (호기 없음 · 뱅크 가득 · 설정 적용 대기 · 로봇이 다른 이동 중) — 나중에 다시 + need_force, // 로봇이 캐빈 · 문턱일 수 있어 끝내지 못한다 — 로봇을 꺼낸 뒤 force 로 + cannot, // 지금 그 명령을 할 수 없다 (message 를 본다) + invalid // 요청이 틀렸다 · 모르는 id +} + +table Violation { + rule: string; + message: string; +} + +table Error { + code: ErrorCode; + message: string; + violations: [Violation]; // configure 가 invalid 일 때 +} + +table Empty {} + +// ── ACS → EVCS 뱅크 building//evcs/ ───────────────────────────────── + +table EvcsTransferRequest { + transfer_id: string (required); // ACS 가 붙인다 — 같은 id 로 다시 보내면 같은 답 + robot_id: string (required); + from_level: string (required); // 로봇이 지금 B 에 있는 층 + to_level: string (required); +} +table TransferData { + queued: bool; // 받았지만 줄에 섰다 (호기가 빌 때까지) — 거짓이면 바로 시작 +} +table EvcsTransferResponse { + ok: bool; + error: Error; + data: TransferData; +} + +table EvcsCancelRequest { // transfer_id 와 robot_id 중 하나만 + transfer_id: string; // 그 이동을 멈춘다 · 끝낸다 + robot_id: string; // status.alone 의 로봇을 뺐다 — 뱅크 막음을 푼다 + force: bool; // 로봇이 캐빈 · 문턱 밖임을 ACS 가 확인했다 — 세션을 닫는다 + reason: string; // "emergency" — 안전하게 끝낸다 (force 아님). 문턱이면 들어가거나 나와서, 캐빈이면 도착층에서 +} +table EvcsCancelResponse { + ok: bool; + error: Error; + data: Empty; +} + +table EvcsResumeRequest { // 멈춘(stuck) 이동을 잇는다 + transfer_id: string (required); +} +table EvcsResumeResponse { + ok: bool; + error: Error; + data: Empty; +} + +enum Phase : ubyte { calling, boarding, riding, alighting, dropoff, done } +enum Outcome : ubyte { succeeded, returned, held } + +table VendorStep { // 업체 세션이 어디까지 왔나 — 보이기만 한다 (목록은 README) + code: string; // 업체 중립 단계 — called · car_coming · car_at_start · boarding · boarded · car_to_dest · car_at_dest · alighting · alighted · ended + raw: string; // 업체 원래 단계 이름 · 번호 (표시 · 대조용) — 업체 말이 없으면 빠진다 + at_ms: long; // 그 단계를 안 때 (epoch ms) +} +table VendorEnd { // 업체가 세션을 끝냈다 + reason: string; // door_time · fault · deadline · no_car · exit_count · emergency · by_us · comm (README) + raw: string; // 업체 원문 — 업체 말이 없으면 빠진다 +} +table CarCalls { // 호기에 걸린 호출 (건물 맵 층 id) + car: [string]; // 캐빈 안에서 누른 층 + up: [string]; // 올라가려고 홀에서 부른 층 + down: [string]; // 내려가려고 홀에서 부른 층 +} + +table Transfer { + transfer_id: string (required); + robot_id: string; + phase: Phase; + car_id: string; // 건물 맵 호기 id — 배정 뒤 + stuck: bool; // 멈춰 있다 — 저절로 풀리기도 하고, resume · cancel 을 기다리기도 한다 + reason: string; // stuck 이면 왜 멈췄나, done{returned} 면 왜 돌아갔나 + outcome: Outcome; // done 일 때. done 은 60초 동안 실린다 + vendor_session: string; // 업체 세션 id — 세션이 없으면 빠진다 + started_at_ms: long; // EVCS 가 업체 호출을 낸 때 (epoch ms) + vendor_step: VendorStep; // 업체 세션이 어디까지 왔나 — 모르면 빠진다 + vendor_end: VendorEnd; // 업체가 끝낸 까닭 — 끝내지 않았으면 빠진다 + place: string; // 로봇 몸의 실제 자리 — outside · doorway · cabin. 모르면 빠진다 + step: string; // 트리 단계 — CALL · GET_ON · SEND_ELEVATOR · RIDE · GET_OFF · GO_TO_GOAL · GO_BACK. 모르면 빠진다 + step_since_ms: long; // 그 단계에 들어간 때 (epoch ms) + session_state: string; // active · ended — 업체 세션을 연 적이 없으면 빠진다. 새 세션이 열리면 active 로 돌아간다 + session_end_by: string; // ended 일 때 robot(EVCS 가 끊음) · vendor(업체가 끊음) + session_end_reason: string; // ended 일 때 까닭 코드 + session_end_at_ms: long; // ended 일 때 끝난 때 (epoch ms) + actions: [string]; // 지금 받는 운영자 동작 — resume · send_back · take_out · cancel. 빈 목록 = 받지 않음 + actions_why: string; // 받지 않는 동작마다 사람 문장 까닭 (JSON 객체 문자열 {"resume":"비상정지가 눌려 있다", ...}) + wait: bool; // 기다림인가 — 원인이 풀리면 EVCS 가 스스로 잇는다. stuck 일 때만 뜻이 있다 + done_place: string; // done 일 때 로봇 자리 — outside · doorway · cabin + done_node: string; // done 일 때 가까운 노드 — B(출발 입구) · C(도착 출구) · 모르면 빠진다 + urgent: bool; // 비상정지 · 범퍼로 멈춘 채 엘리베이터 세션을 60초 넘게 붙잡고 있다 — 승객이 그 호기를 못 쓴다. 사람을 빨리 보낸다 +} +table AloneRobot { // transfer 없이 이 뱅크의 캐빈 · 문턱에 있는 로봇 — 그 뱅크는 새 transfer 를 받지 않는다 + robot_id: string (required); + car_id: string; +} +table Car { // 이 뱅크의 호기 한 대 — 업체가 알려 준 지금 모습 (보이기만 한다). 모르는 칸은 없다 + car_id: string (required); // 건물 맵 호기 id + level: string; // 지금 층 (건물 맵 층 id) + direction: string; // up · down · stop + door: string; // open · closed · opening · closing + mode: string; // normal · broken · check · parked · emergency · other + at_ms: long; // 업체에게서 받은 때 (epoch ms) — 오래됐으면 흐리게 + calls: CarCalls; // 걸린 호출 — 업체가 주지 않으면 빠진다 +} +table EvcsStatusEvent { // 1초마다 + transfers: [Transfer]; + alone: [AloneRobot]; // 나가면 빠진다 + accepting: bool; // 지금 transfer 를 보내면 뱅크가 받는다 (로봇 조건은 transfer 답이 본다) + reason: string; // accepting 이 거짓이면 왜 — vendor_offline · bank_full · robot_alone · applying + vendor_events: string; // 업체 실시간 알림 — "ok" | "quiet" (끊겨 조회로만 돈다 · 운행은 막지 않는다). 알림을 안 쓰는 업체는 늘 "ok" + cars: [Car]; // 이 뱅크의 호기들 — 쉬는 호기까지. 이동이 탄 호기는 transfers[].car_id 로 찾는다 +} + +// ── ACS → EVCS 설정 building//evcs/config ──────────────────────────────── + +table MiriSettings { + base_url: string; + api_key: string; // 비밀값 + api_secret: string; // 비밀값 +} +table UnsSettings { + base_url: string; + organization_id: string; + elevator_type: string; // TK · FU + robot_type: string; // HTR · LTR + client_id: string; + client_secret: string; // 비밀값 +} +table Vendors { + miri: MiriSettings; + uns: UnsSettings; +} +table Settings { + vendors: Vendors; + robots: [string]; // 등록 로봇 id — 있으면 이 로봇만 받는다. [] 이면 아무도, 칸이 없으면(옛 ACS) 모두 +} + +table FloorMap { + level: string; + topology: string; // topology.json 파일 내용 그대로 — sha256 이 건물 맵과 맞아야 한다 +} + +table ConfigConfigureRequest { // 늘 통째로 — 비밀값에 "***" 를 넣으면 지금 값을 쓴다 + building_map: string (required); // 건물 맵 JSON 문서 그대로 + floor_maps: [FloorMap]; // 건물 맵의 층 전부 + settings: Settings; +} +table ConfigureData { + map_hash: string; // 이 묶음 전체(건물 맵 · 층 맵 · 설정)의 해시. 진행 중 이동이 끝나면 다시 떠서 적용한다 — status.map_hash 로 본다 +} +table ConfigConfigureResponse { + ok: bool; + error: Error; + data: ConfigureData; +} + +table ConfigStatusEvent { // 1초마다 + map_hash: string; // 지금 쓰는 묶음의 해시 (configure 답과 같은 값). "" = 아직 설정이 없다 (뱅크 창구가 없다) +} + +// flatc 가 스키마 파일을 내려면 하나가 필요하다 — 실제 루트는 키마다 다르다 (머리말 참고). +root_type EvcsStatusEvent; diff --git a/acs/v1/evcs_plugin.fbs b/acs/v1/evcs_plugin.fbs new file mode 100644 index 00000000..de431f12 --- /dev/null +++ b/acs/v1/evcs_plugin.fbs @@ -0,0 +1,191 @@ +// EVCS ↔ Muscat 플러그인 (EVCS 레포 plugins/muscat). +// 모든 메시지는 FlatBuffers. 키 앞머리는 amr//evcs/ — 로봇 회사 키(amr//move/… 등)와 겹치지 않는다. +// 모르는 칸은 무시한다. 시각은 epoch ms (보내는 쪽 시계). +namespace EVCS_PLUGIN; + +table Point { + x: double; + y: double; +} + +// 지금 층에서 배정된 호기의 캐빈 축 — 눈 사실(inside · coming_out …)을 셀 상자를 정한다. 타기 전에도 실린다 +table Axis { + level: string; // 건물 맵 층 id + map: string; // 그 층 맵 이름 + car_id: string; + inside_node: string; // K + inside: Point; + front_node: string; // F + front: Point; + door_ratio: double; + robot_length: double; + margin: double; +} + +// 문 앞 한 걸음 허락 — 호기가 로봇을 태우고 출발층을 떠난 뒤(left_start)에만 Intent 에 실린다. 내린 뒤에는 빠진다. +// 플러그인은 EVCS 와 끊긴 동안에만, 아래가 다 맞을 때 혼자 inside → front 로 곧게 나간다 (돌지 않는다): +// 맵 = goal_map · 위치 good · inlier_ratio ≥ min_inlier_ratio · 몸이 캐빈 안(EVCS 와 같은 자리 규칙) · 문선 ~ front 길이 비었다. +// 확실히 문 밖(EVCS 규칙)이 되면 멈추고 Sense.stepped_out 을 올린다. +table StepOut { + transfer_id: string; + goal_level: string; // 건물 맵 층 id (예: 5F) + goal_map: string; // 그 층 맵 이름 (slamnav status map_name) + car_id: string; // 건물 맵 호기 id + inside_node: string; // K — 캐빈 자리 (그 층 맵 좌표) + inside: Point; + front_node: string; // F — 문 앞 + front: Point; + door_ratio: double; // 문선 = F 에서 F→K 길이 × door_ratio + robot_length: double; // m — 몸 길이 (F→K 축 방향) + margin: double; // m — 문선 앞뒤 여유. 몸 앞끝 ≤ 문선 − margin 이면 확실히 문 밖 + min_inlier_ratio: double; // 맵 위치가 이만큼 맞아야 한다 (근거 하나가 아니다 — 맵 모양은 층마다 같을 수 있다) + start_level: string; // 탄 층 (건물 맵 층 id) + floors_apart: int; // 목적층 − 탄 층 (건물 맵 층 차례로, 위가 +) — 수직 이동 · 문 열림 횟수 근거에 쓴다 +} +// '내 층' 은 서로 다른 근거 둘 이상이 목적층을 가리킬 때만 확실하다 (하나면 나가지 않는다): +// 승강장 표식(주) · 탄 뒤 수직 이동 적분(IMU · 기압이 있으면) · 출발 뒤 첫 문 열림이고 시간이 층 수와 맞음 · 목적층 승강장 고유 모양. +// 확실하지 않으면 혼자 나가지 않고, 다시 붙은 뒤 EVCS 판단으로 내린다. + +// amr//evcs/intent — EVCS → 플러그인, put. 바뀔 때 곧바로 + 1초마다 통째로. 끝나면 phase done 을 10초 내고 멈춘다. +table Intent { + stamp_ms: long; + transfer_id: string; + phase: string; // 계약 phase — calling · boarding · riding · alighting · dropoff · done + step: string; // 트리 단계 — CALL · GET_ON · SEND_ELEVATOR · RIDE · GET_OFF · GO_TO_GOAL · GO_BACK · HELP + doing: string; // 지금 도는 동작 노드 ID (WaitForElevator · BackIntoElevator …) + wait_sec: uint; // 그 단계가 알림까지 남은 초 (없으면 0) + say: string; // 이번에 말할 줄 이름 (없으면 "") — sounds/README.md 의 파일 이름 + say_count: uint; // 말할 때마다 1 늘린다 — 같은 줄을 두 번 말해도 안다 + entry_try: uint; + entry_max: uint; + call_try: uint; + call_max: uint; + goal_level: string; // 도착층 (건물 맵 층 id) + car_level: string; // 그 호기의 지금 층 (모르면 "") + stuck: bool; // 계약 status 와 같은 값 + reason: string; + outcome: string; // done 일 때 + step_out: StepOut; // 문 앞 한 걸음 허락 (없으면 허락 없음) + axis: Axis; // 지금 층 · 배정된 호기의 캐빈 축 (모르면 없다) + step_age_sec: uint; // 지금 단계에 들어온 뒤 지난 초 (보류 시간 빼고) + next: string; // 다음 동작 코드 (없으면 "") +} + +// amr//evcs/sense — 플러그인 → EVCS, put. 10 Hz + 바뀔 때 곧바로. 1초 넘게 없으면 EVCS 는 없는 셈 친다. +table Sense { + stamp_ms: long; + transfer_id: string; // 플러그인이 받은 마지막 intent 의 transfer_id + shadow: bool; // 섀도 — 눈(inside … pushed)은 EVCS 가 기록만 하고 트리에 쓰지 않는다 + inside: int; // 캐빈 안 사람 · 물건 묶음 수 (-1 = 모른다) + coming_out: bool; + spot_free: bool; + door_busy: bool; + front_busy: bool; + moved_aside: bool; + pushed: bool; + stepped_out: bool; // 끊긴 동안 StepOut 허락으로 혼자 문 밖에 나왔다 (섀도와 상관없이 EVCS 가 쓴다) + stepped_out_level: string; // 나온 층 (건물 맵 층 id) + stepped_out_ms: long; // 문 밖에 선 때 + bumper_locked: bool; // 안전 보드가 범퍼 정지를 잠가 두었다 (status sf_bumper_detect 그대로) + stepping_out: bool; // 지금 혼자 문 밖으로 나가는 중 — EVCS 는 이 이동을 '다른 쪽이 로봇을 몬다' 로 보지 않는다 + bumper_hit_ms: long; // 이 transfer 에서 범퍼가 마지막으로 눌린 때 (0 = 없음) — 끊긴 동안 눌렸다 풀려도 EVCS 가 안다 +} + +// amr//evcs/ask — 플러그인 → EVCS, put. 화면 버튼. 같은 id 는 한 번만 (끊긴 동안 쌓았다 다시 붙으면 보낸다, 60초 지난 건 버린다). +table Ask { + stamp_ms: long; + transfer_id: string; + ask: string; // robot_first(U5 먼저 타세요) · person_first(U6 제가 먼저) · next_car(U7 다음 거 타 주세요) + id: string; +} + +// ── amr//evcs/plan — EVCS → 플러그인, put. 바뀔 때 곧바로 + 1초마다. transfer 없으면 보내지 않는다. +// 살아 있는 BT 를 읽어 만든다 — 하드코딩 표 없이 트리 모양이 바뀌면 따라간다. + +table PlanStep { + name: string; // 단계 이름 (CALL · GET_ON …) + label: string; // 사람이 읽을 이름 (부르기 · 타기 …, 없으면 name) + alert_sec: uint; // 알림 한도 (초, 0 = 없음) + state: string; // done · now · todo + since_ms: long; // now 일 때 — 이 단계에 들어온 때 (epoch ms) + is_branch: bool; // Fallback 의 대안으로만 도는 Step (레일에서 뺀다) +} + +table PlanTimer { // 노드가 알린 시계 (0.1.13 — 예전 *_sec 포트 짐작 대신) + port: string; // 시계 이름 + port_text: string; // 넘으면: fail · alert · ok · guard + value_sec: double; // 한도 + elapsed_sec: double; // 지난 초 (세지 않으면 0) +} + +// XML 에 적은 포트 아닌 속성 — 사람 문장(say_now · ask · say_over …)은 트리 파일에 적는다. EVCS 는 키를 모른다 +table PlanAttr { + key: string; + value: string; +} + +// 노드가 스스로 알린 시계 — 실행 중 노드와 그 위(Step 포함) · 감시 조건 +table PlanClock { + node_id: string; + node_name: string; + name: string; // 시계 이름 (노드가 정한다) + limit_sec: double; + elapsed_sec: double; + counting: bool; // 지금 세는 중 + on_over: string; // 넘으면: fail(그 노드 실패) · alert(알리고 계속) · ok(그 노드 끝) · guard(감시 걸림) + still: bool; // 못 나아간 시간 (나아가면 0) + attrs: [PlanAttr]; // 시계를 가진 노드에서 Step 까지 모은 속성 (say_over …) + after_id: string; // 넘으면 가는 곳 + after_name: string; + after_attrs: [PlanAttr]; +} + +table PlanNode { + id: string; // 트리 안 고유 경로 (fullPath) + parent: string; // 부모 id + depth: uint; + kind: string; // sequence · reactive_sequence · fallback · retry · inverter · force_success · force_failure · subtree · action · condition · decorator + type: string; // registrationName + name: string; // XML name 속성 (없으면 type) + text: string; // manifest description + status: string; // idle · running · success · failure · skipped + since_ms: long; // 그 상태가 된 때 (epoch ms, 0 = 모름) + tries: uint; // RetryUntilSuccessful 이면 시도한 수 + max_tries: uint; // RetryUntilSuccessful 이면 한도 + timers: [PlanTimer]; // 이 노드의 *_sec 포트와 시계 + inverted: bool; // Inverter 아래면 true (아님) + unnamed_control: bool; // 이름 없는 제어/데코레이터 (접기 대상) + attrs: [PlanAttr]; // 이 노드의 XML 속성 (포트 아닌 것) +} + +table PlanGuard { + node_id: string; // 감시 조건 노드 id + name: string; + text: string; + status: string; // success · failure + reactive_id: string; // ReactiveSequence id + inverted: bool; // Inverter 아래면 true (… 아님) +} + +table PlanNext { + when: string; // ok · fail · timeout · guard + after_sec: double; // 시계가 있으면 남은 초 (없으면 0) + node_id: string; // 가는 노드 id + name: string; // 가는 노드 이름 (XML name 또는 type) + text: string; // 가는 노드 설명 + attrs: [PlanAttr]; // 가는 곳의 사람 문장 (Step 이면 안쪽 첫 잎부터 Step 까지) +} + +table Plan { + stamp_ms: long; + transfer_id: string; + steps: [PlanStep]; + nodes: [PlanNode]; // 지금 단계 서브트리를 평평하게 + guards: [PlanGuard]; + next: [PlanNext]; // 예측 + clocks: [PlanClock]; // 노드가 알린 시계 + face: [PlanAttr]; // 실행 중 잎에서 Step 까지 모은 속성 (가까운 것이 먼저) — 얼굴 '지금' + stalled: bool; // 실행 중 잎이 막혀 있다 (막힘 시계 1.5초 넘게) — 얼굴 '부탁' +} + +root_type Intent;