Improve arm moves, placing and voice stop and resume
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -1039,8 +1039,8 @@ def _said(kind, words, what):
|
|||||||
if kind == "talk":
|
if kind == "talk":
|
||||||
return f"answer \u201c{words}\u201d"
|
return f"answer \u201c{words}\u201d"
|
||||||
a, t = what
|
a, t = what
|
||||||
return {"look": f"look {t}", "lift": f"lift {t}", "wave": "wave", "come": "come to you", "come_back": "go back",
|
return {"look": f"look {t}", "lift": f"lift {t}", "wave": "wave", "come": "come to me", "come_back": "go back",
|
||||||
"follow": "follow you", "go_to": f"go to {brain.place_said(t)}", "arm": f"arm {t}",
|
"follow": "follow me", "go_to": f"go to {brain.place_said(t)}", "arm": f"arm {t}",
|
||||||
"quiet": "be quiet", "waist": f"turn my waist {t}"}.get(a, f"{a} {t}".strip())
|
"quiet": "be quiet", "waist": f"turn my waist {t}"}.get(a, f"{a} {t}".strip())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+94
-18
@@ -141,12 +141,12 @@ FETCH_STOP = re.compile(r"\b(sto+pp?|stob|halt|freeze|don'?t move)\b|^\W*(?:lumi
|
|||||||
FETCH_GIVE = re.compile(r"\bgive (it|that|this|the \w+)( to me)?\b|\bhand (it )?(over|to me)\b|줘|주세요|건네", re.I)
|
FETCH_GIVE = re.compile(r"\bgive (it|that|this|the \w+)( to me)?\b|\bhand (it )?(over|to me)\b|줘|주세요|건네", re.I)
|
||||||
FETCH_PLACE = re.compile(r"\b(put|place|set) (it|that|this|the \w+) (down|on the table)\b|테이블에 ?(놔|놓|둬)|내려 ?(놔|놓)", re.I)
|
FETCH_PLACE = re.compile(r"\b(put|place|set) (it|that|this|the \w+) (down|on the table)\b|테이블에 ?(놔|놓|둬)|내려 ?(놔|놓)", re.I)
|
||||||
FETCH_BRING_IT = re.compile(r"\bbring (it|that|this)\b|가져와|가져다 ?줘|갖다 ?줘", re.I) # no object named
|
FETCH_BRING_IT = re.compile(r"\bbring (it|that|this)\b|가져와|가져다 ?줘|갖다 ?줘", re.I) # no object named
|
||||||
# ---- someone talks to Lumi while it is on a mission (docs/17 §6) ----
|
# ---- someone talks to Lumi while it is on a mission (docs/17 §4) ----
|
||||||
TALK_WORDS = re.compile(r"\b(wait|excuse me|hold on|hey|hi|hello|sorry|stop|robot)\b|잠깐|잠시만|저기요|안녕|멈춰|스톱|로봇", re.I)
|
|
||||||
SAFETY = re.compile(r"\b(watch out|look out|danger(ous)?|emergency|be careful|my (hand|foot|leg|arm))\b|\bstop\s*!|"
|
SAFETY = re.compile(r"\b(watch out|look out|danger(ous)?|emergency|be careful|my (hand|foot|leg|arm))\b|\bstop\s*!|"
|
||||||
r"\bstop[\s,!.]+stop\b|위험|조심해|비상|멈춰\s*!|아파|다쳐|스톱 ?스톱|멈춰 ?멈춰|끼었|끼여", re.I)
|
r"\bstop[\s,!.]+stop\b|위험|조심해|비상|멈춰\s*!|아파|다쳐|스톱 ?스톱|멈춰 ?멈춰|끼었|끼여", re.I)
|
||||||
GO_ON = re.compile(r"\b(go on|carry on|continue|keep going|you can go|go ahead|off you go|on your way|you may go)\b|"
|
GO_ON = re.compile(r"\b(go on|carry on|continue|keep going|you can go|go ahead|off you go|on your way|you may go|resume|"
|
||||||
r"계속 ?(가|해)|가도 ?(돼|됩니다)|가 ?봐|그냥 ?가|다녀오세요|가던 ?길|^\s*(응|네|그래) ?가\b|\byes,? go\b", re.I)
|
r"finish (?:it|the job|your (?:job|task)))\b|계속 ?(가|해|하|진행)|마저 ?(해|하)|"
|
||||||
|
r"가도 ?(돼|됩니다)|가 ?봐|그냥 ?가|다녀오세요|가던 ?길|^\s*(응|네|그래) ?가\b|\byes,? go\b", re.I)
|
||||||
CANCEL_TASK = re.compile(r"\b(cancel|abort|forget)\b.*\b(task|it|mission|delivery|that)\b|\bcancel\b|"
|
CANCEL_TASK = re.compile(r"\b(cancel|abort|forget)\b.*\b(task|it|mission|delivery|that)\b|\bcancel\b|"
|
||||||
r"\b(don'?t|do not|no longer) need\b|필요 ?없|취소", re.I)
|
r"\b(don'?t|do not|no longer) need\b|필요 ?없|취소", re.I)
|
||||||
I_AM = re.compile(r"\b(?:i am|i'm|im|my name is|this is|it's|it is)\s+(?:the\s+)?([a-z][a-z'-]{1,20})\b(?!'s)|\b([a-z][a-z'-]{1,20}) here\b|"
|
I_AM = re.compile(r"\b(?:i am|i'm|im|my name is|this is|it's|it is)\s+(?:the\s+)?([a-z][a-z'-]{1,20})\b(?!'s)|\b([a-z][a-z'-]{1,20}) here\b|"
|
||||||
@@ -209,7 +209,9 @@ LIMIT_SAY = {"yaw": (f"I can turn my head up to {head.AXIS_LIMITS[2][1]:g} degre
|
|||||||
DONE_TALK = re.compile(r"\b(bye+|goodbye|see you|never ?mind|nothing|that'?s (all|it)|no thanks|thanks|thank you|"
|
DONE_TALK = re.compile(r"\b(bye+|goodbye|see you|never ?mind|nothing|that'?s (all|it)|no thanks|thanks|thank you|"
|
||||||
r"okay|ok|fine|alright|cool|whatever)\b|안녕히|잘 ?가|됐어|괜찮아|아니야|고마워|감사|그래|네|수고|알았어|"
|
r"okay|ok|fine|alright|cool|whatever)\b|안녕히|잘 ?가|됐어|괜찮아|아니야|고마워|감사|그래|네|수고|알았어|"
|
||||||
r"그게 ?다|빠이|바이|나중에|안녕\s*[.!]?$", re.I)
|
r"그게 ?다|빠이|바이|나중에|안녕\s*[.!]?$", re.I)
|
||||||
TALK_RECENT_S = 20.0 # s; someone spoke with Lumi this recently: what they say next is to Lumi too
|
RESUME_S = 300.0 # s; "Lumi, keep going" this long after a stop word ended a mission does its rest
|
||||||
|
STOPPED_RECENT_S = 10.0 # s; a mission that ended this recently (a stop word cut its skill first) is the one
|
||||||
|
# a stop word stopped
|
||||||
ENOUGH = re.compile(r"\b(enough|no more)\b|그만해|됐어 ?그만", re.I) # with stop_order: ends a mission at once
|
ENOUGH = re.compile(r"\b(enough|no more)\b|그만해|됐어 ?그만", re.I) # with stop_order: ends a mission at once
|
||||||
ASK_NOT_ORDER = re.compile(r"\b(can|could|would|will) you\b|\bplease\b|줄래|줄 ?수|해 ?줘|주세요|(?<!뭐 )줘", re.I) # a request
|
ASK_NOT_ORDER = re.compile(r"\b(can|could|would|will) you\b|\bplease\b|줄래|줄 ?수|해 ?줘|주세요|(?<!뭐 )줘", re.I) # a request
|
||||||
LOOK_HOLD_S = 35.0 # s; a head direction asked for ("look up / left") is held this long after the last
|
LOOK_HOLD_S = 35.0 # s; a head direction asked for ("look up / left") is held this long after the last
|
||||||
@@ -769,6 +771,7 @@ class Lumi:
|
|||||||
self.current = None # the track we are talking with
|
self.current = None # the track we are talking with
|
||||||
self.mission_hold = None # "talk" / "safety": a mission is halted for someone (mission_talk)
|
self.mission_hold = None # "talk" / "safety": a mission is halted for someone (mission_talk)
|
||||||
self.asked_go_on = False # "Can I go on with my task?" was asked
|
self.asked_go_on = False # "Can I go on with my task?" was asked
|
||||||
|
self.stopped_mission = None # (task, steps left, time) a stop word ended: "Lumi, keep going" (resume_stopped)
|
||||||
self.voice_until = 0.0 # a conversation started by voice with nobody in view lasts until then
|
self.voice_until = 0.0 # a conversation started by voice with nobody in view lasts until then
|
||||||
self.quiet_until = 0.0 # after "be quiet": no greetings until then
|
self.quiet_until = 0.0 # after "be quiet": no greetings until then
|
||||||
self._yaw, self._yaw_time = 0.0, 0.0
|
self._yaw, self._yaw_time = 0.0, 0.0
|
||||||
@@ -1196,12 +1199,21 @@ class Lumi:
|
|||||||
log(f" fetch dialog: {result}")
|
log(f" fetch dialog: {result}")
|
||||||
self.keep_listening()
|
self.keep_listening()
|
||||||
|
|
||||||
def stop_all(self):
|
def stop_all(self, text=""):
|
||||||
"""Stop by voice: the fetch / mission runner, the base, the arm, a trip; then say so."""
|
"""Stop by voice: the fetch / mission runner, the base, the arm, a trip; then say so. An order said after the
|
||||||
|
stop word ("Lumi stop, not the apple, take the cup") is done next; else a stopped mission is kept for "Lumi,
|
||||||
|
keep going" (resume_stopped)."""
|
||||||
from tasks import fetch
|
from tasks import fetch
|
||||||
log(" stop by voice")
|
log(" stop by voice")
|
||||||
self.chain_stop.set()
|
self.chain_stop.set()
|
||||||
|
left = self.mission_left()
|
||||||
safe(fetch.stop)
|
safe(fetch.stop)
|
||||||
|
rest = text and order_after_stop(text, self.markers, getattr(self, "brain", None))
|
||||||
|
if rest:
|
||||||
|
log(f" then the order after the stop: {rest!r}")
|
||||||
|
safe(fetch.end) # the run's thread is over: the new order can start
|
||||||
|
self.pending_text = rest
|
||||||
|
self.stopped_mission = None if rest else left
|
||||||
self.act("stop", "")
|
self.act("stop", "")
|
||||||
if self.patrol:
|
if self.patrol:
|
||||||
self.patrol.pause()
|
self.patrol.pause()
|
||||||
@@ -1315,9 +1327,9 @@ class Lumi:
|
|||||||
safe(fetch.release_now) # the person let go of it / has taken it
|
safe(fetch.release_now) # the person let go of it / has taken it
|
||||||
return True
|
return True
|
||||||
if stop_order(text, self.markers) or ENOUGH.search(text) and "?" not in text:
|
if stop_order(text, self.markers) or ENOUGH.search(text) and "?" not in text:
|
||||||
log(f" mission: stop word ({text!r}) - mission ended") # running or paused: ended, never "going on"
|
log(f" mission: stop word ({text!r}) - mission ended") # running or paused: ended; "Lumi, keep going"
|
||||||
self.mission_hold, self.asked_go_on = None, False
|
self.mission_hold, self.asked_go_on = None, False # starts its rest again (resume_stopped)
|
||||||
self.stop_all()
|
self.stop_all(text)
|
||||||
return True
|
return True
|
||||||
recipient = next((s.get("person") for s in task_steps if s.get("do") == "give" and s.get("person")), None)
|
recipient = next((s.get("person") for s in task_steps if s.get("do") == "give" and s.get("person")), None)
|
||||||
name = claimed_name(text)
|
name = claimed_name(text)
|
||||||
@@ -1325,12 +1337,9 @@ class Lumi:
|
|||||||
mine = owner is not None # the person it is for, or who sent it
|
mine = owner is not None # the person it is for, or who sent it
|
||||||
if mine:
|
if mine:
|
||||||
name = owner # as the mission writes it ("James", not "james")
|
name = owner # as the mission writes it ("James", not "james")
|
||||||
addressed = WAKE.search(text) or TALK_WORDS.search(text) or SAFETY.search(text) or mine or name or \
|
addressed = WAKE.search(text) or SAFETY.search(text) or mine or self.mission_hold or \
|
||||||
STATUS_Q.search(text) or \
|
waiting == "instruction" or waiting and GO_ON.search(text) or getattr(self, "typed_now", False)
|
||||||
REQUEST.search(text) or GIVE_ME.search(text) or self.mission_hold or self.current is not None or \
|
# only Lumi's name halts a job: talk nearby ("네, 안녕하세요.", "Very nice.") paused a pick live (2026-10-27)
|
||||||
time.time() - getattr(self, "last_talk", 0.0) < TALK_RECENT_S or waiting == "instruction" or \
|
|
||||||
waiting and GO_ON.search(text)
|
|
||||||
self.last_talk = time.time()
|
|
||||||
if not addressed:
|
if not addressed:
|
||||||
log(f" mission: not to me, ignored: {text!r}")
|
log(f" mission: not to me, ignored: {text!r}")
|
||||||
return True
|
return True
|
||||||
@@ -1424,6 +1433,48 @@ class Lumi:
|
|||||||
return self.keep_listening() or True
|
return self.keep_listening() or True
|
||||||
return False # a question: answered as usual, still halted
|
return False # a question: answered as usual, still halted
|
||||||
|
|
||||||
|
def mission_left(self):
|
||||||
|
"""(task, the steps from the one running on, time) of the mission running or just ended: what "Lumi, keep
|
||||||
|
going" does after a stop word (resume_stopped). None when no mission runs."""
|
||||||
|
from tasks import fetch
|
||||||
|
st = safe(fetch.state) or {}
|
||||||
|
task = st.get("task") or {}
|
||||||
|
if not task.get("steps") or st.get("status") not in ("running", "stopped", "failed") or \
|
||||||
|
st.get("status") != "running" and time.time() - (st.get("since") or 0.0) > STOPPED_RECENT_S:
|
||||||
|
return None
|
||||||
|
n = [int(m.group(1)) for m in (re.search(r"\bstep (\d+)/\d+:", x) for x in st.get("log") or []) if m]
|
||||||
|
return task, task["steps"][n[-1] - 1 if n else 0:], time.time()
|
||||||
|
|
||||||
|
def resume_stopped(self, text):
|
||||||
|
""""Lumi, keep going" / "루미 계속해" after a stop word ended a mission: its steps from the one stopped on
|
||||||
|
start again (a stopped pick with the thing in the hand counts as done). Only with Lumi's name, not a question,
|
||||||
|
within RESUME_S and while nothing else ran since. True if handled."""
|
||||||
|
from assistant import steps
|
||||||
|
from tasks import fetch
|
||||||
|
left = getattr(self, "stopped_mission", None) # (Lumi.__new__ in the self-checks)
|
||||||
|
if not left or not (WAKE.search(text) and GO_ON.search(text)) or "?" in text or lumi_question(text) or \
|
||||||
|
steps.read(text, self.markers, llm=False)[0]:
|
||||||
|
return False
|
||||||
|
self.stopped_mission = None
|
||||||
|
task, todo, t = left
|
||||||
|
st = safe(fetch.state) or {}
|
||||||
|
if time.time() - t > RESUME_S or st.get("status") == "running" or (st.get("task") or {}).get("steps") != task["steps"]:
|
||||||
|
return False
|
||||||
|
if todo[0]["do"] == "pick" and self.held_now():
|
||||||
|
todo = [{"do": "carry"}] + todo[1:] # stopped after the grasp: finish the lift to look first
|
||||||
|
log(f" mission: going on after the stop: {todo}")
|
||||||
|
try:
|
||||||
|
fetch.run_steps(todo, say=self.fetch_say, sender=task.get("sender"))
|
||||||
|
if todo == [{"do": "carry"}]: # "take the cup" stopped with the cup in the hand
|
||||||
|
self.fetch_say(f"I have {fetch.held_name()} in my hand. Where should I put it?",
|
||||||
|
f"{brain_mod.object_ko(fetch.held_name('ko'))} 들고 있어요. 어디에 둘까요?")
|
||||||
|
return self.keep_listening() or True
|
||||||
|
self.fetch_say("Okay, I'll go on with my task.", "네, 하던 일 계속할게요.")
|
||||||
|
except fetch.FetchError as e:
|
||||||
|
log(f" going on refused: {e}")
|
||||||
|
self.fetch_say(str(e), "죄송해요, 지금은 할 수 없어요.")
|
||||||
|
return self.keep_listening() or True
|
||||||
|
|
||||||
def end_run(self, text):
|
def end_run(self, text):
|
||||||
"""Anyone's new command while the task runner runs (a mission, a fetch): end it with one short line; the
|
"""Anyone's new command while the task runner runs (a mission, a fetch): end it with one short line; the
|
||||||
command is then done. Nothing held is forgotten (a "holding" state is no run)."""
|
command is then done. Nothing held is forgotten (a "holding" state is no run)."""
|
||||||
@@ -1899,6 +1950,19 @@ class Lumi:
|
|||||||
log(f" reach over ({'said ' + repr(text) if text else 'timeout'}): the arm back to look")
|
log(f" reach over ({'said ' + repr(text) if text else 'timeout'}): the arm back to look")
|
||||||
return bool(self.arm_pose("fold"))
|
return bool(self.arm_pose("fold"))
|
||||||
|
|
||||||
|
def typed(self, text):
|
||||||
|
"""Words typed in the dashboard's Command box, answered as if said: nothing of the last voice is used (its
|
||||||
|
whisper confidence asked "say it again" for "look at front", its direction found nobody for "come to me": the
|
||||||
|
person in view is the one, 2026-10-27)."""
|
||||||
|
ears.last_stt.clear()
|
||||||
|
ears.last_stt.update(language="korean" if brain_mod.HANGUL.search(text) else "english", logprob=0.0, text=text)
|
||||||
|
self.voice_trusted = False
|
||||||
|
self.typed_now = True # to Lumi, name or not (mission_talk)
|
||||||
|
try:
|
||||||
|
self.answer(text)
|
||||||
|
finally:
|
||||||
|
self.typed_now = False
|
||||||
|
|
||||||
def held_now(self):
|
def held_now(self):
|
||||||
"""Something in the hand now: the hand is checked (fetch.check_hand, which also forgets a stale "holding");
|
"""Something in the hand now: the hand is checked (fetch.check_hand, which also forgets a stale "holding");
|
||||||
the state when it can't be. The stale state alone refused open / wave on an empty hand (2026-10-23 17:41)."""
|
the state when it can't be. The stale state alone refused open / wave on an empty hand (2026-10-23 17:41)."""
|
||||||
@@ -1921,7 +1985,7 @@ class Lumi:
|
|||||||
cmd = d.get("cmd")
|
cmd = d.get("cmd")
|
||||||
log(f"dashboard: {cmd} {d.get('marker') or d.get('point') or d.get('markers') or ''}")
|
log(f"dashboard: {cmd} {d.get('marker') or d.get('point') or d.get('markers') or ''}")
|
||||||
if cmd == "heard": # the Command box: done as if said (route(), no read-back
|
if cmd == "heard": # the Command box: done as if said (route(), no read-back
|
||||||
self.answer(d.get("text") or "") # for a command or chain: /tasks/parse showed it)
|
self.typed(d.get("text") or "") # for a command or chain: /tasks/parse showed it)
|
||||||
elif cmd == "go":
|
elif cmd == "go":
|
||||||
self.start_trip(d["marker"])
|
self.start_trip(d["marker"])
|
||||||
elif cmd == "go_point":
|
elif cmd == "go_point":
|
||||||
@@ -2652,6 +2716,8 @@ class Lumi:
|
|||||||
return
|
return
|
||||||
if self.mission_running() and self.mission_talk(text): # on a mission: halt for them, refuse other tasks
|
if self.mission_running() and self.mission_talk(text): # on a mission: halt for them, refuse other tasks
|
||||||
return
|
return
|
||||||
|
if self.resume_stopped(text): # "Lumi, keep going" after a stop word ended a mission
|
||||||
|
return
|
||||||
if NAME_ONLY.match(text): # just "Lumi?": they want attention
|
if NAME_ONLY.match(text): # just "Lumi?": they want attention
|
||||||
mouth.say("Yes?" if self.lang == "en" else "네?")
|
mouth.say("Yes?" if self.lang == "en" else "네?")
|
||||||
self.keep_listening()
|
self.keep_listening()
|
||||||
@@ -2660,7 +2726,7 @@ class Lumi:
|
|||||||
kind, data = route(text, self.markers, self.brain, self.held_now,
|
kind, data = route(text, self.markers, self.brain, self.held_now,
|
||||||
seen=lambda x: seeing.answer(x, self.lang, slow_line=mouth.say), last=last, chain_ok=not part and not self.mission_running() and not self.chain_busy())
|
seen=lambda x: seeing.answer(x, self.lang, slow_line=mouth.say), last=last, chain_ok=not part and not self.mission_running() and not self.chain_busy())
|
||||||
if kind == "stop":
|
if kind == "stop":
|
||||||
self.stop_all() # "stop", "stop, where are you going?": stop first, always
|
self.stop_all(text) # "stop", "stop, where are you going?": stop first, always
|
||||||
return
|
return
|
||||||
if self.pointed_drive(text): # "go there" / "저기로 가" with a pointing arm (pointing.py)
|
if self.pointed_drive(text): # "go there" / "저기로 가" with a pointing arm (pointing.py)
|
||||||
return
|
return
|
||||||
@@ -3321,6 +3387,16 @@ def stop_order(text, markers):
|
|||||||
return stop_order_said(text, markers) or bool(bare and bare != text and stop_order_said(bare, markers))
|
return stop_order_said(text, markers) or bool(bare and bare != text and stop_order_said(bare, markers))
|
||||||
|
|
||||||
|
|
||||||
|
def order_after_stop(text, markers, b):
|
||||||
|
""""Lumi stop, not the apple, take the cup", "루미 멈춰, 제자리에 놔": the order said after the stop word (done
|
||||||
|
after the stop), else None ("stop it", "stop, where are you going?", "stop, don't take it")."""
|
||||||
|
m = FETCH_STOP.search(text or "")
|
||||||
|
rest = text[m.end():].strip(" ,.!?~") if m else ""
|
||||||
|
if len(rest.split()) < 2:
|
||||||
|
return None
|
||||||
|
return rest if route(rest, markers, b, chain_ok=False)[0] in ("quick", "hand", "mission", "chain") else None
|
||||||
|
|
||||||
|
|
||||||
def stop_order_said(text, markers):
|
def stop_order_said(text, markers):
|
||||||
""""stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button;
|
""""stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button;
|
||||||
"can you stop?", "멈출 수 있어?" and "stop, where are you going?" do stop. Not a negated stop ("don't stop", "계속
|
"can you stop?", "멈출 수 있어?" and "stop, where are you going?" do stop. Not a negated stop ("don't stop", "계속
|
||||||
|
|||||||
+2
-2
@@ -21,8 +21,8 @@ from assistant import brain, wording
|
|||||||
MOVE_MAX_M = 3.0 # m; a mission's single move is at most this long
|
MOVE_MAX_M = 3.0 # m; a mission's single move is at most this long
|
||||||
TURN_DEG = 90.0 # "turn left" without a number
|
TURN_DEG = 90.0 # "turn left" without a number
|
||||||
SIDE_DEG = {"left": 90.0, "right": -90.0}
|
SIDE_DEG = {"left": 90.0, "right": -90.0}
|
||||||
DO = ("go", "move", "turn", "pick", "receive", "say", "place", "give", "hold", "arm", "wait")
|
DO = ("go", "move", "turn", "pick", "receive", "say", "place", "give", "hold", "arm", "wait", "carry")
|
||||||
MISSION_ONLY = {"move", "turn", "receive", "say", "arm", "wait"} # steps the plain fetch / carry can't do
|
MISSION_ONLY = {"move", "turn", "receive", "say", "arm", "wait", "carry"} # steps the plain fetch / carry can't do
|
||||||
WAIT_SHORT_S = 10.0 # s; "wait a moment", "잠깐 기다렸다가": a short wait
|
WAIT_SHORT_S = 10.0 # s; "wait a moment", "잠깐 기다렸다가": a short wait
|
||||||
WAIT_MAX_S = 1800.0 # s; a longer wait is refused (check)
|
WAIT_MAX_S = 1800.0 # s; a longer wait is refused (check)
|
||||||
WAIT_GIVE_S = 300.0 # s; "wait until someone gives you the cup": the hand is held out this long, then the
|
WAIT_GIVE_S = 300.0 # s; "wait until someone gives you the cup": the hand is held out this long, then the
|
||||||
|
|||||||
+7
-1
@@ -24,7 +24,10 @@ Every value here is a constant at the top of its file, with a comment on what it
|
|||||||
| `robot/motion.py` | `SETTLE_S` | 0.3 s | After each arrival (inpos, joints within 0.3°) the arm stands this long before the next move of a route or wave. Estimate |
|
| `robot/motion.py` | `SETTLE_S` | 0.3 s | After each arrival (inpos, joints within 0.3°) the arm stands this long before the next move of a route or wave. Estimate |
|
||||||
| `manipulation/arm_route.py` | `HEAD_CLEAR_MM` | 250 mm | The gripper (flange, grasp point, finger tips) keeps this from the head's turning centre (`head_cam.head_centre()`) on every pose-graph move, the wave and straight moves with an object. The head camera is 102 mm from that centre; `look` keeps 327 mm. Estimate (head size not measured) |
|
| `manipulation/arm_route.py` | `HEAD_CLEAR_MM` | 250 mm | The gripper (flange, grasp point, finger tips) keeps this from the head's turning centre (`head_cam.head_centre()`) on every pose-graph move, the wave and straight moves with an object. The head camera is 102 mm from that centre; `look` keeps 327 mm. Estimate (head size not measured) |
|
||||||
| `manipulation/arm_route.py` | `EDGES` | give–carry, carry–look, look–wave_out, wave_out–wave_start, wave_start–wave, look–ready | The only joint moves between named poses |
|
| `manipulation/arm_route.py` | `EDGES` | give–carry, carry–look, look–wave_out, wave_out–wave_start, wave_start–wave, look–ready | The only joint moves between named poses |
|
||||||
| `manipulation/arm_route.py` | `JOIN_DEG` | 20° | An arm at no pose (free drive, stopped half way) joins the graph by one checked joint move only when every joint is this close to a pose; else it does not move and asks to be brought near `look` |
|
| `manipulation/arm_route.py` | `LINK_HEAD_CLEAR_MM` | 220 mm | Every arm link (elbow, wrist) keeps this from the head's turning centre on every pose-graph move. Estimate below the least of the taught graph (267 mm at `wave`) |
|
||||||
|
| `manipulation/arm_route.py` | `JOIN_DEG` | 20° | An arm at no pose (free drive, stopped half way) joins the graph by one checked joint move to a pose, the nearest first; joins further than this run at the slow speed |
|
||||||
|
| `manipulation/arm_route.py` | `UP_MM` | 100, 200 mm | When no direct join passes the checks, the arm first goes this far straight up, then joins |
|
||||||
|
| `robot/arm.py` | `RETRIES`, `RETRY_S` | 5, 0.2 s | A dropped controller connection is retried this often, the wait doubling each time (3 s in all); the controller closes connections for ~0.5 s every few seconds |
|
||||||
| `manipulation/arm_route.py` | `AT_POSE_DEG`, `EXACT_DEG` | 3°, 1° | At a pose for programs and `check` / further than 1° from the nearest pose a route first goes to it |
|
| `manipulation/arm_route.py` | `AT_POSE_DEG`, `EXACT_DEG` | 3°, 1° | At a pose for programs and `check` / further than 1° from the nearest pose a route first goes to it |
|
||||||
| `api/dashboard.html` | `MAP_POLL_MS` | 20000 ms | The dashboard reads the map's markers again this often (markers added on the base, a map switched) |
|
| `api/dashboard.html` | `MAP_POLL_MS` | 20000 ms | The dashboard reads the map's markers again this often (markers added on the base, a map switched) |
|
||||||
|
|
||||||
@@ -132,6 +135,9 @@ Every value here is a constant at the top of its file, with a comment on what it
|
|||||||
| File | Name | Default | What it does |
|
| File | Name | Default | What it does |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `tasks/fetch.py` | `PLACE_GRID_X`, `PLACE_GRID_Y` | x −260…−60 step 40, y 640…740 mm | Place spots tried in front (after the pick spot); IK refuses the ones out of reach |
|
| `tasks/fetch.py` | `PLACE_GRID_X`, `PLACE_GRID_Y` | x −260…−60 step 40, y 640…740 mm | Place spots tried in front (after the pick spot); IK refuses the ones out of reach |
|
||||||
|
| `tasks/fetch.py` | `PLACE_LOW_Z` | −480 mm | A level top lower than this (arm frame, lift 0) is a seat, never a place |
|
||||||
|
| `tasks/fetch.py` | `KEEP_R_MM`, `KEEP_STEP_MM`, `KEEP_TOL_MM` | 400, 40, 40 mm | A table seen once is kept on the map; after each move it is looked for only within this radius of its kept spot (on this grid) and this close to its kept height |
|
||||||
|
| `tasks/fetch.py` | `PLACE_NAV_MAX` | 2 | Navigation drives round to a kept table at most this often per place, then straight ways only |
|
||||||
| `tasks/fetch.py` | `PLACE_GOAL` | (−160, 670) mm | Where the base brings a table spot seen further away |
|
| `tasks/fetch.py` | `PLACE_GOAL` | (−160, 670) mm | Where the base brings a table spot seen further away |
|
||||||
| `tasks/fetch.py` | `FAR_R_MM`, `FAR_HALF_DEG`, `FAR_IN_MM` | 0.6–3 m, ±45°, 150 mm | A table further away: level tops looked for on sight lines this far, within this of where the camera looks; the base goes to the point this far in from its nearest edge |
|
| `tasks/fetch.py` | `FAR_R_MM`, `FAR_HALF_DEG`, `FAR_IN_MM` | 0.6–3 m, ±45°, 150 mm | A table further away: level tops looked for on sight lines this far, within this of where the camera looks; the base goes to the point this far in from its nearest edge |
|
||||||
| `tasks/fetch.py` | `TOP_NEAR_MM` | 1500 mm | A named thing's top measured further away is not trusted: the base goes closer first |
|
| `tasks/fetch.py` | `TOP_NEAR_MM` | 1500 mm | A named thing's top measured further away is not trusted: the base goes closer first |
|
||||||
|
|||||||
@@ -7,13 +7,16 @@ moves.
|
|||||||
|
|
||||||
`look` is where every arm action starts (picks and puts go out from it and come back to it, skills.py). From any
|
`look` is where every arm action starts (picks and puts go out from it and come back to it, skills.py). From any
|
||||||
pose of the graph the arm goes to another along the graph, one joint move per edge. An arm at no pose (after free
|
pose of the graph the arm goes to another along the graph, one joint move per edge. An arm at no pose (after free
|
||||||
drive, after a stop half way) joins the graph only by one checked joint move to the nearest pose, at most JOIN_DEG
|
drive, after a stop half way) joins the graph by one checked joint move to a pose of it, the nearest first; when no
|
||||||
on every joint; further away nothing moves and Lumi asks for the arm to be brought near `look` by hand. A task's own
|
such move passes, first straight up by UP_MM (a joint move to the IK pose above, checked the same way), then the
|
||||||
|
join. Joins further than JOIN_DEG run at HOLD_SPEED. Only when nothing passes, nothing moves and Lumi asks for the
|
||||||
|
arm to be brought near `look` by hand. A task's own
|
||||||
way back from the table (`leaf`: it went out from `look` along a checked plan) goes straight to its target.
|
way back from the table (`leaf`: it went out from `look` along a checked plan) goes straight to its target.
|
||||||
|
|
||||||
Each joint move is checked at PATH_POINTS points (kine_forward): joint limits, no joint turning further than
|
Each joint move is checked at PATH_POINTS points (kine_forward): joint limits, no joint turning further than
|
||||||
motion.MAX_TRAVEL, the gripper (flange -> grasp point -> finger tips) at least HEAD_CLEAR_MM from the head's turning
|
motion.MAX_TRAVEL, the gripper (flange -> grasp point -> finger tips) at least HEAD_CLEAR_MM from the head's turning
|
||||||
centre (vision/head_cam.py), never more than skills.PATH_SAG_MM below both ends, and with something in the hand the
|
centre (vision/head_cam.py), every arm link (elbow, wrist; offline kinematics) at least LINK_HEAD_CLEAR_MM from it,
|
||||||
|
never more than skills.PATH_SAG_MM below both ends, and with something in the hand the
|
||||||
cup's lean at most skills.MAX_TILT_DEG. Refusals are RouteError with the reason in English and Korean.
|
cup's lean at most skills.MAX_TILT_DEG. Refusals are RouteError with the reason in English and Korean.
|
||||||
|
|
||||||
A route runs one move at a time (motion.move_path): each to a full stop and SETTLE_S standing, then the next; SPEED
|
A route runs one move at a time (motion.move_path): each to a full stop and SETTLE_S standing, then the next; SPEED
|
||||||
@@ -31,7 +34,7 @@ import time
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from manipulation import skills
|
from manipulation import skills
|
||||||
from robot import arm, gripper, motion
|
from robot import arm, gripper, kinematics, motion
|
||||||
from vision import calib, head_cam
|
from vision import calib, head_cam
|
||||||
|
|
||||||
HOME = "look" # every arm action starts here
|
HOME = "look" # every arm action starts here
|
||||||
@@ -41,10 +44,13 @@ SPEED = "route" # motion.JOINT_SPEED of the moves along the
|
|||||||
HOLD_SPEED = "slow" # ... with something in the hand
|
HOLD_SPEED = "slow" # ... with something in the hand
|
||||||
AT_POSE_DEG = 3.0 # deg; the arm is at a pose when every joint is this close (where, programs)
|
AT_POSE_DEG = 3.0 # deg; the arm is at a pose when every joint is this close (where, programs)
|
||||||
EXACT_DEG = 1.0 # deg; further than this from the nearest pose a route first goes to it
|
EXACT_DEG = 1.0 # deg; further than this from the nearest pose a route first goes to it
|
||||||
JOIN_DEG = 20.0 # deg; an arm at no pose joins the graph only this close to one (every joint)
|
JOIN_DEG = 20.0 # deg; an arm at no pose this close to one (every joint) joins it at the route speed
|
||||||
|
UP_MM = (100.0, 200.0) # mm straight up tried before a join when no direct join passes
|
||||||
PATH_POINTS = 21 # points checked (kine_forward) on every joint move
|
PATH_POINTS = 21 # points checked (kine_forward) on every joint move
|
||||||
HEAD_CLEAR_MM = 250.0 # mm the gripper keeps from the head's turning centre. Estimate: the head camera
|
HEAD_CLEAR_MM = 250.0 # mm the gripper keeps from the head's turning centre. Estimate: the head camera
|
||||||
# is 102 mm from it, the head's size is not measured. `look` keeps 327 mm
|
# is 102 mm from it, the head's size is not measured. `look` keeps 327 mm
|
||||||
|
LINK_HEAD_CLEAR_MM = 220.0 # mm every arm link keeps from the head's turning centre. Estimate below the taught
|
||||||
|
# graph's least (267 mm at `wave`, live); the head's size is not measured
|
||||||
NEVER_RUN = ("hand_shaking.jks",) # Cobo π programs not started any more
|
NEVER_RUN = ("hand_shaking.jks",) # Cobo π programs not started any more
|
||||||
|
|
||||||
# Why the arm does not move, (English, Korean)
|
# Why the arm does not move, (English, Korean)
|
||||||
@@ -150,6 +156,21 @@ def _gripper(c):
|
|||||||
return f, g, g + R @ (skills.TIP_MM * skills.FINGER_DIR), R
|
return f, g, g + R @ (skills.TIP_MM * skills.FINGER_DIR), R
|
||||||
|
|
||||||
|
|
||||||
|
def links(j):
|
||||||
|
"""Joint origins (mm, arm base frame) from the shoulder to the flange at joints j (offline kinematics)."""
|
||||||
|
return [f[:3, 3] for f in kinematics.chain(j)[2:]]
|
||||||
|
|
||||||
|
|
||||||
|
def link_clearance(j0, j1, centre):
|
||||||
|
"""Smallest distance (mm) from `centre` to the arm's links at PATH_POINTS points of the joint move j0 -> j1."""
|
||||||
|
j0, j1 = np.array(j0, float), np.array(j1, float)
|
||||||
|
out = np.inf
|
||||||
|
for k in range(PATH_POINTS):
|
||||||
|
pts = links(list(j0 + (j1 - j0) * k / (PATH_POINTS - 1)))
|
||||||
|
out = min([out] + [_seg_dist(centre, a, b) for a, b in zip(pts, pts[1:])])
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
def flange_clearance(c, centre):
|
def flange_clearance(c, centre):
|
||||||
"""Smallest distance (mm) from `centre` to the gripper at the flange pose c."""
|
"""Smallest distance (mm) from `centre` to the gripper at the flange pose c."""
|
||||||
f, g, tip, _ = _gripper(c)
|
f, g, tip, _ = _gripper(c)
|
||||||
@@ -177,6 +198,9 @@ def move_problem(j0, j1, centre, holding=False):
|
|||||||
clear, ends, low, tilt = profile(j0, j1, centre)
|
clear, ends, low, tilt = profile(j0, j1, centre)
|
||||||
if clear < HEAD_CLEAR_MM:
|
if clear < HEAD_CLEAR_MM:
|
||||||
return NEAR_HEAD, f"the gripper comes {clear:.0f} mm from the head (needs {HEAD_CLEAR_MM:.0f})"
|
return NEAR_HEAD, f"the gripper comes {clear:.0f} mm from the head (needs {HEAD_CLEAR_MM:.0f})"
|
||||||
|
arm_clear = link_clearance(j0, j1, centre)
|
||||||
|
if arm_clear < LINK_HEAD_CLEAR_MM:
|
||||||
|
return NEAR_HEAD, f"the arm comes {arm_clear:.0f} mm from the head (needs {LINK_HEAD_CLEAR_MM:.0f})"
|
||||||
if low < ends - skills.PATH_SAG_MM:
|
if low < ends - skills.PATH_SAG_MM:
|
||||||
return BLOCKED, f"the gripper dips to z {low:.0f} mm"
|
return BLOCKED, f"the gripper dips to z {low:.0f} mm"
|
||||||
if holding and tilt > skills.MAX_TILT_DEG:
|
if holding and tilt > skills.MAX_TILT_DEG:
|
||||||
@@ -213,10 +237,50 @@ def check_moves(now, targets, holding=False):
|
|||||||
return seq
|
return seq
|
||||||
|
|
||||||
|
|
||||||
|
def _up(now, mm):
|
||||||
|
"""Joints with the flange `mm` straight above where it is at `now` (same orientation), None without an IK answer."""
|
||||||
|
c = skills._ask("kine_forward", jointPosition=[float(v) for v in now])["cartPosition"]
|
||||||
|
r = skills._ask("kine_inverse", jointPosition=[float(v) for v in now], cartPosition=[c[0], c[1], c[2] + mm, *c[3:]])
|
||||||
|
return r.get("jointPosition")
|
||||||
|
|
||||||
|
|
||||||
|
def join(now, target, holding=False):
|
||||||
|
"""[(pose, joints)] of a checked way from an arm at no pose of the graph to `target`: one joint move to a graph
|
||||||
|
pose (the nearest first), then along the graph; else first straight up by UP_MM. RouteError(UNKNOWN) when no way
|
||||||
|
passes the checks; nothing moved."""
|
||||||
|
nodes, p = graph(), motion.poses()
|
||||||
|
if target not in nodes:
|
||||||
|
raise RouteError(*NOT_TAUGHT)
|
||||||
|
order = sorted(nodes, key=lambda n: (_deg(now, nodes[n]), n != HOME))
|
||||||
|
for mm in (None, *UP_MM):
|
||||||
|
first = [] if mm is None else [("up", _up(now, mm))]
|
||||||
|
if first and first[0][1] is None:
|
||||||
|
continue
|
||||||
|
for n in order:
|
||||||
|
names = _path(n, target, nodes)
|
||||||
|
if names is None:
|
||||||
|
continue
|
||||||
|
way = first + [(x, p[x]) for x in names]
|
||||||
|
try:
|
||||||
|
return list(zip([x for x, _ in way], check_moves(now, [j for _, j in way], holding)))
|
||||||
|
except RouteError as e:
|
||||||
|
if e.args == UNSURE:
|
||||||
|
raise
|
||||||
|
log(f"arm route: arm at {_r(now)}: no checked way to {target}")
|
||||||
|
raise RouteError(*UNKNOWN)
|
||||||
|
|
||||||
|
|
||||||
def plan(target, holding=False, leaf=False, now=None):
|
def plan(target, holding=False, leaf=False, now=None):
|
||||||
"""[(pose, joints)] of the checked way from here to `target` ([] when it is there). RouteError to refuse."""
|
"""[(pose, joints)] of the checked way from here to `target` ([] when it is there). RouteError to refuse."""
|
||||||
now = skills._joints() if now is None else now
|
now = skills._joints() if now is None else now
|
||||||
names = hops(now, target, leaf)
|
try:
|
||||||
|
names = hops(now, target, leaf)
|
||||||
|
except RouteError as e:
|
||||||
|
if e.args != UNKNOWN:
|
||||||
|
raise
|
||||||
|
seq = join(now, target, holding)
|
||||||
|
log(f"arm route: joining from {_r(now)} by {' -> '.join(n for n, _ in seq)}, checked")
|
||||||
|
return seq
|
||||||
p = motion.poses()
|
p = motion.poses()
|
||||||
return list(zip(names, check_moves(now, [p[n] for n in names], holding)))
|
return list(zip(names, check_moves(now, [p[n] for n in names], holding)))
|
||||||
|
|
||||||
@@ -235,7 +299,10 @@ def move(seq, speed=None, holding=False):
|
|||||||
|
|
||||||
def goto(target, holding=False, leaf=False, speed=None):
|
def goto(target, holding=False, leaf=False, speed=None):
|
||||||
"""Plan, check and go to pose `target` along the graph. Returns the poses passed."""
|
"""Plan, check and go to pose `target` along the graph. Returns the poses passed."""
|
||||||
seq = plan(target, holding, leaf)
|
now = skills._joints()
|
||||||
|
seq = plan(target, holding, leaf, now)
|
||||||
|
if not leaf and min(_deg(now, j) for j in graph().values()) > JOIN_DEG:
|
||||||
|
speed = HOLD_SPEED # a join from far: slow
|
||||||
if seq:
|
if seq:
|
||||||
log(f"arm route to {target}: {' -> '.join(n for n, _ in seq)}, checked")
|
log(f"arm route to {target}: {' -> '.join(n for n, _ in seq)}, checked")
|
||||||
move(seq, speed, holding)
|
move(seq, speed, holding)
|
||||||
|
|||||||
+3
-2
@@ -18,7 +18,8 @@ READ_ONLY = {"get_data", "get_joint_pos", "get_tcp_pos", "get_robot_state", "get
|
|||||||
"kine_inverse", "kine_forward"}
|
"kine_inverse", "kine_forward"}
|
||||||
ABSOLUTE_MOVES = {"moveL", "joint_move"}
|
ABSOLUTE_MOVES = {"moveL", "joint_move"}
|
||||||
SET_VALUE = {"set_digital_output", "stop_program"}
|
SET_VALUE = {"set_digital_output", "stop_program"}
|
||||||
RETRIES, RETRY_S = 3, 0.2
|
RETRIES, RETRY_S = 5, 0.2 # tries; s before the 2nd, doubled each time (0.2 ... 1.6, 3 s in all): the controller
|
||||||
|
# closes every connection for ~0.5 s every few seconds, whatever the request rate
|
||||||
|
|
||||||
|
|
||||||
def cmd(name, **args):
|
def cmd(name, **args):
|
||||||
@@ -34,7 +35,7 @@ def cmd(name, **args):
|
|||||||
except (ConnectionError, OSError):
|
except (ConnectionError, OSError):
|
||||||
if i == tries - 1:
|
if i == tries - 1:
|
||||||
raise
|
raise
|
||||||
time.sleep(RETRY_S)
|
time.sleep(RETRY_S * 2 ** i)
|
||||||
|
|
||||||
|
|
||||||
def _send(name, args):
|
def _send(name, args):
|
||||||
|
|||||||
+164
-55
@@ -70,6 +70,12 @@ BIG_TOPS = ("dining table", "desk", "bed") # things named for a place whose YO
|
|||||||
FAR_REACH_MM = 850.0 # mm from the arm base; level points of a far table past this are out of reach
|
FAR_REACH_MM = 850.0 # mm from the arm base; level points of a far table past this are out of reach
|
||||||
PLACE_REFUSALS = 8 # place spots tried before giving up on this view (callers order them nearest first)
|
PLACE_REFUSALS = 8 # place spots tried before giving up on this view (callers order them nearest first)
|
||||||
FAR_SPOTS = 4 # spots of a table further away tried from where the base is (_place_far)
|
FAR_SPOTS = 4 # spots of a table further away tried from where the base is (_place_far)
|
||||||
|
PLACE_LOW_Z = -480.0 # mm, arm frame at lift 0: a level top lower than this is a chair's seat or a stool,
|
||||||
|
# never a table to put on (live 2026-10-27 -549 and -542 were driven to)
|
||||||
|
KEEP_R_MM = 400.0 # mm; a table kept on the map is looked for again within this of its kept spot ...
|
||||||
|
KEEP_STEP_MM = 40.0 # ... on a grid this fine ...
|
||||||
|
KEEP_TOL_MM = 40.0 # ... at its kept height +- this (measured from 1.5 m it can be ~30 mm off)
|
||||||
|
PLACE_NAV_MAX = 2 # navigation drives round to a kept table at most this often, then straight ways only
|
||||||
TOP_NEAR_MM = 1500.0 # mm from the arm base; a named thing's top measured further away is not trusted
|
TOP_NEAR_MM = 1500.0 # mm from the arm base; a named thing's top measured further away is not trusted
|
||||||
# (2026-10-20 a white thing 3.8 m away read -258, then -620 mm): go closer first
|
# (2026-10-20 a white thing 3.8 m away read -258, then -620 mm): go closer first
|
||||||
KNOWN_M = 0.5 # m; a thing seen this near where it was taught is that thing
|
KNOWN_M = 0.5 # m; a thing seen this near where it was taught is that thing
|
||||||
@@ -161,6 +167,7 @@ SAME_PLACE_M = 0.05 # m; closer than this to the target point (and SAME
|
|||||||
SAME_ANGLE_RAD = 0.05
|
SAME_ANGLE_RAD = 0.05
|
||||||
AXIS_STEP_M = 0.10 # m the base drives forward (and back) in measure-axis
|
AXIS_STEP_M = 0.10 # m the base drives forward (and back) in measure-axis
|
||||||
AXIS_SPEED = 0.05 # m/s; straight with joy_control (navigation may turn in place, the arm is over the table)
|
AXIS_SPEED = 0.05 # m/s; straight with joy_control (navigation may turn in place, the arm is over the table)
|
||||||
|
SHORT_LOG_M = 0.03 # m; a straight drive (timed) that odometry says came this much short is logged
|
||||||
COAST_S = 0.3 # s; the base coasts a little after a joy_control stop: frames from then on are used
|
COAST_S = 0.3 # s; the base coasts a little after a joy_control stop: frames from then on are used
|
||||||
# (estimate; measure-axis waits 1 s for its pose)
|
# (estimate; measure-axis waits 1 s for its pose)
|
||||||
GIVE_WAIT_S = 30.0 # s; no release by then: keep holding it and go back to carry (never drop it)
|
GIVE_WAIT_S = 30.0 # s; no release by then: keep holding it and go back to carry (never drop it)
|
||||||
@@ -701,9 +708,10 @@ def _waist_to(rel):
|
|||||||
log("not turning my waist: Patrol is off")
|
log("not turning my waist: Patrol is off")
|
||||||
return False
|
return False
|
||||||
_go_on()
|
_go_on()
|
||||||
|
yaw, pitch = head.status()[2:] # head_hits turns the head to the side: it comes back with the waist
|
||||||
if _sweep_blocked(d, "turning my waist"):
|
if _sweep_blocked(d, "turning my waist"):
|
||||||
return False
|
return False
|
||||||
lift, waist, yaw, pitch = head.status()
|
lift, waist = head.status()[:2]
|
||||||
log(f"waist {waist:.0f} -> {waist + d:.0f} deg")
|
log(f"waist {waist:.0f} -> {waist + d:.0f} deg")
|
||||||
_body_move([lift, waist + d, yaw, pitch], vel=WAIST_VEL, acc=20, timeout=60)
|
_body_move([lift, waist + d, yaw, pitch], vel=WAIST_VEL, acc=20, timeout=60)
|
||||||
skills.moved()
|
skills.moved()
|
||||||
@@ -1247,6 +1255,9 @@ def _straight_clear(dist, speed=None, stop=True):
|
|||||||
if free > 0:
|
if free > 0:
|
||||||
log(f"straight {sign * free:+.2f} m")
|
log(f"straight {sign * free:+.2f} m")
|
||||||
free = _straight(sign * free, speed or AXIS_SPEED, stop=stop or blocked)
|
free = _straight(sign * free, speed or AXIS_SPEED, stop=stop or blocked)
|
||||||
|
went = math.hypot(agv.pose()[0] - x, agv.pose()[1] - y)
|
||||||
|
if (stop or blocked) and went < free - SHORT_LOG_M: # the drive is timed: say when odometry disagrees
|
||||||
|
log(f"the base went {went:.2f} m of {free:.2f} m (odometry)")
|
||||||
return free
|
return free
|
||||||
|
|
||||||
|
|
||||||
@@ -1612,11 +1623,17 @@ def _reach(task, obj, say):
|
|||||||
raise FetchError("I still can't reach it.", "아직 손이 닿지 않아요.")
|
raise FetchError("I still can't reach it.", "아직 손이 닿지 않아요.")
|
||||||
|
|
||||||
|
|
||||||
def table_ahead():
|
def place_band():
|
||||||
|
"""surface_band for putting things down: no lower than PLACE_LOW_Z (a seat)."""
|
||||||
|
low, high = surface_band()
|
||||||
|
return max(low, PLACE_LOW_Z - head.status()[0] + LIFT_RANGE[0]), high
|
||||||
|
|
||||||
|
|
||||||
|
def table_ahead(band=None):
|
||||||
"""Height (mm) of the table in front: the level top most sight lines over the place grid meet (skills.flat_top:
|
"""Height (mm) of the table in front: the level top most sight lines over the place grid meet (skills.flat_top:
|
||||||
a chair's back or seat, the table's edge, the floor don't count) at a height the arm can work at (surface_band);
|
a chair's back or seat, the table's edge, the floor don't count) within `band` (default place_band); None when
|
||||||
None when too little table is in view."""
|
too little table is in view."""
|
||||||
top = skills.flat_top([(x, y) for y in PLACE_GRID_Y for x in PLACE_GRID_X], surface_band())
|
top = skills.flat_top([(x, y) for y in PLACE_GRID_Y for x in PLACE_GRID_X], band or place_band())
|
||||||
return None if top is None else top[0]
|
return None if top is None else top[0]
|
||||||
|
|
||||||
|
|
||||||
@@ -1643,12 +1660,12 @@ def place_spots(held, base_now, seen, table=None):
|
|||||||
return tries + skills.on_table(grid, table)
|
return tries + skills.on_table(grid, table)
|
||||||
|
|
||||||
|
|
||||||
def _place_here(top0):
|
def _place_here(top0, kept=None):
|
||||||
"""One look for a place from where the arm is (look, the held object out of the view): measure the table, fit the
|
"""One look for a place from where the arm is (look, the held object out of the view): measure the table (the
|
||||||
lift, try the spots. True when the object was put down, else None."""
|
kept one's height only, _kept_band), fit the lift, try the spots. True when the object was put down, else None."""
|
||||||
table = table_ahead()
|
table = table_ahead(_kept_band(kept))
|
||||||
if _fit_lift(table):
|
if _fit_lift(table):
|
||||||
table = table_ahead()
|
table = table_ahead(_kept_band(kept))
|
||||||
log(f"table here at {table:.0f} mm" if table is not None else "no table in view")
|
log(f"table here at {table:.0f} mm" if table is not None else "no table in view")
|
||||||
if table is None: # never put it down on a table not measured right now
|
if table is None: # never put it down on a table not measured right now
|
||||||
return None
|
return None
|
||||||
@@ -1677,6 +1694,68 @@ def _place_view(top0):
|
|||||||
return True if far and _place_far(top0, far) else far
|
return True if far and _place_far(top0, far) else far
|
||||||
|
|
||||||
|
|
||||||
|
def _keep(xy, table):
|
||||||
|
"""A table to put on, kept by its map place: seen at xy (mm, arm frame now) with its top at `table` mm (None: not
|
||||||
|
measured yet). From then on it is looked for there (_kept_at), never another one."""
|
||||||
|
return {"world": map_xy({"x": xy[0], "y": xy[1]}), "table": table, "lift": head.status()[0]}
|
||||||
|
|
||||||
|
|
||||||
|
def _kept_at(kept):
|
||||||
|
"""(x, y, height) mm, arm frame now, of the table kept on the map (height None: not measured yet)."""
|
||||||
|
x, y = arm_frame(kept["world"])
|
||||||
|
z = None if kept["table"] is None else kept["table"] - (head.status()[0] - kept["lift"])
|
||||||
|
return float(x), float(y), z
|
||||||
|
|
||||||
|
|
||||||
|
def _kept_band(kept):
|
||||||
|
"""Heights (mm, arm frame now) a level top must have to be the kept table: its own +- KEEP_TOL_MM; place_band
|
||||||
|
when nothing is kept or its height is not measured yet."""
|
||||||
|
z = None if kept is None else _kept_at(kept)[2]
|
||||||
|
return place_band() if z is None else (z - KEEP_TOL_MM, z + KEEP_TOL_MM)
|
||||||
|
|
||||||
|
|
||||||
|
def _place_kept_view(top0, kept):
|
||||||
|
"""One look for the kept table: put it down on it in reach (True), else on it further away where the arm reaches a
|
||||||
|
spot of it from here (True); else where it is now (far_table near its kept spot and height, kept from now on);
|
||||||
|
None when it is not in view."""
|
||||||
|
if _place_here(top0, kept):
|
||||||
|
return True
|
||||||
|
x, y, _ = _kept_at(kept)
|
||||||
|
far = far_table((x, y), _kept_band(kept))
|
||||||
|
if far is None:
|
||||||
|
return None
|
||||||
|
kept.update(_keep((far["x"], far["y"]), far["table"]))
|
||||||
|
return True if _place_far(top0, far) else far
|
||||||
|
|
||||||
|
|
||||||
|
def _place_kept(top0, kept, tried):
|
||||||
|
"""Bring the table kept on the map (_keep) to PLACE_GOAL with the base and put the held object down on it. After
|
||||||
|
every move the waist and the head turn to where it must be now (odometry) and look for it there, at its height
|
||||||
|
(_place_kept_view): it is never lost to a new search nor swapped for another table or a seat; not seen from a
|
||||||
|
spot, the base goes on to where it is kept. At most APPROACH_TRIES moves, PLACE_NAV_MAX of them driving round
|
||||||
|
(then straight ways only); it stops when the base brings it no nearer. A pause keeps all of it. True when it is
|
||||||
|
down."""
|
||||||
|
for i in range(APPROACH_TRIES):
|
||||||
|
if arm_yaw() is None or _charging():
|
||||||
|
break
|
||||||
|
if sum(isinstance(k, int) for k in tried) >= PLACE_NAV_MAX:
|
||||||
|
tried.update(APPROACH_SIDES) # no more driving round
|
||||||
|
x, y, _ = _kept_at(kept)
|
||||||
|
log(f"the table at ({x:.0f}, {y:.0f}): going closer ({i + 1}/{APPROACH_TRIES})")
|
||||||
|
moved = _go_to({"x": x, "y": y}, PLACE_GOAL, tried, holding=True) is not False
|
||||||
|
x, y, _ = _kept_at(kept)
|
||||||
|
side = math.degrees(math.atan2(-x, y)) # + left of where the arm looks
|
||||||
|
got = _look_at(_waist_turn() + (side if abs(side) > TORSO_HALF_DEG else 0.0),
|
||||||
|
lambda: _place_kept_view(top0, kept))
|
||||||
|
if got is True:
|
||||||
|
return True
|
||||||
|
if not moved: # the base brings it no nearer
|
||||||
|
break
|
||||||
|
if got is None:
|
||||||
|
log(f"the table is not in view: going on to where I keep it ({x:.0f}, {y:.0f})")
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _place_far(top0, far):
|
def _place_far(top0, far):
|
||||||
"""Put it down on the table far_table() found when the arm reaches a spot of it from here: its level points nearest
|
"""Put it down on the table far_table() found when the arm reaches a spot of it from here: its level points nearest
|
||||||
PLACE_GOAL that the depth camera sees as table all round (skills.on_table) and free, at most FAR_SPOTS of them
|
PLACE_GOAL that the depth camera sees as table all round (skills.on_table) and free, at most FAR_SPOTS of them
|
||||||
@@ -1735,22 +1814,25 @@ def _place_at(tries, top):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def far_table():
|
def far_table(around=None, band=None):
|
||||||
"""A table seen further away by the torso camera, else by the head camera as it is turned: {"x", "y"} (mm, arm
|
"""A table seen further away by the torso camera, else by the head camera as it is turned: {"x", "y"} (mm, arm
|
||||||
frame now) FAR_IN_MM in from the point of its level top nearest PLACE_GOAL (that is its edge), "table" (its height,
|
frame now) FAR_IN_MM in from the point of its level top nearest PLACE_GOAL (that is its edge), "table" (its height,
|
||||||
mm), "camera", "points" (x, y of its level top seen by the torso camera, for _place_far); None when neither sees a
|
mm), "camera", "points" (x, y of its level top seen by the torso camera, for _place_far); None when neither sees a
|
||||||
level top at a height some lift can work at (surface_band)."""
|
level top within `band` (default place_band). `around` (x, y): only within KEEP_R_MM of there (a kept table)."""
|
||||||
band = surface_band()
|
guess = TABLE_PROVEN_Z if band is None else sum(band) / 2 # aims the sight lines (a kept table: its height)
|
||||||
|
band = band or place_band()
|
||||||
views = [("torso", skills.objects.base_from_camera())]
|
views = [("torso", skills.objects.base_from_camera())]
|
||||||
if _head_ok():
|
if _head_ok():
|
||||||
views.append(("head", head_cam.base_from_head(*head.status()[2:])))
|
views.append(("head", head_cam.base_from_head(*head.status()[2:])))
|
||||||
|
steps = np.arange(-KEEP_R_MM, KEEP_R_MM + 1.0, KEEP_STEP_MM)
|
||||||
for cam, T in views:
|
for cam, T in views:
|
||||||
if T is None:
|
if T is None:
|
||||||
continue
|
continue
|
||||||
a = math.degrees(math.atan2(T[1, 2], T[0, 2])) # where the camera looks, in the arm frame
|
a = math.degrees(math.atan2(T[1, 2], T[0, 2])) # where the camera looks, in the arm frame
|
||||||
pts = [(r * math.cos(math.radians(a + b)), r * math.sin(math.radians(a + b)))
|
pts = [(r * math.cos(math.radians(a + b)), r * math.sin(math.radians(a + b)))
|
||||||
for r in FAR_R_MM for b in range(-FAR_HALF_DEG, FAR_HALF_DEG + 1, FAR_STEP_DEG)]
|
for r in FAR_R_MM for b in range(-FAR_HALF_DEG, FAR_HALF_DEG + 1, FAR_STEP_DEG)] if around is None else \
|
||||||
top = skills.flat_top(pts, band, TABLE_PROVEN_Z, cam, T)
|
[(around[0] + dx, around[1] + dy) for dx in steps for dy in steps if math.hypot(dx, dy) <= KEEP_R_MM]
|
||||||
|
top = skills.flat_top(pts, band, guess, cam, T)
|
||||||
if top is None:
|
if top is None:
|
||||||
continue
|
continue
|
||||||
p = np.array(min(((q[0], q[1]) for q in top[1]),
|
p = np.array(min(((q[0], q[1]) for q in top[1]),
|
||||||
@@ -1868,11 +1950,13 @@ def _usable(usable, seen):
|
|||||||
return
|
return
|
||||||
things = [o for o in seen if o["name"] not in objects.ROUND]
|
things = [o for o in seen if o["name"] not in objects.ROUND]
|
||||||
def note(xy, top, o=None):
|
def note(xy, top, o=None):
|
||||||
|
if top < place_band()[0]: # a seat: never a place
|
||||||
|
return
|
||||||
near = [t for t in things if math.hypot(t["x"] - xy[0], t["y"] - xy[1]) < SUPPORT_NEAR_MM]
|
near = [t for t in things if math.hypot(t["x"] - xy[0], t["y"] - xy[1]) < SUPPORT_NEAR_MM]
|
||||||
o = o or (min(near, key=lambda t: math.hypot(t["x"] - xy[0], t["y"] - xy[1])) if near else {})
|
o = o or (min(near, key=lambda t: math.hypot(t["x"] - xy[0], t["y"] - xy[1])) if near else {})
|
||||||
label = " ".join(w for w in (colour_of(o), o["name"].replace("dining table", "table")) if w) if o else "table"
|
label = " ".join(w for w in (colour_of(o), o["name"].replace("dining table", "table")) if w) if o else "table"
|
||||||
usable.append({"map": map_xy({"x": xy[0], "y": xy[1]}), "label": label, "colour": colour_of(o) if o else None,
|
usable.append({"map": map_xy({"x": xy[0], "y": xy[1]}), "label": label, "colour": colour_of(o) if o else None,
|
||||||
"names": o.get("names") or ([o["name"]] if o else []), "top_mm": top,
|
"names": o.get("names") or ([o["name"]] if o else []), "top_mm": top, "lift": head.status()[0],
|
||||||
"width_mm": o.get("width_mm")})
|
"width_mm": o.get("width_mm")})
|
||||||
table = table_ahead()
|
table = table_ahead()
|
||||||
if table is not None:
|
if table is not None:
|
||||||
@@ -1885,24 +1969,6 @@ def _usable(usable, seen):
|
|||||||
note((o["x"], o["y"]), level, o)
|
note((o["x"], o["y"]), level, o)
|
||||||
|
|
||||||
|
|
||||||
def _place_near(top0, tried):
|
|
||||||
"""Put it down on a table in front, going closer to a table seen further ahead up to APPROACH_TRIES times (no
|
|
||||||
whole search). True when it is down."""
|
|
||||||
moved = True
|
|
||||||
for i in range(APPROACH_TRIES + 1):
|
|
||||||
got = _look_at(0.0, lambda: _place_view(top0))
|
|
||||||
if got is True:
|
|
||||||
return True
|
|
||||||
if got is None or i == APPROACH_TRIES or _charging():
|
|
||||||
return False
|
|
||||||
if not moved: # the base is as near as it gets: a low table stays out of reach
|
|
||||||
_too_low(got) # (said then, not after 24-31 moves; X1 r11: not earlier either)
|
|
||||||
log(f"a table at {got['table']:.0f} mm further away ({got['camera']} camera), at ({got['x']:.0f}, "
|
|
||||||
f"{got['y']:.0f}): going closer ({i + 1}/{APPROACH_TRIES})")
|
|
||||||
moved = _go_to(got, PLACE_GOAL, tried, holding=True) is not False
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
def _put_on(top0, on, say):
|
def _put_on(top0, on, say):
|
||||||
"""Put the held object on a named thing (a chair, a sink, "the white table", "the table or chair"): one search
|
"""Put the held object on a named thing (a chair, a sink, "the white table", "the table or chair"): one search
|
||||||
(_look_around) for it (_support); seen: go to it, measure its level top, fit the lift and put it there. Not seen,
|
(_look_around) for it (_support); seen: go to it, measure its level top, fit the lift and put it there. Not seen,
|
||||||
@@ -1917,6 +1983,8 @@ def _put_on(top0, on, say):
|
|||||||
seen = skills.look(ignore=())
|
seen = skills.look(ignore=())
|
||||||
return _support(on, seen, heights) or _usable(usable, seen)
|
return _support(on, seen, heights) or _usable(usable, seen)
|
||||||
thing = _look_around(view, holding=True, say=say)
|
thing = _look_around(view, holding=True, say=say)
|
||||||
|
if thing is not None and any(n in BIG_TOPS for n in thing.get("names") or [thing.get("name", on["name"])]):
|
||||||
|
return _put_on_table(top0, thing, label, tried) # a table (not a chair said as "or chair")
|
||||||
for i in range(APPROACH_TRIES + 1):
|
for i in range(APPROACH_TRIES + 1):
|
||||||
if thing is None and heights and not usable: # seen, but no lift brings its top in reach
|
if thing is None and heights and not usable: # seen, but no lift brings its top in reach
|
||||||
off = heights[0] - TABLE_PROVEN_Z
|
off = heights[0] - TABLE_PROVEN_Z
|
||||||
@@ -1926,12 +1994,6 @@ def _put_on(top0, on, say):
|
|||||||
return _put_instead(top0, on, label, usable, tried, say)
|
return _put_instead(top0, on, label, usable, tried, say)
|
||||||
surface = None if thing.get("head") else _workable(thing)
|
surface = None if thing.get("head") else _workable(thing)
|
||||||
can_move = arm_yaw() is not None and i < APPROACH_TRIES and not _charging()
|
can_move = arm_yaw() is not None and i < APPROACH_TRIES and not _charging()
|
||||||
big = on["name"] in BIG_TOPS
|
|
||||||
far = None
|
|
||||||
if surface is None and big: # a table's box centre moves with the view (2026-10-26 18:55:
|
|
||||||
surface = table_ahead() # (22, 623), then (-349, 647) for the same table): its level top
|
|
||||||
far = far_table() if surface is None else None # in front or further away instead
|
|
||||||
surface = far["table"] if far else surface
|
|
||||||
if surface is None:
|
if surface is None:
|
||||||
if not can_move:
|
if not can_move:
|
||||||
raise FetchError(f"I can't see the top of the {label} well enough.", "윗면이 잘 안 보여요.")
|
raise FetchError(f"I can't see the top of the {label} well enough.", "윗면이 잘 안 보여요.")
|
||||||
@@ -1945,19 +2007,39 @@ def _put_on(top0, on, say):
|
|||||||
continue
|
continue
|
||||||
top = _top_on(top0, surface)
|
top = _top_on(top0, surface)
|
||||||
centre = [(thing["x"] + dx, thing["y"] + dy) for dx in (0, -50, 50) for dy in (0, -50, 50)]
|
centre = [(thing["x"] + dx, thing["y"] + dy) for dx in (0, -50, 50) for dy in (0, -50, 50)]
|
||||||
grid = [p for p in place_spots(skills._held, agv.pose(), skills.look(), surface) # a big top (a table):
|
grid = [p for p in place_spots(skills._held, agv.pose(), skills.look(), surface)
|
||||||
if math.hypot(p[0] - thing["x"], p[1] - thing["y"]) <= NEAR_THING_MM] # its near part
|
if math.hypot(p[0] - thing["x"], p[1] - thing["y"]) <= NEAR_THING_MM]
|
||||||
spots = grid + [p for p in skills.on_table(centre, surface) if p not in grid] if big else \
|
spots = skills.on_table(centre, surface) + grid
|
||||||
skills.on_table(centre, surface) + grid
|
if spots and _place_at(list(dict.fromkeys(spots)), top):
|
||||||
if spots and _place_at(list(dict.fromkeys(spots)), top) or far and _place_far(top0, far):
|
|
||||||
return True
|
return True
|
||||||
if not can_move:
|
if not can_move:
|
||||||
break
|
break
|
||||||
_go_to(far or thing, PLACE_GOAL, tried, holding=True)
|
_go_to(thing, PLACE_GOAL, tried, holding=True)
|
||||||
thing = _look_at(0.0, lambda: _support(on))
|
thing = _look_at(0.0, lambda: _support(on))
|
||||||
raise FetchError(f"I couldn't reach a free spot on the {label}.", "놓을 자리에 손이 닿지 않아요.")
|
raise FetchError(f"I couldn't reach a free spot on the {label}.", "놓을 자리에 손이 닿지 않아요.")
|
||||||
|
|
||||||
|
|
||||||
|
def _put_on_table(top0, thing, label, tried):
|
||||||
|
"""Put it down on the named table `thing` (its YOLO box: the centre moves with the view, the label flips, a round
|
||||||
|
table up close reads "sink"): from now on it is kept by the level top seen around that box (far_table there; not
|
||||||
|
measured yet: by the box until it is) and approached by its map place (_place_kept); in reach it is put down at
|
||||||
|
once."""
|
||||||
|
far = far_table((thing["x"], thing["y"]))
|
||||||
|
kept = _keep((far["x"], far["y"]), far["table"]) if far else _keep((thing["x"], thing["y"]), None)
|
||||||
|
log(f"{label} at ({thing['x']:.0f}, {thing['y']:.0f}), " +
|
||||||
|
(f"its top at {far['table']:.0f} mm: I keep it" if far else "its top not measured yet: I keep it"))
|
||||||
|
try:
|
||||||
|
if _place_kept_view(top0, kept) is True or _place_kept(top0, kept, tried):
|
||||||
|
return True
|
||||||
|
except FetchError as e:
|
||||||
|
if kept["table"] is not None:
|
||||||
|
_too_low({"table": _kept_at(kept)[2]}, e)
|
||||||
|
raise
|
||||||
|
if kept["table"] is not None:
|
||||||
|
_too_low({"table": _kept_at(kept)[2]})
|
||||||
|
raise FetchError(f"I couldn't reach a free spot on the {label}.", "놓을 자리에 손이 닿지 않아요.")
|
||||||
|
|
||||||
|
|
||||||
def _put_instead(top0, on, label, usable, tried, say):
|
def _put_instead(top0, on, label, usable, tried, say):
|
||||||
"""The thing `on` names was not seen: put it on the surface seen on the way that comes closest to what was said
|
"""The thing `on` names was not seen: put it on the surface seen on the way that comes closest to what was said
|
||||||
(`usable`, _usable: its colour first, then its kind, then on["prefer"], else the nearest) and say so. FetchError
|
(`usable`, _usable: its colour first, then its kind, then on["prefer"], else the nearest) and say so. FetchError
|
||||||
@@ -1977,9 +2059,7 @@ def _put_instead(top0, on, label, usable, tried, say):
|
|||||||
w, name = u["map"], u["label"]
|
w, name = u["map"], u["label"]
|
||||||
held = held_name().replace("something", "it")
|
held = held_name().replace("something", "it")
|
||||||
log(f"no {label} anywhere; the {name} at ({w[0]:.2f}, {w[1]:.2f}) on the map can take it: going there")
|
log(f"no {label} anywhere; the {name} at ({w[0]:.2f}, {w[1]:.2f}) on the map can take it: going there")
|
||||||
xy = arm_frame(w)
|
if not _place_kept(top0, {"world": np.asarray(w, float), "table": u["top_mm"], "lift": u["lift"]}, tried):
|
||||||
_go_to({"x": float(xy[0]), "y": float(xy[1])}, PLACE_GOAL, tried, holding=True)
|
|
||||||
if not _place_near(top0, tried):
|
|
||||||
raise FetchError(f"I couldn't find the {label}, and I couldn't reach a free spot on the {name} either.",
|
raise FetchError(f"I couldn't find the {label}, and I couldn't reach a free spot on the {name} either.",
|
||||||
"그곳을 못 찾았고, 다른 곳에도 놓지 못했어요.")
|
"그곳을 못 찾았고, 다른 곳에도 놓지 못했어요.")
|
||||||
_say(say, f"I couldn't find the {label}, so I put {held} on the {name} here.",
|
_say(say, f"I couldn't find the {label}, so I put {held} on the {name} here.",
|
||||||
@@ -2049,15 +2129,15 @@ def _put_down(say=None, on=None):
|
|||||||
return
|
return
|
||||||
if got is not None and arm_yaw() is not None and not _charging():
|
if got is not None and arm_yaw() is not None and not _charging():
|
||||||
log(f"a table at {got['table']:.0f} mm further away ({got['camera']} camera), at ({got['x']:.0f}, "
|
log(f"a table at {got['table']:.0f} mm further away ({got['camera']} camera), at ({got['x']:.0f}, "
|
||||||
f"{got['y']:.0f}): going closer")
|
f"{got['y']:.0f}): I keep it")
|
||||||
|
kept = _keep((got["x"], got["y"]), got["table"])
|
||||||
try:
|
try:
|
||||||
_go_to(got, PLACE_GOAL, tried, holding=True)
|
if _place_kept(top, kept, tried):
|
||||||
if _place_near(top, tried):
|
|
||||||
return
|
return
|
||||||
except FetchError as e:
|
except FetchError as e:
|
||||||
_too_low(got, e)
|
_too_low({"table": _kept_at(kept)[2]}, e) # its height as last measured, nearest
|
||||||
raise
|
raise
|
||||||
_too_low(got)
|
_too_low({"table": _kept_at(kept)[2]})
|
||||||
_lift_to(LIFT_DRIVE_MM)
|
_lift_to(LIFT_DRIVE_MM)
|
||||||
raise FetchError("I can't find a free place on a table around me.", "주변에 내려놓을 빈 자리를 못 찾았어요.")
|
raise FetchError("I can't find a free place on a table around me.", "주변에 내려놓을 빈 자리를 못 찾았어요.")
|
||||||
|
|
||||||
@@ -2146,16 +2226,43 @@ def _pick_here(task, say):
|
|||||||
_say(say, "I've got it.", "잡았어요.")
|
_say(say, "I've got it.", "잡았어요.")
|
||||||
_step("carry")
|
_step("carry")
|
||||||
skills._guarded(skills._line, "up", waypoints[0][1]) # straight up to the approach height first
|
skills._guarded(skills._line, "up", waypoints[0][1]) # straight up to the approach height first
|
||||||
|
_carry_from(waypoints[0][1], ja)
|
||||||
|
|
||||||
|
|
||||||
|
def _carry_from(above, ja):
|
||||||
|
"""Holding, the arm at `above` (flange pose over the pick spot, joints `ja` there): to look the way a pick ends."""
|
||||||
try:
|
try:
|
||||||
_line_holding("carry") # straight: the cup stays upright (a turned grasp
|
_line_holding("carry") # straight: the cup stays upright (a turned grasp
|
||||||
except FetchError: # can't go straight to look) ...
|
except FetchError: # can't go straight to look) ...
|
||||||
plan = skills.carry_up(waypoints[0][1], ja) # ... or, when that line jumps (carry has the elbow
|
plan = skills.carry_up(above, ja) # ... or, when that line jumps (carry has the elbow
|
||||||
if plan is None: # almost straight), further up and one joint move
|
if plan is None: # almost straight), further up and one joint move
|
||||||
raise
|
raise
|
||||||
skills._guarded(skills.carry_by_joints, plan)
|
skills._guarded(skills.carry_by_joints, plan)
|
||||||
_line_holding(LOOK_POSE) # then look to drive
|
_line_holding(LOOK_POSE) # then look to drive
|
||||||
|
|
||||||
|
|
||||||
|
def _carry_held():
|
||||||
|
"""The step {"do": "carry"}: a pick stopped after the grasp left the object just above the table; straight up to
|
||||||
|
the pick's approach height (clear_above over the grasp point, never down), then to look as a pick ends. Nothing
|
||||||
|
said. Already at look or carry: only on to look."""
|
||||||
|
if not _state["holding"]:
|
||||||
|
raise FetchError("My hand is empty, I'm not holding anything.", "손에 든 게 없어요.")
|
||||||
|
_step("carry")
|
||||||
|
if not (_at_pose(LOOK_POSE) or _at_pose("carry")):
|
||||||
|
h, now = skills._held, motion.tcp()
|
||||||
|
z = now[2] + skills.ABOVE_MM - skills.LIFT_MM # not known how high it was picked: as after the lift
|
||||||
|
if h.get("top_mm") is not None:
|
||||||
|
below = h.get("below", skills.BELOW_RIM_MM)
|
||||||
|
grasp = skills.flange_for(h["x"], h["y"], h["top_mm"] - below, h.get("yaw", 0.0), h.get("tips", False))
|
||||||
|
z = grasp[2] + skills.clear_above(below)
|
||||||
|
above = skills.up(now, max(0.0, z - now[2]))
|
||||||
|
if above[2] > now[2] + 1.0:
|
||||||
|
skills._guarded(skills._line, "up", above)
|
||||||
|
_carry_from(above, skills._joints())
|
||||||
|
else:
|
||||||
|
_line_holding(LOOK_POSE)
|
||||||
|
|
||||||
|
|
||||||
def _fail(e, say):
|
def _fail(e, say):
|
||||||
"""End of a run that did not finish: stopped (STOP pressed) or failed with a spoken reason."""
|
"""End of a run that did not finish: stopped (STOP pressed) or failed with a spoken reason."""
|
||||||
if _stop.is_set() or isinstance(e, Stopped):
|
if _stop.is_set() or isinstance(e, Stopped):
|
||||||
@@ -2558,6 +2665,8 @@ def _do_step(s, say):
|
|||||||
raise FetchError("Nobody took it, I'm still holding it.", "아무도 안 받아서 계속 들고 있어요.")
|
raise FetchError("Nobody took it, I'm still holding it.", "아무도 안 받아서 계속 들고 있어요.")
|
||||||
elif d == "arm":
|
elif d == "arm":
|
||||||
_arm(s["pose"])
|
_arm(s["pose"])
|
||||||
|
elif d == "carry":
|
||||||
|
_carry_held()
|
||||||
# "hold": nothing to do, the mission ends holding
|
# "hold": nothing to do, the mission ends holding
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+139
-18
@@ -73,6 +73,9 @@ CAM_SCALE_SD = 0.008 # per-scene depth scale error
|
|||||||
CAM_NOISE_MM = 2.0 # per-frame noise of a detection's centre
|
CAM_NOISE_MM = 2.0 # per-frame noise of a detection's centre
|
||||||
ARM_XY_ERR_M = 0.03 # true arm base origin off the calibrated one by up to this (samples spread 6-19 cm in x)
|
ARM_XY_ERR_M = 0.03 # true arm base origin off the calibrated one by up to this (samples spread 6-19 cm in x)
|
||||||
ARM_YAW_ERR_DEG = 1.0
|
ARM_YAW_ERR_DEG = 1.0
|
||||||
|
FURN_SAMPLES = 9 # a table top / chair seat sampled this many points a side for its detection ...
|
||||||
|
ROUND_SINK_MM = 1300.0 # a round table's box this near the arm base is named "sink" (live 2026-10-20)
|
||||||
|
FURN_MIN_PART = 0.2 # ... detected when this part of it is in the camera's view
|
||||||
STALL_GAPS = (0.10, 0.25) # m in front of the base where its own safety stop holds it (per scene)
|
STALL_GAPS = (0.10, 0.25) # m in front of the base where its own safety stop holds it (per scene)
|
||||||
|
|
||||||
EVENTS = ("no box for it", "the base went", "an obstacle", "plan refused", "straight move to carry",
|
EVENTS = ("no box for it", "the base went", "an obstacle", "plan refused", "straight move to carry",
|
||||||
@@ -151,14 +154,18 @@ def arm_to_world(a):
|
|||||||
|
|
||||||
|
|
||||||
def rect_dist(p, r):
|
def rect_dist(p, r):
|
||||||
"""Distance (m) from map point p to rectangle r {c, half, ang} (0 inside)."""
|
"""Distance (m) from map point p to rectangle r {c, half, ang} or round table {c, r} (0 inside)."""
|
||||||
|
if "r" in r:
|
||||||
|
return max(0.0, float(np.linalg.norm(np.asarray(p, float) - r["c"])) - r["r"])
|
||||||
q = rot2(-r["ang"]) @ (np.asarray(p, float) - r["c"])
|
q = rot2(-r["ang"]) @ (np.asarray(p, float) - r["c"])
|
||||||
d = np.maximum(np.abs(q) - r["half"], 0.0)
|
d = np.maximum(np.abs(q) - r["half"], 0.0)
|
||||||
return float(np.hypot(*d))
|
return float(np.hypot(*d))
|
||||||
|
|
||||||
|
|
||||||
def legs(t):
|
def legs(t):
|
||||||
"""Map points (m) of a table's four legs (LEG_IN_M in from its corners)."""
|
"""Map points (m) of a table's four legs (LEG_IN_M in from its corners); a round table: three under its rim."""
|
||||||
|
if "r" in t:
|
||||||
|
return [t["c"] + (t["r"] - LEG_IN_M) * np.array([math.cos(a), math.sin(a)]) for a in (0.5, 2.6, 4.7)]
|
||||||
hx, hy = t["half"][0] - LEG_IN_M, t["half"][1] - LEG_IN_M
|
hx, hy = t["half"][0] - LEG_IN_M, t["half"][1] - LEG_IN_M
|
||||||
return [t["c"] + rot2(t["ang"]) @ [sx * hx, sy * hy] for sx in (-1, 1) for sy in (-1, 1)]
|
return [t["c"] + rot2(t["ang"]) @ [sx * hx, sy * hy] for sx in (-1, 1) for sy in (-1, 1)]
|
||||||
|
|
||||||
@@ -213,9 +220,8 @@ def render(u, v):
|
|||||||
t1, t2 = (lo - rel_o) / rel_d, (hi - rel_o) / rel_d
|
t1, t2 = (lo - rel_o) / rel_d, (hi - rel_o) / rel_d
|
||||||
tn, tf = np.nanmax(np.minimum(t1, t2), 1), np.nanmin(np.maximum(t1, t2), 1)
|
tn, tf = np.nanmax(np.minimum(t1, t2), 1), np.nanmin(np.maximum(t1, t2), 1)
|
||||||
take(tn, tn <= tf)
|
take(tn, tn <= tf)
|
||||||
cup = W.get("arm_cup")
|
for cyl in W["arm_discs"] + ([W["arm_cup"]] if W.get("arm_cup") is not None else []):
|
||||||
if cup is not None:
|
(cx, cy), r, z0, z1 = cyl # round table tops and the cup: upright cylinders
|
||||||
(cx, cy), r, z0, z1 = cup
|
|
||||||
px, py = o[0] - cx, o[1] - cy
|
px, py = o[0] - cx, o[1] - cy
|
||||||
a = D[:, 0] ** 2 + D[:, 1] ** 2
|
a = D[:, 0] ** 2 + D[:, 1] ** 2
|
||||||
b = 2 * (px * D[:, 0] + py * D[:, 1])
|
b = 2 * (px * D[:, 0] + py * D[:, 1])
|
||||||
@@ -255,6 +261,11 @@ def measured(p):
|
|||||||
|
|
||||||
|
|
||||||
def detections():
|
def detections():
|
||||||
|
return cup_seen() + [{**o, "position_mm": [float(v) for v in measured(np.array(o["position_mm"]))]}
|
||||||
|
for o in furniture(torso_sees, 0.0)]
|
||||||
|
|
||||||
|
|
||||||
|
def cup_seen():
|
||||||
cup = W.get("cup")
|
cup = W.get("cup")
|
||||||
if cup is None or W["in_hand"]:
|
if cup is None or W["in_hand"]:
|
||||||
return []
|
return []
|
||||||
@@ -274,6 +285,47 @@ def detections():
|
|||||||
"height_mm": cup["top"] - cup["table"] + float(W["rng"].normal(0, 2.0))}]
|
"height_mm": cup["top"] - cup["table"] + float(W["rng"].normal(0, 2.0))}]
|
||||||
|
|
||||||
|
|
||||||
|
def furniture(fov, noise_mm):
|
||||||
|
"""Tables ("dining table", white unless the scene says) and chairs ("chair", grey) as a camera detects them in
|
||||||
|
place scenes: the middle of the part of the top in its view, `fov(p)` (a big box's centre moves with the view),
|
||||||
|
at the top's height; a part below FURN_MIN_PART of the top in view is not detected."""
|
||||||
|
if not W.get("furniture"):
|
||||||
|
return []
|
||||||
|
out, g = [], np.linspace(-1.0, 1.0, FURN_SAMPLES)
|
||||||
|
for kind, t in [("dining table", t) for t in W["tables"]] + [("chair", b) for b in W["boxes"]]:
|
||||||
|
if "r" in t:
|
||||||
|
pts = [t["c"] + t["r"] * np.array([a, b]) for a in g for b in g if a * a + b * b <= 1.0]
|
||||||
|
else:
|
||||||
|
pts = [t["c"] + rot2(t["ang"]) @ (np.array([a, b]) * t["half"]) for a in g for b in g]
|
||||||
|
top = [np.append(world_to_arm(p), t["z"]) for p in pts]
|
||||||
|
seen = [p for p in top if fov(p)]
|
||||||
|
if len(seen) < FURN_MIN_PART * len(top):
|
||||||
|
continue
|
||||||
|
c = np.mean(seen, axis=0) + np.append(W["rng"].normal(0, noise_mm, 2), 0.0)
|
||||||
|
size = 2000.0 * (t["r"] if "r" in t else max(t["half"]))
|
||||||
|
if "r" in t and np.linalg.norm(c[:2]) < ROUND_SINK_MM:
|
||||||
|
kind = "sink" # live: the round white table up close read "sink"
|
||||||
|
out.append({"name": kind, "colour": t.get("colour", "white" if kind == "dining table" else "grey"),
|
||||||
|
"score": 0.8, "box": [0, 0, 1, 1], "position_mm": [float(v) for v in c],
|
||||||
|
"top_mm": float(t["z"]), "width_mm": size})
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def torso_sees(p):
|
||||||
|
pc = np.linalg.inv(cam_true()) @ np.append(p, 1.0)
|
||||||
|
if pc[2] <= 0 or np.linalg.norm(pc[:3]) > DET_RANGE_MM:
|
||||||
|
return False
|
||||||
|
u, v = INTR["fx"] * pc[0] / pc[2] + INTR["cx"], INTR["fy"] * pc[1] / pc[2] + INTR["cy"]
|
||||||
|
return EDGE_PX <= u < INTR["width"] - EDGE_PX and EDGE_PX <= v < INTR["height"] - EDGE_PX
|
||||||
|
|
||||||
|
|
||||||
|
def head_sees(p):
|
||||||
|
pc = np.linalg.inv(head_T(*W["body"][2:])) @ np.append(p, 1.0)
|
||||||
|
return pc[2] > 0 and np.linalg.norm(pc[:3]) <= DET_RANGE_MM and \
|
||||||
|
abs(math.degrees(math.atan2(pc[0], pc[2]))) <= HEAD_FOV_DEG[0] and \
|
||||||
|
abs(math.degrees(math.atan2(pc[1], pc[2]))) <= HEAD_FOV_DEG[1]
|
||||||
|
|
||||||
|
|
||||||
def head_T(yaw, pitch):
|
def head_T(yaw, pitch):
|
||||||
"""Head camera -> arm transform at head (yaw, pitch): at the head's centre, looking ahead (arm +y) turned by yaw
|
"""Head camera -> arm transform at head (yaw, pitch): at the head's centre, looking ahead (arm +y) turned by yaw
|
||||||
(+ left) and tilted by pitch (+ up). Its depth frames are not simulated (camview.depth gives None)."""
|
(+ left) and tilted by pitch (+ up). Its depth frames are not simulated (camview.depth gives None)."""
|
||||||
@@ -287,7 +339,12 @@ def head_T(yaw, pitch):
|
|||||||
|
|
||||||
|
|
||||||
def head_detections():
|
def head_detections():
|
||||||
"""The cup as the head camera sees it (positions in the arm frame, HEAD_NOISE_MM), inside its field of view."""
|
"""The cup (and in place scenes the furniture) as the head camera sees it (positions in the arm frame,
|
||||||
|
HEAD_NOISE_MM), inside its field of view."""
|
||||||
|
return head_cup() + furniture(head_sees, HEAD_NOISE_MM)
|
||||||
|
|
||||||
|
|
||||||
|
def head_cup():
|
||||||
cup = W.get("cup")
|
cup = W.get("cup")
|
||||||
if cup is None or W["in_hand"]:
|
if cup is None or W["in_hand"]:
|
||||||
return []
|
return []
|
||||||
@@ -307,7 +364,9 @@ def refresh():
|
|||||||
yaw, org = arm_true()
|
yaw, org = arm_true()
|
||||||
x, y, th = W["base"]
|
x, y, th = W["base"]
|
||||||
boxes = []
|
boxes = []
|
||||||
for r, z0, z1 in [(t, t["z"] - TABLE_THICK_MM, t["z"]) for t in W["tables"]] + \
|
W["arm_discs"] = [(world_to_arm(t["c"]), t["r"] * 1000.0, t["z"] - TABLE_THICK_MM, t["z"])
|
||||||
|
for t in W["tables"] if "r" in t]
|
||||||
|
for r, z0, z1 in [(t, t["z"] - TABLE_THICK_MM, t["z"]) for t in W["tables"] if "r" not in t] + \
|
||||||
[(b, FLOOR_Z, b["z"]) for b in W["boxes"]]:
|
[(b, FLOOR_Z, b["z"]) for b in W["boxes"]]:
|
||||||
c = world_to_arm(r["c"])
|
c = world_to_arm(r["c"])
|
||||||
a = math.radians(r["ang"] - math.degrees(th) - yaw)
|
a = math.radians(r["ang"] - math.degrees(th) - yaw)
|
||||||
@@ -381,9 +440,11 @@ def f_open(wait=True):
|
|||||||
bottom = g[2] + held["below"] - held["h"] # grasp point is `below` under its top
|
bottom = g[2] + held["below"] - held["h"] # grasp point is `below` under its top
|
||||||
xy = arm_to_world(g)
|
xy = arm_to_world(g)
|
||||||
on = [t for t in W["tables"] if rect_dist(xy, t) == 0.0]
|
on = [t for t in W["tables"] if rect_dist(xy, t) == 0.0]
|
||||||
|
edge = lambda t: t["r"] - float(np.linalg.norm(xy - t["c"])) if "r" in t else \
|
||||||
|
-max(np.abs(rot2(-t["ang"]) @ (xy - t["c"])) - t["half"])
|
||||||
W["rec"]["released"] = {"xy": [round(float(v), 3) for v in xy],
|
W["rec"]["released"] = {"xy": [round(float(v), 3) for v in xy],
|
||||||
"edge_m": round(min((-max(np.abs(rot2(-t["ang"]) @ (xy - t["c"])) - t["half"])
|
"edge_m": round(min((edge(t) for t in on), default=-1.0), 3),
|
||||||
for t in on), default=-1.0), 3),
|
"table": next((W["tables"].index(t) for t in on), None),
|
||||||
"above_table_mm": round(float(bottom - on[0]["z"]), 1) if on else None}
|
"above_table_mm": round(float(bottom - on[0]["z"]), 1) if on else None}
|
||||||
W["hand"].update(holding=False, closed=False)
|
W["hand"].update(holding=False, closed=False)
|
||||||
refresh()
|
refresh()
|
||||||
@@ -601,6 +662,15 @@ def pick_at(x, y, top, grip=80.0, gap=0.10, height=110.0, variant="table", stall
|
|||||||
"tables": [table], "boxes": boxes, "stall_gap": stall_gap, "err_seed": err_seed}
|
"tables": [table], "boxes": boxes, "stall_gap": stall_gap, "err_seed": err_seed}
|
||||||
|
|
||||||
|
|
||||||
|
def place_at(tables, boxes=(), on=None, stall_gap=0.25, err_seed=3):
|
||||||
|
"""A fixed place scene: `tables` / `boxes` (chairs) as in make_place, map frame m (the base at the origin facing
|
||||||
|
+x), the cup held as after a pick from a table at -328 mm; `on`: what the command named."""
|
||||||
|
return {"kind": "place", "i": 0, "seed": 0, "bearing": 0.0, "dist_mm": 0, "variant": "fixed", "other": None,
|
||||||
|
"held": {"grip": 80.0, "h": 110.0, "table0": -328.0}, "tables": [dict(t) for t in tables],
|
||||||
|
"boxes": [dict(b) for b in boxes], "stall_gap": stall_gap, "err_seed": err_seed,
|
||||||
|
**({"on": on} if on else {})}
|
||||||
|
|
||||||
|
|
||||||
def make_place(i, seed):
|
def make_place(i, seed):
|
||||||
rng = random.Random(seed * 200003 + i)
|
rng = random.Random(seed * 200003 + i)
|
||||||
for _ in range(200):
|
for _ in range(200):
|
||||||
@@ -618,11 +688,49 @@ def make_place(i, seed):
|
|||||||
other = None
|
other = None
|
||||||
if rng.random() < 0.25: # another cup already on it, near its front edge
|
if rng.random() < 0.25: # another cup already on it, near its front edge
|
||||||
other = [float(v) for v in table["c"] - n * (depth / 2 - 0.12)]
|
other = [float(v) for v in table["c"] - n * (depth / 2 - 0.12)]
|
||||||
return {"kind": "place", "i": i, "seed": seed, "bearing": round(bearing, 1), "dist_mm": round(near * 1000),
|
sc = {"kind": "place", "i": i, "seed": seed, "bearing": round(bearing, 1), "dist_mm": round(near * 1000),
|
||||||
"variant": "table" + ("+cup" if other else ""),
|
"variant": "table" + ("+cup" if other else ""),
|
||||||
"held": {"grip": round(rng.uniform(72, 92), 1), "h": round(h, 1), "table0": -403.0 + 75.0},
|
"held": {"grip": round(rng.uniform(72, 92), 1), "h": round(h, 1), "table0": -403.0 + 75.0},
|
||||||
"tables": [{**table, "c": [float(v) for v in table["c"]]}], "boxes": [], "other": other,
|
"tables": [{**table, "c": [float(v) for v in table["c"]]}], "boxes": [], "other": other,
|
||||||
"stall_gap": rng.choice(STALL_GAPS), "err_seed": rng.randrange(1 << 30)}
|
"stall_gap": rng.choice(STALL_GAPS), "err_seed": rng.randrange(1 << 30)}
|
||||||
|
return place_extras(sc, n, near, width, random.Random(seed * 300007 + i))
|
||||||
|
|
||||||
|
|
||||||
|
def place_extras(sc, n, near, width, rng):
|
||||||
|
"""What the live place of 2026-10-27 had (a separate random stream: the scenes above stay as they were): a round
|
||||||
|
table, a chair beside the table (its seat ~20 cm lower), "the white dining table" said by name, another (black,
|
||||||
|
higher) table elsewhere."""
|
||||||
|
t = sc["tables"][0]
|
||||||
|
side = np.array([-n[1], n[0]])
|
||||||
|
if rng.random() < 0.25:
|
||||||
|
r = rng.uniform(0.35, 0.6)
|
||||||
|
t = {"c": [float(v) for v in n * (near + r) + side * rng.uniform(-0.15, 0.15)], "r": r, "z": t["z"]}
|
||||||
|
sc["tables"] = [t]
|
||||||
|
sc["variant"] += "+round"
|
||||||
|
W["tables"], W["boxes"] = [{**t, "c": np.array(t["c"])}], []
|
||||||
|
if rng.random() < 0.4:
|
||||||
|
for _ in range(20):
|
||||||
|
c = n * (near + rng.uniform(-0.3, 0.1)) + side * rng.choice((-1, 1)) * (width / 2 + rng.uniform(0.3, 0.5))
|
||||||
|
chair = {"c": c, "half": (0.22, 0.22), "ang": rng.uniform(0, 90), "z": t["z"] - rng.uniform(180, 260)}
|
||||||
|
if np.linalg.norm(c) > 0.6 and rect_dist(c, W["tables"][0]) > 0.25:
|
||||||
|
sc["boxes"] = [{**chair, "c": [float(v) for v in c], "half": list(chair["half"])}]
|
||||||
|
sc["variant"] += "+chair"
|
||||||
|
break
|
||||||
|
if rng.random() < 0.35:
|
||||||
|
sc["on"] = {"name": "dining table", "colour": "white"}
|
||||||
|
sc["variant"] += "+named"
|
||||||
|
if rng.random() < 0.5:
|
||||||
|
for _ in range(20):
|
||||||
|
a = math.atan2(n[1], n[0]) + math.radians(rng.choice((-1, 1)) * rng.uniform(90, 180))
|
||||||
|
m = np.array([math.cos(a), math.sin(a)])
|
||||||
|
c = m * rng.uniform(0.9, 1.8)
|
||||||
|
grey = {"c": c, "half": (0.3, 0.4), "ang": math.degrees(a), "z": rng.uniform(-300, -260),
|
||||||
|
"colour": "black"} # (grey would match "white": one light colour)
|
||||||
|
if rect_dist(c, W["tables"][0]) > 0.6 and rect_dist((0, 0), grey) > 0.45:
|
||||||
|
sc["tables"].append({**grey, "c": [float(v) for v in c], "half": list(grey["half"])})
|
||||||
|
sc["variant"] += "+other table"
|
||||||
|
break
|
||||||
|
return sc
|
||||||
|
|
||||||
|
|
||||||
def setup(sc, cam=1.0):
|
def setup(sc, cam=1.0):
|
||||||
@@ -632,7 +740,8 @@ def setup(sc, cam=1.0):
|
|||||||
W.update(lines=lines, in_hand=False, base=np.zeros(3), body=[0.0, WAIST_REF, 0.0, -5.0], nav=None,
|
W.update(lines=lines, in_hand=False, base=np.zeros(3), body=[0.0, WAIST_REF, 0.0, -5.0], nav=None,
|
||||||
joy={"v": 0.0, "t": 0.0, "want": 0.0, "start": np.zeros(3)},
|
joy={"v": 0.0, "t": 0.0, "want": 0.0, "start": np.zeros(3)},
|
||||||
J=list(motion.poses()["look"]), hand={"holding": False, "closed": False}, rng=nr,
|
J=list(motion.poses()["look"]), hand={"holding": False, "closed": False}, rng=nr,
|
||||||
tables=[{**t, "c": np.array(t["c"]), "half": np.array(t["half"])} for t in sc["tables"]],
|
tables=[{**t, "c": np.array(t["c"]), **({"half": np.array(t["half"])} if "half" in t else {})}
|
||||||
|
for t in sc["tables"]], furniture=sc["kind"] == "place",
|
||||||
boxes=[{**b, "c": np.array(b["c"]), "half": np.array(b["half"])} for b in sc["boxes"]],
|
boxes=[{**b, "c": np.array(b["c"]), "half": np.array(b["half"])} for b in sc["boxes"]],
|
||||||
stall_gap=sc["stall_gap"], col=COLUMN_BASE_M, rec={"moves": []})
|
stall_gap=sc["stall_gap"], col=COLUMN_BASE_M, rec={"moves": []})
|
||||||
e = nr.normal(0, CAM_ROT_SD_DEG * cam, 3)
|
e = nr.normal(0, CAM_ROT_SD_DEG * cam, 3)
|
||||||
@@ -720,9 +829,11 @@ def run_scene(sc, cam=1.0):
|
|||||||
fetch._pick_here({"object": "cup", "colour": None}, None)
|
fetch._pick_here({"object": "cup", "colour": None}, None)
|
||||||
rec["result"] = "ok" if W["hand"]["holding"] else "not holding"
|
rec["result"] = "ok" if W["hand"]["holding"] else "not holding"
|
||||||
else:
|
else:
|
||||||
fetch._put_down(None)
|
fetch._put_down(None, on=sc.get("on"))
|
||||||
rel = rec.get("released")
|
rel = rec.get("released")
|
||||||
rec["result"] = "ok" if rel and rel["edge_m"] >= 0.0 else "released off a table" if rel else "not released"
|
rec["result"] = "ok" if rel and rel["edge_m"] >= 0.0 and rel["table"] == 0 else \
|
||||||
|
"on another table" if rel and rel["edge_m"] >= 0.0 else \
|
||||||
|
"released off a table" if rel else "not released"
|
||||||
except fetch.Stopped:
|
except fetch.Stopped:
|
||||||
rec["result"] = "stopped"
|
rec["result"] = "stopped"
|
||||||
except (fetch.FetchError, skills.SkillError) as e:
|
except (fetch.FetchError, skills.SkillError) as e:
|
||||||
@@ -893,6 +1004,15 @@ def report(rows, path, title, mtimes):
|
|||||||
f"{sum(r['still'] > 0 for r in places)} scenes; repeated: {sum(r['repeats'] for r in places)}; tried again "
|
f"{sum(r['still'] > 0 for r in places)} scenes; repeated: {sum(r['repeats'] for r in places)}; tried again "
|
||||||
f"later from the same spot: {sum(r.get('loops', 0) for r in places)} in "
|
f"later from the same spot: {sum(r.get('loops', 0) for r in places)} in "
|
||||||
f"{sum(r.get('loops', 0) > 0 for r in places)} scenes", ""]
|
f"{sum(r.get('loops', 0) > 0 for r in places)} scenes", ""]
|
||||||
|
out += ["| scenes | ok |", "|---|---|"]
|
||||||
|
for tag in ("plain", "round", "chair", "named", "other table"):
|
||||||
|
sel = [r for r in places if (tag in r["variant"]) if tag != "plain"] if tag != "plain" else \
|
||||||
|
[r for r in places if "+" not in r["variant"].replace("+cup", "")]
|
||||||
|
if sel:
|
||||||
|
out.append(f"| {tag} | {100 * sum(r['result'] == 'ok' for r in sel) / len(sel):.0f}% ({len(sel)}) |")
|
||||||
|
navs = [sum(m[0] == "nav" for m in r["moves"]) for r in places]
|
||||||
|
out += ["", f"- navigation drives: {sum(navs)} in {sum(n > 0 for n in navs)} scenes, at most {max(navs)} in one; "
|
||||||
|
f"base moves in all: {sum(r['base_moves'] for r in places)}", ""]
|
||||||
rel = [r["released"] for r in places if r.get("released") and r["released"]["above_table_mm"] is not None]
|
rel = [r["released"] for r in places if r.get("released") and r["released"]["above_table_mm"] is not None]
|
||||||
if rel:
|
if rel:
|
||||||
hz = [x["above_table_mm"] for x in rel]
|
hz = [x["above_table_mm"] for x in rel]
|
||||||
@@ -952,7 +1072,8 @@ def main():
|
|||||||
scenes = [s for s in scenes if (s["kind"], str(s["i"])) in want]
|
scenes = [s for s in scenes if (s["kind"], str(s["i"])) in want]
|
||||||
for s in scenes: # numpy -> plain values for the records
|
for s in scenes: # numpy -> plain values for the records
|
||||||
for t in s["tables"] + s["boxes"]:
|
for t in s["tables"] + s["boxes"]:
|
||||||
t["half"] = [float(v) for v in t["half"]]
|
if "half" in t:
|
||||||
|
t["half"] = [float(v) for v in t["half"]]
|
||||||
logs = ROOT / "logs"
|
logs = ROOT / "logs"
|
||||||
jl, md = logs / f"pick_sweep_{a.round}.jsonl", logs / f"pick_sweep_{a.round}.md"
|
jl, md = logs / f"pick_sweep_{a.round}.jsonl", logs / f"pick_sweep_{a.round}.md"
|
||||||
stamp = mtimes()
|
stamp = mtimes()
|
||||||
|
|||||||
+10
-1
@@ -22,6 +22,9 @@ motion.poses = lambda: dict(POSES)
|
|||||||
head_cam.head_centre = lambda: head["centre"]
|
head_cam.head_centre = lambda: head["centre"]
|
||||||
gripper.state = lambda: {"holding": False, "ai": [160]}
|
gripper.state = lambda: {"holding": False, "ai": [160]}
|
||||||
arm_route.log = fetch.log = lambda *a: None
|
arm_route.log = fetch.log = lambda *a: None
|
||||||
|
LOOK_LIVE = [-239.2, -88.4, -29.5, 200.0, 81.4, 158.3] # the taught look: its links clear the head
|
||||||
|
assert arm_route.link_clearance(LOOK_LIVE, LOOK_LIVE, np.array([-93.0, -19.9, 356.1])) > arm_route.LINK_HEAD_CLEAR_MM
|
||||||
|
arm_route.links = lambda j: [] # toy kinematics: no links, the gripper is checked
|
||||||
motion.SETTLE_S = 0.05 # quick here; the pause itself is checked below
|
motion.SETTLE_S = 0.05 # quick here; the pause itself is checked below
|
||||||
|
|
||||||
|
|
||||||
@@ -41,6 +44,8 @@ class FakeArm:
|
|||||||
if name == "kine_forward":
|
if name == "kine_forward":
|
||||||
j = a["jointPosition"]
|
j = a["jointPosition"]
|
||||||
return {"cartPosition": [30 * j[0], 30 * j[1], 30 * j[2]] + list(skills.GRASP_RPY), "errorCode": "0"}
|
return {"cartPosition": [30 * j[0], 30 * j[1], 30 * j[2]] + list(skills.GRASP_RPY), "errorCode": "0"}
|
||||||
|
if name == "kine_inverse":
|
||||||
|
return {"errorCode": "-1", "errorMsg": "no IK in the toy"}
|
||||||
if name == "get_data":
|
if name == "get_data":
|
||||||
return {"joint_actual_position": list(self.j), "inpos": True}
|
return {"joint_actual_position": list(self.j), "inpos": True}
|
||||||
if name == "get_motion_state":
|
if name == "get_motion_state":
|
||||||
@@ -105,7 +110,10 @@ assert arm_route.goto("carry") == ["look", "carry"] and fake.sent == [POSES["loo
|
|||||||
fake = use([20.5, 0, 0, 0, 0, 0]) # within EXACT_DEG of carry: straight on
|
fake = use([20.5, 0, 0, 0, 0, 0]) # within EXACT_DEG of carry: straight on
|
||||||
assert arm_route.goto("give") == ["give"]
|
assert arm_route.goto("give") == ["give"]
|
||||||
|
|
||||||
# ---------- far from every pose, or a move that passes the head: refused, nothing sent ----------
|
# ---------- far from every pose: one checked joint move to the nearest pose, slow; none passes: refused ----------
|
||||||
|
fake = use([60.0, 60.0, 0, 0, 0, 0])
|
||||||
|
assert arm_route.goto("carry") == ["look", "carry"] and fake.sent == [POSES["look"], POSES["carry"]], fake.sent
|
||||||
|
head["centre"] = np.array([1800.0, 1800.0, 0.0]) # the gripper is at the head: every way refused
|
||||||
fake = use([60.0, 60.0, 0, 0, 0, 0])
|
fake = use([60.0, 60.0, 0, 0, 0, 0])
|
||||||
refused(arm_route.UNKNOWN, arm_route.goto, "look")
|
refused(arm_route.UNKNOWN, arm_route.goto, "look")
|
||||||
try:
|
try:
|
||||||
@@ -114,6 +122,7 @@ try:
|
|||||||
except fetch.FetchError as e:
|
except fetch.FetchError as e:
|
||||||
assert e.args == arm_route.UNKNOWN
|
assert e.args == arm_route.UNKNOWN
|
||||||
assert fake.sent == []
|
assert fake.sent == []
|
||||||
|
head["centre"] = FAR
|
||||||
fake = use([60.0, 60.0, 0, 0, 0, 0]) # a task's own way back from the table: straight
|
fake = use([60.0, 60.0, 0, 0, 0, 0]) # a task's own way back from the table: straight
|
||||||
assert arm_route.goto("look", leaf=True) == ["look"]
|
assert arm_route.goto("look", leaf=True) == ["look"]
|
||||||
head["centre"] = np.array([300.0, 0.0, 0.0]) # on the way look -> carry (flange x 0 -> 600)
|
head["centre"] = np.array([300.0, 0.0, 0.0]) # on the way look -> carry (flange x 0 -> 600)
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ for name in ("follow_stop", "voice_setting", "fixed_answer", "drive_words", "mis
|
|||||||
L.fetch_status = lambda: None
|
L.fetch_status = lambda: None
|
||||||
L.keep_listening = lambda: None
|
L.keep_listening = lambda: None
|
||||||
L.fetch_say = lambda *a: None
|
L.fetch_say = lambda *a: None
|
||||||
L.stop_all = lambda: rec("stop")
|
L.stop_all = lambda text="": rec("stop")
|
||||||
L.chain_request = lambda text, plan=None: rec("chain", [[k, w] for k, w, _ in plan])
|
L.chain_request = lambda text, plan=None: rec("chain", [[k, w] for k, w, _ in plan])
|
||||||
L.mission_request = lambda text, read=None: rec("talk") if read[1] else rec("steps", read[0])
|
L.mission_request = lambda text, read=None: rec("talk") if read[1] else rec("steps", read[0])
|
||||||
L.hand_command = hand
|
L.hand_command = hand
|
||||||
|
|||||||
+4
-1
@@ -549,6 +549,9 @@ st = run(fetch.place, None, {"name": "chair", "colour": "orange"})
|
|||||||
assert st["status"] == "done" and ("place",) in calls, st["log"][-4:]
|
assert st["status"] == "done" and ("place",) in calls, st["log"][-4:]
|
||||||
# "the grey table": the cameras call it a white sink (flat, table height) -> on it; nothing named in view -> any table
|
# "the grey table": the cameras call it a white sink (flat, table height) -> on it; nothing named in view -> any table
|
||||||
sink = {"name": "sink", "colour": "white", "x": -160.0, "y": 760.0, "top_mm": -400.0, "seen": 8, "spread": 1.0}
|
sink = {"name": "sink", "colour": "white", "x": -160.0, "y": 760.0, "top_mm": -400.0, "seen": 8, "spread": 1.0}
|
||||||
|
flat_fixed = skills.flat_points # the table stands still: in the arm frame it moves with the lift
|
||||||
|
skills.flat_points = lambda pts, guess_z=-400.0, camera="torso", T=None: \
|
||||||
|
[(p[0], p[1], surface["z"] + 75.0 - body["lift"]) for p in pts]
|
||||||
for seen in ([chair, sink], []):
|
for seen in ([chair, sink], []):
|
||||||
reset()
|
reset()
|
||||||
hand.update(holding=True, closed=True)
|
hand.update(holding=True, closed=True)
|
||||||
@@ -563,7 +566,7 @@ for seen in ([chair, sink], []):
|
|||||||
instead = "white sink" if seen else "table" # not exactly what was said: the closest (white = grey, a
|
instead = "white sink" if seen else "table" # not exactly what was said: the closest (white = grey, a
|
||||||
assert any(f"couldn't find the grey table, so I put it on the {instead} here" in w for w in said), said # flat
|
assert any(f"couldn't find the grey table, so I put it on the {instead} here" in w for w in said), said # flat
|
||||||
assert seen or not any("sink" in l for l in this), this # furniture word), after the one whole search; else any
|
assert seen or not any("sink" in l for l in this), this # furniture word), after the one whole search; else any
|
||||||
skills.look, skills.on_table = real_look, real_on_table
|
skills.look, skills.on_table, skills.flat_points = real_look, real_on_table, flat_fixed
|
||||||
fetch._set(holding=False, status="idle")
|
fetch._set(holding=False, status="idle")
|
||||||
hand.update(holding=False, closed=False)
|
hand.update(holding=False, closed=False)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
"""Self-check of the mission step {"do": "carry"} (tests/pick_sweep.py simulator, no robot): a pick stopped right after
|
||||||
|
the grasp leaves the cup just above the table; the step lifts it straight up and brings it to look, saying nothing:
|
||||||
|
python tests/test_fetch_carry.py"""
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||||
|
from tests import pick_sweep as ps
|
||||||
|
|
||||||
|
ps.install()
|
||||||
|
fetch, skills, motion = ps.fetch, ps.skills, ps.motion
|
||||||
|
|
||||||
|
|
||||||
|
class Halt(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def halt_up(what, pose): # the pick is stopped before its straight move up: holding, 3 cm up
|
||||||
|
if what == "up":
|
||||||
|
raise Halt()
|
||||||
|
REAL_LINE(what, pose)
|
||||||
|
|
||||||
|
|
||||||
|
REAL_LINE = skills._line
|
||||||
|
|
||||||
|
|
||||||
|
for name, sc in (("straight", ps.pick_at(-96, 598, -260)), ("turned", ps.pick_at(260, 722, -186))):
|
||||||
|
ps.setup(sc, 0.0)
|
||||||
|
skills._line = halt_up
|
||||||
|
try:
|
||||||
|
fetch._pick_here({"object": "cup", "colour": None}, None)
|
||||||
|
raise AssertionError("the pick was not stopped")
|
||||||
|
except Halt:
|
||||||
|
pass
|
||||||
|
skills._line = REAL_LINE
|
||||||
|
assert ps.W["hand"]["holding"] and fetch._state["holding"], name
|
||||||
|
z0 = ps.kin.pose(ps.W["J"])[2]
|
||||||
|
assert not fetch._at_pose("look"), name
|
||||||
|
said, ups = [], []
|
||||||
|
skills._line = lambda what, pose: (ups.append(pose[2]), REAL_LINE(what, pose))
|
||||||
|
fetch._do_step({"do": "carry"}, lambda en, ko=None: said.append(en))
|
||||||
|
skills._line = REAL_LINE
|
||||||
|
assert fetch._at_pose("look") and ps.W["hand"]["holding"], name
|
||||||
|
assert ups and ups[0] >= z0 + skills.ABOVE_MM - skills.LIFT_MM - 1.0, (name, z0, ups) # straight up first
|
||||||
|
assert not said, said
|
||||||
|
fetch._do_step({"do": "carry"}, lambda en, ko=None: said.append(en)) # at look already: nothing moves
|
||||||
|
assert fetch._at_pose("look") and not said
|
||||||
|
print(name, "lifted", round(ups[0] - z0), "mm, then to look")
|
||||||
|
|
||||||
|
fetch._state.update(holding=False)
|
||||||
|
try:
|
||||||
|
fetch._carry_held()
|
||||||
|
raise AssertionError("carried with an empty hand")
|
||||||
|
except fetch.FetchError:
|
||||||
|
pass
|
||||||
|
print("fetch carry ok")
|
||||||
@@ -205,9 +205,8 @@ only_chair = [white_t, {**grey_t, "name": "chair", "names": ["chair"]}]
|
|||||||
assert fetch._support(brain.place_on("put it on the black table"), only_chair) is None
|
assert fetch._support(brain.place_on("put it on the black table"), only_chair) is None
|
||||||
usable, went, said = [], [], []
|
usable, went, said = [], [], []
|
||||||
fetch._usable(usable, only_chair)
|
fetch._usable(usable, only_chair)
|
||||||
real_go_to, real_near = fetch._go_to, fetch._place_near
|
real_go_to, real_kept = fetch._go_to, fetch._place_kept
|
||||||
fetch._go_to = lambda thing, goal, tried, holding=False: went.append((round(thing["x"]), round(thing["y"])))
|
fetch._place_kept = lambda top0, kept, tried: went.append(tuple(round(v) for v in fetch._kept_at(kept)[:2])) or True
|
||||||
fetch._place_near = lambda top0, tried: True
|
|
||||||
fetch._state.update(holding=True, held_object={"object": "cup", "colour": "grey"})
|
fetch._state.update(holding=True, held_object={"object": "cup", "colour": "grey"})
|
||||||
fetch._put_instead(-260.0, brain.place_on("put it on the black table"), "black table", usable, set(),
|
fetch._put_instead(-260.0, brain.place_on("put it on the black table"), "black table", usable, set(),
|
||||||
lambda en, ko: said.append(en))
|
lambda en, ko: said.append(en))
|
||||||
@@ -217,7 +216,7 @@ went.clear(); said.clear()
|
|||||||
fetch._put_instead(-260.0, brain.place_on("put it on the lower red sofa"), "red sofa", usable, set(),
|
fetch._put_instead(-260.0, brain.place_on("put it on the lower red sofa"), "red sofa", usable, set(),
|
||||||
lambda en, ko: said.append(en))
|
lambda en, ko: said.append(en))
|
||||||
assert went == [(300, 900)] and "on the black chair here" in said[0], (went, said) # same kind, the lower one
|
assert went == [(300, 900)] and "on the black chair here" in said[0], (went, said) # same kind, the lower one
|
||||||
fetch._go_to, fetch._place_near = real_go_to, real_near
|
fetch._place_kept = real_kept
|
||||||
fetch._state.update(holding=False, held_object=None)
|
fetch._state.update(holding=False, held_object=None)
|
||||||
skills.flat_points = flat
|
skills.flat_points = flat
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,222 @@
|
|||||||
|
"""Self-check of the owner's live test of 2026-10-27 (logs/lumi.log 10:45-11:19), no robot, no audio, no LLM:
|
||||||
|
python tests/test_mission_name.py
|
||||||
|
1. While a mission picks / places / carries, only words with Lumi's name halt it ("Lumi, wait", "루미 멈춰"); talk
|
||||||
|
around it ("네, 안녕하세요.", "Very nice.", "Okay.") neither halts nor resumes it. Stop words and safety words from
|
||||||
|
anyone still stop at once. "Lumi, keep going" / "루미 계속해" after a stop does the rest of the job.
|
||||||
|
2. "Lumi stop, not the apple, take the cup": stopped, then the new order is done. Holding after a stop: put it back /
|
||||||
|
on the table / down again, at every speech level, English and Korean.
|
||||||
|
3. The dashboard's Command box: "come to me" reads back as "Come to me." and, typed, comes to the person in view."""
|
||||||
|
import re
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
|
re._MAXCACHE = 100000
|
||||||
|
|
||||||
|
from assistant import lumi
|
||||||
|
from tasks import fetch
|
||||||
|
|
||||||
|
M = ["home", "dock2", "exit", "final"] + [f"p{i}" for i in range(1, 11)]
|
||||||
|
TAKE = [{"do": "pick", "object": "cup", "colour": None}] # the dashboard's "Take the cup"
|
||||||
|
DELIVERY = TAKE + [{"do": "go", "to": "p6"}, {"do": "give", "person": "James"}]
|
||||||
|
done = []
|
||||||
|
run = {"status": "running", "paused": False, "steps": TAKE, "log": [], "holding": False, "since": time.time()}
|
||||||
|
|
||||||
|
|
||||||
|
def _stop():
|
||||||
|
done.append("stop")
|
||||||
|
run.update(status="stopped", since=time.time())
|
||||||
|
|
||||||
|
|
||||||
|
fetch.state = lambda: {"status": run["status"], "task": {"steps": run["steps"], "sender": None}, "log": run["log"],
|
||||||
|
"holding": run["holding"], "since": run["since"]}
|
||||||
|
fetch.pause = lambda: (done.append("pause"), run.update(paused=True), True)[-1] if run["status"] == "running" else False
|
||||||
|
fetch.paused = lambda: run["paused"]
|
||||||
|
fetch.resume = lambda: (done.append("resume"), run.update(paused=False))
|
||||||
|
fetch.stop = _stop
|
||||||
|
fetch.end = lambda timeout=5.0: (done.append("end"), run.update(status="stopped"))
|
||||||
|
fetch.replace = lambda steps, say=None: done.append(("replace", steps))
|
||||||
|
fetch.proceed = lambda: done.append("proceed")
|
||||||
|
fetch.run_steps = lambda steps, say=None, sender=None: done.append(("run", steps))
|
||||||
|
fetch.check_hand = lambda: run["holding"]
|
||||||
|
fetch.held_name = lambda lang="en": "the cup" if lang == "en" else "컵"
|
||||||
|
lumi.agv.cancel = lambda: done.append("agv cancel")
|
||||||
|
lumi.mouth.say = lambda text, **k: done.append(("say", text))
|
||||||
|
|
||||||
|
|
||||||
|
class Track:
|
||||||
|
def __init__(self, tid):
|
||||||
|
self.id, self.person, self.angle, self.distance, self.greeted = tid, None, -9.0, 2.35, False
|
||||||
|
|
||||||
|
|
||||||
|
class Brain:
|
||||||
|
history = []
|
||||||
|
|
||||||
|
|
||||||
|
def fresh(steps=TAKE, current=None, holding=False, log=()):
|
||||||
|
L = lumi.Lumi.__new__(lumi.Lumi)
|
||||||
|
L.markers, L.lang, L.current, L.mission_hold, L.asked_go_on = M, "en", current, None, False
|
||||||
|
L.patrol, L.chain_stop, L.brain, L.pending_text = None, threading.Event(), Brain(), None
|
||||||
|
L.last_activity, L.said = time.time(), []
|
||||||
|
L.fetch_say = lambda en, ko: L.said.append(en)
|
||||||
|
L.keep_listening = lambda: None
|
||||||
|
L.act = lambda action, target: done.append(("act", action))
|
||||||
|
L.head_rest = lambda: None
|
||||||
|
done.clear()
|
||||||
|
run.update(status="running", paused=False, steps=steps, log=list(log), holding=holding, since=time.time())
|
||||||
|
return L
|
||||||
|
|
||||||
|
|
||||||
|
bad = []
|
||||||
|
|
||||||
|
|
||||||
|
def check(ok, what):
|
||||||
|
if not ok:
|
||||||
|
bad.append(what)
|
||||||
|
print("WRONG", what)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------- 1. talk around Lumi on a pick: never halts it, never resumes it ----------
|
||||||
|
for current in (None, Track(97)):
|
||||||
|
L = fresh(current=current)
|
||||||
|
L.last_talk = time.time() # someone talked a moment ago (10:56:01 "네.")
|
||||||
|
for said in ("네, 안녕하세요.", "네.", "Very nice.", "Okay.", "네, 네, 네, 네, 네.", "hello", "hi there", "excuse me",
|
||||||
|
"sorry", "what are you doing?", "그렇죠.", "I'm Tom.", "the robot is slow", "로봇 신기하다", "hey"):
|
||||||
|
L.mission_talk(said)
|
||||||
|
check(not done and not L.said, f"plain talk {said!r} halted or answered: {done} {L.said}")
|
||||||
|
for said in ("come to me", "give me that", "go to p3"): # an order without the name: not to Lumi on a job
|
||||||
|
L.mission_talk(said)
|
||||||
|
check("end" not in done and "pause" not in done, f"{said!r} without the name ended the job: {done}")
|
||||||
|
# said to Lumi by name: halts it
|
||||||
|
for said in ("Lumi, wait", "Hi Lumi!", "루미야 잠깐", "루미야, 뭐 해?", "Lumi, what are you doing?", "hey Lumi"):
|
||||||
|
L = fresh()
|
||||||
|
L.mission_talk(said)
|
||||||
|
check(done[:1] == ["pause"], f"{said!r} did not halt it: {done}")
|
||||||
|
# stop and safety words from anyone, with or without the name: at once, as before
|
||||||
|
for said in ("stop", "Stop it.", "멈춰", "그만", "Lumi, stop", "루미 멈춰", "stop Lumi"):
|
||||||
|
L = fresh()
|
||||||
|
check(L.mission_talk(said) and "stop" in done, f"{said!r} did not stop it: {done}")
|
||||||
|
for said in ("watch out!", "아파", "my hand!", "위험해"):
|
||||||
|
L = fresh()
|
||||||
|
check(L.mission_talk(said) and "pause" in done and L.mission_hold == "safety", f"{said!r} no safety halt: {done}")
|
||||||
|
# halted by name, then "Lumi, keep going" at every level: goes on
|
||||||
|
GO_EN = ["Lumi, keep going", "Lumi, go on", "Lumi, continue", "Lumi, carry on", "okay Lumi, you can go on",
|
||||||
|
"Lumi, keep going please", "Lumi, resume", "Lumi, finish the job"]
|
||||||
|
GO_KO = ["루미 계속해", "루미야 계속해", "루미야 계속해요", "루미야 계속하세요", "루미야 계속하십시오", "루미야 계속해 줘",
|
||||||
|
"루미야 계속해 주세요", "루미 계속 진행해", "루미야 하던 거 계속해", "루미야 마저 해", "루미야 마저 하세요"]
|
||||||
|
for said in GO_EN + GO_KO:
|
||||||
|
L = fresh()
|
||||||
|
L.mission_talk("Lumi, wait")
|
||||||
|
check(L.mission_talk(said) and done[-1] == "resume", f"{said!r} did not go on: {done}")
|
||||||
|
|
||||||
|
# ---------- 1b. "Lumi, stop", then "Lumi, keep going": the rest of the job is done ----------
|
||||||
|
for said in GO_EN + GO_KO:
|
||||||
|
for steps_, log_, holding, want in ((TAKE, ["10:46:01 step 1/1: {'do': 'pick'}"], False, TAKE),
|
||||||
|
(DELIVERY, ["step 1/3: pick", "step 2/3: go"], True, DELIVERY[1:]),
|
||||||
|
(DELIVERY, ["step 1/3: pick"], True, # held: lifted, then on
|
||||||
|
[{"do": "carry"}] + DELIVERY[1:]),
|
||||||
|
(DELIVERY, ["step 1/3: pick"], False, DELIVERY)):
|
||||||
|
L = fresh(steps_, holding=holding, log=log_)
|
||||||
|
L.mission_talk("Lumi, stop")
|
||||||
|
check(not L.mission_running() and L.resume_stopped(said) and done[-1] == ("run", want),
|
||||||
|
f"stop, then {said!r} ({log_[-1]}, holding {holding}): {done[-1]} not {want}")
|
||||||
|
L = fresh(TAKE, holding=True, log=["step 1/1: pick"]) # "take the cup" stopped with the cup in the hand
|
||||||
|
L.mission_talk("Lumi, stop")
|
||||||
|
check(L.resume_stopped("Lumi, keep going") and done[-1] == ("run", [{"do": "carry"}])
|
||||||
|
and "the cup" in L.said[-1], f"held, nothing left: lifted to look, then asked: {done} {L.said}")
|
||||||
|
for said in ("keep going", "계속해", "Lumi, keep going?", "did you keep going, Lumi?"): # no name, or a question
|
||||||
|
L = fresh(DELIVERY, log=["step 1/3: pick"])
|
||||||
|
L.mission_talk("stop")
|
||||||
|
check(not L.resume_stopped(said), f"{said!r} after a stop restarted the job")
|
||||||
|
L = fresh(log=["step 1/1: pick"]) # long after the stop: not taken
|
||||||
|
L.mission_talk("Lumi, stop")
|
||||||
|
L.stopped_mission = L.stopped_mission[:2] + (time.time() - lumi.RESUME_S - 1,)
|
||||||
|
check(not L.resume_stopped("Lumi, keep going"), "keep going long after the stop restarted the job")
|
||||||
|
|
||||||
|
# ---------- 2. a stop with a new order after it: stopped, then the new order ----------
|
||||||
|
for said, want in (("Lumi stop, not the apple, take the cup", ("pick", "cup")),
|
||||||
|
("Lumi, stop. Take the cup instead.", ("pick", "cup")),
|
||||||
|
("루미 멈춰, 사과 말고 컵 집어", ("pick", "cup")),
|
||||||
|
("루미야 멈춰 그거 말고 컵 집어 주세요", ("pick", "cup")),
|
||||||
|
("stop Lumi, put it back", ("put", "back")),
|
||||||
|
("루미 멈춰, 제자리에 놔", ("put", "back"))):
|
||||||
|
L = fresh(log=["step 1/1: pick"])
|
||||||
|
check(L.mission_talk(said) and "stop" in done and "end" in done and L.pending_text, f"{said!r}: {done} {L.pending_text!r}")
|
||||||
|
got = lumi.route(L.pending_text or "", M, Brain(), holding=False, chain_ok=False)
|
||||||
|
check(got == ("quick", want), f"{said!r}: then {L.pending_text!r} read {got}, not {want}")
|
||||||
|
check(L.stopped_mission is None, f"{said!r}: the old job is still kept to go on with")
|
||||||
|
for said in ("Stop it.", "Lumi, stop!", "stop, stop", "루미야 멈춰 주세요", "stop, where are you going?",
|
||||||
|
"Lumi, stop, you're going to hit the table", "stop, don't take the cup"): # nothing to do after it
|
||||||
|
L = fresh()
|
||||||
|
L.mission_talk(said)
|
||||||
|
check(not L.pending_text, f"{said!r}: {L.pending_text!r} taken as an order after the stop")
|
||||||
|
|
||||||
|
# holding after a stop: put it back / on the table / down again, every level, English and Korean
|
||||||
|
EN_LEVELS = ["{x}", "please {x}", "{x}, please", "can you {x}?", "could you {x}?", "would you {x}?", "will you {x}?",
|
||||||
|
"could you please {x}?", "I need you to {x}", "hey Lumi, {x}", "Lumi, {x} now", "go ahead and {x}", "kindly {x}",
|
||||||
|
"if you don't mind, {x}", "do me a favor and {x}", "{x} pls", "Lumi could you {x}"]
|
||||||
|
|
||||||
|
|
||||||
|
def ko_levels(v, h):
|
||||||
|
return [v, f"{v} 줘", f"{v}요", f"{v} 주세요", f"{h}세요", f"{h}십시오", f"{v} 주십시오", f"{v} 주시겠어요?",
|
||||||
|
f"{v} 주시겠습니까?", f"{v} 줄래?", f"{v} 주실래요?", f"{v} 주게", f"{v} 주이소", f"{v} 도", f"{v} 주라",
|
||||||
|
f"{v} 주시면 감사하겠습니다", f"{v} 주면 안 될까요?", f"{v} 주실 수 있나요?", f"{v}줘", f"{v} 줘 봐", f"{v} 주시오"]
|
||||||
|
|
||||||
|
|
||||||
|
def put_down(text):
|
||||||
|
kind, data = lumi.route(text, M, Brain(), holding=True, chain_ok=False)
|
||||||
|
return kind == "quick" and data[:2] == ("put", "back") or kind == "hand" and data[0][0] == "place"
|
||||||
|
|
||||||
|
|
||||||
|
HELD = [f.format(x=x) for x in ("put it back", "put it on the table", "put it down again", "put it down") for f in EN_LEVELS]
|
||||||
|
HELD += [w.format(f) for w, v, h in (("제자리에 {}", "놔", "놓으"), ("다시 {}", "놔", "놓으"), ("테이블에 {}", "놔", "놓으"),
|
||||||
|
("다시 {}", "내려놔", "내려놓으"), ("원래 자리에 {}", "갖다 놔", "갖다 놓으"))
|
||||||
|
for f in ko_levels(v, h)]
|
||||||
|
for text in HELD:
|
||||||
|
check(put_down(text), f"holding: {text!r} does not put it down")
|
||||||
|
check(lumi.route("take the apple", M, Brain(), holding=False, chain_ok=False) == ("quick", ("pick", "apple")),
|
||||||
|
"then another thing is not taken")
|
||||||
|
|
||||||
|
# ---------- 3. the Command box: "come to me" ----------
|
||||||
|
from api import server
|
||||||
|
server.agv.markers = lambda: M
|
||||||
|
for text, want in (("come to me", "Come to me."), ("이리 와", "Come to me."), ("follow me", "Follow me.")):
|
||||||
|
got = server.task_parse(server.ParseBody(text=text))
|
||||||
|
check(got["sentence"] == want and got["action"] == "command", f"box {text!r}: {got['sentence']!r}")
|
||||||
|
# typed: no voice this turn, so the person in view is the one (11:18:02: a stale voice direction, nobody found)
|
||||||
|
came = []
|
||||||
|
L = fresh()
|
||||||
|
run.update(status="idle", steps=[])
|
||||||
|
L.voice_angle, L.voice_trusted, L.current = 60.0, True, None # the last voice, long ago, from the side
|
||||||
|
|
||||||
|
|
||||||
|
class Vision:
|
||||||
|
camera = "head"
|
||||||
|
tracks = [Track(97)]
|
||||||
|
lock = threading.Lock()
|
||||||
|
|
||||||
|
def present(self, t):
|
||||||
|
return t in self.tracks
|
||||||
|
|
||||||
|
def near_angle(self, angle, max_diff=20):
|
||||||
|
return next((t for t in self.tracks if abs(t.angle - angle) <= max_diff), None)
|
||||||
|
|
||||||
|
def only_person(self):
|
||||||
|
return self.tracks[0]
|
||||||
|
|
||||||
|
|
||||||
|
L.vision = Vision()
|
||||||
|
L.turn_head = lambda yaw: None
|
||||||
|
L.come_to = lambda track, say=False: came.append(track if track is not None else L.find_caller(L.voice_angle, L.voice_trusted))
|
||||||
|
L.answer = lambda text: L.come_to(L.current, say=True)
|
||||||
|
L.typed("come to me")
|
||||||
|
check(came and came[0] is not None and came[0].id == 97, f"typed come to me: came to {came}")
|
||||||
|
check(lumi.ears.understood(), "typed words taken as not understood (11:22:46 'look at front': 'say it again')")
|
||||||
|
|
||||||
|
L = fresh() # typed in the box on a job: to Lumi
|
||||||
|
L.answer = lambda text: L.mission_talk(text)
|
||||||
|
L.typed("come to me")
|
||||||
|
check("end" in done, f"typed 'come to me' on a job was ignored: {done}")
|
||||||
|
|
||||||
|
if bad:
|
||||||
|
raise SystemExit(f"{len(bad)} wrong")
|
||||||
|
print(f"mission name ok ({len(HELD)} held commands)")
|
||||||
@@ -43,7 +43,7 @@ ok, said = talk(L, "what are you doing?")
|
|||||||
assert not ok
|
assert not ok
|
||||||
ok, said = talk(L, "okay, you can go")
|
ok, said = talk(L, "okay, you can go")
|
||||||
assert ok and done[-1] == "resume" and L.mission_hold is None, done
|
assert ok and done[-1] == "resume" and L.mission_hold is None, done
|
||||||
ok, said = talk(L, "go to p3") # anyone's new task: the mission ends with one line, then it is done
|
ok, said = talk(L, "Lumi, go to p3") # a new task said to Lumi: the mission ends with one line, then it is done
|
||||||
assert ok is False and done[-1] == "end" and said == "Okay, I've stopped my task.", (done, said)
|
assert ok is False and done[-1] == "end" and said == "Okay, I've stopped my task.", (done, said)
|
||||||
L = fresh()
|
L = fresh()
|
||||||
ok, said = talk(L, "Lumi, I'm James, give it to me") # the person it is for
|
ok, said = talk(L, "Lumi, I'm James, give it to me") # the person it is for
|
||||||
|
|||||||
@@ -48,4 +48,30 @@ for group, scenes in (("must", MUST), ("physical", PHYSICAL), ("open", OPEN)):
|
|||||||
elif group == "physical" and (r["result"] == "ok" or ps.way_exists(sc) is not None):
|
elif group == "physical" and (r["result"] == "ok" or ps.way_exists(sc) is not None):
|
||||||
bad.append((name, "no longer physical", r["result"]))
|
bad.append((name, "no longer physical", r["result"]))
|
||||||
assert not bad, bad
|
assert not bad, bad
|
||||||
|
|
||||||
|
# ---------- places, the live run of 2026-10-27 (named white table, a higher grey one, a chair seat at -549) ----------
|
||||||
|
P = lambda deg, m: [m * ps.math.cos(ps.math.radians(deg)), m * ps.math.sin(ps.math.radians(deg))]
|
||||||
|
WHITE = {"name": "dining table", "colour": "white"}
|
||||||
|
SEAT = {"c": P(-55, 1.3), "half": [0.22, 0.22], "ang": 10.0, "z": -549.0}
|
||||||
|
PLACES = { # name: (scene, must end on table 0)
|
||||||
|
"10:55 the white table by name, far right": (ps.place_at(
|
||||||
|
[{"c": P(-70, 1.9), "r": 0.5, "z": -330.0},
|
||||||
|
{"c": P(-120, 1.6), "half": [0.3, 0.4], "ang": -120.0, "z": -267.0, "colour": "black"}], [SEAT], WHITE), True),
|
||||||
|
"10:55 the same, the base stops 0.1 m early": (ps.place_at(
|
||||||
|
[{"c": P(-70, 1.9), "r": 0.5, "z": -330.0},
|
||||||
|
{"c": P(-120, 1.6), "half": [0.3, 0.4], "ang": -120.0, "z": -267.0, "colour": "black"}], [SEAT], WHITE,
|
||||||
|
stall_gap=0.1), True),
|
||||||
|
"10:59 a chair seat, no table": (ps.place_at([], [{**SEAT, "c": P(-20, 1.1)}]), False),
|
||||||
|
"10:59 a chair seat ahead": (ps.place_at([], [{**SEAT, "c": P(0, 1.1)}]), False),
|
||||||
|
"11:13 the round table ahead, flush": (ps.place_at([{"c": P(0, 0.95), "r": 0.5, "z": -330.0}]), True),
|
||||||
|
}
|
||||||
|
for name, (sc, must) in PLACES.items():
|
||||||
|
r = ps.run_scene(sc, 1.0)
|
||||||
|
navs = sum(m[0] == "nav" for m in r["moves"])
|
||||||
|
drives = sum(m[0] == "nav" or m[0] == "straight" and m[1] > 0 for m in r["moves"]) # towards something
|
||||||
|
print(f"place {name:44s} {r['result']:8s} moves {[m[:3] for m in r['moves']]} {r.get('why') or ''}")
|
||||||
|
if must and r["result"] != "ok" or not must and (r.get("released") or drives) or navs > ps.fetch.PLACE_NAV_MAX \
|
||||||
|
or r["result"] in ("exception", "timeout"):
|
||||||
|
bad.append((name, r["result"], r.get("why"), r["moves"]))
|
||||||
|
assert not bad, bad
|
||||||
print("pick sweep scenes ok")
|
print("pick sweep scenes ok")
|
||||||
|
|||||||
+4
-3
@@ -135,9 +135,10 @@ wave.wave()
|
|||||||
assert a.sent[:4] == [LOOK, POSES["wave_out"], top, swing], a.sent
|
assert a.sent[:4] == [LOOK, POSES["wave_out"], top, swing], a.sent
|
||||||
del POSES["carry"]
|
del POSES["carry"]
|
||||||
|
|
||||||
# ---------- an unknown start (after free drive: the wrist the other way round), base, power ----------
|
# ---------- an unknown start (after free drive: the wrist the other way round): joins by a checked move; power ----------
|
||||||
a = use(FakeArm([-249.1, -90.9, -29.1, 14.6, -83.8, -33.0]))
|
a = use(FakeArm([-249.1, -90.9, -29.1, 14.6, -83.8, -33.0]))
|
||||||
refused(wave.UNKNOWN_POSE)
|
wave.wave()
|
||||||
|
assert a.sent[0][1:3] == LOOK[1:3] and swing in a.sent, a.sent
|
||||||
use(FakeArm(LOOK, enable=False))
|
use(FakeArm(LOOK, enable=False))
|
||||||
refused(wave.OFF)
|
refused(wave.OFF)
|
||||||
base["move_status"] = "running"
|
base["move_status"] = "running"
|
||||||
@@ -153,7 +154,7 @@ POSES["wave"] = swing
|
|||||||
del POSES["wave_out"]
|
del POSES["wave_out"]
|
||||||
refused(wave.NOT_TAUGHT)
|
refused(wave.NOT_TAUGHT)
|
||||||
POSES["wave_out"] = [-50.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
POSES["wave_out"] = [-50.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
||||||
assert a.sent == []
|
assert arm.cmd.sent == [] # nothing sent for any refusal
|
||||||
|
|
||||||
# ---------- the assistant: a greeting sends no arm command; a wave asked while holding is refused aloud ----------
|
# ---------- the assistant: a greeting sends no arm command; a wave asked while holding is refused aloud ----------
|
||||||
calls = []
|
calls = []
|
||||||
|
|||||||
Reference in New Issue
Block a user