diff --git a/assistant/bank_words/arm_more.py b/assistant/bank_words/arm_more.py index aeb6c73..d6da6f0 100644 --- a/assistant/bank_words/arm_more.py +++ b/assistant/bank_words/arm_more.py @@ -366,6 +366,7 @@ RECEIVE += [ "hold onto this for me", "take it, it's for you", "here, grab this from me", "i'm handing it to you", "keep it for me", "이거 받아 주게나", "이거 받아 주세유", "이거 가지고 있어", "이거 들고 계세요", "이거 쥐고 있어 줘", "이것 좀 맡아 줘", "이거 맡아 주세요", "자 이거", "옛다", "받으세유", "받아 주시길 바랍니다", + "이거 받게", "이거 받게나", "이 받게", " 받게", "이 받으시게", "이거 받으시오", "이거 받으소", "이거 받아 두게", ] NO += [ "왼쪽에 놔둔 컵 누구 거야?", "오른쪽에 둔 거 뭐야?", "왼쪽에 내려놨어?", "오른쪽에 놓을까?", "왼쪽에 놓으면 돼?", @@ -376,5 +377,128 @@ NO += [ "왼쪽에 컵 있어?", "오른쪽에 뭐 있어?", "옆에 컵 있네", "앞에 컵 있다", ] + +# ---------- dialects (제주, 경상, 전라, 충청), 하오체 / 하게체, honorific receivers, glued slips ---------- + +DIALECT = [" 줍서", " 주십서", " 도고", " 도가", " 주이소 예", " 주이소마", " 주씨요", " 주쇼 잉", " 줘 잉", " 주랑께요", + " 주셔유", " 주시유", " 줘 봐유", " 봐 도고", " 주라 마", " 주소 마", " 주게 자네", " 주시구려", " 주구려", + " 주오", " 주시오 그려", " 주시게나", " 주겠는가?", " 주시겠는가?"] +DIALECT_CORES = [ # (list, stems) + (WAVE, ["손 흔들어", "악수해", "손 인사 해", "팔 흔들어", "손 흔들어서 인사해"]), + (ARM_REACH, ["손 내밀어", "팔 뻗어", "손 이리 내밀어", "손 줘"]), + (ARM_FOLD, ["팔 접어", "팔 거둬", "손 내려", "팔 넣어"]), + (ARM_OPEN, ["손 펴", "손가락 펴", "그리퍼 열어"]), + (ARM_CLOSE, ["주먹 쥐어", "손 쥐어", "그리퍼 닫아"]), + (PICK, [" 집어", " 잡아", " 들어"]), + (FETCH, [" 가져다", " 갖다"]), +] +for _list, _stems in DIALECT_CORES: + _list += _ko(_stems, DIALECT) +WAVE += [ + "손 흔들어 주시구려", "악수 한번 하시구려", "악수나 한번 하세", "자네 악수 한번 하세", "악수 한번 합세", "손 한번 흔드시오", + "할머님께 손 한번 흔들어 드리시게", "어르신들께 손 흔들어 드리십시오", "아버님께 악수 청해 보세요", "교수님께 손 흔들어 드려라", + "손 흔들어 줍서", "손 흔들어 도고", "악수 하입시더 예", "악수 하자 잉", "악수 혀 봐유", "악수 하드래요", + "손흔들어줘요", "손흔들어봐", "손 흔들어줘", "악수하자요", "악수해요루미", "손흔드러", "손 흔드러 줘요", "악수 해 조요", + "웨이브해줘", "웨이브해주세요", "쉐이크핸드해줘", "핸드쉐이크해줘", "wave해줘", "wave해주세요", "악수해줄래", + "wave to grandpa please", "say hi to grandpa with your hand", "wave at mommy", "wave at daddy", "wave to teacher", + "wave to the teacher please", "go on wave to mister kim", "wave hi to everybody here", "wave to all of us", + "handshake me please robot", "you shake hand with my father", "please you give me handshake", "shake hand with me ok", + "shake hands ok", "wave ok", "wave okay?", "you can wave please", "wave for me robot friend", +] +ARM_REACH += [ + "손 좀 내밀어 주시구려", "손 한번 내미시오", "팔 한번 뻗어 보시게나", "자네 손 좀 내밀어 보게", "손 내밀어 줍서", "손 도고", + "손 이리 도고", "손 내밀어 도고", "팔 뻗어 보래이 마", "손 줘 잉", "손 줘 봐유", "손 이리 주셔유", + "손내밀어봐", "손줘봐", "손좀줘", "팔뻗어봐", "손 내밀어줘요", "손 쭉내밀어", "팔쭉뻗어줘", "핸드줘", "핸드 내밀어줘", + "reach out to grandma", "hold your hand out to my son", "give your hand to my daughter", "reach out to the kid", + "give grandpa your hand", "hold out your hand to the lady", "you give hand to my mom", "hand to grandma please", +] +ARM_FOLD += [ + "팔 거두시구려", "팔 접으시구려", "팔 좀 거두시게나", "자네 팔 좀 접게", "팔 접어 줍서", "팔 접어 도고", "팔 거둬 잉", + "팔 접어 주셔유", "팔 넣어 도고", "팔접어줘요", "팔거둬", "팔거둬줘", "팔넣어줘", "손내려줘", "팔 내려줘요", "팔 접어줘요", + "arm back please robot friend", "ok arm in now", "put your arm back now please", "arm back in place", +] +ARM_OPEN += ["손 펴 주시구려", "손 좀 펴 보시게나", "손 펴 줍서", "손 펴 도고", "손펴줘요", "손가락펴", "손가락펴줘요", + "그리퍼열어", "그리퍼열어줘"] +ARM_CLOSE += ["주먹 쥐어 주시구려", "손 좀 쥐어 보시게나", "주먹 쥐어 줍서", "주먹 쥐어 도고", "주먹쥐어줘요", "손쥐어줘", + "그리퍼닫아줘", "손 꽉쥐어"] +PICK += [" 집어 주시구려", " 좀 집어 보시게나", " 집어 줍서", " 집어 도고", "집어줘요", + "잡아줘", "들어줘", " 집어줘", " 잡아줘요", "좀집어줘"] +FETCH += [" 가져다 주시구려", " 좀 가져오시게나", " 가져다 줍서", " 갖다 도고", " 가 온나 마", + "가져다줘요", "갖다줘", "좀가져와", " 가져와줘요"] +NO += [ + "손 흔들어 주면 사탕 줄게", "if you wave i'll clap", "손 흔들면 사진 찍어 줄게", "악수하면 친구 하는 거야", "악수하자고 했잖아", + "손 흔들어 달라고 했는데 안 했어", "손 흔들어 준 거 고마워", "악수해 줘서 고마워요", "thanks for the wave", "thanks for shaking my hand", + "that was a good handshake", "i liked your wave", "your wave was too slow", "can you wave faster next time", + "팔 접는 게 왜 이렇게 느려?", "손 펴는 거 신기하다", "주먹 쥐는 거 귀엽네", "컵 집는 거 다시 보고 싶다", + "민수야 컵 가져와", +] + + +# ---------- English depth: indirect, kids, elderly, non-native, slang ---------- +WAVE += [ + "it would make her day if you waved", "a wave would make his day", + "say goodbye to us with a wave", "wave us farewell", "give us a goodbye wave", "a goodbye wave please", + "wavey wave for the baby", "robot wave hi hi", "do the bye bye", "do bye bye with your hand", "bye bye hand please", + "hand bye bye", "hand hello please", "hello hand please", "you do hand hello", "make bye bye", "make the wave", + "wave it", "wave it up", "wave that hand", "wave that arm", "wave that thing", "flap that hand at me", + "yo wave at me", "yo, shake my hand", "bro, shake hands", "dude, wave", "come shake hands", "c'mon, shake", + "lemme shake your hand", "lemme get a wave", "gimme a handshake real quick", "quick wave", "quick handshake", + "if it's no trouble, a wave", "would you mind giving us a wave", "could you do me a wave", "would it be possible to wave", + "please, a handshake", "kindly greet us by waving", "please greet my grandmother with a wave", + "you wave hand hello for grandma", "you make handshake grandma", "please doing wave", "doing handshake please", + "you waving please", "waving please", "waving hand please", "shaking hand please", +] +ARM_REACH += [ + "can the baby touch your hand, hold it out", + "hold it out so she can touch it", "hold your hand out so we can see it", "put your hand out for the photo", + "stick your hand out for the picture", "hand out for the photo please", "reach out so i can touch your hand", + "let her touch your hand", "your hand, let me touch it", "touch hands with me", "high hand please", + "robot hand out", "robot hand to me", "you hand to me", "hand me hand", "stretch stretch", "arm long long", + "make arm go out", "arm go out", "arm go forward please", "hand go forward", "yo, hand out", "c'mon, gimme your hand", + "if it's no trouble, hold out your hand", "would it be possible to extend your arm", "kindly extend your hand", + "please extend your hand towards me", "please, your hand", +] +ARM_FOLD += [ + "you can stop holding your arm out", "you don't need your arm out anymore, fold it", "no more arm out, fold it", + "enough with the arm, put it away", "we're done with the arm", "done, arm back", "finished, put your arm away", + "the photo is done, arm down", "photo's done, you can lower your arm", "arm go back", "arm come back", + "hand come back", "hand go back", "make arm small", "arm small please", "yo, arm in", "c'mon, put your arm away", + "if it's no trouble, fold your arm", "would it be possible to lower your arm", "kindly retract your arm", + "please return your arm to its resting position", "please put your arm back to rest", + "bring your hand home", "bring your hand home now", "would you please bring your hand home", "hand home please", + "bring your hand back home", "bring the hand home", "bring your hands home", +] +ARM_OPEN += [ + "open your hand for the photo", "show us your open hand", "open open hand", "hand open open", "make hand open", + "make the fingers open", "yo, open your hand", "if it's no trouble, open your hand", "kindly open the gripper", + "would it be possible to open your gripper", +] +ARM_CLOSE += [ + "close your hand for the photo", "make your hand closed", "close close hand", "hand close close", "make hand close", + "make the fingers close", "yo, close your hand", "if it's no trouble, close your hand", "kindly close the gripper", + "would it be possible to close your gripper", +] +PICK += [ + "pick up the for the kids", + "show the kids, pick up the ", "pick up the so we can see", "robot pick ", " pick robot", + "you pick up", " you grab please", "yo, grab the ", "c'mon, pick up the ", + "if it's no trouble, pick up the ", "kindly lift the ", "would it be possible to pick up the ", + "please take hold of the ", +] +FETCH += [ + "my son wants the , bring it", "bring the to my son", "grandma needs the , fetch it", "robot bring ", + " bring robot", "you bring me", "yo, bring me the ", "c'mon, fetch the ", + "if it's no trouble, bring me the ", "kindly fetch the ", "would it be possible to bring me the ", +] +NO += [ + "my son waved at you", "the kids want to wave at you", "my daughter wants to shake your hand later", + "can my son shake your hand", "can i touch your hand", "may i shake your hand", "should i wave back", + "is it ok if i wave", "wave if you can hear me", "if you can hear me, wave", "wave when i say go", + "don't wave yet", "not yet, don't reach out", "wait, don't pick it up yet", "you don't need to fold your arm", + "no need to open your hand", "your hand doesn't need to close", "i don't want the cup", "i don't need the bottle", + "the photo was great, thanks", "nice wave, thank you", "great handshake, thanks", "that handshake was firm", + "wave hello to my friend on the phone, no wait, never mind", "pick it up? no, leave it", +] + INTENT = {"wave": WAVE, "arm_reach": ARM_REACH, "arm_fold": ARM_FOLD, "arm_open": ARM_OPEN, "arm_close": ARM_CLOSE, "pick": PICK, "fetch": FETCH, "put": PUT, "give": GIVE, "receive": RECEIVE, "no": NO} diff --git a/assistant/bank_words/questions.py b/assistant/bank_words/questions.py index bceb27d..5408d66 100644 --- a/assistant/bank_words/questions.py +++ b/assistant/bank_words/questions.py @@ -425,10 +425,13 @@ QUICK_KINDS["mics"] = ([ "where are your microphones", "how far can you hear", "can you tell where a voice comes from", "소리는 무엇으로 들으십니까", "소리는 뭘로 들어요", "마이크 몇 개예요", "마이크 있어요", "마이크가 어디 있어", "얼마나 멀리서 들려요", "귀가 어디야", "어떻게 들어요", "소리 어떻게 들어", -], {"en": ["I hear with a ring of six microphones in my head, from about 3 to 5 metres away, and I can tell where a voice comes from.", - "Six microphones in my head: they hear people 3 to 5 metres away and tell me which direction a voice comes from."], - "ko": ["머리에 있는 마이크 6개로 들어요. 3에서 5미터 거리까지 듣고, 목소리가 어느 쪽에서 오는지도 알 수 있어요.", - "머리에 마이크가 6개 있어요. 3~5미터 떨어진 목소리를 듣고 방향도 알아요."]}) +], {"en": ["I hear with a ring of six microphones in my head, from about 3 to 5 metres away, and I can tell where a voice comes from. " + "Visitors can also talk to me through a small wireless clip microphone.", + "Six microphones in my head: they hear people 3 to 5 metres away and tell me which direction a voice comes from. " + "In a noisy place a small wireless clip microphone helps."], + "ko": ["머리에 있는 마이크 6개로 들어요. 3에서 5미터 거리까지 듣고, 목소리가 어느 쪽에서 오는지도 알 수 있어요. " + "작은 무선 클립 마이크로 말씀하셔도 돼요.", + "머리에 마이크가 6개 있어요. 3~5미터 떨어진 목소리를 듣고 방향도 알아요. 시끄러운 곳에서는 무선 클립 마이크를 쓸 수 있어요."]}) QUICK["no"] += ["can you hear me", "do you hear me", "들려", "내 말 들려요", "제 말 들리세요", "hello can you hear me", "are you listening", "듣고 있어"] QUICK["no"] += [ @@ -656,3 +659,82 @@ QUICK["time_now"] += _ko(["몇 시", "지금 몇 시", "시방 몇 시"], ["유" "몇시입니까", "지금몇시야", "몇시임", "지금몇시예요", "몇시야", "지금몇시입니까", "몇시예요"] QUICK["height"] += ["몇센티임", "너몇센티임", "키얼마유", "키가얼마유", "키 얼마나 된당가", "너 키 얼마나 된당가", "키howmuch"] QUICK["weight"] += ["howheavy해요", "너무게얼마인지알려주시겠어요", "무게얼마인지알려주세요"] +QUICK["tts"] = QUICK.get("tts", []) + _ko(["너 목소리 real person", "목소리 진짜 사람", "너 목소리 진짜 사람", "목소리 사람 목소리", "목소리 녹음한 거", + "그 목소리 사람"], ["이야", "이에요", "이니", "입니까", "인가요", "이고", "임"]) + [ + "is your voice a real person", "is that a real person's voice", "is your voice recorded", "whose voice is that", + "is your voice real", "is that voice real", "your voice is a real person", "목소리 누구 거야", "목소리 누구 목소리예요"] + +# round 4: the small kinds at every Korean level and in more English frames (same meanings, same answers) +_N = ["야", "예요", "에요", "니", "입니까", "인가요", "고", "여", "임", "냐", "유", "일까요", "인지 알려 줘", "인지 알려 주세요"] # after 뭐 / 어디 / 몇 개 +_USE = ["써", "써요", "쓰니", "쓰세요", "쓰십니까", "씁니까", "쓰나요", "쓰노", "써유", "쓰냐", "쓰시나요", "쓰는지 알려 주세요"] +_HAVE = ["있어", "있어요", "있니", "있나요", "있습니까", "있으세요", "있으십니까", "있노", "있어유", "있냐", "있나"] +_BE = ["돼", "돼요", "되니", "되나요", "됩니까", "되세요", "되십니까", "되노", "돼유", "되냐", "되나"] +_WHO_KO = ["", "너 ", "루미 ", "이 로봇 "] +QUICK["mics"] = QUICK.get("mics", []) + [w + x for w in _WHO_KO for x in _ko(["마이크 몇 개", "마이크가 몇 개", "마이크는 몇 개"], _N) + + _ko(["마이크 ", "마이크가 ", "귀 "], _HAVE) + _ko(["마이크 뭐 ", "마이크 어떤 거 "], _USE)] + _ko( + ["얼마나 멀리서 들려", "몇 미터까지 들려", "멀리서도 들려"], ["", "요", "?", "니", "요?"]) + _ko( + ["소리 나는 방향 알", "목소리 방향 알 수 있", "누가 말하는지 방향 알"], ["아", "아요", "니", "습니까", "아유"]) + [ + "how many microphones do you have", "how many mics do you have", "do you have microphones", "do you have a microphone", + "what microphones do you use", "where are your microphones", "how far away can you hear", "how far can you hear", + "can you tell where a voice comes from", "can you tell which direction a voice is from", "how do you hear", "what do you hear with", + "do you have ears", "where are your ears", "mic 몇 개야", "마이크 how many", "how many mic you have"] +QUICK["stt"] = QUICK.get("stt", []) + [w + x for w in _WHO_KO[:3] for x in _ko(["음성 인식 뭐 ", "음성 인식은 뭐 ", "음성 인식 엔진 뭐 ", "STT 뭐 ", + "위스퍼 ", "음성 인식 모델 뭐 "], _USE) + + _ko(["음성 인식 엔진이 뭐", "음성 인식 모델이 뭐", "STT 모델이 뭐", "말 알아듣는 프로그램이 뭐"], _N)] + _ko( + ["말은 어떻게 알아들", "말을 어떻게 알아들", "내 말 어떻게 알아들", "사람 말 어떻게 알아들"], + ["어", "어요", "으세요", "으십니까", "습니까", "니", "나요", "노", "어유", "냐"]) + [ + "what speech recognition do you use", "which speech recognition model do you use", "how do you understand speech", + "how do you understand what people say", "what's your speech to text", "which stt do you use", "what stt model do you use", + "do you use whisper", "is it whisper", "speech recognize what model", "speech to text what model", "how do you turn speech into text", + "what model listens to people", "음성 인식 what model", "speech recognition 뭐야"] +QUICK["tts"] = QUICK.get("tts", []) + [w + x for w in _WHO_KO[:3] for x in _ko(["음성 합성 뭐 ", "TTS 뭐 ", "목소리 프로그램 뭐 ", "목소리 엔진 뭐 "], _USE) + + _ko(["목소리 프로그램이 뭐", "음성 합성 엔진이 뭐", "TTS 엔진이 뭐", "목소리 엔진이 뭐"], _N)] + _ko( + ["목소리는 어떻게 내", "목소리 어떻게 만들", "말소리는 어떻게 내", "목소리는 뭘로 내", "목소리 어떻게 나와"], + ["", "요", "니", "세요", "십니까", "나요", "노", "유", "냐"]) + [ + "what text to speech do you use", "which tts do you use", "what tts engine do you use", "how do you speak", "how do you make your voice", + "what makes your voice", "is your voice synthesized", "is your voice a computer voice", "your voice what program", + "what program is your voice", "voice engine what", "what's your voice engine", "tts 뭐야", "voice 뭘로 만들어요"] +QUICK["reply_time"] = QUICK.get("reply_time", []) + _ko( + ["대답하는 데 얼마나 걸려", "답하는 데 몇 초 걸려", "대답까지 얼마나 걸려", "말하면 얼마 만에 대답해", "질문하면 몇 초 만에 대답해"], + ["", "요", "?", "니", "요?", "유"]) + _ko( + ["대답하는 데 얼마나 걸리", "대답까지 몇 초 걸리"], ["세요", "십니까", "나요", "노", "니", "냐"]) + _ko( + ["반응 속도가 ", "대답 속도가 ", "응답 시간이 ", "응답 속도가 "], ["얼마야", "얼마예요", "얼마입니까", "얼마나 돼", "얼마나 돼요", "어떻게 되세요", + "어때", "어때요", "얼마고", "몇 초야", "몇 초예요"]) + [ + "how long does it take you to answer", "how long do you need to reply", "how quick are your answers", "how fast are your replies", + "what's your reaction time", "how many seconds to answer", "response time?", "how fast you answer", "answer speed 얼마야"] +QUICK["used_where"] = QUICK.get("used_where", []) + _ko( + ["어디에 쓰", "어디서 쓰", "어디에 쓰려고 만들", "어떤 데서 쓰"], ["여", "여요", "이니", "입니까", "이나요", "이노", "여유", "이세요"]) + _ko( + ["용도가 뭐", "너 용도가 뭐", "쓰임새가 뭐", "주 용도가 뭐", "무슨 용도"], _N) + _ko( + ["어디서 일하", "어디에서 일하", "주로 어디서 일하"], ["", "니", "세요", "십니까", "나요", "노", "냐"]) + [ + "what are you used for", "what's your purpose", "what is this robot for", "where would i use you", "what kind of places use you", + "where do robots like you work", "what job were you built for", "what can you be used for", "use case?", "your use case what", + "어디 쓰는 로봇이에요", "너 어디에 써먹어", "이 로봇 뭐에 써요", "어디다 써요", "이거 뭐에 쓰는 거예요"] +QUICK["internet"] = QUICK.get("internet", []) + [w + x for w in _WHO_KO[:3] for x in _ko(["인터넷 ", "인터넷 연결 ", "와이파이 ", "클라우드 "], _USE) + + _ko(["인터넷 ", "인터넷 연결 ", "인터넷에 연결 "], _BE)] + [ + "are you online", "are you connected to the internet", "do you use the internet", "do you need the internet", "do you use the cloud", + "can you work offline", "do you work without internet", "are you on wifi", "internet 돼요", "인터넷 없이도 움직여요", "오프라인으로도 돼요"] +QUICK["computer"] = QUICK.get("computer", []) + [w + x for w in _WHO_KO[:3] for x in _ko(["컴퓨터 뭐 ", "무슨 컴퓨터 ", "어떤 컴퓨터 ", "칩 뭐 ", + "GPU 뭐 ", "프로세서 뭐 "], _USE) + + _ko(["컴퓨터가 뭐", "두뇌가 뭐", "뇌가 뭐", "컴퓨터 사양이 뭐", "GPU가 뭐"], _N)] + _ko( + ["머리에 컴퓨터 ", "안에 컴퓨터 ", "몸에 컴퓨터 "], _HAVE) + [ + "what computer do you have inside", "what's your brain", "what chip do you use", "what gpu do you have", "what processor do you use", + "is there a computer in your head", "what hardware runs you", "do you use nvidia", "is it a jetson", "computer 뭐 써요", "jetson이에요"] +QUICK["operator"] = QUICK.get("operator", []) + _ko(["누가 관리", "누가 운영", "누가 담당"], ["해", "해요", "하니", "하세요", "하십니까", "합니까", "하나요", + "하노", "해유", "하냐"]) + _ko( + ["관리자가 누구", "담당자가 누구", "책임자가 누구", "운영자가 누구", "주인이 누구"], ["야", "예요", "에요", "니", "입니까", "인가요", "고", "여", "임", "냐"]) + [ + "who looks after you", "who is your owner", "who owns you", "who is responsible for you here", "who manages you", "who's your operator", + "who takes care of this robot", "owner 누구야"] +QUICK["estop"] = QUICK.get("estop", []) + _ko(["비상 정지 버튼 어디 ", "비상 버튼 어디 ", "정지 버튼 어디 ", "빨간 버튼 어디 ", "비상 스위치 어디 "], _HAVE) + _ko( + ["비상 정지 버튼이 어디", "비상 버튼이 어디", "정지 버튼이 어디", "비상 스위치가 어디"], _N) + _ko( + ["위험하면 어떻게 멈춰", "급할 때 어떻게 세워", "비상시에 어떻게 멈춰"], ["", "요", "?", "요?", "야 돼", "야 돼요"]) + [ + "where's the e-stop", "how do i stop the robot in an emergency", "is there a kill switch", "where is the kill switch", + "how can someone stop you quickly", "emergency stop button where", "e-stop 어디야"] +QUICK["dof"] = QUICK.get("dof", []) + _ko(["관절이 몇 개", "관절 몇 개", "자유도가 몇", "자유도 몇", "축이 몇 개", "모터가 몇 개"], _N) + [ + "how many degrees of freedom do you have", "how many dof do you have", "how many joints do you have", "how many axes do you have", + "how many motors do you have", "dof?", "degrees of freedom?", "자유도 how many"] +QUICK["safety"] = QUICK.get("safety", []) + _ko(["너 안전한 로봇", "안전한 로봇"], ["이야", "이에요", "이니", "입니까", "인가요", "이고", "임"]) + [ + "is it dangerous to be near you", "can you hurt people", "do you hurt people", "are robots like you safe", "safe?"] +QUICK["no"] += ["한 번에 몇 초 걸려", "몇 초 걸려", "몇 초나 걸려요", "how many seconds does it take", "how long does one take", + "how long does it take", "얼마나 걸려요", "시간 얼마나 걸려"] +QUICK["mics"] += ["clip mic 있어요", "클립 마이크 있어요", "무선 마이크 있어요", "시끄러우면 마이크 써", "시끄러우면 마이크 씀", "do you have a clip mic", + "is there a wireless microphone", "can i use a microphone", "마이크 따로 있어요"] diff --git a/assistant/brain.py b/assistant/brain.py index bae1297..7c9a069 100644 --- a/assistant/brain.py +++ b/assistant/brain.py @@ -2420,6 +2420,12 @@ CARRY_HELD = re.compile(r"\b(?:take|bring|carry|move|get) (?:it|that|this|them|t r"(?:으로|로|에|까지)\s*(?:좀\s*)?(?:가져가|가지고 ?가|갖고 ?가|들고 ?가|옮겨|가져다 ?놔|가 ?줘|가)", re.I) +def object_ko(name): + """"흰 컵" -> "흰 컵을", "물병" -> "물병을", "사과" -> "사과를": a Korean object with its object particle.""" + c = name[-1:] + return name + ("을" if "가" <= c <= "힣" and (ord(c) - 0xAC00) % 28 else "를") + + def held_carry(text, markers=()): """With something in the hand: the words ask to take it to a marker ("take it to p5", "p5로 가져가 주세요", "그거 p5로 옮겨 줘"); a direct order that names a place on this map.""" @@ -2717,7 +2723,8 @@ LOOKUP_MORE = re.compile(r"\b(he|she|him|his|her|they|them|their|there|it|that)\ SPEAK_IN = re.compile(r"(english|영어|korean|한국어)\s?로\s*(?:다시\s*|좀\s*|한 ?번\s*)*(?:말|얘기|소개|대답|답|설명|자기소개|" r"해\s*(?:줘|주|봐))(?!.*(?:해도|도 ?돼|할 ?수|할 ?줄))|" r"\b(?:speak|talk|answer|reply|introduce yourself)\b.*\bin (english|korean)\b", re.I) -SHORT_Q = re.compile(r"\?|^\W*(?:where|who|what|when|how|which|why)\b|몇|어디|누가|누구|뭐|언제|왜|얼마|어떻게", re.I) +SHORT_Q = re.compile(r"\?|^\W*(?:where|who|what|when|how|which|why)\b|몇|어디|어딘|누가|누구|누군|뭐|뭔|무엇|무슨|어느|언제|언젠|" + r"왜|얼마|어떻게|어떤", re.I) # 하게체 / no "?" from the voice: "그게 언젠가", "공을 꺼낸 방법 무엇인가" ABOUT_YOU = re.compile(r"\b(?:you|your|yourself|lumi)\b|너|네가|니가|넌|루미|당신", re.I) # a follow-up about Lumi itself FOLLOW_UP = re.compile(r"\b(more|why|how come|details?|explain|elaborate|and then|what else|tell me more)\b|자세히|더 알려|왜|그리고", re.I) _CLOSE_WORD = (r"(ok(ay)?|okay then|thanks?( you)?( very much)?( a lot)?|cheers|thank you( so much)?|got it|alright|all right|" @@ -2986,6 +2993,9 @@ WHAT_IS = re.compile(r"(?:뭐|무엇|뭔|머)(?:예요|에요|야|이야|입니 r"^\W*what(?:'s| is| are| does)\b", re.I) # "X는 뭐예요?", "What is X?": a definition THAT_ONE_KO = re.compile(rf"(? 1 and self._asks_again(header, parts[0], text): stream.close() # "Sorry, I didn't catch that." to clear words: once more retried, skip_head, buf, full = True, True, "", "" - messages[-1]["content"] += UNCLEAR_RETRY + messages[-1]["content"] += self._unclear_retry() stream = _stream(messages) continue for sentence in parts[:-1]: @@ -3200,7 +3210,7 @@ class Brain: buf = buf.partition("\n")[2] if not said and not retried and buf.strip() and self._asks_again(header, buf, text): try: # a one-sentence "say it again?" to clear words - again = _chat(messages[:-1] + [dict(messages[-1], content=messages[-1]["content"] + UNCLEAR_RETRY)]) + again = _chat(messages[:-1] + [dict(messages[-1], content=messages[-1]["content"] + self._unclear_retry())]) again = "\n".join(ln for ln in again.splitlines() if not re.match(r"\s*\**ACTION", ln)).strip() if again and not ASKS_AGAIN.search(again): buf = full = again @@ -3234,6 +3244,14 @@ class Brain: first.endswith("?") or re.search(r"궁금|\bwonder|good question|좋은 질문", first, re.I) \ else {"action": "none", "target": ""} # the query written out, "궁금하시군요." then "잠시만요": a lookup + def _unclear_retry(self): + """UNCLEAR_RETRY, and in a talk what the words most likely ask about: "why prison?", "누가 그랬는가?" right after + an answer were asked to be said again even on the retry (r13 train, 2026-10-27).""" + last = " ".join(ln for ln in topic_turn(self.history)[1].splitlines() + if not re.match(r"\s*\**ACTION", ln)).strip() if self.history else "" + return UNCLEAR_RETRY + (f"\n(Most likely they ask about your answer \"{last[:FRAGMENT_CHARS * 2]}\": answer that " + f"question about it, in a sentence or two.)" if last else "") + def _asks_again(self, header, sentence, text): """The model talks (action none) but asks to hear clear words again ("I'm not sure what you mean, could you say it again?" to "Why the 15th?"): it is asked once more with UNCLEAR_RETRY.""" @@ -3258,7 +3276,8 @@ class Brain: Lumi's own things ("속도는 얼마예요?", "이름이 뭐예요?") keeps them. Returns those subjects, the question before first ([] when none).""" def named(t): # "공식적으로는 언제로 쳐요?" names no subject (an adverb + 는) return [m.group(0) for m in OWN_SUBJECT.finditer(core(t)) if not NOT_SUBJECT_KO.search(m.group(0))] + \ - [m.group(1) for m in EN_SUBJECT.finditer(core(t))] + [m.group(1) for m in THAT_ONE_KO.finditer(core(t))] + [m.group(1) for m in EN_SUBJECT.finditer(core(t))] + [m.group(1) for m in THAT_ONE_KO.finditer(core(t))] + \ + [m.group(1) for m in OF_THING_KO.finditer(core(t))] qs = [topic_turn(self.history)[0]] + [h[0] for h in reversed(self.history[-3:])] if self.history else [""] q = next((x for x in qs if named(x)), qs[0]) # "문어 피는?" "왜?" "심장은?": the octopus, two turns back if named(text) and WHAT_IS.search(core(text)): diff --git a/assistant/chain.py b/assistant/chain.py index a2b7e18..0d9c290 100644 --- a/assistant/chain.py +++ b/assistant/chain.py @@ -15,7 +15,7 @@ QUICK = {"look", "lift", "wave", "arm", "go_to", "come", "come_back", "follow", DRIVES = {"go_to", "come", "come_back", "follow", "move", "turn"} # after a failed step these depend on where Lumi is _KO_ORDER = {"보": "봐", "흔들": "흔들어", "흔드": "흔들어", "돌": "돌아", "도": "돌아", "올리": "올려", "내리": "내려", "높이": "높여", "낮추": "낮춰", "들": "들어", "드": "들어", "숙이": "숙여", "커지": "커져", "작아지": "작아져", - "낮아지": "낮아져", "높아지": "높아져", "돌리": "돌려", "오": "와", "따라오": "따라와", "가": "가"} + "낮아지": "낮아져", "높아지": "높아져", "돌리": "돌려", "오": "와", "따라오": "따라와", "가": "가", "하": "해", "알리": "알려"} # "나 보고 ..." -> "나 봐", "고개 들고 ..." -> "고개 들어", "저를 보시고 ..." -> "저를 봐", "왼쪽으로 도시고" -> "왼쪽으로 돌아" _KO_AND = re.compile(r"(" + "|".join(sorted(_KO_ORDER, key=len, reverse=True)) + r")(?:시)?고$") ASK = re.compile(r"\?\s*$|^\W*(?:(?:also|and|then|so|ok|okay|robot|please|first|now|plus|oh|ah|um|uh|lumi)\W+)*" @@ -23,7 +23,7 @@ ASK = re.compile(r"\?\s*$|^\W*(?:(?:also|and|then|so|ok|okay|robot|please|first| r"would|should|time|day|date|year|old|much|many|far|long|about|kind|your|you|made|built|created|" r"invented|owns|makes)\b)|why\b|is|are|do|does|did|tell me|explain|describe)\b|" r"\b(?:tell|telling) (?:me|us)\b|\bintroduce yourself\b|\b(?:say|tell me) your name\b|" - r"몇 ?시|몇|뭐|무엇|어때|알려|언제|어디|누구|왜|얼마|날씨|설명해|말해 ?줘|말하|얘기해|소개", re.I) + r"몇 ?시|몇|뭐|무엇|어때|알려|알리(?=고)|날짜|언제|어디|누구|왜|얼마|날씨|설명해|말해 ?줘|말하|얘기해|소개", re.I) _SPLIT = re.compile(steps._SPLIT.pattern, re.I) FETCHING = re.compile(r"\b(?:bring|fetch|deliver|carry)\b|가져|갖다", re.I) # a part that carries something somewhere _FILL = re.compile(rf"(?:{steps._FILL}|루미야?|lumi|hey|do me a favou?r|부탁(?:해|해요|할게)?|dear|sir|ma'?am|madam|buddy|" @@ -70,7 +70,7 @@ def _rule(words, markers): ko = _KO_AND.sub(lambda m: _KO_ORDER[m.group(1)], words.strip()) if not rule and ko != words.strip(): rule = brain.intent(ko, markers) - m = not rule and re.fullmatch(r"(?:(나|저|날|나를|저를)\s+)?([a-z][a-z ]*?)\s*(?:하고|해|해요|해 ?줘)?", words.strip()) + m = not rule and re.fullmatch(r"(?:(나|저|날|나를|저를)\s+)?([a-z][a-z ]*?)\s*(?:하고|해|해요|해 ?줘|해 ?주세요|해 ?주십시오|해 ?줄래요?\??|해 ?주실래요?\??|해 ?봐)?", words.strip()) if m: # Konglish: "나 look 하고" -> "look at me", "wave 해" -> "wave" en = m.group(2) + ((" at me" if m.group(2) == "look" else " me") if m.group(1) else "") rule = brain.intent(en, markers) diff --git a/assistant/llm_direct.py b/assistant/llm_direct.py index 7283820..1ba92af 100644 --- a/assistant/llm_direct.py +++ b/assistant/llm_direct.py @@ -121,13 +121,25 @@ def _task(base): def _pieces(r): + """The reply's text pieces. An empty thought block the model writes itself ("<|channel>thought\n", + the turn's NO_THINKING once more) is dropped: it was said as the whole reply once (r13 check, 2026-10-27).""" + thinking = False with r: for line in r: if not line.startswith(b"data: "): continue d = json.loads(line[6:]) - if d.get("content"): - yield d["content"] + piece, out = d.get("content") or "", "" + while piece: + if thinking: + _, end, piece = piece.partition("") + thinking = not end + else: + said, start, piece = piece.partition("<|channel>") + out, thinking = out + said, bool(start) + piece = out + if piece: + yield piece if d.get("stop"): return diff --git a/assistant/lumi.py b/assistant/lumi.py index e92870a..e477a99 100644 --- a/assistant/lumi.py +++ b/assistant/lumi.py @@ -1177,7 +1177,7 @@ class Lumi: status = self.fetch_status() if status == "holding": from tasks import fetch - self.fetch_say(f"I'm holding {fetch.held_name()}, where should I put it first?", "뭔가 들고 있어요. 먼저 어디에 둘까요?") + self.fetch_say(f"I'm holding {fetch.held_name()}, where should I put it first?", f"{brain_mod.object_ko(fetch.held_name('ko'))} 들고 있어요. 먼저 어디에 둘까요?") return if status == "running": self.end_run(text) @@ -1510,12 +1510,13 @@ class Lumi: f"try another way, or go back.", f"{name}(으)로 가다가 길이 막혀서 멈췄어요. 다시 가거나, 다른 길로 가거나, 돌아갈 수 있어요.") elif held: - en, ko = f"I'm holding {held} and waiting for what to do with it.", "물건을 들고 다음 지시를 기다리고 있어요." + en, ko = f"I'm holding {held} and waiting for what to do with it.", f"{brain_mod.object_ko(fetch.held_name('ko'))} 들고 다음 지시를 기다리고 있어요." else: return ("I'm talking with you. I'm not doing any task right now, and my hand is empty.", "지금은 이야기하고 있어요. 하고 있는 일은 없고, 손도 비어 있어요.") if held and (running or self.traveling()): en += f" I'm holding {held}." + ko += f" {brain_mod.object_ko(fetch.held_name('ko'))} 들고 있어요." return en, ko # ---------- several commands in one sentence (assistant/chain.py) ---------- @@ -1685,7 +1686,7 @@ class Lumi: from tasks import fetch ko = fetch.OBJECTS.get(name, "물건") if held: - self.fetch_say(f"My hand is full, I'm holding {fetch.held_name()}.", "손에 이미 물건을 들고 있어요.") + self.fetch_say(f"My hand is full, I'm holding {fetch.held_name()}.", f"손에 이미 {brain_mod.object_ko(fetch.held_name('ko'))} 들고 있어요.") return if self.arm_off(): return @@ -1764,7 +1765,12 @@ class Lumi: return if action == "put": back = target == "back" - said = ("Okay, putting it back.", "네, 제자리에 놓을게요.") if back else ("Okay, putting it down.", "네, 내려놓을게요.") + from tasks import fetch # the held thing named when it is known ("the white cup") + what = (fetch.held_name(), fetch.held_name("ko")) if (safe(fetch.state) or {}).get("holding") else ("it", "") + what = what if what[0] != "something" else ("it", "") + ko = brain_mod.object_ko(what[1]) + " " if what[1] else "" + said = (f"Okay, putting {what[0]} back.", f"네, {ko}제자리에 놓을게요.") if back else \ + (f"Okay, putting {what[0]} down.", f"네, {ko}내려놓을게요.") done = ("Done.", "다 했어요.") run = lambda: skills.put_down(back=back) else: diff --git a/assistant/quick_answers.py b/assistant/quick_answers.py index 2cd6de6..611f4af 100644 --- a/assistant/quick_answers.py +++ b/assistant/quick_answers.py @@ -56,12 +56,12 @@ KINDS = { "누구야", "넌 누구니", "누구세요", "당신은 누구예요", "너 뭐야", "자기소개 해 줘", "자기소개 좀 해 주세요", "소개해 주세요", "어떤 로봇이에요", "이 로봇은 뭐예요", "이건 무슨 로봇이야", "루미가 뭐야", "니 누고", "누구당가", "넌 뭐 하는 애야", "여기서 뭐 하는 로봇이에요", "who are you 너", "넌 who야", - ], {"en": ["I'm Lumi, a mobile robot assistant developed by Cutshion Company.", + ], {"en": ["I'm Lumi, a mobile robot assistant developed by Cutshion Company. I talk with visitors, go to places and pick up and bring things.", "I'm Lumi, a robot assistant made by Cutshion Company. I can talk, see, drive around and use my arm.", - "My name is Lumi. I'm a mobile robot assistant from Cutshion Company."], - "ko": ["저는 루미예요. 쿳션이 개발한 모바일 로봇 어시스턴트예요.", + "My name is Lumi. I'm a mobile robot assistant from Cutshion Company: I answer questions, guide people and bring things."], + "ko": ["저는 루미예요. 쿳션이 개발한 모바일 로봇 어시스턴트예요. 대화하고, 여러 곳에 가고, 물건을 집어서 가져다드려요.", "저는 쿳션이 만든 로봇 어시스턴트 루미예요. 대화하고, 보고, 움직이고, 팔도 쓸 수 있어요.", - "루미라고 해요. 쿳션에서 개발한 모바일 로봇이에요."]}), + "루미라고 해요. 쿳션에서 개발한 모바일 로봇이에요. 질문에 대답하고, 길을 안내하고, 물건도 가져다드려요."]}), "age": ([ "how old are you", "what is your age", "what's your age", "how old r u", "how old is lumi", "when were you born", "when were you made", "when were you built", "how old is this robot", "are you old", "are you new", "your age?", @@ -291,7 +291,11 @@ EVENT_TIME = re.compile(r"\b(?:what time|what day|which day|what date) (?:does|d r"\b(?:open|close)\b(?!\s+(?:a|the|my|your|this|that|doors?)\b)|\b(?:start|end|begin|finish)\b|열어요|닫아요|시작|끝나", re.I) # an event's time: the LLM OTHER_FIRM = re.compile(r"\b(?:openai|google|samsung|apple|lg|microsoft|tesla|nvidia|hyundai|naver|kakao|meta|amazon|sony)\b|" r"오픈 ?ai|오픈에이아이|구글|삼성|애플|엘지|마이크로소프트|테슬라|엔비디아|현대|네이버|카카오|메타|아마존|소니", re.I) -OTHER_ROBOT = re.compile(r"\b(?:jaka|jacka|k1[wl]?|kargo|peitian|tusk)\b|자카|작카|节卡|페이톈|페이티엔|터스크", re.I) +OTHER_ROBOT = re.compile(r"\b(?:jaka|jacka|k1[wl]?|kargo|peitian|tusk)\b|자카|작카|节卡|페이톈|페이티엔|터스크|" + r"\b(?:that|the other|other|another|those) robots?\b|(?:저|그|옆에|옆의|옆|다른) ?로봇", re.I) +OTHER_DAY = re.compile(r"\b(?:tomorrow|yesterday|next (?:week|month|year|monday|tuesday|wednesday|thursday|friday|saturday|sunday)|" + r"last (?:week|month|year))\b|내일|어제|모레|그저께|글피|다음 ?주|지난 ?주|다음 ?달|지난 ?달|내년|" + r"(?:크리스마스|성탄절?)(?:가|는|이|은)? ?(?:무슨|몇) ?요일|\b(?:what|which) day (?:is|was|will be) christmas\b", re.I) NAMES_LUMI = re.compile(r"\b(?:you|your|yourself|u|ur|lumi)\b|(?:^|\s)(?:너|넌|니|네|당신|루미|본인|자기)", re.I) _bank = None @@ -341,7 +345,7 @@ ASKING = re.compile(r"^\W*(?:(?:hang on|wait|okay|ok|so|um+|uh+|hey|excuse me|so # "May I ask your age?", "Hang on, let me ask it. What's your name?", "궁금한데, 몇 살이에요?": the question after OPENER = re.compile(r"^\W*(?:(?:hello|hi|hllo|helo|hey|excuse me|well|okay|ok|oh|ah|g'?day|oppa|grabe|so like|dear|buddy|mate|" r"sir|ma'?am|my (?:new )?friend|little robot|big robot|mr\.? robot|" - r"어이|이보게|여보게|야야|아야|우리|애기야|브로|bro|큰 로봇아|(?:오빠|언니|이쁜이|선배님|사장님|기사님|아가씨|로봇 양반|양반)(?=\s*,)|" + r"어이|이보게|여보게|야야|아야|우리|애기야|브로|bro|큰 로봇아|그려|옳지|잘 들어|자|(?:오빠|언니|이쁜이|선배님|사장님|기사님|아가씨|로봇 양반|양반)(?=\s*,)|" r"얘|쟤|마|야|저기|저기요|잠깐(?:만)?|대박|사와디캅|참|아 맞다|맞다|" r"(?:야|아야|우리|이보게|어이|야야) ?(?:루미야|루미|로봇아|로봇)|실례합니다|실례지만|실례할게요|하나 묻겠습니다|하나 물을게(?:요)?|루미루미|누미야|" r"루미 ?(?:님|군|상|씨|언니|오빠|누나|형)|루미야|루미|로봇(?:아|님|씨)?|robot|lumi)(?![\w가-힣])[\s,.!?~:-]*)+", re.I) @@ -372,7 +376,8 @@ def _core(text): if len(rest.split()) >= 2 or re.search(r"[가-힣]{4}", rest): # "hello there", "hi lumi" stay whole t = rest t = ASKING.sub("", brain.CALLING.sub("", t).strip()).strip() or text or "" - if not re.search(r"\b(?:is|was|name|named|called)\s+lumi\W*$", t, re.I): # the subject: "How wide is Lumi?" + if not re.search(r"\b(?:is|was|name|named|called)\s+lumi\W*$|이름(?:이|은|을)?\s*루미", t, re.I): # "How wide is Lumi?", + # "왜 이름이 루미야?": the subject t = re.sub(r"[\s,]*(?:lumi|루미야|루미)?[\s,.!?~]*$", "", t, flags=re.I).strip() if re.fullmatch(r"(?:무슨|뭔|무엇의?) ?뜻\S*", t) and "루미" in (text or ""): t = "루미 " + t # "루미 무슨 뜻이에요?": what the name means @@ -413,6 +418,14 @@ def guarded(text, history=()): return "event time" if re.search(r"타워|빌딩|건물|(?= 2 and ASKS.search(rest): + if not got and rest != text and len(rest.split()) >= 2 and ASKS.search(rest): got = kind_of(rest, history, False) - if got: - return got head, comma, tail = rest.rpartition(",") + if not comma: # "셀카 찍을 거니까 너 몇 살이야?", "My move: why are you called Lumi?" + m = list(ASIDE.finditer(rest)) + head, comma, tail = (rest[:m[-1].start()], ",", rest[m[-1].end():]) if m else (rest, "", "") if comma and len(tail.split()) >= (2 if re.search(r"[가-힣]", tail) else 3) and ASKS.search(tail) and \ not ASKS.search(head) and not ORDER.search(head): # "Your voice, what program?": the head is the topic - return kind_of(tail, history, False) - return None + last = kind_of(tail, history, False) + if got and last and last != got: + return None # "저기 평가 항목, 루미, 오늘 무슨 요일이야?" read whole as another kind + return got or last + return got def _kind(text, history): diff --git a/assistant/steps.py b/assistant/steps.py index ae5203d..8acc132 100644 --- a/assistant/steps.py +++ b/assistant/steps.py @@ -422,7 +422,9 @@ def _wait(c, markers, after): g = m.groups() obj = next((x for x in g if x in brain.OBJECTS), None) num = next((x for x in g if x and re.fullmatch(r"[\d.]+", x)), None) - return [{"do": "receive", "object": brain.OBJECTS[obj] if obj else None, "wait_s": float(num) if num else WAIT_GIVE_S}] + col = next((brain.COLOURS[g[i - 1]] for i, x in enumerate(g) if x == obj and i and g[i - 1] in brain.COLOURS), None) + return [{"do": "receive", "object": brain.OBJECTS[obj] if obj else None, "wait_s": float(num) if num else WAIT_GIVE_S, + **({"colour": col} if col else {})}] # the colour said: told back, the person gives what they give m = re.fullmatch(rf"(?:(.+?)에서\s*)?(?:(\d+(?:\.\d+)?) s\s*(?:동안|정도|만)?\s*)?{_KO_GIVER}\s*(?:({COL})\s*)?({OBJ}|물건|뭔가|무언가|그거|뭐|무엇을|뭘|이거)?\s*" r"(?:을|를)?\s*(?:주면|건네주면|건네면|갖다주면|가져다주면|가져다 주면|줄 때까지|건네줄 때까지|줄 거야|" r"줄 거예요|가져올 거야)\s*(?:기다렸다가|기다려서|기다리고|기다려|기다려요)?\s*" @@ -430,7 +432,8 @@ def _wait(c, markers, after): if m and (m.group(1) is None or _at_place(m.group(1), markers)): obj = brain.OBJECTS.get(m.group(4) or "") return ([{"do": "go", "to": _at_place(m.group(1), markers)}] if m.group(1) else []) + \ - [{"do": "receive", "object": obj, "wait_s": float(m.group(2)) if m.group(2) else WAIT_GIVE_S}] + \ + [{"do": "receive", "object": obj, "wait_s": float(m.group(2)) if m.group(2) else WAIT_GIVE_S, + **({"colour": brain.COLOURS[m.group(3)]} if m.group(3) else {})}] + \ ([{"do": "go", "to": "here"}] if re.fullmatch(r"받아 ?(?:가지고 ?)?와", m.group(5) or "") else []) if after and re.fullmatch(r"(?:거기|여기)(?:서|에서)", c): return [] # "p3로 가서 | 거기서 | 기다려": the place of the next step diff --git a/manipulation/skills.py b/manipulation/skills.py index 32e3f1a..1c2ad01 100644 --- a/manipulation/skills.py +++ b/manipulation/skills.py @@ -162,7 +162,8 @@ CARRY_UP_MM = (100.0, 200.0) # holding the cup: when the str # first, then one checked joint move to carry (carry_up) HOVER_MM = 60.0 # hover(): the grasp point this far over the top (the fingers lie level # near its height, owner's tape on the tips grasp; TIP_MM is a margin) -LINE_STEPS = 10 # ... that straight up is IK-checked at this many points +LINE_STEPS = 10 # ... that straight up is checked at this many points (line_joints) +LINE_POINTS = 20 # points checked on a longer straight line with the cup (line_joints) LINE_STEP_DEG = 25.0 # ... no joint turning more than this between two of them OFFLINE_KINE = True # kine_forward / kine_inverse answered by robot/kinematics.py (fitted # to the controller, < 0.5 mm): a plan asks hundreds, and the controller @@ -799,41 +800,74 @@ def tilt_on(j0, j1): def place_options(x, y, top_mm, start): """(waypoints, joints above) of every grasp turn (GRASP_YAWS, the held turn first) and wrist solution that puts the held object down at (x, y) with its top at `top_mm`: a joint move from the joints `start` to above the spot - that stays above it and keeps the cup upright (MAX_TILT_DEG), then straight down and up. An upright cup turned - about its own axis stands the same: any turn will do, as for the pick.""" + that stays above it and keeps the cup upright (MAX_TILT_DEG), then straight down and up; after all of those, a + straight line from where the hand is to above the spot (first waypoint "above place (straight)": line_joints). + An upright cup turned about its own axis stands the same: any turn will do, as for the pick.""" held = _held.get("yaw", 0.0) - for yaw in sorted(GRASP_YAWS, key=lambda a: abs((a - held + 180.0) % 360.0 - 180.0)): + yaws = sorted(GRASP_YAWS, key=lambda a: abs((a - held + 180.0) % 360.0 - 180.0)) + for yaw in yaws: way = plan_place(x, y, top_mm, yaw=yaw) for ja in above_joints(way[0][1], start): rows = ik_chain(way[1:], ja) if not rows[-1][3] and wrist_ok([ja] + [r[2] for r in rows]) and move_ok(start, ja) and \ tilt_on(start, ja) <= MAX_TILT_DEG and confirm(way, ja): yield way, ja + c0 = _ask("kine_forward", jointPosition=[float(v) for v in start])["cartPosition"] + for yaw in yaws: # a joint move from look leans the cup where a line keeps it upright + way = plan_place(x, y, top_mm, yaw=yaw) + way[0] = ("above place (straight)", way[0][1]) + ja = line_joints(c0, start, way[0][1]) + if ja is None: + continue + rows = ik_chain(way[1:], ja) + if not rows[-1][3] and wrist_ok([ja] + [r[2] for r in rows]) and confirm(way, ja): + yield way, ja + + +def line_joints(c0, j0, target, steps=LINE_POINTS): + """Joints at the end of the straight move with the held cup from the flange pose `c0` (joints `j0`) to `target`: + IK at `steps` points, no joint turning more than LINE_STEP_DEG between two, J5 off 0, the cup leaning at most + MAX_TILT_DEG, the gripper HEAD_CLEAR_MM from the head (its place measured); None when not.""" + from manipulation import arm_route + centre = arm_route.head_cam.head_centre() + c0 = np.array(c0, float) + d = np.array(target, float) - c0 + d[3:] = (d[3:] + 180.0) % 360.0 - 180.0 + rows = ik_chain([(f"line {k}", [float(v) for v in c0 + d * k / steps]) for k in range(1, steps + 1)], j0) + if centre is None or rows[-1][3]: + return None + js = [list(j0)] + [r[2] for r in rows] + axis = calib.rpy_matrix(*GRASP_RPY).T @ [0.0, 0.0, 1.0] # cup axis in the flange frame + if max(abs(b - a) for p, q in zip(js, js[1:]) for a, b in zip(p, q)) > LINE_STEP_DEG or not wrist_ok(js[1:]) or \ + any((calib.rpy_matrix(*r[1][3:]) @ axis)[2] < math.cos(math.radians(MAX_TILT_DEG)) for r in rows) or \ + min(arm_route.flange_clearance(r[1], centre) for r in rows) < arm_route.HEAD_CLEAR_MM: + return None + return js[-1] def place_turned(way, ja): - """Put down along a place_options() option: joint move to above the spot, then down, open, up and home.""" + """Put down along a place_options() option: to above the spot (a joint move, or the straight line it was planned + with), then down, open, up and home.""" _go_on() - log(f"above place: joint move, grasp turned {yaw_of(way[0][1]):+.0f} deg, wrist J5 {ja[4]:+.0f}") - motion.move_joints(ja, HOLDING_SPEED) + log(f"{way[0][0]}: grasp turned {yaw_of(way[0][1]):+.0f} deg, wrist J5 {ja[4]:+.0f}") + if way[0][0].endswith("(straight)"): + motion.move_linear(target=way[0][1], speed=HOLDING_SPEED, path_checked=True) + else: + motion.move_joints(ja, HOLDING_SPEED) _do_place(way) def carry_up(above, ja): """Another way to carry for a held cup whose straight line from above the pick spot (flange pose `above`, joints - `ja`) to carry is refused: straight up CARRY_UP_MM (IK at LINE_STEPS points, no joint turning more than - LINE_STEP_DEG between two, J5 off 0), then one joint move to carry, the cup upright, clear of the head, no dip - (arm_route.check_moves). (pose up there, carry joints) or None.""" + `ja`) to carry is refused: straight up CARRY_UP_MM (line_joints at LINE_STEPS points), then one joint move to + carry, the cup upright, clear of the head, no dip (arm_route.check_moves). (pose up there, carry joints) or None.""" from manipulation import arm_route for dz in CARRY_UP_MM: - rows = ik_chain([(f"up {k}", up(above, dz * k / LINE_STEPS)) for k in range(1, LINE_STEPS + 1)], ja) - if rows[-1][3]: - continue - js = [list(ja)] + [r[2] for r in rows] - if max(abs(b - a) for p, q in zip(js, js[1:]) for a, b in zip(p, q)) > LINE_STEP_DEG or not wrist_ok(js): + j = line_joints(above, ja, up(above, dz), LINE_STEPS) + if j is None: continue try: - return rows[-1][1], arm_route.check_moves(js[-1], [motion.poses()["carry"]], holding=True)[0] + return up(above, dz), arm_route.check_moves(j, [motion.poses()["carry"]], holding=True)[0] except arm_route.RouteError: continue return None diff --git a/tasks/fetch.py b/tasks/fetch.py index 52ac9ab..1ec0c4a 100644 --- a/tasks/fetch.py +++ b/tasks/fetch.py @@ -124,6 +124,8 @@ FURNITURE_RANGES = (0.6, 1.0, 1.4) # ... and m from the base centre where the FURNITURE_HIT_M = 0.3 # ... the lidar sees now (closer than this) and the map does not have (nothing FURNITURE_MAP_M = 0.5 # on the map this near): tables, chairs, boxes, where an object most likely stands NEAR_GAP_M = 0.4 # m; something this near the base's outline when nothing is seen ahead: back off ... +NEAR_RING_M = 0.5 # m from the base centre where _near_look probes for something near after a failed search +NEAR_VIEWS = (0.0, 60.0, -60.0) # deg; _near_look's views after it turned to what is near NEAR_BACK_M = 0.3 # ... this much and look again before the whole search (a cup < ~450 mm from the column # is below both cameras, X1's sweep) LOST_BACK_M = 0.15 # an object lost after a base move: back off this much (the camera sees more) ... @@ -1116,6 +1118,33 @@ def _go_to(thing, goal, tried, holding=False): _approach({"x": float(x), "y": float(y)}, arm_yaw(), tried, goal=goal, holding=holding) +def _near_look(attempt, holding=False): + """The whole search found nothing, but the lidar sees something near the base on some side (NEAR_RING_M from its + centre, within NEAR_GAP_M): a cup on it, or the table to put on, is below both cameras' view, and beside Lumi a + turn there is refused while the arm is over it. Back off NEAR_BACK_M, turn to the middle of what is near (sweep + checked) and look ahead and to each side once (NEAR_VIEWS; X1's sweep: cups 450-720 mm beside on tables 0.2-0.4 m + from the base). None when nothing is near or nothing is seen.""" + if stay_put or _charging(): + return None + x, y, th = agv.pose() + near = [math.radians(d) for d in np.arange(-157.5, 180.1, 22.5) + if agv.clearance(x + NEAR_RING_M * math.cos(th + math.radians(d)), + y + NEAR_RING_M * math.sin(th + math.radians(d))) <= NEAR_GAP_M] + if not near: + return None + d = round(math.degrees(math.atan2(sum(map(math.sin, near)), sum(map(math.cos, near))))) # the middle of it (a + log(f"something near me at {d:+d} deg: backing off and turning to it to look") # table, not one leg) + _straight_clear(-NEAR_BACK_M) + if abs(d) >= TURN_MIN_DEG: + _turn(d, holding, why="to look at what is near me") + for view in NEAR_VIEWS: # ahead, then the waist each way once (X1: a cup 60 deg aside) + got = _look_at(view, attempt) + if got is not None: + return got + _waist_front() + return None + + def _see(task, say=None): """Find the object (_look_around: the torso camera, else the head camera, which shows where to go: the base goes there and they look again), fit the lift to its table and look once more.""" @@ -1130,7 +1159,7 @@ def _see(task, say=None): _straight_clear(-NEAR_BACK_M) obj = _look_at(0.0, attempt) if obj is None and i == 0: - obj = _look_around(attempt, say=say) # one whole search + obj = _look_around(attempt, say=say) or _near_look(attempt) # one whole search if obj is None: break if not obj.get("head"): @@ -1990,7 +2019,8 @@ def _put_down(say=None, on=None): _put_on(top, on, say) # a chair, or "the white table": that thing, by colour return tried = set() - got = _look_around(lambda: _place_view(top), holding=True, say=say) + got = _look_around(lambda: _place_view(top), holding=True, say=say) or \ + _near_look(lambda: _place_view(top), holding=True) if got is True: return if got is not None and arm_yaw() is not None and not _charging(): diff --git a/tests/bank_check.py b/tests/bank_check.py index 5d33c45..12cf962 100644 --- a/tests/bank_check.py +++ b/tests/bank_check.py @@ -8,6 +8,7 @@ leaves to the LLM. Nothing moves; only the embedding server is asked. .venv/bin/python tests/bank_check.py --blind # tests/blind/train/*.py and tests/blind/r2/train/*.py too .venv/bin/python tests/bank_check.py -v # print every hit too, not only the wrong ones .venv/bin/python tests/bank_check.py --blind --rounds r4,r6 --out bank_check_a3.md # some rounds, own report + .venv/bin/python tests/bank_check.py --blind --stress --fast --jobs 4 --rounds r6,r8,r9 # the bank alone, quick A case reaches the bank when command_check's rules (lumi.route without the bank) leave it to the LLM. -> logs/bank_check.md @@ -102,12 +103,13 @@ def judge(expect, got): ROUNDS = [] # --rounds r1,r2: only these blind rounds (r1 = tests/blind/train) +KNOWN = {} QUERIES = ROOT / "data" / "bank_check_queries.npz" # the cases' embeddings, kept between runs (a re-run embeds only # the words it has not seen: minutes instead of an hour) def _cached_embed(): - """knowledge.embed with the case texts' vectors kept in QUERIES; returns a function that saves them.""" + """knowledge.embed with the case texts' vectors kept in QUERIES; returns the dict of known vectors.""" import numpy as np from assistant import knowledge real, known = knowledge.embed, {} @@ -116,40 +118,34 @@ def _cached_embed(): known = dict(zip(z["texts"].tolist(), z["vecs"])) except (OSError, ValueError, KeyError): pass - n0 = len(known) def embed(texts): new = [t for t in dict.fromkeys(texts) if t not in known] if new: known.update(zip(new, real(new))) return np.array([known[t] for t in texts]) - - def save(): - if len(known) > n0: - tmp = QUERIES.with_suffix(".tmp.npz") - np.savez(tmp, texts=np.array(list(known)), vecs=np.array(list(known.values()))) - tmp.replace(QUERIES) knowledge.embed = embed - return save + return known -def main(args): - global OUT - if "--rounds" in args: - ROUNDS[:] = args[args.index("--rounds") + 1].split(",") - if "--out" in args: - OUT = OUT.with_name(args[args.index("--out") + 1]) - marks = markers() - save_queries = _cached_embed() - stress, verbose = "--stress" in args, "-v" in args - from assistant import steps +def _save_queries(known): + import numpy as np + tmp = QUERIES.with_suffix(".tmp.npz") + np.savez(tmp, texts=np.array(list(known)), vecs=np.array(list(known.values()))) + tmp.replace(QUERIES) + + +def _run(job): + """One share of the cases: (counts by set, wrong, hits, read times, missed, new query vectors).""" + part, stress, fast, marks = job + known = KNOWN # the embed wrapper's own dict (in a forked job: its copy) + n0 = set(known) + from assistant import detour, steps steps._ollama = lambda *a: (_ for _ in ()).throw(command_check.NoLLM()) real = intent_bank.read by = collections.defaultdict(collections.Counter) wrong, hits, times, missed = [], [], [], [] - from assistant import detour - no_stuck = detour.recent - for name, text, expect, state, mk, before, *goal in cases("--blind" in args): + for name, text, expect, state, mk, before, *goal in part: mk = mk or marks stuck = {"goal": goal[0]} if state == "stuck" and goal else None # right after a blocked drive detour.recent = lambda: stuck @@ -158,9 +154,9 @@ def main(args): b.history.append(tuple(before)) brain.FORCED_LANG["lang"] = "ko" if brain.HANGUL.search(text) else "en" intent_bank.read = lambda *a, **k: None # the rules alone first - how = stuck and detour.read(text, mk, stuck["goal"]) try: - ruled = f"detour {how}" if how else command_check.rules(text, state, mk, b) + how = stuck and not fast and detour.read(text, mk, stuck["goal"]) + ruled = "llm?" if fast else f"detour {how}" if how else command_check.rules(text, state, mk, b) except command_check.NoLLM: ruled = "llm?" finally: @@ -185,13 +181,47 @@ def main(args): else: by[name][tag] += 1 hits.append(f"- [{name}/{state}] {text!r} -> {g}") - detour.recent = no_stuck - save_queries() + return by, wrong, hits, times, missed, {t: v for t, v in known.items() if t not in n0} + + +def main(args): + """--fast: the rules are not run (0.8 s a case): wrong and llm are the same, hit and agree are counted together as + hit. --jobs N: N processes (the embedding server is shared).""" + global OUT + if "--rounds" in args: + ROUNDS[:] = args[args.index("--rounds") + 1].split(",") + if "--out" in args: + OUT = OUT.with_name(args[args.index("--out") + 1]) + marks = markers() + global KNOWN + known = KNOWN = _cached_embed() + stress, verbose, fast = "--stress" in args, "-v" in args, "--fast" in args + jobs = int(args[args.index("--jobs") + 1]) if "--jobs" in args else 1 + intent_bank._load(), intent_bank._codes() # loaded once, shared by the forked jobs + every = cases("--blind" in args) + parts = [(every[i::jobs], stress, fast, marks) for i in range(jobs)] + if jobs > 1: + import multiprocessing + with multiprocessing.get_context("fork").Pool(jobs) as pool: + done = pool.map(_run, parts) + else: + done = [_run(parts[0])] + by = collections.defaultdict(collections.Counter) + wrong, hits, times, missed = [], [], [], [] + for b, w, h, t, m, v in done: + for k, c in b.items(): + by[k].update(c) + wrong += w + hits += h + times += t + missed += m + known.update(v) + _save_queries(known) for c in by.values(): c["cases"] = sum(c.values()) total = sum(by.values(), collections.Counter()) ms = sorted(times) - lines = [f"# Bank check ({time.strftime('%Y-%m-%d %H:%M')}{', stress' if stress else ''})", "", + lines = [f"# Bank check ({time.strftime('%Y-%m-%d %H:%M')}{', stress' if stress else ''}{', fast' if fast else ''})", "", f"bank: {len(intent_bank.examples())} wordings; read time median {1000 * ms[len(ms) // 2]:.0f} ms, " f"max {1000 * ms[-1]:.0f} ms over {len(ms)} reads" if ms else "", "", "hit: the rules left it to the LLM, the bank answered right; agree: the rules answered and the bank " diff --git a/tests/pick_sweep.py b/tests/pick_sweep.py index dd95761..2231409 100644 --- a/tests/pick_sweep.py +++ b/tests/pick_sweep.py @@ -799,7 +799,8 @@ def _why_class(r): return "knocked over: cup wider than ~88 mm (its chord does not pass the hooks' neck)" return "knocked over (finger landed on the cup)" w = r.get("why") or r["result"] - for key, name in (("too small", "cup too small (physical)"), ("too big", "cup too big (physical)"), + for key, name in (("too low for me", "table too low for the camera at lift 0 (physical)"), + ("too small", "cup too small (physical)"), ("too big", "cup too big (physical)"), ("too thin", "cup too thin (physical)"), ("can't see", "not seen"), ("looked all around", "not seen"), ("still can't reach", "out of reach after every way"), ("way to get close", "no way to get close"), ("not answering", "controller not answering"), diff --git a/tests/qa_eval.py b/tests/qa_eval.py index f17dd4f..497b58f 100644 --- a/tests/qa_eval.py +++ b/tests/qa_eval.py @@ -131,6 +131,30 @@ POS.update({ # night 4, round 2 NEG += ["move forward 4 meters", "앞으로 5미터 가 줘", "grab the paper cup", "종이컵 좀 집어 주세요", "how old is the mayor?", "사장님 연세가 어떻게 되세요?", "who leads samsung?"] +POS.update({ # night 5: openers, asides, Konglish, 하게체, run-together words, guesses + "safety": ["Is it safe to stand next to you?", "아이들 옆에 있어도 안전합니까?", "너 위험하지 않아?", "are you dangerous for kids?"], + "cameras": ["How many cameras do you have?", "카메라 뭐 쓰세요?", "what camera model do you use?", "카메라 몇 대 있어요?"], + "faces": ["Do you do face recognition?", "얼굴 알아볼 수 있어요?", "can you remember faces?"], + "mics": ["How many microphones do you have?", "마이크 몇 개 있어요?", "how far away can you hear?"], + "tts": ["What text to speech do you use?", "목소리는 뭘로 내세요?", "너 목소리 진짜 사람이야?"], + "stt": ["Which speech recognition do you use?", "음성 인식 뭐 쓰십니까?", "말은 어떻게 알아들으세요?"], +}) +POS["age"] += ["궁금한 게, 브로, 너 몇 살이야?", "루미 군, 너 몇 살인가?", "에이지가 몇이야?", "you're about five, right?"] +POS["height"] += ["농사일에 쓸라 카는데, 로봇아, 키가 몇이에요?", "하이트가 얼마야?", "키 how much?", "너 2미터지?"] +POS["maker"] += ["메이커가 어디야?", "LG가 만들었지?", "아야 루미, 어느 회사가 너를 만들었는교?"] +POS["battery_life"] += ["배터리 수명 얼마나 되는가?", "battery life 얼마야?", "하루 종일 가나?"] +NEG += ["내일 며칠이야?", "어제 무슨 요일이었어?", "what's the date tomorrow?", "what day was yesterday?", "크리스마스가 무슨 요일이야?", + "what day is christmas this year?", "다음 주 금요일이 며칠이야?", "몇 시에 문 닫아요?", "what time does the store close?", + "how tall is namsan tower?", "롯데타워 높이가 얼마야?", "BTS 나이가 어떻게 돼?", "how old is the president?", "how heavy is an elephant?", + "코끼리 무게가 얼마야?", "how fast is a cheetah?", "치타 얼마나 빨라?", "핸드폰 배터리 얼마나 가요?", "how long does a phone battery last?", + "who made the iphone?", "who invented robots?", "브라질은 무슨 언어 써?", "what language do they speak in Brazil?", + "what's your mom's name?", "너네 엄마 이름 뭐야?", "what's my name?", "내 나이 맞혀 봐", "몇 살로 보여요?", + "오픈AI 대표 누구야?", "환율 얼마야?", "1달러 얼마야?", "what does JAKA stand for?", "자카 로봇 몇 대 팔렸어?", + "follow me, how tall are you?", "이리 와. 몇 살이야?", "take the cup, then tell me the time", "손 흔들고 몇 시인지 알려 줘", + "what's your name? where's the toilet?", "how are you and what time is it?", "언제?", "how do you know?", "really? how old?", + "그거 몇 킬로야?", "that one, how heavy?", "저 로봇 이름 뭐야?", "옆에 로봇은 몇 살이야?", "what's the name of that robot?"] + + def run(): ok = bad = miss = 0 lines = [] diff --git a/tests/qa_sweep.py b/tests/qa_sweep.py index b830321..c0b6d0f 100644 --- a/tests/qa_sweep.py +++ b/tests/qa_sweep.py @@ -1,50 +1,93 @@ -"""Every first utterance (commands: 'text' with no 'before'; dialogues: first turn 'say') of the blind train sets -through quick_answers.kind_of with no history: list the hits for review. +"""The blind train sets through quick_answers.kind_of with no history (the quick lane alone, no rules before it). - python tests/qa_sweep.py # train, r2-r4, r6, r8, r9, r10 train - python tests/qa_sweep.py r9 r10 # only these rounds' train sets + python tests/qa_sweep.py # first words (commands: 'text' with no 'before'; dialogues: first turn + # 'say') of train, r2-r4, r6, r8, r9, r10: the hits, for review + python tests/qa_sweep.py r9 r10 # only these rounds' train sets + python tests/qa_sweep.py --questions r6 r8 r9 # questions_world: want-quick answered at once, and every quick + # answer that misses the case's must / says its must_not (wrong) + python tests/qa_sweep.py --questions -v r9 # ... and the questions left to the LLM + +The words are embedded in batches first (the embedding server is shared), then read from memory. """ -import glob, importlib, sys +import glob, importlib, re, sys sys.path.insert(0, __file__.rsplit("/tests/", 1)[0]) -from assistant import quick_answers as qa -ROUNDS = sys.argv[1:] or ["train", "r2", "r3", "r4", "r6", "r8", "r9", "r10"] -from assistant import knowledge +from assistant import knowledge, quick_answers as qa +QUESTIONS, VERBOSE = "--questions" in sys.argv, "-v" in sys.argv +ROUNDS = [a for a in sys.argv[1:] if not a.startswith("-")] or \ + (["r6", "r8", "r9"] if QUESTIONS else ["train", "r2", "r3", "r4", "r6", "r8", "r9", "r10"]) _embed, _known = knowledge.embed, {} -def embed(texts): # one batch for all the first words first, then from memory +def embed(texts): # batches first, then from memory new = [t for t in dict.fromkeys(texts) if t not in _known] if new: _known.update(zip(new, _embed(new))) return [_known[t] for t in texts] -knowledge.embed = embed -seen = set() -hits = 0 -todo = [] -for r in ROUNDS: +def pieces(t): + """The words kind_of may embed for t: the whole, each sentence, after a connective, after the last comma.""" + t = qa._tidy(t) + out = [t] + qa.SENTENCES.split(t) + m = qa.CONNECT.match(t) + rest = t[m.end():] if m else t + out += [rest, rest.rpartition(",")[2]] + return [qa._core(p) for p in out if p.strip()] + + +def sets(r, questions): for f in sorted(glob.glob("tests/blind/train/*.py" if r == "train" else f"tests/blind/{r}/train/*.py")): - mod = f[:-3].replace("/", ".") - if mod.endswith("__init__") or "questions_world" in mod: # those are scored by blind_check + if f.endswith("__init__.py") or ("questions_world" in f) != questions: continue - m = importlib.import_module(mod) - texts = [] - for c in getattr(m, "CASES", []): - if isinstance(c, dict) and c.get("text") and not c.get("before") and not c.get("ctx"): - texts.append((c["text"], c.get("expect") or c.get("kind"))) - for d in getattr(m, "DIALOGUES", []): - t = d.get("turns") or [] - if t and t[0].get("say"): - texts.append((t[0]["say"], t[0].get("expect_action"))) - for t, e in texts: - if t not in seen: - seen.add(t) - todo.append((t, e, f"{r}/{mod.split('.')[-1]}")) -embed([qa._core(qa._tidy(t)) for t, _, _ in todo]) -for t, e, where in todo: - k = qa.kind_of(t) - if k: - hits += 1 - print(f"{k:12} {where:22} {t!r} want={e}") -print("texts", len(seen), "quick", hits) + yield f, importlib.import_module(f[:-3].replace("/", ".")) + + +def first_words(): + seen, todo = set(), [] + for r in ROUNDS: + for f, m in sets(r, False): + texts = [(c["text"], c.get("expect") or c.get("kind")) for c in getattr(m, "CASES", []) + if isinstance(c, dict) and c.get("text") and not c.get("before") and not c.get("ctx")] + texts += [(d["turns"][0]["say"], d["turns"][0].get("expect_action")) for d in getattr(m, "DIALOGUES", []) + if d.get("turns") and d["turns"][0].get("say")] + for t, e in texts: + if t not in seen: + seen.add(t) + todo.append((t, e, f"{r}/{f.rsplit('/', 1)[1][:-3]}")) + embed([p for t, _, _ in todo for p in pieces(t)]) + hits = 0 + for t, e, where in todo: + k = qa.kind_of(t) + if k: + hits += 1 + print(f"{k:12} {where:22} {t!r} want={e}") + print("texts", len(seen), "quick", hits) + + +def questions(): + from tests import company_check + cases = [c for r in ROUNDS for _, m in sets(r, True) for c in m.CASES] + embed([p for c in cases for p in pieces(c["text"])]) + want = hit = wrong = 0 + for c in cases: + k = qa.kind_of(c["text"]) + quick = c["expect"] == "quick" + want += quick + if k is None: + if quick and VERBOSE: + print(f"miss [{c['q']}] {c['text']!r}") + continue + hit += quick + lang = "ko" if c["lang"] == "ko" or re.search(r"[가-힣]", c["text"]) and c["lang"] != "en" else "en" + lines = [qa.clock_words(x, lang) for x in qa.KINDS[k][1][lang]] + probs = sorted({p for x in lines for p in company_check.problems(c, lang, x)}) + if c["expect"].startswith("lookup:"): + probs.append(f"want {c['expect']}") + if probs: + wrong += 1 + print(f"WRONG [{c['q']}, {c['expect']}] {c['text']!r} -> {k} {probs[:2]}") + print(f"{' '.join(ROUNDS)}: cases {len(cases)}, want quick {want}, answered at once {hit}, wrong quick answers {wrong}") + + +knowledge.embed = embed +questions() if QUESTIONS else first_words() diff --git a/tests/test_arm_bank.py b/tests/test_arm_bank.py index fd66221..fb387bc 100644 --- a/tests/test_arm_bank.py +++ b/tests/test_arm_bank.py @@ -31,6 +31,10 @@ READS = [ # (words, holding, (action, target)) ("컵 집으시게", False, ("pick", "cup")), ("fetch me that cup", False, ("fetch", "fetch me that cup")), ("컵 챙겨 와 주세요", False, ("fetch", "컵 챙겨 와 주세요")), + ("손 흔들어 줍서", False, ("wave", "")), + ("팔 거두시구려", False, ("arm", "fold")), + ("손내밀어봐", False, ("arm", "reach")), + ("your job now is to fold your arm", False, ("arm", "fold")), ] NOT = [ # (words, holding, motions it must not be): a side word or a hand word is never a drive / turn / look ("pick up the cup on your left", False, ("turn", "move", "look", "go_to", "wave", "arm")), @@ -45,6 +49,8 @@ NEVER = [ # no motion at all from the bank ("the cup on your left is mine", False), ("왼쪽에 컵 있어", False), ("you picked the wrong cup", False), ("팔이 어디까지 닿아?", False), ("why are you waving", False), ("아까 악수했잖아", False), ("shake your head", False), ("pick up the pace", False), ("give it up for lumi", False), + ("thanks for the wave", False), ("악수해 줘서 고마워요", False), ("close your eyes", False), ("의자 들어 줄래?", False), + ("the kids want to wave at you", False), ("can my son shake your hand", False), ] diff --git a/tests/test_command_box.py b/tests/test_command_box.py index fa4981d..84e64bf 100644 --- a/tests/test_command_box.py +++ b/tests/test_command_box.py @@ -329,6 +329,8 @@ READ = [ # the owner's Korean cup / delivery list (2026-10-26 18:40), then mor ("put it on the white table on your right", True, "place right white table"), ("set it down on your left", True, "place left table"), ("excuse me robot, first look me, then follow me", False, "chain"), ("야 루미, 오른쪽 보고 손 흔들어라", False, "chain"), ("hello robot, first turn left, then lower yourself", False, "chain"), + ("악수하고 lower yourself 해 주세요", False, "chain"), ("오늘 날짜 알리고 look left 해 주세요", False, "chain"), + ("wave 하고 look left 해 줘", False, "chain"), ("컵이랑 같이 p5로 가", False, "fetch cup here>p5 hold"), ("컵 하고 같이 exit 가 줘", False, "fetch cup here>exit hold"), ("컵 가지고 p5에서 기다려", False, "pick cup; go p5; wait"), ("컵 들고 p5에 가 있어", False, "pick cup; go p5; wait"), ("이 컵 p5까지 좀 날라 줘", False, "fetch cup here>p5 hold"), ("컵 좀 p5로 옮겨 줘", False, "fetch cup here>p5 hold"), diff --git a/tests/test_fetch_ways.py b/tests/test_fetch_ways.py index 861847f..0f9c357 100644 --- a/tests/test_fetch_ways.py +++ b/tests/test_fetch_ways.py @@ -388,4 +388,20 @@ assert not cups() st = run(fetch.start, TASK) assert any("backing off" in l for l in st["log"]) and st["status"] == "holding", st["log"] assert not any("look around" in l.lower() for l in st["log"]), st["log"] +# ---------- X1 round 5: a cup beside Lumi on a table at its side, below both cameras: after the whole search, back +# off, turn to what is near and look ---------- +for edge, cup in ((0.42, (0.15, 0.6)), (0.7, (0.15, 0.85))): + setup(None, table=(-0.4, 0.5, edge, edge + 0.8)) + room["cups"].append({"id": 1, "map": np.array(cup)}) + assert not cups() + st = run(fetch.start, TASK) + assert st["status"] == "holding", st["log"] + print("beside, table", edge, "m:", [l.split(" ", 1)[1] for l in st["log"] if "near me" in l or "front of me" in l]) +real_around = fetch._look_around # the whole search sees nothing (waist turns refused) +fetch._look_around = lambda *a, **k: None +setup(None, table=(-0.4, 0.5, 0.7, 1.5)) +room["cups"].append({"id": 1, "map": np.array([0.15, 0.85])}) +st = run(fetch.start, TASK) +fetch._look_around = real_around +assert st["status"] == "holding" and any("near me at +90 deg" in l for l in st["log"]), st["log"] print("fetch ways ok") diff --git a/tests/test_fetch_words.py b/tests/test_fetch_words.py index a884b56..ee1f838 100644 --- a/tests/test_fetch_words.py +++ b/tests/test_fetch_words.py @@ -15,7 +15,9 @@ def short(s): if w[0] == "pick": return {"do": "pick", "object": w[-1], "colour": w[1] if len(w) == 3 else None} if w[0] == "receive": - return {"do": "receive", "object": w[1], **({"wait_s": steps.WAIT_GIVE_S} if w[-1] == "wait" else {})} + col = w.pop(1) if len(w) > 2 and w[1] in steps.brain.COLOURS.values() else None # "receive red cup wait" + return {"do": "receive", "object": w[1], **({"wait_s": steps.WAIT_GIVE_S} if w[-1] == "wait" else {}), + **({"colour": col} if col else {})} if w[0] == "wait": if w[1:2] == ["order"]: return {"do": "wait", "s": steps.WAIT_ORDER_S, "until": "instruction"} @@ -101,7 +103,7 @@ STEPS = { "point one에서 빨간 컵 가져와서 P5에 있는 사람한테 줘": "go p1 | pick red cup | go p5 | give", "take the banana to the main stage and give it too Mr. Kim": "pick banana | go Main_Stage | give Mr. Kim", "에구 하얀 컵 집어서 p4로 가져가서 테이블에 놔, 응": "pick white cup | go p4 | place dining table", - "p4에 가서 누가 빨간 컵 주면 받아 가지고 와": "go p4 | receive cup wait | go here", + "p4에 가서 누가 빨간 컵 주면 받아 가지고 와": "go p4 | receive red cup wait | go here", "p4 가서 십 초 wait 하고 와": "go p4 | wait 10 | go here", # a new order on the way (lumi.mission_talk reads it with steps.read) "no, bring it to p4 instead": "go p4", diff --git a/tests/test_quick_answers.py b/tests/test_quick_answers.py index a78b9c1..7120d8f 100644 --- a/tests/test_quick_answers.py +++ b/tests/test_quick_answers.py @@ -27,11 +27,23 @@ KIND = { # words (no talk before) -> kind "are you a Korean robot?": "country", "어느 나라 로봇이에요?": "country", "what computer do you use?": "computer", "관절이 몇 개예요?": "dof", "음성 인식 뭐 써요?": "stt", "how fast do you answer?": "reply_time", "where are you used?": "used_where", "인터넷 써요?": "internet", + # openers, asides, remarks, connectives, stutters, run-together words (night 5) + "hello robot, you name is?": "name", "루미 님, 배터리 수명 얼마나 됩니까?": "battery_life", "누미야 너 몇 살이야": "age", + "실례합니다. 몇 살입니까?": "age", "하나 여쭤봐도 될까요? 너 이름 어떻게 되세요?": "name", "너 살아 있어? ㅎㅎ": "robot", + "Christmas 얼마나 남았어요? 알고 싶어요.": "days_to_christmas", "얘 몇 살일까? 너 몇 살이야?": "age", + "형 비켜 봐, 키가 몇이에요?": "height", "My new friend Lumi, how heavy are you?": "weight", "아 그리고 몇 개 국어 해?": "languages", + "그러면 키가 몇이에요?": "height", "키가 얼— 얼마예요?": "height", "너 너 몇 살이야": "age", "이보게 루미, 지금 몇 시인가?": "time_now", + "누가너를만들었습니까?": "maker", "루미군,오늘무슨요일인가?": "date_today", "키가 얼마인지 알려 주시겠어요?": "height", + "You're Siri, aren't you?": "name", "너 2미터지?": "height", "Samsung made you, right?": "maker", "이번 달 알려 줘.": "date_today", + "에이지가 몇이야?": "age", "스피드가 얼마야?": "speed", "메이커가 어디야?": "maker", "do you have the time?": "time_now", + "아이들 옆에 있어도 안전해?": "safety", "what cameras do you have?": "cameras", "얼굴 인식 돼요?": "faces", + "컴퍼니 오픈 언제예요?": "co_founded", "참, 로봇 양반, 이름이 무슨 뜻이야?": "name_meaning", "Your voice, what program?": "tts", } IN_TALK = { # words after TALK -> kind or None "how old are you?": "age", "who made you?": "maker", "what's your name?": "name", "how old?": None, "몇 살이에요?": None, "hello": None, "why?": None, "really?": None, "and you?": None, "who runs it?": None, "how many people work there?": None, "진짜?": None, "왜요?": None, "너는?": None, "무겁습니까?": None, "어떤 로봇이요?": None, + "그럼 몇 살이에요?": None, "and how old?": None, "근데 너 몇 살이야?": "age", } NEVER = [ # no talk before: never a quick answer "can you see me?", "what am I holding?", "what colour is my shirt?", "how old do I look?", "how tall am I?", @@ -46,6 +58,12 @@ NEVER = [ # no talk before: never a quick answer "로봇 미국 회사 맞아요?", "when is your birthday?", "생일이 언제예요?", "완충까지 몇 시간이에요?", "how slow can you drive?", "what are you doing?", "너 자카 로봇이야?", "can you hear me?", "키 줄여 줘", "Price of the ice cream robot?", + # night 5: other things' facts, commands among sentences or before a comma, fragments + "몇씨야? 아니 몇 살로 보여?", "Is it Samsung? Who made you?", "What's your name? Where's the toilet?", "fold it fold it! your arm!", + "손! 손 내밀어!", "go the souvenir shop, ehh, tell me time", "Turn your head toward me, young robot.", "배터리, 아 아니, 지금 뭐 해?", + "오픈AI 대표 누군가?", "1달러에 원화로 얼만가?", "롯데타워 하이트 얼마야?", "K1 정밀도 어때요?", "PEITIAN 로봇의 가반하중은 얼마입니까?", + "배터리 수명이 몇 년이에요?", "배터리 얼만가?", "do you have time?", "언제?", "How do you know?", + "위험해", "손에 뭐 있어?", "what can your camera see?", "do you recognize me?", "저기 평가 항목, 루미, 오늘 무슨 요일이야?", ] FACT = {"chatgpt": r"\bno\b|아니", "name": r"lumi|루미", "who": r"lumi|루미", "age": r"\b2\b|two|두 살", "maker": r"cutshion|쿳션", "height": r"146", "battery_life": r"10", "languages": r"english|영어", "model": r"gemma|젬마", diff --git a/tests/test_reach.py b/tests/test_reach.py index d77912d..8c5f471 100644 --- a/tests/test_reach.py +++ b/tests/test_reach.py @@ -121,6 +121,15 @@ for r, b in ((600, 60), (600, -60), (550, 90), (600, -100), (730, 7), (720, 25)) for r, b in ((1000, 0), (950, 40)): # too far for any waist turn: the base has to move o = around(r, b) assert all(trusted(fetch.turned(o, d)) is None for d in fetch.waist_for(o)), (r, b) +# the live cases of 2026-10-26 with trusted turns only: from here, after a waist turn, or the base moves (none) +LIVE = (((262, 774, -189), "base"), ((267, 763, -188), "base"), ((260, 722, -186), "base"), # missed at -45 / -30 + ((300, 621, -191), "waist"), ((-99, 738, -181), "waist"), # missed at -30 / carry line jumped at -30 + ((-141, 869, -186), "base"), ((-117, 960, -186), "base"), # across the table / far + ((-104, 694, -186), "here"), ((-73, 588, -186), "here"), ((-96, 598, -260), "here")) # carried / picked +for (x, y, top), how in LIVE: + o = cup(x, y, top) + got = "here" if trusted(o) else "waist" if any(trusted(fetch.turned(o, d)) for d in fetch.waist_for(o)) else "base" + assert got == how, ((x, y, top), got, how) body["waist"] = 100.0 # the waist near its limit (140): no turn past it assert all(body["waist"] + d <= 140.0 for d in fetch.waist_for(around(600, 80))) body["waist"] = -20.31 @@ -168,6 +177,22 @@ calls.clear() scene["cup"] = around(600, -70) # the cup was moved away while the waist turned skills.look = lambda *a, **k: [] assert fetch._waist_reach(task, scene["cup"], None) is None and any(c[0] == "waist" for c in calls) +# ---------- put down: where no joint move from look keeps the cup upright, a straight line to above the spot does +skills._held.clear() +skills._held.update(top_mm=-300.0, yaw=0.0, tips=False, below=40.0) +opts = list(skills.place_options(200.0, 500.0, -300.0, list(LOOK))) +assert opts and all(w[0][0] == "above place (straight)" for w, _ in opts), [w[0][0] for w, _ in opts] +way, ja = opts[0] +assert np.allclose(kinematics.pose(ja)[:3], way[0][1][:3], atol=0.05) +moved = [] +real_lin, real_jm, real_place = skills.motion.move_linear, skills.motion.move_joints, skills._do_place +skills.motion.move_linear = lambda **k: moved.append(("line", k["target"])) +skills.motion.move_joints = lambda j, s: moved.append(("joints", j)) +skills._do_place = lambda w: moved.append(("down",)) +skills.place_turned(way, ja) +assert moved[0] == ("line", way[0][1]) and moved[1] == ("down",), moved +skills.motion.move_linear, skills.motion.move_joints, skills._do_place = real_lin, real_jm, real_place + # ---------- the controller confirms only the chosen plan (a stand-in behind arm.cmd here) ---------- asked, shift = [], {"mm": 0.0} def controller(name, **a): diff --git a/tests/test_steps.py b/tests/test_steps.py index b6ef363..dadbfe9 100644 --- a/tests/test_steps.py +++ b/tests/test_steps.py @@ -26,7 +26,8 @@ def short(s): if do == "receive" and w[1:] == ["hand"]: return {"do": "receive", "object": None, "from_hand": True} # "take this from me": from the person's hand if do == "receive": - out = {"do": "receive", "object": w[1] if len(w) > 1 and w[1] != "wait" else None} + col = w.pop(1) if len(w) > 2 and w[1] in steps.brain.COLOURS.values() else None # "receive red cup wait" + out = {"do": "receive", "object": w[1] if len(w) > 1 and w[1] != "wait" else None, **({"colour": col} if col else {})} if "wait" in w: out["wait_s"] = float(w[-1]) if w[-1] != "wait" else steps.WAIT_GIVE_S return out diff --git a/tests/test_talk.py b/tests/test_talk.py index e7d1547..5f3c901 100644 --- a/tests/test_talk.py +++ b/tests/test_talk.py @@ -54,6 +54,10 @@ def main(): ("", "부엉이 그거 목 을매나 돌아가노?", ["부엉이"]), ("", "너 그거 할 수 있어?", []), ("", "루미 그거 뭐야?", []), + ("", "블루투스 이름은 왜 그렇게 지었나?", ["블루투스"]), + ("", "에펠탑의 높이는 얼마예요?", ["에펠탑"]), + ("", "너 이름은 뭐야?", []), + ("", "루미 이름은 누가 지었어?", []), ("문어는 피가 무슨 색이야?", "심장은 몇 개고?", ["문어", "심장"])]: b = brain.Brain() b.history = [(before, "ACTION: none -\n네.")] if before else [] @@ -72,6 +76,15 @@ def main(): assert picked[-1] and all(e[0] in brain.WORLD_EXAMPLES for e in picked[-1]), "world: world examples only" brain._examples("이름이 뭐예요?") assert any(e[0] == "name" for e in picked[-1]) + import io + import json + from assistant import llm_direct # the model's own empty thought block is never said + def sse(pieces): + return io.BytesIO(b"".join(b"data: " + json.dumps({"content": p}).encode() + b"\n" for p in pieces)) + assert list(llm_direct._pieces(sse(["<|channel>", "thought", "\n", "", "No, ", "she didn't."]))) == \ + ["No, ", "she didn't."] + assert list(llm_direct._pieces(sse(["<|channel>thought\nYes."]))) == ["Yes."] + assert list(llm_direct._pieces(sse(["ACTION: none -\n", "Hi."]))) == ["ACTION: none -\n", "Hi."] print("talk: ok")