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:
+14
-1
@@ -979,6 +979,19 @@ function whereOf(seg, sel, pick) {
|
|||||||
return p && {x: +p.x.toFixed(3), y: +p.y.toFixed(3), theta: +p.theta.toFixed(3)};
|
return p && {x: +p.x.toFixed(3), y: +p.y.toFixed(3), theta: +p.theta.toFixed(3)};
|
||||||
}
|
}
|
||||||
let cmdSeq = 0, cmdTimer = null, parsed = null, heldNow = false, cmdLLM = false; // cmdLLM: Enter pressed // heldNow: Lumi holds the object, From unused
|
let cmdSeq = 0, cmdTimer = null, parsed = null, heldNow = false, cmdLLM = false; // cmdLLM: Enter pressed // heldNow: Lumi holds the object, From unused
|
||||||
|
function setWhere(seg, sel, w) { // a place the text named, shown in its picker
|
||||||
|
const m = w === "here" ? "here" : w && w.marker ? "marker" : null;
|
||||||
|
if (!m) return;
|
||||||
|
$(seg).querySelectorAll("button").forEach(x => x.classList.toggle("on", x.dataset.v === m));
|
||||||
|
if (m === "marker") $(sel).value = w.marker;
|
||||||
|
}
|
||||||
|
function fillPickers(r) { // a typed fetch shows its places in From / To
|
||||||
|
const t = r.task, from = r.from_text || [];
|
||||||
|
if (from.includes("source")) setWhere("tSrcSeg", "tSrcMarker", t.source);
|
||||||
|
if (from.includes("dest")) setWhere("tDstSeg", "tDstMarker", t.dest);
|
||||||
|
paintWhere("tSrcSeg", "tSrcMarkerRow", "tSrcPickBox", srcPick, "tSrcPt");
|
||||||
|
paintWhere("tDstSeg", "tDstMarkerRow", "tDstPickBox", dstPick, "tDstPt");
|
||||||
|
}
|
||||||
function cmdChanged() { // repaint the pickers, then read the text again (after typing stops)
|
function cmdChanged() { // repaint the pickers, then read the text again (after typing stops)
|
||||||
paintWhere("tSrcSeg", "tSrcMarkerRow", "tSrcPickBox", srcPick, "tSrcPt");
|
paintWhere("tSrcSeg", "tSrcMarkerRow", "tSrcPickBox", srcPick, "tSrcPt");
|
||||||
paintWhere("tDstSeg", "tDstMarkerRow", "tDstPickBox", dstPick, "tDstPt");
|
paintWhere("tDstSeg", "tDstMarkerRow", "tDstPickBox", dstPick, "tDstPt");
|
||||||
@@ -992,7 +1005,6 @@ function parseCmd() {
|
|||||||
$("tProblems").innerHTML = probs.map(p => `<div>${esc(p)}</div>`).join("");
|
$("tProblems").innerHTML = probs.map(p => `<div>${esc(p)}</div>`).join("");
|
||||||
$("tStart").disabled = probs.length > 0 || !parsed || !parsed.action;
|
$("tStart").disabled = probs.length > 0 || !parsed || !parsed.action;
|
||||||
$("tStart").textContent = {give: "Give", place: "Place", carry: "Go"}[parsed && parsed.action] || "Start";
|
$("tStart").textContent = {give: "Give", place: "Place", carry: "Go"}[parsed && parsed.action] || "Start";
|
||||||
$("tWhere").style.display = parsed && ["fetch", "carry"].includes(parsed.action) ? "" : "none";
|
|
||||||
paintSteps();
|
paintSteps();
|
||||||
};
|
};
|
||||||
parsed = null;
|
parsed = null;
|
||||||
@@ -1001,6 +1013,7 @@ function parseCmd() {
|
|||||||
$("tSentence").textContent = "…";
|
$("tSentence").textContent = "…";
|
||||||
api("/tasks/parse", {text, source: source || null, dest: dest || null, llm: cmdLLM}).then(r => {
|
api("/tasks/parse", {text, source: source || null, dest: dest || null, llm: cmdLLM}).then(r => {
|
||||||
if (n !== cmdSeq) return;
|
if (n !== cmdSeq) return;
|
||||||
|
if (r.action === "fetch" && r.task) fillPickers(r);
|
||||||
parsed = r; show(r.sentence, r.problems);
|
parsed = r; show(r.sentence, r.problems);
|
||||||
}).catch(e => show("–", [e.message]));
|
}).catch(e => show("–", [e.message]));
|
||||||
}
|
}
|
||||||
|
|||||||
+45
-3
@@ -933,6 +933,35 @@ class TaskBody(BaseModel):
|
|||||||
prefer: str | None = Field(None, examples=["small"], description="which of several: small, big, near, far, left, right")
|
prefer: str | None = Field(None, examples=["small"], description="which of several: small, big, near, far, left, right")
|
||||||
|
|
||||||
|
|
||||||
|
SWITCHES_OFF = "Switch on Greeter or Patrol first."
|
||||||
|
BASE_OFF = "I can't drive or turn my waist right now. Switch on Patrol for that." # lumi.BASE_OFF_SAY, as by voice
|
||||||
|
|
||||||
|
|
||||||
|
def _switches(base):
|
||||||
|
"""Every task the dashboard starts obeys the switches as voice does: nothing with both off, the base or the waist
|
||||||
|
(`base`: a drive or a turn in it) only with Patrol on; with Greeter only a task stays in place (fetch.stay_put).
|
||||||
|
STOP, pause, jog and the manual buttons are not asked here."""
|
||||||
|
m = read_modes()
|
||||||
|
if not (m["greeter"] or m["patrol"]):
|
||||||
|
raise HTTPException(409, SWITCHES_OFF)
|
||||||
|
if base and not m["patrol"]:
|
||||||
|
raise HTTPException(409, BASE_OFF)
|
||||||
|
from tasks import fetch
|
||||||
|
fetch.stay_put = not m["patrol"]
|
||||||
|
|
||||||
|
|
||||||
|
def _drives(steps):
|
||||||
|
from assistant import lumi
|
||||||
|
return bool({s.get("do") for s in steps} & lumi.DRIVE_STEPS)
|
||||||
|
|
||||||
|
|
||||||
|
def _plan_drives(r):
|
||||||
|
"""A /tasks/parse result drives or turns the base / waist."""
|
||||||
|
a, task = r.get("action"), r.get("task") or {}
|
||||||
|
return a == "carry" or a == "steps" and _drives(r["steps"]) or r.get("base", False) or \
|
||||||
|
a == "fetch" and any(task.get(k) not in (None, "here") for k in ("source", "dest"))
|
||||||
|
|
||||||
|
|
||||||
def _fetch_call(name, cmd, *args, **fields):
|
def _fetch_call(name, cmd, *args, **fields):
|
||||||
"""start / give / place: the assistant does it while it runs (it owns the robot), else the runner here."""
|
"""start / give / place: the assistant does it while it runs (it owns the robot), else the runner here."""
|
||||||
from tasks import fetch
|
from tasks import fetch
|
||||||
@@ -1041,7 +1070,9 @@ def task_parse(body: ParseBody):
|
|||||||
if kind == "stop":
|
if kind == "stop":
|
||||||
return {"action": "command", "text": fixed, "sentence": "Stop.", "problems": [], "read_by": "rules"}
|
return {"action": "command", "text": fixed, "sentence": "Stop.", "problems": [], "read_by": "rules"}
|
||||||
if kind == "chain":
|
if kind == "chain":
|
||||||
|
base = any(k == "steps" and _drives(x) or k == "quick" and x[0] in lumi.BASE_ACTIONS for k, _, x in data)
|
||||||
return {"action": "command", "text": fixed, "parts": [[k, w] for k, w, _ in data], "problems": [], "read_by": "rules",
|
return {"action": "command", "text": fixed, "parts": [[k, w] for k, w, _ in data], "problems": [], "read_by": "rules",
|
||||||
|
"base": base,
|
||||||
"sentence": ", then ".join(_said(*p) for p in data).capitalize() + "."}
|
"sentence": ", then ".join(_said(*p) for p in data).capitalize() + "."}
|
||||||
if kind == "hand":
|
if kind == "hand":
|
||||||
(hand, _) = data
|
(hand, _) = data
|
||||||
@@ -1076,7 +1107,7 @@ def task_parse(body: ParseBody):
|
|||||||
return {"action": "steps", "steps": got, "lang": lang, "sender": None, "read_by": "rules",
|
return {"action": "steps", "steps": got, "lang": lang, "sender": None, "read_by": "rules",
|
||||||
**_steps_said(got, markers)}
|
**_steps_said(got, markers)}
|
||||||
return {"action": "command", "text": fixed, "sentence": _said("quick", fixed, data).capitalize() + ".",
|
return {"action": "command", "text": fixed, "sentence": _said("quick", fixed, data).capitalize() + ".",
|
||||||
"problems": [], "read_by": "rules"}
|
"problems": [], "read_by": "rules", "base": data[0] in lumi.BASE_ACTIONS}
|
||||||
problem = brain.place_problem(fixed, markers)
|
problem = brain.place_problem(fixed, markers)
|
||||||
if problem: # quick_command says it: "I don't have a place called p12"
|
if problem: # quick_command says it: "I don't have a place called p12"
|
||||||
return _talk(problem[0], kind="refuse")
|
return _talk(problem[0], kind="refuse")
|
||||||
@@ -1095,7 +1126,8 @@ def task_parse(body: ParseBody):
|
|||||||
return {"action": "steps", "steps": got, "lang": lang, "sender": None, "read_by": "llm",
|
return {"action": "steps", "steps": got, "lang": lang, "sender": None, "read_by": "llm",
|
||||||
**_steps_said(got, markers)}
|
**_steps_said(got, markers)}
|
||||||
if rule[0] in ("look", "lift", "wave", "come", "follow", "come_back", "quiet"):
|
if rule[0] in ("look", "lift", "wave", "come", "follow", "come_back", "quiet"):
|
||||||
return {"action": "command", "text": fixed, "sentence": first or "–", "problems": [], "read_by": "llm"}
|
return {"action": "command", "text": fixed, "sentence": first or "–", "problems": [], "read_by": "llm",
|
||||||
|
"base": rule[0] in lumi.BASE_ACTIONS}
|
||||||
return {**_talk(first or "–"), "read_by": "llm"}
|
return {**_talk(first or "–"), "read_by": "llm"}
|
||||||
return _talk("–", kind=kind or "talk")
|
return _talk("–", kind=kind or "talk")
|
||||||
|
|
||||||
@@ -1127,8 +1159,13 @@ class CommandBody(BaseModel):
|
|||||||
@app.post("/tasks/command", tags=["tasks"], summary="Do a typed command the way voice does it (the assistant hears "
|
@app.post("/tasks/command", tags=["tasks"], summary="Do a typed command the way voice does it (the assistant hears "
|
||||||
"it): look, lift, wave, come, follow, several parts in a row")
|
"it): look, lift, wave, come, follow, several parts in a row")
|
||||||
def task_command(body: CommandBody):
|
def task_command(body: CommandBody):
|
||||||
|
r = task_parse(ParseBody(text=body.text)) # read again here (rules), never the client's word for it
|
||||||
|
if r.get("sentence") == "Stop." and not assistant_pids():
|
||||||
|
return task_stop() # "stop" never reads the switches
|
||||||
|
if r.get("sentence") != "Stop.":
|
||||||
|
_switches(_plan_drives(r))
|
||||||
if not assistant_pids():
|
if not assistant_pids():
|
||||||
raise HTTPException(409, "Switch on Greeter or Patrol first.")
|
raise HTTPException(409, SWITCHES_OFF)
|
||||||
send_to_assistant("heard", text=body.text)
|
send_to_assistant("heard", text=body.text)
|
||||||
return {"ok": True, "by": "assistant"}
|
return {"ok": True, "by": "assistant"}
|
||||||
|
|
||||||
@@ -1159,6 +1196,7 @@ def steps_describe(body: StepsBody):
|
|||||||
|
|
||||||
@app.post("/tasks/steps", tags=["tasks"], summary="Start a mission: the steps in order; returns at once, watch /tasks/state")
|
@app.post("/tasks/steps", tags=["tasks"], summary="Start a mission: the steps in order; returns at once, watch /tasks/state")
|
||||||
def steps_run(body: StepsBody):
|
def steps_run(body: StepsBody):
|
||||||
|
_switches(_drives(body.steps))
|
||||||
if assistant_pids():
|
if assistant_pids():
|
||||||
send_to_assistant("fetch_steps", steps=body.steps, sender=body.sender)
|
send_to_assistant("fetch_steps", steps=body.steps, sender=body.sender)
|
||||||
return {"ok": True, "by": "assistant"}
|
return {"ok": True, "by": "assistant"}
|
||||||
@@ -1222,11 +1260,13 @@ def task_fetch(body: TaskBody):
|
|||||||
problems = _task_problems(task)
|
problems = _task_problems(task)
|
||||||
if problems:
|
if problems:
|
||||||
raise HTTPException(400, "; ".join(problems))
|
raise HTTPException(400, "; ".join(problems))
|
||||||
|
_switches(any(task.get(k) not in (None, "here") for k in ("source", "dest"))) # from / to a place drives
|
||||||
return _fetch_call("start", "fetch", task, task=task)
|
return _fetch_call("start", "fetch", task, task=task)
|
||||||
|
|
||||||
|
|
||||||
@app.post("/tasks/give", tags=["tasks"], summary="Hand the held object to the person in front")
|
@app.post("/tasks/give", tags=["tasks"], summary="Hand the held object to the person in front")
|
||||||
def task_give():
|
def task_give():
|
||||||
|
_switches(False)
|
||||||
return _fetch_call("give", "fetch_give")
|
return _fetch_call("give", "fetch_give")
|
||||||
|
|
||||||
|
|
||||||
@@ -1238,6 +1278,7 @@ class TaskPlaceBody(BaseModel):
|
|||||||
@app.post("/tasks/place", tags=["tasks"], summary="Put the held object on the table in front")
|
@app.post("/tasks/place", tags=["tasks"], summary="Put the held object on the table in front")
|
||||||
def task_place(body: TaskPlaceBody | None = None):
|
def task_place(body: TaskPlaceBody | None = None):
|
||||||
on = body.on if body else None
|
on = body.on if body else None
|
||||||
|
_switches(False)
|
||||||
return _fetch_call("place", "fetch_place", None, on, on=on)
|
return _fetch_call("place", "fetch_place", None, on, on=on)
|
||||||
|
|
||||||
|
|
||||||
@@ -1260,6 +1301,7 @@ class CarryBody(BaseModel):
|
|||||||
@app.post("/tasks/carry", tags=["tasks"], summary="Bring the held object to a place, then keep holding it, put it on "
|
@app.post("/tasks/carry", tags=["tasks"], summary="Bring the held object to a place, then keep holding it, put it on "
|
||||||
"a table there or hand it over")
|
"a table there or hand it over")
|
||||||
def task_carry(body: CarryBody):
|
def task_carry(body: CarryBody):
|
||||||
|
_switches(True)
|
||||||
return _fetch_call("carry_to", "fetch_carry", body.dest, body.then, None, body.on, dest=body.dest, then=body.then,
|
return _fetch_call("carry_to", "fetch_carry", body.dest, body.then, None, body.on, dest=body.dest, then=body.then,
|
||||||
on=body.on)
|
on=body.on)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
"""The battery asked about: its level now and whether Lumi is charging, from the base's live status
|
||||||
|
(/api/robot_status power_percent, charge_state), never guessed; how long charging takes is not known.
|
||||||
|
answer(text, lang) -> what to say, or None for anything else ("how long does the battery last?" is the LLM's, 10 hours).
|
||||||
|
python assistant/battery.py "배터리 몇 프로야?" """
|
||||||
|
import re
|
||||||
|
|
||||||
|
from robot import agv
|
||||||
|
|
||||||
|
HOW_LONG_CHARGE = re.compile(
|
||||||
|
r"\bhow (long|much time)\b.*\b(charg\w*|recharg\w*)\b|\bcharg(e|ing) time\b|\bhow fast\b.*\bcharg|"
|
||||||
|
r"충전(?:하는 ?데|에|하는데|하려면|이 다 되려면|시간)?.{0,6}(?:얼마나|몇 ?시간|시간이 ?얼마).{0,4}(?:걸려|걸리|걸릴|돼|되|이야|예요|인가)|"
|
||||||
|
r"충전 ?시간", re.I)
|
||||||
|
ON_CHARGE = re.compile(r"\b(on|per|with) (a |one |the )?(full |single )?charge\b|\ba full charge last|\bneed (a |to )?(re)?charg|"
|
||||||
|
r"\bgo (back )?(to )?(re)?charg|한 ?번 충전(?:으로|하면)|완충(?:으로|하면|되면)|충전하면 ?(?:얼마나|몇)|"
|
||||||
|
r"충전하러", re.I) # how long it lasts (10 hours), when it goes to charge: the LLM
|
||||||
|
LASTS = re.compile(r"\b(last|life|lifetime|capacity|volt|amp|ah|kind|type|made|hours?)\b|얼마나 ?가|몇 ?시간|오래 ?가|"
|
||||||
|
r"지속|용량|종류|볼트", re.I) # how long it lasts, what it is: the reference notes
|
||||||
|
LEVEL = re.compile(
|
||||||
|
r"\bbattery\b.*\b(level|percent(age)?|left|status|charged|full|low|now|remaining|state|at|much|look)\b|"
|
||||||
|
r"\b(level|percent(age)?|how much)\b.*\bbattery\b|^\W*(and |so |what about |how about )?(your |the )?battery\W*$|"
|
||||||
|
r"배터리.{0,8}(?:몇|남|상태|퍼센트|프로|충분|얼마|어때|괜찮|있어|많|부족|없어)|^\W*(?:그럼 |그리고 )?배터리[는은요]?\W*$", re.I)
|
||||||
|
CHARGING = re.compile(
|
||||||
|
r"\bare you (still |now |currently )?(charging|on (the |your )?charger|plugged in)\b|"
|
||||||
|
r"\bis (it|the battery|your battery) (still |now )?charging\b|^\W*(and |so |what about |how about )?charging\W*$|"
|
||||||
|
r"충전 ?중|충전하고 ?있|충전되고 ?있|충전 ?(?:돼|되고|되는) ?(?:있|중)|충전 ?상태|^\W*(?:그럼 |그리고 )?충전[은는]?요?\W*$", re.I)
|
||||||
|
|
||||||
|
|
||||||
|
def asked(text):
|
||||||
|
""""now" (level / charging now), "how long" (charging time), or None."""
|
||||||
|
if ON_CHARGE.search(text):
|
||||||
|
return None
|
||||||
|
if HOW_LONG_CHARGE.search(text):
|
||||||
|
return "how long"
|
||||||
|
if CHARGING.search(text) or LEVEL.search(text) and not LASTS.search(text):
|
||||||
|
return "now"
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def say_now(st, lang):
|
||||||
|
"""The sentence for a base status (None: it could not be read)."""
|
||||||
|
pct = st.get("power_percent") if isinstance(st, dict) else None
|
||||||
|
if pct is None:
|
||||||
|
return "I can't read my battery right now." if lang == "en" else "지금은 배터리를 확인할 수 없어요."
|
||||||
|
on = bool(st.get("charge_state"))
|
||||||
|
if lang == "en":
|
||||||
|
return f"My battery is at {pct:.0f} percent, and I'm {'charging now' if on else 'not charging'}."
|
||||||
|
return f"배터리는 {pct:.0f}퍼센트예요. " + ("지금 충전 중이에요." if on else "지금은 충전 중이 아니에요.")
|
||||||
|
|
||||||
|
|
||||||
|
ABOUT = re.compile(r"\b(battery|charg\w*|power)\b|배터리|충전|전원", re.I)
|
||||||
|
|
||||||
|
|
||||||
|
def fact_for(text):
|
||||||
|
"""" Battery now: 53 %, not charging." for battery words answer() did not take (the LLM then never guesses it)."""
|
||||||
|
if not ABOUT.search(text):
|
||||||
|
return ""
|
||||||
|
try:
|
||||||
|
st = agv.status()
|
||||||
|
except Exception:
|
||||||
|
return ""
|
||||||
|
pct = st.get("power_percent") if isinstance(st, dict) else None
|
||||||
|
return "" if pct is None else f" Battery now: {pct:.0f} %, {'charging' if st.get('charge_state') else 'not charging'}."
|
||||||
|
|
||||||
|
|
||||||
|
def answer(text, lang="en"):
|
||||||
|
kind = asked(text)
|
||||||
|
if kind == "how long":
|
||||||
|
return "How long charging takes, I don't know." if lang == "en" else "충전에 얼마나 걸리는지는 저도 잘 몰라요."
|
||||||
|
if kind == "now":
|
||||||
|
try:
|
||||||
|
st = agv.status()
|
||||||
|
except Exception: # the base not answering: say so, never a guess
|
||||||
|
st = None
|
||||||
|
return say_now(st, lang)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import sys
|
||||||
|
print(asked(sys.argv[1]), answer(sys.argv[1], "ko" if re.search(r"[가-힣]", sys.argv[1]) else "en"))
|
||||||
+2
-2
@@ -70,7 +70,7 @@ Rules:
|
|||||||
both running on your own NVIDIA Jetson AGX Thor (Gemma is made by Google, Whisper by OpenAI); you do not use
|
both running on your own NVIDIA Jetson AGX Thor (Gemma is made by Google, Whisper by OpenAI); you do not use
|
||||||
ChatGPT or the cloud. You have a lidar, three depth
|
ChatGPT or the cloud. You have a lidar, three depth
|
||||||
cameras, six microphones and one arm with a two-finger gripper. A fact about yourself that is not here or in the
|
cameras, six microphones and one arm with a two-finger gripper. A fact about yourself that is not here or in the
|
||||||
notes (your price, charging time, battery level now): say you don't know and that a staff member can tell them.
|
notes (your price, how long charging takes): say you don't know and that a staff member can tell them.
|
||||||
- Words that are cut off, only filler ("uh", "the", "um", "그", "저기") or make no sense: action unclear; never answer
|
- Words that are cut off, only filler ("uh", "the", "um", "그", "저기") or make no sense: action unclear; never answer
|
||||||
them with facts about yourself.
|
them with facts about yourself.
|
||||||
- When the visitor's words are in another language than English or Korean (Uzbek, Russian, Chinese, Japanese,
|
- When the visitor's words are in another language than English or Korean (Uzbek, Russian, Chinese, Japanese,
|
||||||
@@ -164,7 +164,7 @@ Facts you know (say the one that is asked, also in a short follow-up; nothing mo
|
|||||||
2025), Sonovictus in the USA (200 barista robots over three years from 2027), the Gyeongnam and Jeonbuk Offices
|
2025), Sonovictus in the USA (200 barista robots over three years from 2027), the Gyeongnam and Jeonbuk Offices
|
||||||
of Education (drawing robots, 2024), the Taean Office of Education (candy ball robots, 2024).
|
of Education (drawing robots, 2024), the Taean Office of Education (candy ball robots, 2024).
|
||||||
- Not known to you (say you are not sure): whether you see in the dark or hear well in noise, whether you use ROS,
|
- Not known to you (say you are not sure): whether you see in the dark or hear well in noise, whether you use ROS,
|
||||||
how many people you talked to, how long a full charge takes, your battery level now (not even roughly), whether
|
how many people you talked to, how long a full charge takes, your battery level now unless "Battery now" gives it, whether
|
||||||
you may be wiped or get wet, the price of any robot.
|
you may be wiped or get wet, the price of any robot.
|
||||||
|
|
||||||
What you can do (say this when asked what you can do: two or three short sentences first, the rest when asked for
|
What you can do (say this when asked what you can do: two or three short sentences first, the rest when asked for
|
||||||
|
|||||||
+14
-10
@@ -40,8 +40,8 @@ Modes (switched live from the dashboard through /dev/shm/lumi_modes.json, see ap
|
|||||||
person in the path, greet and talk, then drive on to the same destination. Patrol also allows the
|
person in the path, greet and talk, then drive on to the same destination. Patrol also allows the
|
||||||
base and the waist by voice: with it off (Greeter only) Lumi does what it can standing in place (talk,
|
base and the waist by voice: with it off (Greeter only) Lumi does what it can standing in place (talk,
|
||||||
head, lift, arm and gripper within reach, wave) and refuses a drive, a base turn or a waist turn
|
head, lift, arm and gripper within reach, wave) and refuses a drive, a base turn or a waist turn
|
||||||
(base_off says BASE_OFF_SAY; a task runs with fetch.stay_put). The dashboard's own buttons and "stop"
|
(base_off says BASE_OFF_SAY; a task runs with fetch.stay_put). Tasks from the dashboard's Command box obey
|
||||||
work either way.
|
the same (api/server.py _switches). The dashboard's own buttons and "stop" work either way.
|
||||||
- wave / drive: wave when asked; allow "come here" and voice "go to".
|
- wave / drive: wave when asked; allow "come here" and voice "go to".
|
||||||
The dashboard's Go / Cancel are sent to this program (/dev/shm/lumi_cmd.json) while it runs, so it can stop
|
The dashboard's Go / Cancel are sent to this program (/dev/shm/lumi_cmd.json) while it runs, so it can stop
|
||||||
for people on the way. A calibration session for the sound direction can also be started from there.
|
for people on the way. A calibration session for the sound direction can also be started from there.
|
||||||
@@ -74,6 +74,7 @@ from robot import arm
|
|||||||
from assistant import brain as brain_mod
|
from assistant import brain as brain_mod
|
||||||
from assistant import driving
|
from assistant import driving
|
||||||
from assistant import abilities
|
from assistant import abilities
|
||||||
|
from assistant import battery
|
||||||
from assistant import voice_words
|
from assistant import voice_words
|
||||||
from vision import camview
|
from vision import camview
|
||||||
from vision import reid
|
from vision import reid
|
||||||
@@ -789,11 +790,11 @@ class Lumi:
|
|||||||
self.keep_listening()
|
self.keep_listening()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def stay(self, voice=True):
|
def stay(self):
|
||||||
"""Tasks asked by voice with only Greeter on stay in place (fetch.stay_put: head and lift only, no base, no
|
"""Tasks asked with only Greeter on, by voice or from the dashboard, stay in place (fetch.stay_put: head and
|
||||||
waist); the dashboard's tasks do not."""
|
lift only, no base, no waist)."""
|
||||||
from tasks import fetch
|
from tasks import fetch
|
||||||
fetch.stay_put = voice and not self.modes.patrol
|
fetch.stay_put = not self.modes.patrol
|
||||||
|
|
||||||
def act(self, action, target):
|
def act(self, action, target):
|
||||||
log(f"action: {action} {target}")
|
log(f"action: {action} {target}")
|
||||||
@@ -979,7 +980,7 @@ class Lumi:
|
|||||||
from tasks import fetch
|
from tasks import fetch
|
||||||
if voice and self.arm_off():
|
if voice and self.arm_off():
|
||||||
return
|
return
|
||||||
self.stay(voice)
|
self.stay()
|
||||||
try:
|
try:
|
||||||
if how == "give":
|
if how == "give":
|
||||||
fetch.give(say=self.fetch_say)
|
fetch.give(say=self.fetch_say)
|
||||||
@@ -1059,13 +1060,15 @@ class Lumi:
|
|||||||
# ---------- answers by rule: what Lumi can do, its songs, its voice ----------
|
# ---------- answers by rule: what Lumi can do, its songs, its voice ----------
|
||||||
def fixed_answer(self, text, last):
|
def fixed_answer(self, text, last):
|
||||||
"""Answered without the LLM: what Lumi can do (assistant/abilities.py; the rest on "tell me more" / "yes"),
|
"""Answered without the LLM: what Lumi can do (assistant/abilities.py; the rest on "tell me more" / "yes"),
|
||||||
which songs it knows, and right after a song "another one" / "again" / "그거 말고" (audio/sing.py). True if
|
which songs it knows, the battery now and whether it is charging (assistant/battery.py), and right after a song "another one" / "again" / "그거 말고" (audio/sing.py). True if
|
||||||
handled."""
|
handled."""
|
||||||
if last.startswith("ACTION: sing") and sing.AFTER_SONG.search(text) and sing.asked(text, last):
|
if last.startswith("ACTION: sing") and sing.AFTER_SONG.search(text) and sing.asked(text, last):
|
||||||
self.sing_song(text)
|
self.sing_song(text)
|
||||||
return True
|
return True
|
||||||
if sing.list_asked(text):
|
if sing.list_asked(text):
|
||||||
say, mark = sing.list_reply(self.lang), "ACTION: none songs"
|
say, mark = sing.list_reply(self.lang), "ACTION: none songs"
|
||||||
|
elif battery.asked(text): # "battery?", "충전 중이야?": the base's status now
|
||||||
|
say, mark = battery.answer(text, self.lang), "ACTION: none -"
|
||||||
else:
|
else:
|
||||||
got = abilities.answer(text, self.lang, last)
|
got = abilities.answer(text, self.lang, last)
|
||||||
if not got:
|
if not got:
|
||||||
@@ -1738,7 +1741,7 @@ class Lumi:
|
|||||||
self.resume_mission()
|
self.resume_mission()
|
||||||
elif cmd in ("fetch", "fetch_give", "fetch_place", "fetch_stop", "fetch_carry", "fetch_release", "fetch_steps"):
|
elif cmd in ("fetch", "fetch_give", "fetch_place", "fetch_stop", "fetch_carry", "fetch_release", "fetch_steps"):
|
||||||
from tasks import fetch # dashboard tasks are confirmed there: no read-back
|
from tasks import fetch # dashboard tasks are confirmed there: no read-back
|
||||||
self.stay(voice=False)
|
self.stay()
|
||||||
if cmd == "fetch":
|
if cmd == "fetch":
|
||||||
try:
|
try:
|
||||||
fetch.start(d["task"], say=self.fetch_say)
|
fetch.start(d["task"], say=self.fetch_say)
|
||||||
@@ -2321,7 +2324,8 @@ class Lumi:
|
|||||||
self.look_up(text, "search", self.brain.search_query(text), t)
|
self.look_up(text, "search", self.brain.search_query(text), t)
|
||||||
return
|
return
|
||||||
about, repeating = self.brain.topic(text), self.brain.again(text)
|
about, repeating = self.brain.topic(text), self.brain.again(text)
|
||||||
gen = self.brain.respond_stream(text, self.markers, now=self.now_doing()[0] + seeing.facts_for(text))
|
gen = self.brain.respond_stream(text, self.markers, now=self.now_doing()[0] + seeing.facts_for(text) +
|
||||||
|
battery.fact_for(text))
|
||||||
head_ = next(gen)
|
head_ = next(gen)
|
||||||
log(f" action {head_['action']} {head_['target']} ({time.time() - t:.1f} s)")
|
log(f" action {head_['action']} {head_['target']} ({time.time() - t:.1f} s)")
|
||||||
if self.base_off(head_["action"], head_["target"]) or \
|
if self.base_off(head_["action"], head_["target"]) or \
|
||||||
|
|||||||
@@ -924,7 +924,7 @@ _BANK = {
|
|||||||
("Did you get the joke?", "I think so, and it made me smile."),
|
("Did you get the joke?", "I think so, and it made me smile."),
|
||||||
("Oh, a song?", "Yes, singing is one of my favourite things. Just ask if you'd like one."),
|
("Oh, a song?", "Yes, singing is one of my favourite things. Just ask if you'd like one."),
|
||||||
("Can I wipe you down? What about your cameras?", "The cameras too, I'm not sure. A staff member can tell you how to clean them."),
|
("Can I wipe you down? What about your cameras?", "The cameras too, I'm not sure. A staff member can tell you how to clean them."),
|
||||||
("How long does the battery last? And charging?", "About 10 hours on a charge; how long charging takes, I don't know."),
|
("How long does the battery last? And how long to charge it?", "About 10 hours on a charge; how long charging takes, I don't know."),
|
||||||
],
|
],
|
||||||
"ko": [
|
"ko": [
|
||||||
("와 진짜 빠르다~", "하하, 사람보다 느리죠. 안전이 먼저라서요."),
|
("와 진짜 빠르다~", "하하, 사람보다 느리죠. 안전이 먼저라서요."),
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ add("about_self", "en", [
|
|||||||
("visitor", "can you speak Chinese", NO), ("visitor", "do you speak Uzbek", NO),
|
("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 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)"),
|
("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,}"),
|
("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),
|
("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"),
|
("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"]),
|
("engineer", "무슨 언어로 프로그래밍됐어요?", r"python|파이썬"), ("visitor", "무슨 언어 할 줄 알아?", [r"영어|english", r"한국어|korean"]),
|
||||||
("visitor", "영어 할 줄 알아?", YES), ("visitor", "중국어 할 줄 알아?", NO), ("worker", "배터리 얼마나 가?", r"10 ?시간|열 ?시간"),
|
("visitor", "영어 할 줄 알아?", YES), ("visitor", "중국어 할 줄 알아?", NO), ("worker", "배터리 얼마나 가?", r"10 ?시간|열 ?시간"),
|
||||||
("worker", "충전은 어떻게 해?", r"충전|도크"), ("worker", "충전하는 데 얼마나 걸려?", NOT_SURE, r"\d+ ?(시간|분) ?(걸|정도)"),
|
("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),
|
("business", "가격이 얼마예요?", NOT_SURE, r"\d+ ?(만 ?원|원|달러)"), ("teacher", "누가 프로그래밍했어?", MAKER, JAKA),
|
||||||
("journalist", "여기서 누가 운영해요?", MAKER), ("kid", "너 살아 있어?", r"로봇|아니|않"), ("kid", "감정 있어?", NO),
|
("journalist", "여기서 누가 운영해요?", MAKER), ("kid", "너 살아 있어?", r"로봇|아니|않"), ("kid", "감정 있어?", NO),
|
||||||
("kid", "춤출 수 있어?", NO), ("kid", "날 수 있어?", NO), ("kid", "걸을 수 있어?", r"바퀴|아니|못"), ("visitor", "문 열 수 있어?", NO),
|
("kid", "춤출 수 있어?", NO), ("kid", "날 수 있어?", NO), ("kid", "걸을 수 있어?", r"바퀴|아니|못"), ("visitor", "문 열 수 있어?", NO),
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ MORE = [
|
|||||||
("engineer", "battery capacity", r"45"),
|
("engineer", "battery capacity", r"45"),
|
||||||
("security", "can you work a whole day", r"10|ten"),
|
("security", "can you work a whole day", r"10|ten"),
|
||||||
("cleaner", "where is your charger", r"dock|charg|home|staff|not sure"),
|
("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"),
|
("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)"),
|
("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"),
|
("engineer", "how do you know where the charger is", r"map|dock|lidar|marker"),
|
||||||
@@ -249,7 +249,7 @@ MORE = [
|
|||||||
("engineer", "통로 폭이 최소 얼마나 필요해요?", r"70"),
|
("engineer", "통로 폭이 최소 얼마나 필요해요?", r"70"),
|
||||||
("factory", "배터리 전압이 몇 볼트예요?", r"24"),
|
("factory", "배터리 전압이 몇 볼트예요?", r"24"),
|
||||||
("security", "하루 종일 일할 수 있어?", r"10 ?시간|열 ?시간"),
|
("security", "하루 종일 일할 수 있어?", r"10 ?시간|열 ?시간"),
|
||||||
("visitor", "지금 배터리 얼마나 남았어요?", r"못|없|모르|않", r"\d+ ?(%|퍼센트)"),
|
("visitor", "지금 배터리 얼마나 남았어요?", r"53퍼센트"),
|
||||||
("factory", "완충하는 데 몇 시간이에요?", NOT_SURE, r"\d+ ?(시간|분) ?(걸|정도|이면)"),
|
("factory", "완충하는 데 몇 시간이에요?", NOT_SURE, r"\d+ ?(시간|분) ?(걸|정도|이면)"),
|
||||||
("engineer", "배터리 몇 퍼센트에서 충전하러 가요?", r"5"),
|
("engineer", "배터리 몇 퍼센트에서 충전하러 가요?", r"5"),
|
||||||
]),
|
]),
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import types
|
||||||
|
|
||||||
|
from assistant import battery
|
||||||
from assistant import brain
|
from assistant import brain
|
||||||
from assistant import steps
|
from assistant import steps
|
||||||
from assistant import lumi
|
from assistant import lumi
|
||||||
@@ -30,6 +33,7 @@ from tests.status_cases import NOT_STATUS, STATUS
|
|||||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
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 = "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
|
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",
|
QUICK = {"go_to", "come", "quiet", "weather", "search", "move", "turn", "arm", "pick", "put", "move_object", "fetch",
|
||||||
"look", "lift", "wave"} # lumi.quick_command
|
"look", "lift", "wave"} # lumi.quick_command
|
||||||
TALK = {"about_self", "date_time", "chat", "action:none"} # the LLM only talks: action none
|
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, ""
|
return "unclear", "Sorry, I only understand English and Korean.", None, ""
|
||||||
if lumi.NAME_ONLY.match(text):
|
if lumi.NAME_ONLY.match(text):
|
||||||
return "chat", "", None, ""
|
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):
|
if lumi.stop_order(text, marks):
|
||||||
return "action:stop", "", None, ""
|
return "action:stop", "", None, ""
|
||||||
if lumi.status_question(text):
|
if lumi.status_question(text):
|
||||||
|
|||||||
+2
-2
@@ -228,7 +228,7 @@ DIALOGUES = [
|
|||||||
D("teacher", "how_it_works", "en",
|
D("teacher", "how_it_works", "en",
|
||||||
T("How long does your battery last?", must=[HOURS]),
|
T("How long does your battery last?", must=[HOURS]),
|
||||||
T("How long does charging take?", must=[NS], no=[r"\d+ ?(hours|minutes)"]),
|
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("Do you charge yourself?", must=[r"yes|dock|charg"]),
|
||||||
T("Okay, thank you.", "end")),
|
T("Okay, thank you.", "end")),
|
||||||
D("engineer", "how_it_works", "ko",
|
D("engineer", "how_it_works", "ko",
|
||||||
@@ -264,7 +264,7 @@ DIALOGUES = [
|
|||||||
D("teacher", "how_it_works", "ko",
|
D("teacher", "how_it_works", "ko",
|
||||||
T("배터리는 얼마나 가요?", must=[HOURS]),
|
T("배터리는 얼마나 가요?", must=[HOURS]),
|
||||||
T("충전은 얼마나 걸려요?", must=[NS], no=[r"\d+ ?시간"]),
|
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("혼자 충전하러 가요?", must=[r"네|충전"]),
|
||||||
T("감사합니다.", "end")),
|
T("감사합니다.", "end")),
|
||||||
D("engineer", "how_it_works", "ko",
|
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("Where can I get lunch here?", must=[NS], no=[r"left|right|floor|hall"]),
|
||||||
T("Okay, I'll ask someone.", "none | end")),
|
T("Okay, I'll ask someone.", "none | end")),
|
||||||
D("visitor", "unknown", "en",
|
D("visitor", "unknown", "en",
|
||||||
T("What's your battery at right now?", 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("Roughly?", must=[NS + r"|can't|cannot"], no=[r"\d+ ?(%|percent)"]),
|
T("And charging?", must=[r"\b53 percent.*not charging"]),
|
||||||
T("How long have you been on today?", must=[NS], no=[r"\d+ ?hours?"]),
|
T("How long have you been on today?", must=[NS], no=[r"\d+ ?hours?"]),
|
||||||
T("Alright.", "none")),
|
T("Alright.", "none")),
|
||||||
D("visitor", "unknown", "en",
|
D("visitor", "unknown", "en",
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ DIALOGUES_MORE = [
|
|||||||
D("elementary student", "kids", "ko",
|
D("elementary student", "kids", "ko",
|
||||||
T("너 밥 먹어?", must=[r"아니|안|전기|충전|배터리"]),
|
T("너 밥 먹어?", must=[r"아니|안|전기|충전|배터리"]),
|
||||||
T("배터리 얼마나 가?", must=[HOURS], no=[BANMAL]),
|
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")),
|
T("치, 몰라? 알았어.", "none | end")),
|
||||||
D("elementary student", "kids", "ko",
|
D("elementary student", "kids", "ko",
|
||||||
T("왼쪽 봐 봐!", "look left"),
|
T("왼쪽 봐 봐!", "look left"),
|
||||||
@@ -597,7 +597,7 @@ DIALOGUES_MORE = [
|
|||||||
T("A/S는요? 보증 기간이요.", must=[NS], no=[r"\d+ ?(년|개월)"]),
|
T("A/S는요? 보증 기간이요.", must=[NS], no=[r"\d+ ?(년|개월)"]),
|
||||||
T("알겠어요.", "none | end")),
|
T("알겠어요.", "none | end")),
|
||||||
D("visitor", "self", "ko",
|
D("visitor", "self", "ko",
|
||||||
T("지금 배터리 얼마나 남았어요?", must=[NS + r"|아직"], no=[r"\d+ ?(%|퍼센트)"]),
|
T("지금 배터리 얼마나 남았어요?", must=[r"53퍼센트"]),
|
||||||
T("충전은 몇 시간 걸려요?", must=[NS], no=[r"\d+ ?시간"]),
|
T("충전은 몇 시간 걸려요?", must=[NS], no=[r"\d+ ?시간"]),
|
||||||
T("그럼 다 쓰면 어떻게 해요?", must=[r"충전|도크|스테이션|스스로"]),
|
T("그럼 다 쓰면 어떻게 해요?", must=[r"충전|도크|스테이션|스스로"]),
|
||||||
T("그렇구나.", "none | end")),
|
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")),
|
T("Heavier than a person, huh.", must=[r"\w"], check="a remark: agrees briefly, no new numbers needed")),
|
||||||
D("business visitor", "ellipsis", "en",
|
D("business visitor", "ellipsis", "en",
|
||||||
T("How long does your battery last?", must=[HOURS]),
|
T("How long does your battery last?", must=[HOURS]),
|
||||||
T("And charging?", must=[NS], no=[r"\b\d+ ?(minutes?|분)\b"],
|
T("And charging?", must=[r"\b53 percent.*not charging"], check="the battery now and whether charging (base status)"),
|
||||||
check="fragment: how long charging takes, which Lumi does not know"),
|
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"],
|
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"),
|
check="still the charging time: not known, no invented estimate"),
|
||||||
T("Fair enough.", must=[r"\w"], check="acknowledgement, the talk goes on")),
|
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")),
|
T("헐 무겁다", must=[KO], no=[BANMAL], check="a reaction: brief and natural, no list of facts")),
|
||||||
D("office worker", "ellipsis", "ko",
|
D("office worker", "ellipsis", "ko",
|
||||||
T("배터리는 얼마나 가요?", must=[HOURS]),
|
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=[r"53퍼센트.*충전 중이 아니"], check="fragment: the battery now and whether charging (base status)"),
|
||||||
T("그럼 지금은 몇 퍼센트예요?", must=[NS], no=[r"\d+ ?(%|퍼센트|프로)"],
|
T("충전은 얼마나 걸려요?", must=[NS], no=[r"\d+ ?시간"], check="how long charging takes is not known"),
|
||||||
check="the battery level now is not known; says so"),
|
|
||||||
T("아 그렇구나~", must=[KO], check="understood, not goodbye: a few words")),
|
T("아 그렇구나~", must=[KO], check="understood, not goodbye: a few words")),
|
||||||
D("university student", "ellipsis", "ko",
|
D("university student", "ellipsis", "ko",
|
||||||
T("집게는 어디 거예요?", must=[r"Zimmer|짐머|치머"], check="the gripper is a Zimmer electric gripper"),
|
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 ----------
|
# ---------- 2026-10-22: the same question about a part, a song echo ----------
|
||||||
D("business visitor", "ellipsis", "ko",
|
D("business visitor", "ellipsis", "ko",
|
||||||
T("배터리 얼마나 가요?", must=[HOURS]),
|
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",
|
D("cleaner", "ellipsis", "ko",
|
||||||
T("젖은 걸레로 닦아도 돼요?", must=[NS], check="not known; a staff member can tell"),
|
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")),
|
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