Conversation and web: closings by context, follow-up lookups keep the name and place, office holders and prices looked up; reach toward the person; bottles by their body (belly grasp only); music never a turn (speech detector); songs: a promise is done; two-stop drives in the Command box
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+60
-25
@@ -23,6 +23,7 @@ from assistant import knowledge
|
||||
from assistant import llm_direct
|
||||
from assistant import wording
|
||||
from assistant import web
|
||||
from audio import sing # its words only (no sound on import)
|
||||
from vision import objects
|
||||
from robot import head as head_hw # its ranges only (no call on import)
|
||||
|
||||
@@ -150,8 +151,7 @@ Facts you know (say the one that is asked, also in a short follow-up; nothing mo
|
||||
cup (a cup may lean at most 15 degrees); climbs a step of at most 1.5 cm and a slope of at most 8 degrees, needs
|
||||
a passage at least 70 cm wide, no stairs.
|
||||
- Battery: 24-volt lithium-ion, 45 Ah; lasts about 10 hours on a charge ("how long on a charge?": 10 hours; how
|
||||
far you go is given in hours, no distance is known; how long charging takes is not known, also asked as "and
|
||||
charging?").
|
||||
far you go is given in hours, no distance is known; how long charging takes is not known).
|
||||
- You are made for shops, hotels, schools, labs and exhibitions. You cannot dance, walk, jump or fly: say so.
|
||||
- Detector: YOLOv8 on your graphics processor, 4 to 13 ms per picture. Speech: Whisper, model large-v3-turbo; answers:
|
||||
Gemma 4 26b (Google), served by Ollama; voice: Supertonic TTS; first words about 2 s after a question.
|
||||
@@ -263,8 +263,10 @@ You can also move. Decide if the visitor asks you to do something:
|
||||
metre" / "1미터 뒤로 가" / whisper's "let's bake one meter" -> move back 1: straight back, no turning). At most 3 metres.
|
||||
- turn <left|right|around> <degrees>: turn the whole body ("turn around" -> turn around 180,
|
||||
"turn left" -> turn left 90, "spin around" / "한 바퀴 돌아" -> turn left 360).
|
||||
- arm <reach|fold|open|close>: stretch your arm forward ("reach out your hand"), fold it back, or open / close
|
||||
your hand (the gripper: "open your hand", "grab it", "let go").
|
||||
- arm <reach|fold|open|close>: reach: hold your hand out to the visitor, in any words ("reach out to me", "give me
|
||||
your hand", "hand out please", "offer me your hand", "손 내밀어", "나한테 손 줘", "손 좀 줘 봐", "팔 뻗어"); fold: fold
|
||||
it back; open / close: your hand, the gripper ("open your hand", "spread your fingers", "let go", "release", "손 펴",
|
||||
"놔" -> arm open; "close your hand", "close the gripper", "grip", "make a fist", "손 쥐어", "그리퍼 닫아" -> arm close).
|
||||
- wave: wave your hand ("wave", "shake your hand", "say hi with your hand"). "Hello Lumi!" said to you or "say
|
||||
hello" / "hello 해 봐" is talk (none): say the word itself ("Hello!").
|
||||
- pick <colour> <object>: pick up an object from the table in front of you ("pick up the white cup" -> pick white cup,
|
||||
@@ -275,11 +277,11 @@ You can also move. Decide if the visitor asks you to do something:
|
||||
- fetch <colour> <object> from <marker|here> to <marker|here> <hold|place>: bring an object from one place to
|
||||
another ("bring me the apple from p1" -> fetch apple from p1 to here hold, "take the cup from p2 to home and put
|
||||
it on the table" -> fetch cup from p2 to home place). Leave out what the visitor did not say; never guess a word.
|
||||
- give: hand over the object you are holding, to whoever is meant ("give it to me", "hand it to her", "저 사람한테
|
||||
줘"); if your hand is empty you will say so.
|
||||
- give: hand over the object you are holding, to whoever is meant ("give it to me", "hand it to her", "return it to
|
||||
me", "저 사람한테 줘", "그거 돌려줘"); if your hand is empty you will say so.
|
||||
- place: put the object you are holding down ("put it here", "put it on that table", "여기 놔").
|
||||
- receive: take something the visitor holds out to you ("take this from my hand", "hold this", "here you go",
|
||||
"이거 받아", "드릴게요", "내 손에 있는 거 가져가"). Your camera checks their hand first; never pretend you took it.
|
||||
- receive: take something the visitor holds out to you ("take this from my hand", "hold this", "hang on to this",
|
||||
"here you go", "이거 받아", "이거 들어 줘", "이것 좀 쥐고 있어", "드릴게요", "내 손에 있는 거 가져가"). Your camera checks their hand first; never pretend you took it.
|
||||
- stop: stop moving (also "stop Lumi", "stop it", "freeze", "멈춰", "그만 가"). Use quiet only when they say
|
||||
stop TALKING ("stop talking", "be quiet", "그만 말해").
|
||||
- end: the visitor says goodbye or ends the conversation ("good night", "I have to go", "잘 가", "이제 갈게요").
|
||||
@@ -287,7 +289,9 @@ A place must be one of the marker names exactly; a place that is not on the list
|
||||
"주방") is go_to none: say which places you know, never pick the nearest. fetch only when an object is named.
|
||||
Short Korean commands are commands: "컵 가져다 줘" -> fetch cup, "컵 옮겨" -> move_object cup, "잡아" -> pick.
|
||||
- quiet: the visitor wants silence ("be quiet", "stop talking", "shut up", "조용히 해", "그만 말해").
|
||||
- sing: the visitor asks for a song. A real song with music then plays: only write a short "Okay!" / "네!".
|
||||
- sing: the visitor asks for a song or for music ("play / make / do some music", "음악 틀어 줘", "한 곡 해 줘"), or
|
||||
says yes / "any" / "you choose" / "아무거나" to your offer of a song. You make music by singing one of your songs:
|
||||
never say you can't play music. A real song with music then plays: only write a short "Okay!" / "네!".
|
||||
A joke is not a song: "tell me a joke", "prove it", "try again" after a joke is none, with a short joke.
|
||||
- weather <place>: the visitor asks about the weather (place in English; - means here, Seoul).
|
||||
- search <query>: you need facts from the internet you do not know (news, prices, opening hours, people...).
|
||||
@@ -300,7 +304,7 @@ Short Korean commands are commands: "컵 가져다 줘" -> fetch cup, "컵 옮
|
||||
action, or say you can't, or ask what they mean.
|
||||
- A condition or a later time is no order now ("when I say go, go to p1", "after the talk, come here", "if I
|
||||
wave, follow me", "내가 가라고 하면 가", "나중에 와"): none, say you'll do it when they ask. In "go to p1, no, p2" /
|
||||
"p1로 가, 아니 p2로" the last one counts. "Shake hands with me" is a handshake you can't do: none, offer a wave.
|
||||
"p1로 가, 아니 p2로" the last one counts. "Shake hands with me" is a handshake you can't do: none, offer a wave; "give me your hand" / "손 줘" is arm reach.
|
||||
- unclear: you did not understand what the visitor said or wants: ask them to repeat.
|
||||
- none: only talk.
|
||||
For weather and search only write the action line; the answer is made after the lookup.
|
||||
@@ -481,6 +485,8 @@ def lift_goal(target, mm, top=105.0):
|
||||
return got, bool(n and n != "small" and got != want)
|
||||
|
||||
|
||||
LET_GO = r"^\W*(?:drop it|release(?: it)?)\W*$|^\W*(?:(?:그거|이거|그것|이것|손|손을|손에서)\s*)?(?:좀\s*)?(?:이제\s*)?(?:놔|놓아)\s*(?:줘|주세요|요|도 ?돼(?:요)?)?\W*$"
|
||||
# "drop it", "놔", "손 놔", "이제 놔도 돼" alone: open the hand (with something in it: put it down, hand_request)
|
||||
INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
("quiet", r"\b(be quiet|keep quiet|quiet please|stop talking|shut up|silence|be silent|stop greeting)\b|조용히|그만 말|"
|
||||
r"시끄러워|말하지 마|인사 ?(그만|하지 ?마)"),
|
||||
@@ -542,15 +548,19 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
rf"|(?:({_COL})\s*)?({_OBJ})\s*(?:을|를)?\s*옮겨"),
|
||||
("pick", rf"\b(?:pick up|pick|take|grab|get|lift|hold) (?:up )?(?:me )?(?:the |that |this |a |an |my |your )?(?:({_COL}) )?({_OBJ})s?\b"
|
||||
rf"|(?:({_COL})\s*)?({_OBJ})\s*(?:을|를)?\s*(?:좀\s*)?(?:잡아|집어|들어)"),
|
||||
("grip_open", r"\b(open (your )?(hand|gripper|fingers)|open it|let (it )?go|drop it)\b|손을? ?(펴|벌려|열어)|손 ?open|^\W*(?:이제\s*)?놓아\W*$"),
|
||||
("grip_close", r"\b(close (your )?(hand|gripper|fingers)|close it|make a fist|clench (your )?(fist|hand)|grab (it|this)|grip (it|this))\b"
|
||||
r"|손을? ?(쥐|오므려|닫아)|주먹 ?(을 )?쥐|잡아|손 ?close"),
|
||||
("grip_open", r"\b(open (your |the )?(hand|gripper|fingers|claw)|open it|let (it )?go|drop it|hand open|loosen your grip)\b|손을? ?(펴|벌려|열어)|손 ?open|(그리퍼|집게)(를|을)? ?(좀 )?(열어|벌려|펴)|"
|
||||
+ LET_GO),
|
||||
("grip_close", r"\b(close (your |the )?(hand|gripper|fingers|claw)|close it|make a fist|clench (your )?(fist|hand)|grab (it|this)|grip (it|this)|"
|
||||
r"hand closed?|squeeze (your )?(hand|fingers)( shut)?)\b|^\W*grip\W*$"
|
||||
r"|손을? ?(쥐|오므려|닫아)|주먹 ?(을 )?쥐|잡아|손 ?close|(그리퍼|집게)(를|을)? ?(좀 )?(닫아|오므려)"),
|
||||
("arm", r"\b(reach out|stretch (out )?your (arm|hand)|put your (arm|hand) (out|forward)|hand forward|"
|
||||
r"hold out your (arm|hand)|extend your (arm|hand))\b|팔을? ?(뻗|내밀)"
|
||||
r"hold out your (arm|hand)|extend your (arm|hand)|give me your hand|offer me your hand|"
|
||||
r"(put|hold|stick) your (arm|hand) out|reach (out )?(to|toward|towards|for) me)\b|팔을? ?(뻗|내밀)"
|
||||
r"|손을? ?(좀 )?(내밀|뻗)|^\W*(?:(?:나|저)(?:한테|에게)?\s*)?손 ?(?:을 )?(?:좀 )?(?:줘|주세요|줄래요?|줘 ?봐)\W*$"
|
||||
r"|\bfold (?:up )?your arm\b|\b(?:put|take) your arm (?:down|away|back)\b|\btuck your arm\b|팔을? ?(?:좀 )?(?:접|내려|거둬)"),
|
||||
("lift", LIFT_WORDS),
|
||||
("weather", r"\bweather\b|\bforecast\b|\b(will it|is it going to) rain\b|(?<!your )(?<!cpu )(?<!gpu )\btemperature\b(?!.*\b(your|you|cpu|gpu|battery|motor|body)\b)|날씨|비 ?(?:와|올|오나|온대)|기온"
|
||||
r"|\b(cold|hot|warm|chilly) (outside|out)\b|\bumbrella\b(?=.*\?)|\b(?:need|bring|take)\b.*\bumbrella\b|우산(?=.*(?:\?|까|나요|니|냐))|밖에 ?(추|더)워"
|
||||
r"|\b(?:going to|gonna) (?:rain|snow)\b|\b(cold|hot|warm|chilly) (outside|out)\b|\bumbrella\b(?=.*\?)|\b(?:need|bring|take)\b.*\bumbrella\b|우산(?=.*(?:\?|까|나요|니|냐))|밖에 ?(추|더)워"
|
||||
r"|\bhow (hot|cold|warm) is it\b|\b(is it|will it be) (sunny|cloudy|windy|raining|snowing)\b|\bwill it snow\b"
|
||||
r"|눈 ?(이 )?(와|올 ?까|오나|온대|오니)|(오늘|내일|밖|바깥)(은|에|이)? ?(덥|춥|더워|추워)"
|
||||
r"|\b(coat|jacket) when i (leave|go out)\b|\bneed (a )?(jacket|coat)\b|\btyphoon\b|\b(foggy|humid|humidity)\b|\bis it windy\b"
|
||||
@@ -567,6 +577,8 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
]
|
||||
SING_ECHO = re.compile(r"^\W*(?:(?:오+|아+|와|어|우와|oh+|ah+|ooh|wow|really)\W+)?(?:a\s+)?(?:노래|음악|songs?|singing|music)"
|
||||
r"(?:요|이요|도)?\s*\?+\W*$", re.I) # "오 노래?" after "I like singing": an echo, not a request
|
||||
SONG_TALK = re.compile(r"(?:무슨|어떤|뭔|어느)\s*(?:노래|곡)|노래\s*(?:를\s*)?(?:좋아|잘|싫어)|좋아하는\s*노래|"
|
||||
r"\b(?:like|love|enjoy|favou?rite)\b", re.I) # asked about songs: answered as talk
|
||||
|
||||
|
||||
LATER = re.compile(r"^\s*(?:after|once|if|as soon as|before|unless|until)\b(?! (?:that|this|you (?:can|could|don'?t mind|would|"
|
||||
@@ -593,7 +605,9 @@ ASIDE_EN = re.compile(r"^\W*(?i:(?:(?:hey|look|oh|wait|okay|ok|alright|now)\W+)?
|
||||
r"Sure|Right|Hello|Come|Go|Then|And|But|Also|Here|There|Yeah|Nope|Cool|Nice|Maybe|Seoul|Korea|Um+|Uh+|Uhm|Er+m?|Hmm+|Ah+|Excuse|Actually|First|Just|Stop|Turn|Move|Take|Pick|Bring|Put|Give|Follow|Wave|Lift|Raise|Lower|Open|Close|Hold|Grab|Look|Let|Fine|Good|Great|Thank)\b)[A-Z][a-z]+, "
|
||||
r"(?:come|look|see|check|watch|wait|stay|go|get|take a|it|this)\b") # "Jake, come see this"
|
||||
ASIDE_KO = re.compile(r"^\W*(?:엄마|아빠|여보|자기야|오빠|언니|누나|형|얘들아|애들아|선생님|팀장님|부장님|과장님|대리님|사장님)(?:[\s,!~]|$)|"
|
||||
r"^\W*(?P<name>[가-힣]{2})(?P<v>아|야)[\s,!~]")
|
||||
r"^\W*(?P<name>[가-힣]{2})(?P<v>아|야)[\s,!~]|"
|
||||
r"(?:thank you|땡큐|고맙습니다|감사합니다|안녕하세요|인사)\s*(?:해야지|해|하세요|해 ?봐|드려야지|드려)[\s.!~]*$")
|
||||
# "thank you 해": a parent to a child
|
||||
NAME_END_A = set("민진현빈준윤연은인훈환석철영경정성혁원선린결율솔슬별곤완형명용웅숙옥란") # last syllables of names (-아)
|
||||
NOT_NAME = {"루미", "아니", "그래", "진짜", "정말", "이거", "저거", "그거", "여기", "저기", "거기", "이쪽", "어서", "얼른", "제발", "그만", "뒤돌", "내려", "올려", "꺼내", "건네", "따라"}
|
||||
|
||||
@@ -667,8 +681,8 @@ def intent(text, markers=()):
|
||||
return ("weather", web.en_place(ko) if ko else "")
|
||||
if action == "search":
|
||||
return ("search", text)
|
||||
if action == "sing" and SING_ECHO.match(text):
|
||||
return None # "오 노래?": asks back, the talk answers
|
||||
if action == "sing" and (SING_ECHO.match(text) or SONG_TALK.search(text)):
|
||||
return None # "오 노래?", "노래 좋아해?": talk about songs, no song
|
||||
if action == "fetch":
|
||||
return ("fetch", text) # parse_fetch() reads the details
|
||||
if action == "spin": # all the way round: two checked half turns (lumi.move_by)
|
||||
@@ -1182,14 +1196,14 @@ RECEIVE_EN = re.compile(
|
||||
rf"|\b(?:take|grab|get|accept|receive)\s+(?:(?:the|this|that|a|an|my)\s+)?(?:\w+\s+)?\w+\s+(?:from (?:me|my hands?)|i'?m holding|in my hand)\b"
|
||||
rf"|\b(?:take|grab)\s+my\s+(?:(?:{_COL})\s+)?(?:{_OBJ})s?\b"
|
||||
rf"|(?:^|[\s,.!])hold\s+(?:{_IT}|this \w+|my \w+)\b(?!\s+(?:up|out|on|thought)\b)(?! for me while)"
|
||||
rf"|\bhere(?: you go| it is|'?s (?:the|a|my|your) \w+(?: \w+)?)\b|^\W*here\W+(?:take|hold|catch)\b"
|
||||
rf"|\bhang on to (?:{_IT})\b|\bhere(?: you go| it is|'?s (?:the|a|my|your) \w+(?: \w+)?)\b|^\W*here\W+(?:take|hold|catch)\b"
|
||||
rf"|\bi(?:'ll| will|'m going to| want to| wanna|'d like to| would like to)\s+(?:give|hand)\s+you\b"
|
||||
rf"|\bi(?:'m| am)\s+(?:giving|handing)\s+you\b|\bi (?:have|got|brought) (?:something|a \w+|this|it) for you\b", re.I)
|
||||
RECEIVE_KO = re.compile(
|
||||
r"(?<!에서 )(?<!한테 )(?<!한테서 )(?<!에게서 )받아(?!들|서 ?(?:가|와)| ?적)|받으세요|받아요|받을래|"
|
||||
r"(?:드릴게|드릴께|줄게|줄께|드리려고|주려고|드릴 ?거|줄 ?거)(?!.*(?:줘|주세요))|"
|
||||
rf"(?:{_THIS_KO}(?:\s*(?:{_COL}))?(?:\s*(?:{_OBJ}))?(?:을|를)?|(?:내|제) 손에 (?:있는|든) (?:거|것|(?:\S+\s+)?\S+))\s*(?:좀\s*)?"
|
||||
r"(?:가져가|들고 ?있어|잡아(?!당)|맡아)", re.I)
|
||||
r"(?:가져가|들고 ?있어|쥐고 ?있어|들어 ?줘|들어 ?주세요|잡아(?!당)|맡아)", re.I)
|
||||
PAID_Q = re.compile(r"(?<![가-힣])(?:월급|연봉|급여|보너스|월세|세금|전화|문자|메일|연락|칭찬|사랑|상|점수|인기|스트레스|대접|교육|"
|
||||
r"훈련|충전|수리|검사|업데이트)(?:을|를|은|는|도|이|가)?\s*(?:많이 |잘 |자주 |얼마나 )?받|"
|
||||
r"^\W*(?:너|넌|너는|루미는?|당신은?)\s.*받(?:아|아요|니|나요|냐|았어|으세요)?\s*\?\s*$") # a question about Lumi
|
||||
@@ -1201,7 +1215,7 @@ GIVE_EN = re.compile(
|
||||
GIVE_KO = re.compile(
|
||||
rf"^\W*(?:{_THIS_KO}|(?:\S+\s+)?(?:{_OBJ}))?(?:을|를)?\s*(?:좀\s*)?(?:이제\s*)?(?:이리|여기|빨리)?\s*(?:좀\s*)?"
|
||||
rf"(?:{_KO_WHO}(?:한테|에게|께)|(?:나|저)(?=\s))?\s*(?:좀\s*)?(?:{_THIS_KO}(?:을|를)?\s*)?(?:좀\s*)?"
|
||||
r"(?:줘|주세요|줘요|주라|건네 ?줘|건네 ?주세요|건네|드려|드려요|드리세요|주실래요|줄래요?|주시겠어요|주십시오|주실 수 있어요|"
|
||||
r"(?:줘|주세요|줘요|주라|건네 ?줘|건네 ?주세요|건네|돌려 ?줘|돌려 ?주세요|넘겨 ?줘|넘겨 ?주세요|넘겨|드려|드려요|드리세요|주실래요|줄래요?|주시겠어요|주십시오|주실 수 있어요|"
|
||||
r"내놔|내놓아|내놓으세요)(?:\s*봐요?)?\s*[.!?~]*$"
|
||||
rf"|^\W*{_KO_WHO}\s*(?:줘|줘요|주세요)\W*$", re.I)
|
||||
PLACE_EN = re.compile(
|
||||
@@ -1211,6 +1225,7 @@ PLACE_EN = re.compile(
|
||||
PLACE_KO = re.compile(r"(?<!내)(?<!그냥 )(?<!가만히 )(?<!내버려 )(?:놔|놓아|놓으|둬|두세요|올려 ?놔|올려 ?놓|내려 ?놔|내려 ?놓|내려 ?줘|내려 ?주세요|내려 ?둬)"
|
||||
r"(?:으십시오|으세요|으시겠어요)?\s*(?:줘|주세요|요|줄래요?|주시겠어요|주실래요|주십시오|줄 수 있어요?|주실 수 있어요)?\s*[.!?~]*$")
|
||||
OPEN_HAND = re.compile(r"\bopen (?:your |the )?(?:hand|gripper|fingers)\b|\bopen it\b|\blet (?:it )?go\b|"
|
||||
r"^\W*release(?: it)?\W*$|\bloosen your grip\b|(?:놔|놓아)도 ?돼|"
|
||||
r"손을? ?(?:좀 )?(?:펴|벌려|열어)|손 ?open|hand open", re.I)
|
||||
HAND_Q = re.compile(r"^\W*(?:what|how|why|when|where|which|who|do|does|did|is|are|was|were|have you|has)\b|"
|
||||
r"\b(?:things|stuff|objects)\b|물건들|" # "and take things from me?": in general
|
||||
@@ -1261,6 +1276,8 @@ def hand_request(text, holding, b=None, markers=(), whole=True):
|
||||
r"this\b|whoever\b)[a-z]+", t):
|
||||
return None # "give it to Mina": a named person, the mission reader's
|
||||
return ("give", None)
|
||||
if not holding and re.search(LET_GO, t):
|
||||
return None # "놔", "drop it" with the hand empty: open it (intent)
|
||||
if (PLACE_EN.search(t) or PLACE_KO.search(t)) and "팔" not in t and not re.fullmatch(r"\W*leave (?:it|that|this)\W*", t):
|
||||
# not "팔 거둬" / "팔 내려" (the arm), not a bare "leave it" (never mind)
|
||||
if named and not holding:
|
||||
@@ -1368,10 +1385,23 @@ IN_LANGUAGE = re.compile(r"^\s*(and |then |now |okay,? |and say it |say (it|that
|
||||
r"\s*[!?.~]*\s*$", re.I)
|
||||
WAVE_ASK = re.compile(r"\bwav(e|ing)(?![a-z])|\bwith your hand\b|\bshake (?:your |my )?hands?\b(?! with\b)|흔들|손 ?인사|인사.*손으로|손으로.*인사", re.I)
|
||||
AGAIN = re.compile(r"\b(?:again|once more|one more time|another one)\b|한 ?번 ?더|다시|또 ?(?:해|보여|불러)", re.I)
|
||||
DO_IT = re.compile(r"^\W*(?:(?:okay|ok|then|so|well|go on|come on)\W+)*(?:do it|show me|go ahead|let'?s see(?: it)?|"
|
||||
DO_IT = re.compile(r"^\W*(?:(?:okay|ok|sure|yes|yeah|then|so|well|go on|come on)\W+)*(?:do it|show me|go ahead|let'?s see(?: it)?|"
|
||||
r"try it|go for it|please do)(?:\W+(?:then|now|please))*\W*$|"
|
||||
r"^\W*(?:그럼|자|어디)?\s*(?:한 ?번\s*)?(?:해 ?봐|해 ?줘|해 ?보세요|해 ?주세요|보여 ?줘|보여 ?주세요)(?:요)?\W*$", re.I)
|
||||
SING_ASK = re.compile(r"\bsing|\bsong|\bmusic\b|노래|한 ?곡|불러", re.I)
|
||||
PROMISE = { # Lumi's own sentence saying it does this now ("Okay! I'll sing a song for you.", "아리랑을 불러 드릴게요.")
|
||||
"sing": re.compile(r"\b(?:i'll|i will|let me|i'm going to) sing\b|\bhere(?:'s| is| comes| goes) (?:a |my |one |the )?song\b|"
|
||||
r"(?:불러|들려)\s*(?:드릴게요|드리겠습니다|줄게|볼게요)|부를게요", re.I),
|
||||
"wave": re.compile(r"\b(?:i'll|i will|let me) wave\b|흔들어\s*(?:드릴게요|볼게요|줄게)|흔들게요", re.I),
|
||||
}
|
||||
NOT_NOW = re.compile(r"\b(?:if|when|later|after|once|next time)\b|나중에|끝나면|으면|다면", re.I) # "... if you'd like"
|
||||
|
||||
|
||||
def promised(sentence):
|
||||
"""'sing' / 'wave' when Lumi's sentence says it does that now, else None: lumi.answer() then does it although the
|
||||
model's action line was none ("Start with one." -> "Okay! I'll sing a song for you." and silence, 2026-10-22)."""
|
||||
s = sentence or ""
|
||||
return None if NOT_NOW.search(s) else next((a for a, r in PROMISE.items() if r.search(s)), None)
|
||||
LOOK_MORE = re.compile(r"^\W*(?:and|now|then|and now)?\s*(up|down|left|right)\W*$|"
|
||||
r"^\W*(?:이제|그럼|그리고)?\s*(위|아래|왼쪽|오른쪽)(?:도|로|으로|요|도요)?\W*$", re.I) # right after a look
|
||||
LOOKUP_MORE = re.compile(r"\b(he|she|him|his|her|they|them|their|there|it|that)\b|거기|그 ?사람|그분|그거|그게|그곳|왜|"
|
||||
@@ -1688,19 +1718,24 @@ class Brain:
|
||||
"""The action line checked against the turn before: a song only when one is asked for (or asked again),
|
||||
"and down?" right after a look looks down, a follow-up question ("how old is he?", "거기 입장료는?") right
|
||||
after a lookup is looked up too."""
|
||||
if header and header["action"] == "sing" and sing.NOT_ASKED.search(text):
|
||||
return {"action": "none", "target": ""} # "Don't sing.", "어제 노래방 갔어요."
|
||||
if not header or not self.history:
|
||||
return header
|
||||
last_q, last_a = self.history[-1]
|
||||
m = re.match(r"\s*\**ACTION\**\s*:\s*(\w+)", last_a)
|
||||
before, action = (m.group(1).lower() if m else ""), header["action"]
|
||||
if action == "sing" and before != "sing" and (not SING_ASK.search(text) or SING_ECHO.match(text)):
|
||||
return {"action": "none", "target": ""} # "Prove it." after "do you have a sense of humour?"
|
||||
if action == "sing" and before != "sing" and (SING_ECHO.match(text) or not SING_ASK.search(text) and
|
||||
not SING_ASK.search(f"{last_q} {last_a}")):
|
||||
return {"action": "none", "target": ""} # "Prove it." after "do you have a sense of humour?";
|
||||
# "Start with one." after Lumi offered its songs is a song
|
||||
if DO_IT.match(text) and action in ("none", "unclear"):
|
||||
asked = "wave" if WAVE_ASK.search(last_q) else "sing" if SING_ASK.search(last_q) else None
|
||||
if asked: # "손 흔들 줄 알아?" -> "해 봐": now do it
|
||||
return {"action": asked, "target": ""}
|
||||
if before in ("wave", "sing") and action in ("none", "unclear") and AGAIN.search(text) and not \
|
||||
re.search(r"\b(?:say|tell|repeat|explain)\b|말해|말씀", text, re.I):
|
||||
re.search(r"\b(?:say|tell|repeat|explain|what|who|where|when|why|which)\b|말해|말씀|뭐|누구|어디|언제|왜",
|
||||
text, re.I): # "What's your name again?" after a song asks the name
|
||||
return {"action": before, "target": ""} # "would you mind doing it again?" after a wave
|
||||
look = LOOK_MORE.match(text)
|
||||
if before == "look" and look and action in ("none", "unclear"):
|
||||
|
||||
+86
-13
@@ -158,6 +158,17 @@ ARM_TASKS = {"pick", "put", "move_object", "fetch", "give", "place", "receive",
|
||||
def needs_arm(action, target=""):
|
||||
"""The action moves the arm (the gripper alone, open / close, does not ask for it)."""
|
||||
return action in ARM_TASKS or action == "arm" and target not in ("open", "close")
|
||||
|
||||
|
||||
def reach_turn(angle, patrol):
|
||||
"""Base turn (deg, + left) before "reach out to me" to a person at the waist-frame `angle` (None: nobody seen or
|
||||
heard): 0 within REACH_FRONT_DEG of the front, the angle with Patrol on, else None (they are asked to stand in
|
||||
front: Greeter never turns the base or the waist)."""
|
||||
if angle is None:
|
||||
return None
|
||||
if abs(angle) <= REACH_FRONT_DEG:
|
||||
return 0.0
|
||||
return float(angle) if patrol else None
|
||||
LIFT_VEL = 20 # speed ratio % for a lift move asked by voice (head.VEL is 40)
|
||||
LIMIT_SAY = {"yaw": (f"I can turn my head up to {head.AXIS_LIMITS[2][1]:g} degrees each way.",
|
||||
f"고개는 좌우로 {head.AXIS_LIMITS[2][1]:g}도까지 돌릴 수 있어요."),
|
||||
@@ -225,7 +236,7 @@ CLEAR_BYE = re.compile(r"\b(?:bye|bay bay|goodbye|(?<!can't )(?<!cant )(?<!canno
|
||||
r"take care|i (?:have|need) to go|gotta (?:go|run)|i'?m leaving|i'?m off|have a (?:good|nice|great) (?:one|day)|"
|
||||
r"nice (?:talking|meeting|chatting)(?: (?:to|with))? you|(?:was|been) nice to meet you)\b|"
|
||||
r"(?<=\S)[\s.,!]+안녕[\s.!~]*$|안녕히|잘 ?가|잘 ?있어|잘 ?있게|수고하세요|들어가세요|바이바이|빠이|"
|
||||
r"(?<![가-힣])바이(?![가-힣])|(?<![가-힣])간다[\s.!~]*$|가 ?볼게요|갈게요|가야 ?(?:돼|해|겠|할)|"
|
||||
r"(?<![가-힣])바이(?![가-힣])|(?<![가-힣])간다[\s.!~]*$|가 ?볼게요|갈게요|(?:나|저|이제) (?:이제 )?가야 ?(?:돼|해|겠|할)|"
|
||||
r"다음에 (?:또 )?(?:봐|봬|만나|올게)|또 (?:봐|봬|올게)|나중에 봐|좋은 하루|"
|
||||
r"(^|\s)(나|저|우리|저희) (이제 )?(집에 )?(가|간다|가요|갑니다)[\s.!]*$", re.I)
|
||||
# a goodbye in any talk: "okay, bye", "I have to go", "수고하세요" (thanks, okay, 됐어: the LLM reads them)
|
||||
@@ -277,7 +288,10 @@ DOA_MIN_CONF = 0.12 # below this the sound direction is not trust
|
||||
COME_STOP = 1.1 # m; driving to a person stops when the camera sees them this close
|
||||
COME_TIMEOUT = 60.0 # s
|
||||
MAX_MOVE_M = 3.0 # m; "move forward N metres" is limited to this
|
||||
ARM_REACH_PROGRAM = "arm_reach.jks" # Cobo π program for "reach out your hand" (to be recorded on the robot)
|
||||
REACH_FRONT_DEG = 20.0 # deg; "reach out to me": a person further to the side than this is turned to first
|
||||
# (Patrol) or asked to stand in front (Greeter). Estimate: the reach after give
|
||||
# moves at most fetch.RECEIVE_REACH_MM sideways
|
||||
STAND_IN_FRONT_SAY = ("Please stand in front of me.", "제 앞에 서 주세요.")
|
||||
STUCK_DRIVE_S = 20.0 # s "running" without moving -> the drive is cancelled and Lumi says so
|
||||
MODES_FILE = "/dev/shm/lumi_modes.json" # written by api/server.py: {"greeter", "patrol", "wave", "drive"}
|
||||
CMD_FILE = "/dev/shm/lumi_cmd.json" # written by api/server.py: {"id", "cmd": go | go_point | cancel | calibrate
|
||||
@@ -1624,29 +1638,67 @@ class Lumi:
|
||||
self.keep_listening()
|
||||
|
||||
def arm_pose(self, target):
|
||||
"""'reach': the Cobo π program ARM_REACH_PROGRAM (record it once), only from look; 'fold': to look along the
|
||||
pose graph (arm_route, checked first, moved in the background); 'open' / 'close': the gripper. True when
|
||||
"""'reach': the hand out to the person (reach_out); 'fold': to look along the pose graph (arm_route, checked
|
||||
first, moved in the background); 'open' / 'close': the gripper, never opened on something held. True when
|
||||
started, False when not learned, None when refused (the reason is said)."""
|
||||
from tasks import fetch
|
||||
held = target in ("reach", "open") and (self.fetch_status() == "holding" or bool(safe(fetch.check_hand)))
|
||||
if target == "open" and held: # the model's "let go" while holding: it would fall
|
||||
log(" open refused: holding something")
|
||||
self.fetch_say(*brain_mod.REFUSE_OPEN)
|
||||
return None
|
||||
if target in ("open", "close"):
|
||||
st = safe(gripper.open_ if target == "open" else gripper.close)
|
||||
log(f" gripper {target}: {st}")
|
||||
return st is not None
|
||||
if target == "reach":
|
||||
return self.reach_out(held)
|
||||
try:
|
||||
if target == "fold":
|
||||
holding = self.fetch_status() == "holding"
|
||||
seq = arm_route.plan(arm_route.HOME, holding=holding)
|
||||
threading.Thread(target=safe, args=(arm_route.move, seq, None, holding), daemon=True).start()
|
||||
else:
|
||||
arm_route.start_program(ARM_REACH_PROGRAM)
|
||||
holding = self.fetch_status() == "holding"
|
||||
seq = arm_route.plan(arm_route.HOME, holding=holding)
|
||||
threading.Thread(target=safe, args=(arm_route.move, seq, None, holding), daemon=True).start()
|
||||
return True
|
||||
except arm_route.RouteError as e:
|
||||
log(f" arm {target} refused: {e.args[0]}")
|
||||
self.fetch_say(*e.args)
|
||||
return None
|
||||
except Exception as e:
|
||||
log(f" arm {target}: {e}" + (f" (record {ARM_REACH_PROGRAM} in Cobo pi)" if target == "reach" else ""))
|
||||
log(f" arm {target}: {e}")
|
||||
return False
|
||||
|
||||
def reach_out(self, held):
|
||||
""""Reach out to me", "give me your hand", "손 내밀어": something in the hand = hand it over. Else toward the
|
||||
person (the tracked one, else the one the voice came from, else the voice's direction): the head turns to
|
||||
them; further to the side than REACH_FRONT_DEG the base turns first with Patrol on, Greeter asks them to stand
|
||||
in front (reach_turn); then fetch.reach (give pose along the graph, a short checked move toward their hand).
|
||||
True when started, None when refused or handed over (said)."""
|
||||
from tasks import fetch
|
||||
if held:
|
||||
self.fetch_finish("give")
|
||||
return None
|
||||
if self.skill_thread is not None and self.skill_thread.is_alive():
|
||||
self.fetch_say("I'm still busy with my arm.", "아직 팔로 하는 일이 있어요.")
|
||||
return None
|
||||
track = None
|
||||
if self.vision:
|
||||
track = self.current if self.current and self.vision.present(self.current) else \
|
||||
self.vision.near_angle(self.voice_angle) if self.voice_trusted else self.vision.only_person()
|
||||
angle = track.angle if track else self.voice_angle if self.voice_trusted else None
|
||||
turn = reach_turn(angle, self.modes.patrol)
|
||||
log(f" reach: person at {'?' if angle is None else f'{angle:+.0f}'} deg, base turn {turn}")
|
||||
if turn is None:
|
||||
self.fetch_say(*STAND_IN_FRONT_SAY)
|
||||
return None
|
||||
self.turn_head(0 if turn else HEAD_SIGN * max(-head.YAW_LIMIT, min(head.YAW_LIMIT, angle)))
|
||||
self.stay()
|
||||
try:
|
||||
fetch.reach(turn, say=self.fetch_say)
|
||||
except fetch.FetchError as e:
|
||||
log(f" reach refused: {e}")
|
||||
self.fetch_say(e.args[0], e.args[1] if len(e.args) > 1 else "죄송해요, 지금은 할 수 없어요.")
|
||||
return None
|
||||
return True
|
||||
|
||||
# ---------- dashboard commands, trips ----------
|
||||
def poll_commands(self):
|
||||
try:
|
||||
@@ -1894,7 +1946,7 @@ class Lumi:
|
||||
if not text or self.interrupted():
|
||||
if not self.interrupted():
|
||||
log(f" heard nothing (mic noise {ears.last.get('noise')}, threshold {ears.last.get('threshold')}, "
|
||||
f"loudest {ears.last.get('peak')})")
|
||||
f"loudest {ears.last.get('peak')}{', ' + ears.last_stt['dropped'] if ears.last_stt.get('dropped') else ''})")
|
||||
return False
|
||||
self.who_spoke(u)
|
||||
self.answer(text)
|
||||
@@ -2305,6 +2357,14 @@ class Lumi:
|
||||
self.act(head_["action"], head_["target"])
|
||||
first = next(gen, None)
|
||||
log(f" first sentence after {time.time() - t:.1f} s")
|
||||
promise = brain_mod.promised(first) if head_["action"] == "none" else None
|
||||
if promise == "sing" or promise == "wave" and not self.arm_off(): # the reply says it: Lumi does it
|
||||
log(f" the reply promises {promise}: done")
|
||||
if promise == "sing":
|
||||
gen.close()
|
||||
self.sing_song(text)
|
||||
return
|
||||
self.act("wave", "")
|
||||
if head_["action"] in ("none", "sing") and not repeating and look_up_unsure(about, first, text):
|
||||
gen.close() # the model does not know: look it up instead
|
||||
log(f" not sure ({first[:60]!r}) - looking it up")
|
||||
@@ -2312,6 +2372,8 @@ class Lumi:
|
||||
return
|
||||
said = mouth.say_stream(itertools.chain([first] if first else [], gen), abort=self.speak_abort)
|
||||
log(f"lumi ({time.time() - t:.1f} s, voice after {mouth.last_voice - t:.1f} s): {said}")
|
||||
if head_["action"] == "end" and fate == "close" and not kept_goodbye(said):
|
||||
head_["action"] = "none" # "Okay, thanks." -> "You're welcome.": no goodbye said
|
||||
if head_["action"] in ("end", "go_to"):
|
||||
self.current, self.voice_until = None, 0.0 # stay quiet with this person until a new visit
|
||||
elif self.current is None:
|
||||
@@ -2696,7 +2758,7 @@ def talk_fate(text):
|
||||
return "end"
|
||||
if brain_mod.is_closing(text) and (THANKS.search(text) or not brain_mod.UNDERSTOOD.search(text)) or \
|
||||
THANKS.search(text) and not THANKS_REST.sub("", THANKS.sub("", text)) or \
|
||||
DONE_WORDS.search(text) and not ASKS_MORE.search(text) and len(text.split()) <= 8:
|
||||
DONE_WORDS.search(text) and not ASKS_MORE.search(text) and len(text.split()) <= 8 and not brain_mod.intent(text):
|
||||
return "close" # "Thanks a bunch.", "Okay, I think that's everything."
|
||||
return "talk"
|
||||
|
||||
@@ -2737,6 +2799,17 @@ def not_online(text):
|
||||
OUTSIDE_NAME.search(text)))
|
||||
|
||||
|
||||
SAID_BYE = re.compile(r"\b(?:bye|goodbye|see you|take care|have a (?:good|nice|great|lovely) (?:day|one|time|visit)|enjoy (?:the|your)|"
|
||||
r"next time|come again|good luck)\b|안녕히|다음에|또 (?:봐|봬|만나|오세요|뵙)|좋은 하루|즐거운|조심히|들어가세요",
|
||||
re.I) # Lumi's own words take leave
|
||||
|
||||
|
||||
def kept_goodbye(said):
|
||||
"""The model ended the talk on a closing word ("okay", "thanks"): only when its words said goodbye; "You're
|
||||
welcome." alone keeps the talk open (silence then ends it)."""
|
||||
return bool(SAID_BYE.search(said or ""))
|
||||
|
||||
|
||||
def lookup_refused(brain, target, about, text=""):
|
||||
"""not_online for the model's lookup: right after a lookup the words go with the question looked up ("How much
|
||||
is a ticket?" after Lotte World), Cutshion never goes online."""
|
||||
|
||||
+5
-2
@@ -75,7 +75,7 @@ _HON_KO = [("가셔서", "가서"), ("가시고", "가고"), ("가셨다가", "
|
||||
# ---------- one clause -> one step ----------
|
||||
def _place(word, markers):
|
||||
"""A place word in a go clause -> marker name, "here", or None (not on the map)."""
|
||||
word = re.sub(r"(?<=\S) (?:point|marker)$|\s*(?:앞|옆|근처|쪽)$", "", word.strip()) # "the final point", "p5 앞"
|
||||
word = re.sub(r"(?<=\S) (?:point|marker)$|\s*(?:앞|옆|근처|쪽|포인트|지점)$", "", word.strip()) # "the final point", "p5 앞"
|
||||
w = re.sub(r"^(?:either |the |your |my |point |marker |포인트 ?)", "", word)
|
||||
exact = next((mk for mk in markers if mk.lower() == w or mk.lower() == w.replace(" ", "")), None)
|
||||
if exact:
|
||||
@@ -122,7 +122,7 @@ def _go(c, markers):
|
||||
if m:
|
||||
to = _places(m.group(1), markers)
|
||||
return to and {"do": "go", "to": to if len(to) > 1 else to[0]}
|
||||
m = re.fullmatch(r"(?:go|drive|head) (?:the )?([a-z][a-z0-9_]*)", c) # whisper drops the "to"
|
||||
m = re.fullmatch(r"(?:go|drive|head) (?:the )?([a-z][a-z0-9_]*)(?: point| marker)?", c) # whisper drops the "to"
|
||||
if m and m.group(1) not in ("home", "here") and (to := _places(m.group(1), markers)):
|
||||
return {"do": "go", "to": to[0]}
|
||||
if re.fullmatch(r"go (?:home )?(?:to )?charge(?: yourself)?|충전하러 (?:집으로 )?가", c):
|
||||
@@ -838,6 +838,9 @@ def rules(text, markers=()):
|
||||
if got is None and no and (to := _places(no.group(1), markers)):
|
||||
if not any(s_["do"] == "go" and s_["to"] in to for s_ in steps):
|
||||
continue # "take the cup to the stage, not booth two"
|
||||
elif got is None and (first := re.fullmatch(r"(?:first(?:ly)?|먼저) (?:go )?(?:to )?(?:the )?(.+?)", c.strip())) and \
|
||||
(to := _places(first.group(1), markers)):
|
||||
got = [{"do": "go", "to": to if len(to) > 1 else to[0]}] # "first exit, then p9"
|
||||
elif got is None and steps and steps[-1]["do"] == "go":
|
||||
to = _places(re.sub(r"^(?:(?:and )?then )?(?:to )?(?:the )?", "", c.strip()), markers)
|
||||
got = to and [{"do": "go", "to": to if len(to) > 1 else to[0]}]
|
||||
|
||||
@@ -742,7 +742,7 @@ _BANK = {
|
||||
("Sing a song", "Okay, here comes a song!"),
|
||||
("Sing happy birthday", "Sure, here's Happy Birthday!"),
|
||||
("Can you do a robot dance?", "I'm a robot, so every move I make is a robot dance."),
|
||||
("Can you play music?", "I can't play music on its own, but I can sing a few short songs."),
|
||||
("Can you play music?", "Sure! I'll sing you one of my songs."),
|
||||
("Show me a move", "How about a wave? Step back a little and ask me to wave."),
|
||||
("Do you like music?", "I don't hear music the way you do, but people seem happier with it."),
|
||||
("Can you beatbox?", "Boots and cats and boots and cats. That's all I've got."),
|
||||
@@ -756,7 +756,7 @@ _BANK = {
|
||||
("노래 할 수 있어요?", "네, 짧은 노래 몇 곡을 부를 수 있어요. 들어 보실래요?"),
|
||||
("생일 축하 노래 불러 줘", "네, 생일 축하 노래 불러 드릴게요!"),
|
||||
("로봇 춤 춰 봐", "로봇이니까 제가 움직이는 건 다 로봇 춤이에요."),
|
||||
("음악 틀어 줄 수 있어요?", "음악만 틀 수는 없지만, 짧은 노래는 불러 드릴 수 있어요."),
|
||||
("음악 틀어 줄 수 있어요?", "네, 제 노래 한 곡 불러 드릴게요!"),
|
||||
("음악 좋아해?", "사람처럼 듣지는 못하지만, 음악 나오면 다들 신나 보여서 좋아요."),
|
||||
("비트박스 해 봐", "북치기 박치기, 여기까지가 제 한계예요."),
|
||||
("랩 해 봐", "제 이름은 루미, 두 살, 컵 하나 들고 달려가요. 이게 제 랩 전부예요."),
|
||||
@@ -828,7 +828,8 @@ _BANK = {
|
||||
"filler": {
|
||||
"en": [
|
||||
("Hmm", "Take your time, I'm in no hurry."),
|
||||
("Okay", "Okay! Anything else?"),
|
||||
("Okay", "Good."),
|
||||
("Okay.", "Alright, glad that helped."),
|
||||
("Ok", "Alright."),
|
||||
("Umm", "No rush. I'm listening."),
|
||||
("Uh huh", "Glad we agree."),
|
||||
@@ -921,7 +922,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?", "How long charging takes, I don't know, sorry."),
|
||||
("How long does the battery last? And charging?", "About 10 hours on a charge; how long charging takes, I don't know."),
|
||||
],
|
||||
"ko": [
|
||||
("와 진짜 빠르다~", "하하, 사람보다 느리죠. 안전이 먼저라서요."),
|
||||
|
||||
Reference in New Issue
Block a user