From 161c598e1078c74892902d1a411436e3aec4b60e Mon Sep 17 00:00:00 2001 From: Cutshion Date: Thu, 29 Oct 2026 10:02:29 +0900 Subject: [PATCH] Improve charger routing and drive checks near obstacles Co-Authored-By: Claude Opus 5.5 --- api/server.py | 4 ++-- assistant/brain.py | 23 ++++++++++++++++++++--- robot/drive_log.py | 15 +++++++++++++++ tasks/fetch.py | 13 +++++++++---- tests/test_fetch.py | 4 ++++ 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/api/server.py b/api/server.py index fc16e93..8eb87fe 100644 --- a/api/server.py +++ b/api/server.py @@ -1498,8 +1498,6 @@ def _supervise(): pass -threading.Thread(target=_supervise, daemon=True).start() - @app.get("/health", tags=["status"]) def health(): return {"ok": True} @@ -1528,4 +1526,6 @@ if __name__ == "__main__": camview.ensure_running() # the camera service owns both cameras threading.Thread(target=start_services, daemon=True).start() threading.Thread(target=_drive_log, daemon=True).start() + # the supervisor here, not on import: a test importing this module started real lumi.py processes (2026-10-28) + threading.Thread(target=_supervise, daemon=True).start() uvicorn.run(app, host="0.0.0.0", port=PORT, log_level="warning") diff --git a/assistant/brain.py b/assistant/brain.py index 2da626e..e508e72 100644 --- a/assistant/brain.py +++ b/assistant/brain.py @@ -229,7 +229,8 @@ up when someone says "Hi Lumi".""" ACTIONS = """ You can also move. Decide if the visitor asks you to do something: - "go_to": drive to a place. "target" must be one of these marker names: {markers}. - "home", "charger", "charging station" and "go back" mean "home". Map spoken names to the closest marker + "home" and "go back" mean "home"; "charger", "charging station" mean the marker "charge" when it is listed, + else "home". Map spoken names to the closest marker name (e.g. "point one" or "포인트 원" -> "point1"). If no marker fits, use "none" and say which places you know. - "look": turn your head. "target" is one of: left, right, center, up, down. - "wave": wave your hand. @@ -350,8 +351,8 @@ def _chat(messages, fmt=None, temperature=0.3): ACTIONS_STREAM = """ You can also move. Decide if the visitor asks you to do something: -- go_to : drive to a place. Marker names: {markers}. "home", "charger", "charging station" mean - home. Map spoken names to the closest marker name (e.g. "point one" -> p1); the same place said in the other +- go_to : drive to a place. Marker names: {markers}. "home" means home; "charger", "charging + station" mean the marker "charge" when it is listed, else home. Map spoken names to the closest marker name (e.g. "point one" -> p1); the same place said in the other language or letters is that marker ("photo zone" -> 포토존, "레지스트레이션" -> Registration, "the meeting room" -> 회의실), but a different name or number is not. - come: come to the visitor ("come here", "come to me", "come closer", "이리 와", "여기로 와"). @@ -1467,6 +1468,9 @@ def _intent(text, markers=()): if action == "go_home": if re.search(r"(^|\s)(나|저|우리|저희)(는|도)?\s", t): return None # "나 이제 집에 가": the visitor goes home + c = charger(markers) + if c and re.search(_CHARGER_WORD, t): + return ("go_to", c) # "let's go charger" with a charge marker on the map return ("go_to", "home") if "home" in markers else None if action == "go_point": g = m.groups() + (None,) * 5 @@ -1854,6 +1858,13 @@ def _recase(t, text): # ---------- fetch tasks (docs/16 §4): strict parsing, nothing is guessed ---------- _HERE = r"here|me|여기|이쪽|나한테|저한테|나에게|저에게" _HOME = r"home|charger|charging station|dock|충전기|충전소" +_CHARGER_WORD = r"\bcharg(?:er|ing)\b|\bgo (?:re)?charge\b|충전|차지하러" # the charger, not home, when the map has one + + +def charger(markers): + """The map's charger marker ("charge"), None when there is none and the charger is home.""" + return next((m for m in markers if re.fullmatch(r"charg(?:e|er|ing)", m.lower())), None) + _TABLE = r"table|테이블|책상|탁자" _PLACE_WORD = rf"(?:point|marker|포인트)\s*(\d+)|(?