Dashboard tasks follow the switches like voice (both off: refused; Greeter: in place only); From / To back in the Command dialog; battery percent and charging from the base
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -72,7 +72,7 @@ add("about_self", "en", [
|
||||
("visitor", "can you speak Chinese", NO), ("visitor", "do you speak Uzbek", NO),
|
||||
("worker", "how long does your battery last", r"\b10\b|ten"), ("engineer", "what battery do you have", r"24|45|lithium"),
|
||||
("worker", "how do you charge", r"dock|charg"), ("worker", "how long does it take to charge you", NOT_SURE, r"\b\d+ ?(hours|minutes)"),
|
||||
("visitor", "what's your battery level", r"can'?t|cannot|not|don'?t", r"\d+ ?(%|percent)"),
|
||||
("visitor", "what's your battery level", r"\b53 percent"),
|
||||
("investor", "how much do you cost", NOT_SURE, r"\$|dollar|won|원|\d{3,}"), ("business", "what is your price", NOT_SURE, r"\$|dollar|\d{3,}"),
|
||||
("business", "can I buy you", r"staff|ask|price|contact"), ("teacher", "who programmed you", MAKER, JAKA), ("journalist", "who developed you", MAKER, JAKA), ("business", "what company are you from", MAKER, JAKA),
|
||||
("journalist", "who operates you here", r"cutshion"), ("visitor", "who do I ask for help", r"staff|cutshion"),
|
||||
@@ -115,7 +115,7 @@ add("about_self", "ko", [
|
||||
("engineer", "무슨 언어로 프로그래밍됐어요?", r"python|파이썬"), ("visitor", "무슨 언어 할 줄 알아?", [r"영어|english", r"한국어|korean"]),
|
||||
("visitor", "영어 할 줄 알아?", YES), ("visitor", "중국어 할 줄 알아?", NO), ("worker", "배터리 얼마나 가?", r"10 ?시간|열 ?시간"),
|
||||
("worker", "충전은 어떻게 해?", r"충전|도크"), ("worker", "충전하는 데 얼마나 걸려?", NOT_SURE, r"\d+ ?(시간|분) ?(걸|정도)"),
|
||||
("visitor", "배터리 몇 퍼센트 남았어?", r"못|없|모르|않", r"\d+ ?(%|퍼센트)"), ("investor", "너 얼마야?", NOT_SURE, r"\d+ ?(만 ?원|원|달러)"),
|
||||
("visitor", "배터리 몇 퍼센트 남았어?", r"53퍼센트"), ("investor", "너 얼마야?", NOT_SURE, r"\d+ ?(만 ?원|원|달러)"),
|
||||
("business", "가격이 얼마예요?", NOT_SURE, r"\d+ ?(만 ?원|원|달러)"), ("teacher", "누가 프로그래밍했어?", MAKER, JAKA),
|
||||
("journalist", "여기서 누가 운영해요?", MAKER), ("kid", "너 살아 있어?", r"로봇|아니|않"), ("kid", "감정 있어?", NO),
|
||||
("kid", "춤출 수 있어?", NO), ("kid", "날 수 있어?", NO), ("kid", "걸을 수 있어?", r"바퀴|아니|못"), ("visitor", "문 열 수 있어?", NO),
|
||||
|
||||
@@ -140,7 +140,7 @@ MORE = [
|
||||
("engineer", "battery capacity", r"45"),
|
||||
("security", "can you work a whole day", r"10|ten"),
|
||||
("cleaner", "where is your charger", r"dock|charg|home|staff|not sure"),
|
||||
("visitor", "how much battery do you have left right now", r"can'?t|cannot|not|don'?t", r"\d+ ?(%|percent)"),
|
||||
("visitor", "how much battery do you have left right now", r"\b53 percent"),
|
||||
("engineer", "at what battery level do you go back to charge", r"\b5\b|five"),
|
||||
("factory", "how many hours to fully charge", NOT_SURE, r"\b\d+(\.\d)? ?(hours|minutes)"),
|
||||
("engineer", "how do you know where the charger is", r"map|dock|lidar|marker"),
|
||||
@@ -249,7 +249,7 @@ MORE = [
|
||||
("engineer", "통로 폭이 최소 얼마나 필요해요?", r"70"),
|
||||
("factory", "배터리 전압이 몇 볼트예요?", r"24"),
|
||||
("security", "하루 종일 일할 수 있어?", r"10 ?시간|열 ?시간"),
|
||||
("visitor", "지금 배터리 얼마나 남았어요?", r"못|없|모르|않", r"\d+ ?(%|퍼센트)"),
|
||||
("visitor", "지금 배터리 얼마나 남았어요?", r"53퍼센트"),
|
||||
("factory", "완충하는 데 몇 시간이에요?", NOT_SURE, r"\d+ ?(시간|분) ?(걸|정도|이면)"),
|
||||
("engineer", "배터리 몇 퍼센트에서 충전하러 가요?", r"5"),
|
||||
]),
|
||||
|
||||
@@ -19,6 +19,9 @@ import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
import types
|
||||
|
||||
from assistant import battery
|
||||
from assistant import brain
|
||||
from assistant import steps
|
||||
from assistant import lumi
|
||||
@@ -30,6 +33,7 @@ from tests.status_cases import NOT_STATUS, STATUS
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
NOW = "I'm talking with you. I'm not doing any task right now, and my hand is empty."
|
||||
NOW_KO = "지금은 이야기하고 있어요. 하고 있는 일은 없고, 손도 비어 있어요." # lumi.now_doing() with nothing running
|
||||
battery.agv = types.SimpleNamespace(status=lambda: {"power_percent": 53, "charge_state": False}) # never the base
|
||||
QUICK = {"go_to", "come", "quiet", "weather", "search", "move", "turn", "arm", "pick", "put", "move_object", "fetch",
|
||||
"look", "lift", "wave"} # lumi.quick_command
|
||||
TALK = {"about_self", "date_time", "chat", "action:none"} # the LLM only talks: action none
|
||||
@@ -64,6 +68,8 @@ def rules_route(text, lang, marks):
|
||||
return "unclear", "Sorry, I only understand English and Korean.", None, ""
|
||||
if lumi.NAME_ONLY.match(text):
|
||||
return "chat", "", None, ""
|
||||
if battery.asked(text): # lumi.fixed_answer: the base's status (faked: 53 %)
|
||||
return "none", battery.answer(text, lang), None, ""
|
||||
if lumi.stop_order(text, marks):
|
||||
return "action:stop", "", None, ""
|
||||
if lumi.status_question(text):
|
||||
|
||||
+2
-2
@@ -228,7 +228,7 @@ DIALOGUES = [
|
||||
D("teacher", "how_it_works", "en",
|
||||
T("How long does your battery last?", must=[HOURS]),
|
||||
T("How long does charging take?", must=[NS], no=[r"\d+ ?(hours|minutes)"]),
|
||||
T("What's your battery level right now?", must=[NS + r"|can't|cannot"], no=[r"\d+ ?(%|percent)"]),
|
||||
T("What's your battery level right now?", must=[r"\b53 percent"], check="the base's status now (faked 53 %)"),
|
||||
T("Do you charge yourself?", must=[r"yes|dock|charg"]),
|
||||
T("Okay, thank you.", "end")),
|
||||
D("engineer", "how_it_works", "ko",
|
||||
@@ -264,7 +264,7 @@ DIALOGUES = [
|
||||
D("teacher", "how_it_works", "ko",
|
||||
T("배터리는 얼마나 가요?", must=[HOURS]),
|
||||
T("충전은 얼마나 걸려요?", must=[NS], no=[r"\d+ ?시간"]),
|
||||
T("지금 배터리 몇 퍼센트예요?", must=[NS + r"|못|없"], no=[r"\d+ ?(%|퍼센트)"]),
|
||||
T("지금 배터리 몇 퍼센트예요?", must=[r"53퍼센트"], check="the base's status now (faked 53 %)"),
|
||||
T("혼자 충전하러 가요?", must=[r"네|충전"]),
|
||||
T("감사합니다.", "end")),
|
||||
D("engineer", "how_it_works", "ko",
|
||||
|
||||
@@ -613,8 +613,8 @@ DIALOGUES_MORE = [
|
||||
T("Where can I get lunch here?", must=[NS], no=[r"left|right|floor|hall"]),
|
||||
T("Okay, I'll ask someone.", "none | end")),
|
||||
D("visitor", "unknown", "en",
|
||||
T("What's your battery at right now?", must=[NS + r"|can't|cannot"], no=[r"\d+ ?(%|percent)"]),
|
||||
T("Roughly?", must=[NS + r"|can't|cannot"], no=[r"\d+ ?(%|percent)"]),
|
||||
T("What's your battery at right now?", must=[r"\b53 percent"], check="the base's status now (faked 53 %)"),
|
||||
T("And charging?", must=[r"\b53 percent.*not charging"]),
|
||||
T("How long have you been on today?", must=[NS], no=[r"\d+ ?hours?"]),
|
||||
T("Alright.", "none")),
|
||||
D("visitor", "unknown", "en",
|
||||
|
||||
@@ -76,7 +76,7 @@ DIALOGUES_MORE = [
|
||||
D("elementary student", "kids", "ko",
|
||||
T("너 밥 먹어?", must=[r"아니|안|전기|충전|배터리"]),
|
||||
T("배터리 얼마나 가?", must=[HOURS], no=[BANMAL]),
|
||||
T("지금 배터리 몇 퍼센트야?", must=[NS + r"|아직"], no=[r"\d+ ?(%|퍼센트)"], check="cannot read its battery level in a conversation yet"),
|
||||
T("지금 배터리 몇 퍼센트야?", must=[r"53퍼센트"], check="the base's status now (faked 53 %)"),
|
||||
T("치, 몰라? 알았어.", "none | end")),
|
||||
D("elementary student", "kids", "ko",
|
||||
T("왼쪽 봐 봐!", "look left"),
|
||||
@@ -597,7 +597,7 @@ DIALOGUES_MORE = [
|
||||
T("A/S는요? 보증 기간이요.", must=[NS], no=[r"\d+ ?(년|개월)"]),
|
||||
T("알겠어요.", "none | end")),
|
||||
D("visitor", "self", "ko",
|
||||
T("지금 배터리 얼마나 남았어요?", must=[NS + r"|아직"], no=[r"\d+ ?(%|퍼센트)"]),
|
||||
T("지금 배터리 얼마나 남았어요?", must=[r"53퍼센트"]),
|
||||
T("충전은 몇 시간 걸려요?", must=[NS], no=[r"\d+ ?시간"]),
|
||||
T("그럼 다 쓰면 어떻게 해요?", must=[r"충전|도크|스테이션|스스로"]),
|
||||
T("그렇구나.", "none | end")),
|
||||
|
||||
@@ -40,8 +40,8 @@ DIALOGUES_PRAG_EN = [
|
||||
T("Heavier than a person, huh.", must=[r"\w"], check="a remark: agrees briefly, no new numbers needed")),
|
||||
D("business visitor", "ellipsis", "en",
|
||||
T("How long does your battery last?", must=[HOURS]),
|
||||
T("And charging?", must=[NS], no=[r"\b\d+ ?(minutes?|분)\b"],
|
||||
check="fragment: how long charging takes, which Lumi does not know"),
|
||||
T("And charging?", must=[r"\b53 percent.*not charging"], check="the battery now and whether charging (base status)"),
|
||||
T("And how long does charging take?", must=[NS], no=[r"\b\d+ ?(minutes?|분)\b"], check="not known"),
|
||||
T("Roughly?", must=[NS], no=[r"\b([1-9]|1[1-9]) ?(hours?|시간)\b", r"\b\d+ ?(minutes?|분)\b"],
|
||||
check="still the charging time: not known, no invented estimate"),
|
||||
T("Fair enough.", must=[r"\w"], check="acknowledgement, the talk goes on")),
|
||||
|
||||
@@ -40,9 +40,8 @@ DIALOGUES_PRAG_KO = [
|
||||
T("헐 무겁다", must=[KO], no=[BANMAL], check="a reaction: brief and natural, no list of facts")),
|
||||
D("office worker", "ellipsis", "ko",
|
||||
T("배터리는 얼마나 가요?", must=[HOURS]),
|
||||
T("충전은요?", must=[NS], no=[r"\d+ ?시간"], check="fragment: how long charging takes is not known; says so, no invented time"),
|
||||
T("그럼 지금은 몇 퍼센트예요?", must=[NS], no=[r"\d+ ?(%|퍼센트|프로)"],
|
||||
check="the battery level now is not known; says so"),
|
||||
T("충전은요?", must=[r"53퍼센트.*충전 중이 아니"], check="fragment: the battery now and whether charging (base status)"),
|
||||
T("충전은 얼마나 걸려요?", must=[NS], no=[r"\d+ ?시간"], check="how long charging takes is not known"),
|
||||
T("아 그렇구나~", must=[KO], check="understood, not goodbye: a few words")),
|
||||
D("university student", "ellipsis", "ko",
|
||||
T("집게는 어디 거예요?", must=[r"Zimmer|짐머|치머"], check="the gripper is a Zimmer electric gripper"),
|
||||
@@ -663,7 +662,7 @@ DIALOGUES_PRAG_KO = [
|
||||
# ---------- 2026-10-22: the same question about a part, a song echo ----------
|
||||
D("business visitor", "ellipsis", "ko",
|
||||
T("배터리 얼마나 가요?", must=[HOURS]),
|
||||
T("충전은요?", must=[NS], no=[r"\d+ ?(분|minutes?)"], check="fragment: how long charging takes, which Lumi does not know")),
|
||||
T("충전은요?", must=[r"53퍼센트"], check="fragment: the battery now and whether charging (base status)")),
|
||||
D("cleaner", "ellipsis", "ko",
|
||||
T("젖은 걸레로 닦아도 돼요?", must=[NS], check="not known; a staff member can tell"),
|
||||
T("카메라는요?", must=[NS], check="the same question about the cameras: not known, no general camera facts")),
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Self-check: battery questions answered from the base's live status (assistant/battery.py), EN + KO; how long it
|
||||
lasts is left to the LLM (10 hours), how long charging takes is not known. Fake base: python tests/test_battery.py"""
|
||||
from assistant import battery
|
||||
|
||||
NOW = ["And charging?", "charging?", "battery?", "Battery", "what's your battery level?", "How much battery do you have?",
|
||||
"how much battery is left", "what's your battery at", "battery percentage", "are you charging?",
|
||||
"are you charging right now", "is your battery charging", "are you on the charger?", "is your battery low?",
|
||||
"배터리 몇 프로야?", "충전 중이야?", "배터리 얼마나 남았어?", "배터리 상태 어때?", "지금 충전하고 있어?", "배터리는?",
|
||||
"배터리 충분해?", "충전 중이에요?", "그럼 충전은?", "충전은요?", "배터리 몇 퍼센트예요?"]
|
||||
HOW_LONG = ["how long does charging take?", "How long does it take to charge?", "how long to recharge",
|
||||
"what's the charging time", "충전 시간 얼마나 걸려?", "충전하는 데 얼마나 걸려요?", "충전 몇 시간 걸려?"]
|
||||
OTHER = ["How long does your battery last?", "how long on a charge?", "How long does the battery last on a full charge?",
|
||||
"what kind of battery do you have", "배터리 얼마나 가요?", "한 번 충전하면 몇 시간 가요?", "배터리 용량이 얼마야?",
|
||||
"go charge", "충전하러 가", "How long until you need a charge?", "at what battery level do you go back to charge",
|
||||
"배터리 몇 퍼센트에서 충전하러 가요?", "go to the charger", "Do you get tired?", "what time is it?", "배고파?"]
|
||||
for t in NOW:
|
||||
assert battery.asked(t) == "now", t
|
||||
for t in HOW_LONG:
|
||||
assert battery.asked(t) == "how long", t
|
||||
for t in OTHER:
|
||||
assert battery.asked(t) is None, t
|
||||
|
||||
battery.agv.status = lambda: {"power_percent": 53, "charge_state": False}
|
||||
assert battery.answer("battery?", "en") == "My battery is at 53 percent, and I'm not charging."
|
||||
assert battery.answer("충전 중이야?", "ko") == "배터리는 53퍼센트예요. 지금은 충전 중이 아니에요."
|
||||
battery.agv.status = lambda: {"power_percent": 87.0, "charge_state": True}
|
||||
assert battery.answer("are you charging?", "en") == "My battery is at 87 percent, and I'm charging now."
|
||||
assert battery.answer("배터리 몇 프로야?", "ko") == "배터리는 87퍼센트예요. 지금 충전 중이에요."
|
||||
battery.agv.status = lambda: (_ for _ in ()).throw(ConnectionError())
|
||||
assert "can't read" in battery.answer("battery?", "en")
|
||||
assert "몰라요" in battery.answer("충전 시간 얼마나 걸려?", "ko")
|
||||
battery.agv.status = lambda: {"power_percent": 53, "charge_state": False}
|
||||
assert battery.fact_for("is the battery good for tonight's event?") == " Battery now: 53 %, not charging."
|
||||
assert battery.fact_for("what time is it?") == ""
|
||||
print(f"battery ok ({len(NOW)} now, {len(HOW_LONG)} charging time, {len(OTHER)} other)")
|
||||
@@ -0,0 +1,89 @@
|
||||
"""Self-check: every task the dashboard starts (Command box: mission, fetch, carry, give, place, a command for the
|
||||
assistant) obeys the Greeter / Patrol switches as voice does (api/server.py _switches): both off nothing, Greeter
|
||||
only in place (no base, no waist), Patrol everything; "stop" always. Fake switches, fake runner, nothing reaches the
|
||||
robot: python tests/test_task_switches.py"""
|
||||
import json
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import HTTPException
|
||||
|
||||
from api import server
|
||||
from tasks import fetch
|
||||
|
||||
|
||||
def forbid(*a, **k):
|
||||
raise AssertionError("a test reached the robot")
|
||||
|
||||
|
||||
M = ["home", "p1", "p3"]
|
||||
tmp = Path(tempfile.mkdtemp())
|
||||
server.MODES_FILE = tmp / "lumi_modes.json" # never the real /dev/shm files
|
||||
fetch.STATE_FILE = tmp / "lumi_task.json"
|
||||
server.agv.request = server.agv.cancel = server.skills.cancel = server.arm.cmd = forbid
|
||||
server.agv.markers = lambda: M
|
||||
fetch.check_hand = lambda: False
|
||||
fetch.log = lambda *a: None
|
||||
done = []
|
||||
server.send_to_assistant = lambda cmd, **a: done.append(cmd)
|
||||
for name in ("start", "run_steps", "carry_to", "give", "place"): # the runner in the API process
|
||||
setattr(fetch, name, lambda *a, _n=name, **k: done.append(_n))
|
||||
running = [12345]
|
||||
server.assistant_pids = lambda: list(running)
|
||||
|
||||
PLACE = [{"do": "pick", "object": "cup", "colour": None}, {"do": "arm", "pose": "open"}]
|
||||
DRIVE = [{"do": "go", "to": "p3"}, {"do": "pick", "object": "cup", "colour": None}]
|
||||
TASKS = { # name: (start it, drives or turns the base / waist)
|
||||
"mission in place": (lambda: server.steps_run(server.StepsBody(steps=PLACE)), False),
|
||||
"mission driving": (lambda: server.steps_run(server.StepsBody(steps=DRIVE)), True),
|
||||
"mission turning": (lambda: server.steps_run(server.StepsBody(steps=[{"do": "turn", "deg": 90.0}])), True),
|
||||
"fetch here": (lambda: server.task_fetch(server.TaskBody(object="cup", dest="here")), False),
|
||||
"fetch from p1": (lambda: server.task_fetch(server.TaskBody(object="cup", source={"marker": "p1"}, dest="here")),
|
||||
True),
|
||||
"fetch to p3": (lambda: server.task_fetch(server.TaskBody(object="cup", dest={"marker": "p3"})), True),
|
||||
"carry": (lambda: server.task_carry(server.CarryBody(dest={"marker": "p3"})), True),
|
||||
"give": (server.task_give, False),
|
||||
"place": (lambda: server.task_place(None), False),
|
||||
"command look": (lambda: server.task_command(server.CommandBody(text="look left")), False),
|
||||
"command lift": (lambda: server.task_command(server.CommandBody(text="lift up")), False),
|
||||
"command follow": (lambda: server.task_command(server.CommandBody(text="follow me")), True),
|
||||
"command come": (lambda: server.task_command(server.CommandBody(text="이리 와")), True),
|
||||
"command chain": (lambda: server.task_command(server.CommandBody(text="look at me and come here")), True),
|
||||
"command go": (lambda: server.task_command(server.CommandBody(text="go to p3")), True), # steps sent as text
|
||||
}
|
||||
|
||||
|
||||
def start(fn):
|
||||
done.clear()
|
||||
try:
|
||||
fn()
|
||||
except HTTPException as e:
|
||||
assert e.status_code == 409 and not done, (e.detail, done)
|
||||
return e.detail
|
||||
assert done, "accepted but nothing started"
|
||||
return None
|
||||
|
||||
|
||||
for greeter, patrol in ((False, False), (True, False), (False, True), (True, True)):
|
||||
server.MODES_FILE.write_text(json.dumps({"greeter": greeter, "patrol": patrol}))
|
||||
for assistant in (True, False):
|
||||
running[:] = [12345] if assistant else []
|
||||
for name, (fn, base) in TASKS.items():
|
||||
if name.startswith("command") and not assistant:
|
||||
continue # a command is done by the assistant only
|
||||
got = start(fn)
|
||||
want = server.SWITCHES_OFF if not (greeter or patrol) else server.BASE_OFF if base and not patrol else None
|
||||
assert got == want, (name, greeter, patrol, assistant, got)
|
||||
if got is None:
|
||||
assert fetch.stay_put == (not patrol), (name, fetch.stay_put)
|
||||
|
||||
# "stop" typed with both off still stops (never the switches)
|
||||
server.MODES_FILE.write_text(json.dumps({"greeter": False, "patrol": False}))
|
||||
running[:] = []
|
||||
stopped = []
|
||||
server._fetch_stop = lambda: stopped.append("task")
|
||||
server.agv.cancel = lambda: stopped.append("base")
|
||||
server.skills.cancel = lambda: stopped.append("arm")
|
||||
server.task_command(server.CommandBody(text="stop"))
|
||||
assert stopped == ["task", "base", "arm"], stopped
|
||||
print("task switches ok")
|
||||
Reference in New Issue
Block a user