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:
@@ -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
|
||||
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
|
||||
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
|
||||
them with facts about yourself.
|
||||
- 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
|
||||
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,
|
||||
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.
|
||||
|
||||
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
|
||||
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
|
||||
(base_off says BASE_OFF_SAY; a task runs with fetch.stay_put). The dashboard's own buttons and "stop"
|
||||
work either way.
|
||||
(base_off says BASE_OFF_SAY; a task runs with fetch.stay_put). Tasks from the dashboard's Command box obey
|
||||
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".
|
||||
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.
|
||||
@@ -74,6 +74,7 @@ from robot import arm
|
||||
from assistant import brain as brain_mod
|
||||
from assistant import driving
|
||||
from assistant import abilities
|
||||
from assistant import battery
|
||||
from assistant import voice_words
|
||||
from vision import camview
|
||||
from vision import reid
|
||||
@@ -789,11 +790,11 @@ class Lumi:
|
||||
self.keep_listening()
|
||||
return True
|
||||
|
||||
def stay(self, voice=True):
|
||||
"""Tasks asked by voice with only Greeter on stay in place (fetch.stay_put: head and lift only, no base, no
|
||||
waist); the dashboard's tasks do not."""
|
||||
def stay(self):
|
||||
"""Tasks asked with only Greeter on, by voice or from the dashboard, stay in place (fetch.stay_put: head and
|
||||
lift only, no base, no waist)."""
|
||||
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):
|
||||
log(f"action: {action} {target}")
|
||||
@@ -979,7 +980,7 @@ class Lumi:
|
||||
from tasks import fetch
|
||||
if voice and self.arm_off():
|
||||
return
|
||||
self.stay(voice)
|
||||
self.stay()
|
||||
try:
|
||||
if how == "give":
|
||||
fetch.give(say=self.fetch_say)
|
||||
@@ -1059,13 +1060,15 @@ class Lumi:
|
||||
# ---------- answers by rule: what Lumi can do, its songs, its voice ----------
|
||||
def fixed_answer(self, text, last):
|
||||
"""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."""
|
||||
if last.startswith("ACTION: sing") and sing.AFTER_SONG.search(text) and sing.asked(text, last):
|
||||
self.sing_song(text)
|
||||
return True
|
||||
if sing.list_asked(text):
|
||||
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:
|
||||
got = abilities.answer(text, self.lang, last)
|
||||
if not got:
|
||||
@@ -1738,7 +1741,7 @@ class Lumi:
|
||||
self.resume_mission()
|
||||
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
|
||||
self.stay(voice=False)
|
||||
self.stay()
|
||||
if cmd == "fetch":
|
||||
try:
|
||||
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)
|
||||
return
|
||||
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)
|
||||
log(f" action {head_['action']} {head_['target']} ({time.time() - t:.1f} s)")
|
||||
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."),
|
||||
("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."),
|
||||
("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": [
|
||||
("와 진짜 빠르다~", "하하, 사람보다 느리죠. 안전이 먼저라서요."),
|
||||
|
||||
Reference in New Issue
Block a user