Improve hand reach and arm return; fix hand state after closing empty
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+13
-1
@@ -517,7 +517,7 @@ def head_goal(target, yaw, pitch, look=None, yaw_max=HEAD_YAW[1], pitch_range=HE
|
|||||||
"""A look target and the head's yaw / pitch now -> (yaw, pitch, limited): limited is "yaw" / "pitch" when a
|
"""A look target and the head's yaw / pitch now -> (yaw, pitch, limited): limited is "yaw" / "pitch" when a
|
||||||
number asked for was past the head's range and was cut to it. look: {direction: (yaw, pitch)} for the plain
|
number asked for was past the head's range and was cut to it. look: {direction: (yaw, pitch)} for the plain
|
||||||
words (lumi.LOOK); +yaw = left, +pitch = up."""
|
words (lumi.LOOK); +yaw = left, +pitch = up."""
|
||||||
look = look or {"left": (40, None), "right": (-40, None), "center": (0, 0), "up": (None, 20), "down": (None, -5)}
|
look = look or {"left": (40, None), "right": (-40, None), "center": (0, head_hw.HEAD_REST_PITCH), "up": (None, 20), "down": (None, -5)}
|
||||||
d, _, n = target.partition(" ")
|
d, _, n = target.partition(" ")
|
||||||
if d == "away": # aside from where it looks now (at the person)
|
if d == "away": # aside from where it looks now (at the person)
|
||||||
return (yaw - HEAD_AWAY_DEG if yaw >= 0 else yaw + HEAD_AWAY_DEG), pitch, None
|
return (yaw - HEAD_AWAY_DEG if yaw >= 0 else yaw + HEAD_AWAY_DEG), pitch, None
|
||||||
@@ -976,6 +976,16 @@ def _other_order(t, m, markers):
|
|||||||
intent(p, markers) is None for p in parts)
|
intent(p, markers) is None for p in parts)
|
||||||
|
|
||||||
|
|
||||||
|
ARM_BACK = re.compile( # the arm back to look (fold), said after a reach; the owner's words of 2026-10-23 17:42
|
||||||
|
r"\b(?:take|pull|bring|draw|put|get) (?:your |the |ur )?(?:hand|arm) (?:back|in|down|away)\b|"
|
||||||
|
r"\b(?:put|get|lower) (?:your |the )?(?:hand|arm) down\b|\blower (?:your |the )?(?:hand|arm)\b|"
|
||||||
|
r"^\W*(?:(?:okay|ok|lumi|now|please)\W+)*(?:your |the )?arm (?:back|down|in)(?: home| now| please)*\W*$|"
|
||||||
|
r"\b(?:back )?to (?:your |the )?look (?:pose|position)\b|^\W*(?:your |the )?look (?:pose|position)\W*$|"
|
||||||
|
r"\bfold (?:your |the )?(?:arm|hand)\b|"
|
||||||
|
r"손 ?(?:을 )?(?:좀 )?(?:내려|거둬|접어|넣어|치워)|팔 ?(?:을 )?(?:좀 )?(?:내려|거둬|접어|넣어|치워|원위치)", re.I)
|
||||||
|
ARM_BACK_NOT = re.compile(r"(?<!why )\b(?:don'?t|do not|never|no need to)\b|[가-힣]지 ?마(?:세요|요|라)?(?![가-힣])")
|
||||||
|
|
||||||
|
|
||||||
def intent(text, markers=()):
|
def intent(text, markers=()):
|
||||||
"""(action, target) for clear requests, or None. Backs up the LLM's ACTION line."""
|
"""(action, target) for clear requests, or None. Backs up the LLM's ACTION line."""
|
||||||
held = not_an_order(text, asked=False) # "민수야 이리 와 봐": to a friend; "she said follow me"
|
held = not_an_order(text, asked=False) # "민수야 이리 와 봐": to a friend; "she said follow me"
|
||||||
@@ -990,6 +1000,8 @@ def intent(text, markers=()):
|
|||||||
re.sub(_LEAD, "", CALLING.sub("", t), flags=re.I)) or LATER.search(CALLING.sub("", t)) # "Lumi, is it
|
re.sub(_LEAD, "", CALLING.sub("", t), flags=re.I)) or LATER.search(CALLING.sub("", t)) # "Lumi, is it
|
||||||
# hard to ...?", "Lumi Lumi, are you still following me?"
|
# hard to ...?", "Lumi Lumi, are you still following me?"
|
||||||
visitor = re.search(r"^\W*(?:can|may|could|should|shall) (?:i|we)\b", CALLING.sub("", t)) # "can I come closer?"
|
visitor = re.search(r"^\W*(?:can|may|could|should|shall) (?:i|we)\b", CALLING.sub("", t)) # "can I come closer?"
|
||||||
|
if ARM_BACK.search(t) and not (held or asks or visitor or ARM_BACK_NOT.search(t)):
|
||||||
|
return ("arm", "fold") # "take your hand back", "back to look position": never the base
|
||||||
for action, pat in INTENTS:
|
for action, pat in INTENTS:
|
||||||
m = re.search(pat, t, re.I)
|
m = re.search(pat, t, re.I)
|
||||||
if not m:
|
if not m:
|
||||||
|
|||||||
+87
-27
@@ -120,7 +120,7 @@ OCCLUSION_DROP = 0.3 # m; while the arm moves, a sudden drop in di
|
|||||||
# the person, not the person moving: ignore it
|
# the person, not the person moving: ignore it
|
||||||
CLOSE_BOX = 0.85 # a person is really closer than TOO_CLOSE only if the box is this tall (frame part)
|
CLOSE_BOX = 0.85 # a person is really closer than TOO_CLOSE only if the box is this tall (frame part)
|
||||||
HEAD_SIGN = 1.0 # +image angle -> +head yaw (checked: + = robot's left)
|
HEAD_SIGN = 1.0 # +image angle -> +head yaw (checked: + = robot's left)
|
||||||
LOOK = {"left": (40, None), "right": (-40, None), "center": (0, 0), "up": (None, 20), "down": (None, -5)}
|
LOOK = {"left": (40, None), "right": (-40, None), "center": (0, head.HEAD_REST_PITCH), "up": (None, 20), "down": (None, -5)}
|
||||||
# ^ yaw/pitch in degrees for "look" commands: +yaw = left, +pitch = up (checked on the dashboard 2026-10-12)
|
# ^ yaw/pitch in degrees for "look" commands: +yaw = left, +pitch = up (checked on the dashboard 2026-10-12)
|
||||||
WAKE = re.compile(r"\b(hi|hey|hello|okay|ok|hai|high)?[\s,.!]*(lumi|lumia|loomi|loomy|lumie|lumee|lumy|lummy|lummi|looney|lu-mi|rumi|rumy|roomie)\b"
|
WAKE = re.compile(r"\b(hi|hey|hello|okay|ok|hai|high)?[\s,.!]*(lumi|lumia|loomi|loomy|lumie|lumee|lumy|lummy|lummi|looney|lu-mi|rumi|rumy|roomie)\b"
|
||||||
r"|루미|누미", re.I)
|
r"|루미|누미", re.I)
|
||||||
@@ -172,7 +172,7 @@ def needs_arm(action, target=""):
|
|||||||
|
|
||||||
|
|
||||||
def reach_turn(angle, patrol):
|
def reach_turn(angle, patrol):
|
||||||
"""Base turn (deg, + left) before "reach out to me" to a person at the waist-frame `angle` (None: nobody seen or
|
"""Waist turn (deg, + left) before "reach out to me" to a person at the waist-frame `angle` (None: nobody seen or
|
||||||
heard): 0 within REACH_FRONT_DEG of the front, the angle with Patrol on, else None (they are asked to stand in
|
heard): 0 within REACH_FRONT_DEG of the front, the angle with Patrol on, else None (they are asked to stand in
|
||||||
front: Greeter never turns the base or the waist)."""
|
front: Greeter never turns the base or the waist)."""
|
||||||
if angle is None:
|
if angle is None:
|
||||||
@@ -193,7 +193,8 @@ DONE_TALK = re.compile(r"\b(bye+|goodbye|see you|never ?mind|nothing|that'?s (al
|
|||||||
TALK_RECENT_S = 20.0 # s; someone spoke with Lumi this recently: what they say next is to Lumi too
|
TALK_RECENT_S = 20.0 # s; someone spoke with Lumi this recently: what they say next is to Lumi too
|
||||||
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_KEEP_S = 60.0 # s after a "look left" (and after the last word or command since) the head stays there
|
LOOK_HOLD_S = 35.0 # s; a head direction asked for ("look up / left") is held this long after the last
|
||||||
|
# word, or until the conversation ends or a stop word (estimate)
|
||||||
COMPANY_Q = re.compile(r"\b(cutshion|barista robot|drawing robot|your (maker|makers|company|ceo|price)|(this|the|that|what|which) company|"
|
COMPANY_Q = re.compile(r"\b(cutshion|barista robot|drawing robot|your (maker|makers|company|ceo|price)|(this|the|that|what|which) company|"
|
||||||
r"ceo of (it|this|the company)|founder of (it|this)|mega ?coffee|"
|
r"ceo of (it|this|the company)|founder of (it|this)|mega ?coffee|"
|
||||||
r"sonovictus|omron|borgwarner|bogate|cnt tech|seed round|target market|business model|(your|cutshion'?s?) awards?|how much (do|does) (you|it|this|lumi) cost)\b|"
|
r"sonovictus|omron|borgwarner|bogate|cnt tech|seed round|target market|business model|(your|cutshion'?s?) awards?|how much (do|does) (you|it|this|lumi) cost)\b|"
|
||||||
@@ -319,6 +320,15 @@ REACH_FRONT_DEG = 20.0 # deg; "reach out to me": a person further to
|
|||||||
# (Patrol) or asked to stand in front (Greeter). Estimate: the reach after give
|
# (Patrol) or asked to stand in front (Greeter). Estimate: the reach after give
|
||||||
# moves at most fetch.RECEIVE_REACH_MM sideways
|
# moves at most fetch.RECEIVE_REACH_MM sideways
|
||||||
STAND_IN_FRONT_SAY = ("Please stand in front of me.", "제 앞에 서 주세요.")
|
STAND_IN_FRONT_SAY = ("Please stand in front of me.", "제 앞에 서 주세요.")
|
||||||
|
GREETER_FRONT_SAY = ("I stay in place now, so I can't turn to you. Please stand in front of me.", # Greeter: the person
|
||||||
|
"지금은 제자리에 있어야 해서 돌 수 없어요. 제 앞에 서 주세요.") # is seen to the side
|
||||||
|
REACH_HOLD_S = 30.0 # s the hand stays held out after a reach, then the arm folds back to look (estimate)
|
||||||
|
REACH_DONE = re.compile(r"\b(?:thanks?|thank you|thx|ok(?:ay)?|got it|done|that'?s (?:it|all|enough)|enough|good|great|"
|
||||||
|
r"nice|cool|alright|all right)\b|고마워|고맙|감사|됐어|됐습니다|됐다|좋아|오케이|그만", re.I)
|
||||||
|
HAND_EMPTY_SAID = re.compile( # the person says Lumi's hand is empty: checked again (fetch.check_hand), not just agreed
|
||||||
|
r"\b(?:nothing|not anything) (?:is )?in (?:your|ur) hand\b|\b(?:your|ur) hand(?:'s| is) empty\b|"
|
||||||
|
r"\byou(?:'re| are) not holding (?:anything|something)\b|\byou have nothing in (?:your|ur) hand\b|"
|
||||||
|
r"손에 ?(?:아무것도|아무 ?것도|뭐 ?없|없)|손 ?비었|빈 ?손이", re.I)
|
||||||
STUCK_DRIVE_S = 20.0 # s "running" without moving -> the drive is cancelled and Lumi says so
|
STUCK_DRIVE_S = 20.0 # s "running" without moving -> the drive is cancelled and Lumi says so
|
||||||
MODES_FILE = "/dev/shm/lumi_modes.json" # written by api/server.py: {"greeter", "patrol", "wave", "drive"}
|
MODES_FILE = "/dev/shm/lumi_modes.json" # written by api/server.py: {"greeter", "patrol", "wave", "drive"}
|
||||||
CMD_FILE = "/dev/shm/lumi_cmd.json" # written by api/server.py: {"id", "cmd": go | go_point | cancel | calibrate
|
CMD_FILE = "/dev/shm/lumi_cmd.json" # written by api/server.py: {"id", "cmd": go | go_point | cancel | calibrate
|
||||||
@@ -735,6 +745,7 @@ class Lumi:
|
|||||||
self.closing_pending = None # time of a weak closing word ("okay", "got it"): silence after it ends the talk
|
self.closing_pending = None # time of a weak closing word ("okay", "got it"): silence after it ends the talk
|
||||||
self.lang = "en"
|
self.lang = "en"
|
||||||
self.skill_thread = None # pick / put / move_object running in the background
|
self.skill_thread = None # pick / put / move_object running in the background
|
||||||
|
self.reached_at = 0.0 # time the hand was held out by "give me your hand" (0: not out; reach_done)
|
||||||
self.busy_now = "" # last written to BUSY_FILE ("" = nothing written yet)
|
self.busy_now = "" # last written to BUSY_FILE ("" = nothing written yet)
|
||||||
self.last_song = None # the song sung last ("another song" is a different one)
|
self.last_song = None # the song sung last ("another song" is a different one)
|
||||||
self.mic = mic.get()
|
self.mic = mic.get()
|
||||||
@@ -763,11 +774,17 @@ class Lumi:
|
|||||||
|
|
||||||
# ---------- actions ----------
|
# ---------- actions ----------
|
||||||
def look_held(self):
|
def look_held(self):
|
||||||
"""After a "look left / behind" the head stays there until LOOK_KEEP_S pass with nothing said or asked."""
|
"""After a "look up / left / behind" the head stays there until LOOK_HOLD_S pass with nothing said or asked,
|
||||||
return time.time() - max(getattr(self, "looked_at", 0.0), getattr(self, "last_activity", 0.0)) < LOOK_KEEP_S \
|
the conversation ends (head_rest) or a stop word."""
|
||||||
|
return time.time() - max(getattr(self, "looked_at", 0.0), getattr(self, "last_activity", 0.0)) < LOOK_HOLD_S \
|
||||||
if getattr(self, "looked_at", 0.0) else False
|
if getattr(self, "looked_at", 0.0) else False
|
||||||
|
|
||||||
def turn_head(self, yaw=None, pitch=None):
|
def turn_head(self, yaw=None, pitch=None, force=False):
|
||||||
|
"""Automatic head moves (toward a speaker, a greeting, back to rest) wait while a look is held; force: an
|
||||||
|
order or a task."""
|
||||||
|
if not force and self.look_held():
|
||||||
|
return
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
try:
|
try:
|
||||||
cur = head.status()
|
cur = head.status()
|
||||||
@@ -776,6 +793,11 @@ class Lumi:
|
|||||||
log(f"head error: {e}")
|
log(f"head error: {e}")
|
||||||
threading.Thread(target=run, daemon=True).start()
|
threading.Thread(target=run, daemon=True).start()
|
||||||
|
|
||||||
|
def head_rest(self):
|
||||||
|
"""End a held look and send the head to rest: ahead, looking down."""
|
||||||
|
self.looked_at = 0.0
|
||||||
|
self.turn_head(0, head.HEAD_REST_PITCH)
|
||||||
|
|
||||||
def wave(self, ok=None, quiet=False):
|
def wave(self, ok=None, quiet=False):
|
||||||
"""Wave because someone asked or said "bye bye" in view (never on a greeting): manipulation/wave.py checks the
|
"""Wave because someone asked or said "bye bye" in view (never on a greeting): manipulation/wave.py checks the
|
||||||
arm, the hand, the start pose and the whole path first; a refusal is said unless `quiet`. Not while following,
|
arm, the hand, the start pose and the whole path first; a refusal is said unless `quiet`. Not while following,
|
||||||
@@ -785,7 +807,7 @@ class Lumi:
|
|||||||
log(" waving is switched off (dashboard)")
|
log(" waving is switched off (dashboard)")
|
||||||
return False
|
return False
|
||||||
st = self.fetch_status()
|
st = self.fetch_status()
|
||||||
why = (wave_mod.HOLDING if st == "holding" else
|
why = (wave_mod.HOLDING if st == "holding" and self.held_now() else # a stale "holding": checked again
|
||||||
wave_mod.BUSY if self.skill_busy() or self.mission_running() else
|
wave_mod.BUSY if self.skill_busy() or self.mission_running() else
|
||||||
wave_mod.DRIVING if follow.running() else None)
|
wave_mod.DRIVING if follow.running() else None)
|
||||||
try:
|
try:
|
||||||
@@ -840,6 +862,8 @@ class Lumi:
|
|||||||
|
|
||||||
def act(self, action, target):
|
def act(self, action, target):
|
||||||
log(f"action: {action} {target}")
|
log(f"action: {action} {target}")
|
||||||
|
if action in ARM_TASKS or action == "stop":
|
||||||
|
self.reached_at = 0.0 # another arm job: the reach's auto fold is off
|
||||||
if self.base_off(action, target, say=False): # answer() has said why
|
if self.base_off(action, target, say=False): # answer() has said why
|
||||||
return
|
return
|
||||||
if action in MOVING_ACTIONS and self.mission_running():
|
if action in MOVING_ACTIONS and self.mission_running():
|
||||||
@@ -853,7 +877,9 @@ class Lumi:
|
|||||||
else:
|
else:
|
||||||
track = track or (self.vision.only_person() if self.vision else None)
|
track = track or (self.vision.only_person() if self.vision else None)
|
||||||
angle = track.angle if track else None # no idea where they are: the head stays
|
angle = track.angle if track else None # no idea where they are: the head stays
|
||||||
self.turn_head(None if angle is None else HEAD_SIGN * max(-head.YAW_LIMIT, min(head.YAW_LIMIT, angle)), 10)
|
self.looked_at = time.time() # held like any look
|
||||||
|
self.turn_head(None if angle is None else HEAD_SIGN * max(-head.YAW_LIMIT, min(head.YAW_LIMIT, angle)), 10,
|
||||||
|
force=True)
|
||||||
elif action == "look" and target.split()[0:1] and (target.split()[0] in LOOK or target == "away"):
|
elif action == "look" and target.split()[0:1] and (target.split()[0] in LOOK or target == "away"):
|
||||||
self.look(target)
|
self.look(target)
|
||||||
elif action == "lift":
|
elif action == "lift":
|
||||||
@@ -1110,6 +1136,7 @@ class Lumi:
|
|||||||
if self.patrol:
|
if self.patrol:
|
||||||
self.patrol.pause()
|
self.patrol.pause()
|
||||||
self.patrol = None
|
self.patrol = None
|
||||||
|
self.head_rest() # a stop word ends a held look
|
||||||
self.fetch_say("Okay, I stopped.", "네, 멈췄어요.")
|
self.fetch_say("Okay, I stopped.", "네, 멈췄어요.")
|
||||||
self.keep_listening()
|
self.keep_listening()
|
||||||
|
|
||||||
@@ -1572,7 +1599,7 @@ class Lumi:
|
|||||||
if not (brain_mod.hand_request(text, False, self.brain, self.markers) or
|
if not (brain_mod.hand_request(text, False, self.brain, self.markers) or
|
||||||
brain_mod.hand_request(text, True, self.brain, self.markers)):
|
brain_mod.hand_request(text, True, self.brain, self.markers)):
|
||||||
return False
|
return False
|
||||||
held = self.fetch_status() == "holding" or bool(safe(fetch.check_hand))
|
held = self.held_now()
|
||||||
kind, what = brain_mod.hand_request(text, held, self.brain, self.markers) or (None, None)
|
kind, what = brain_mod.hand_request(text, held, self.brain, self.markers) or (None, None)
|
||||||
if kind is None:
|
if kind is None:
|
||||||
return False
|
return False
|
||||||
@@ -1720,7 +1747,7 @@ class Lumi:
|
|||||||
first, moved in the background); 'open' / 'close': the gripper, never opened on something held. True when
|
first, moved in the background); 'open' / 'close': the gripper, never opened on something held. True when
|
||||||
started, False when not learned, None when refused (the reason is said)."""
|
started, False when not learned, None when refused (the reason is said)."""
|
||||||
from tasks import fetch
|
from tasks import fetch
|
||||||
held = target in ("reach", "open") and (self.fetch_status() == "holding" or bool(safe(fetch.check_hand)))
|
held = target in ("reach", "open") and self.held_now()
|
||||||
if target == "open" and held: # the model's "let go" while holding: it would fall
|
if target == "open" and held: # the model's "let go" while holding: it would fall
|
||||||
log(" open refused: holding something")
|
log(" open refused: holding something")
|
||||||
self.fetch_say(*brain_mod.REFUSE_OPEN)
|
self.fetch_say(*brain_mod.REFUSE_OPEN)
|
||||||
@@ -1731,6 +1758,7 @@ class Lumi:
|
|||||||
return st is not None
|
return st is not None
|
||||||
if target == "reach":
|
if target == "reach":
|
||||||
return self.reach_out(held)
|
return self.reach_out(held)
|
||||||
|
self.reached_at = 0.0 # folding: no auto fold after it
|
||||||
try:
|
try:
|
||||||
holding = self.fetch_status() == "holding"
|
holding = self.fetch_status() == "holding"
|
||||||
seq = arm_route.plan(arm_route.HOME, holding=holding)
|
seq = arm_route.plan(arm_route.HOME, holding=holding)
|
||||||
@@ -1747,8 +1775,9 @@ class Lumi:
|
|||||||
def reach_out(self, held):
|
def reach_out(self, held):
|
||||||
""""Reach out to me", "give me your hand", "손 내밀어": something in the hand = hand it over. Else toward the
|
""""Reach out to me", "give me your hand", "손 내밀어": something in the hand = hand it over. Else toward the
|
||||||
person (the tracked one, else the one the voice came from, else the voice's direction): the head turns to
|
person (the tracked one, else the one the voice came from, else the voice's direction): the head turns to
|
||||||
them; further to the side than REACH_FRONT_DEG the base turns first with Patrol on, Greeter asks them to stand
|
them; further to the side than REACH_FRONT_DEG the waist turns first with Patrol on, Greeter says it stays in
|
||||||
in front (reach_turn); then fetch.reach (give pose along the graph, a short checked move toward their hand).
|
place and asks them to stand in front (reach_turn); then fetch.reach (give pose along the graph, a short checked
|
||||||
|
move toward their hand). The arm folds back on "thanks" / "okay" or after REACH_HOLD_S (reach_done).
|
||||||
True when started, None when refused or handed over (said)."""
|
True when started, None when refused or handed over (said)."""
|
||||||
from tasks import fetch
|
from tasks import fetch
|
||||||
if held:
|
if held:
|
||||||
@@ -1763,11 +1792,11 @@ class Lumi:
|
|||||||
self.vision.near_angle(self.voice_angle) if self.voice_trusted else self.vision.only_person()
|
self.vision.near_angle(self.voice_angle) if self.voice_trusted else self.vision.only_person()
|
||||||
angle = track.angle if track else self.voice_angle if self.voice_trusted else None
|
angle = track.angle if track else self.voice_angle if self.voice_trusted else None
|
||||||
turn = reach_turn(angle, self.modes.patrol)
|
turn = reach_turn(angle, self.modes.patrol)
|
||||||
log(f" reach: person at {'?' if angle is None else f'{angle:+.0f}'} deg, base turn {turn}")
|
log(f" reach: person at {'?' if angle is None else f'{angle:+.0f}'} deg, waist turn {turn}")
|
||||||
if turn is None:
|
if turn is None:
|
||||||
self.fetch_say(*STAND_IN_FRONT_SAY)
|
self.fetch_say(*(STAND_IN_FRONT_SAY if angle is None else GREETER_FRONT_SAY))
|
||||||
return None
|
return None
|
||||||
self.turn_head(0 if turn else HEAD_SIGN * max(-head.YAW_LIMIT, min(head.YAW_LIMIT, angle)))
|
self.turn_head(0 if turn else HEAD_SIGN * max(-head.YAW_LIMIT, min(head.YAW_LIMIT, angle)), force=True)
|
||||||
self.stay()
|
self.stay()
|
||||||
try:
|
try:
|
||||||
fetch.reach(turn, say=self.fetch_say)
|
fetch.reach(turn, say=self.fetch_say)
|
||||||
@@ -1775,8 +1804,29 @@ class Lumi:
|
|||||||
log(f" reach refused: {e}")
|
log(f" reach refused: {e}")
|
||||||
self.fetch_say(e.args[0], e.args[1] if len(e.args) > 1 else "죄송해요, 지금은 할 수 없어요.")
|
self.fetch_say(e.args[0], e.args[1] if len(e.args) > 1 else "죄송해요, 지금은 할 수 없어요.")
|
||||||
return None
|
return None
|
||||||
|
self.reached_at = time.time()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def reach_done(self, text=None):
|
||||||
|
"""The hand is held out (reach_out) and the reach has ended: "thanks" / "okay" / "고마워" / "됐어" (`text`) or
|
||||||
|
REACH_HOLD_S without one folds the arm back to look. True when it folded."""
|
||||||
|
if not getattr(self, "reached_at", 0.0) or self.fetch_status() == "running":
|
||||||
|
return False
|
||||||
|
if text is None and time.time() - self.reached_at < REACH_HOLD_S or text is not None and not REACH_DONE.search(text):
|
||||||
|
return False
|
||||||
|
if self.fetch_status() != "done": # the reach failed or was stopped: the arm stays as it is
|
||||||
|
self.reached_at = 0.0
|
||||||
|
return False
|
||||||
|
log(f" reach over ({'said ' + repr(text) if text else 'timeout'}): the arm back to look")
|
||||||
|
return bool(self.arm_pose("fold"))
|
||||||
|
|
||||||
|
def held_now(self):
|
||||||
|
"""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)."""
|
||||||
|
from tasks import fetch
|
||||||
|
h = safe(fetch.check_hand)
|
||||||
|
return self.fetch_status() == "holding" if h is None else bool(h)
|
||||||
|
|
||||||
# ---------- dashboard commands, trips ----------
|
# ---------- dashboard commands, trips ----------
|
||||||
def poll_commands(self):
|
def poll_commands(self):
|
||||||
try:
|
try:
|
||||||
@@ -2336,8 +2386,9 @@ class Lumi:
|
|||||||
mouth.say(bye, abort=self.speak_abort)
|
mouth.say(bye, abort=self.speak_abort)
|
||||||
self.current, self.voice_until, self.closing_pending = None, 0.0, None
|
self.current, self.voice_until, self.closing_pending = None, 0.0, None
|
||||||
self.brain.reset()
|
self.brain.reset()
|
||||||
if not self.look_held(): # "look behind": the head stays there a while (LOOK_KEEP_S)
|
if not quiet: # a goodbye ends a held look; silence keeps it (LOOK_HOLD_S)
|
||||||
self.turn_head(0, 0)
|
self.looked_at = 0.0
|
||||||
|
self.turn_head(0, head.HEAD_REST_PITCH) # waits while a look is held
|
||||||
if self.traveling():
|
if self.traveling():
|
||||||
log(" conversation over - driving on")
|
log(" conversation over - driving on")
|
||||||
self.patrol.wait_until = time.time() + 0.5
|
self.patrol.wait_until = time.time() + 0.5
|
||||||
@@ -2390,7 +2441,7 @@ class Lumi:
|
|||||||
mouth.say("Okay, I'll be quiet." if en else "네, 조용히 할게요.")
|
mouth.say("Okay, I'll be quiet." if en else "네, 조용히 할게요.")
|
||||||
self.quiet_until = time.time() + QUIET_S
|
self.quiet_until = time.time() + QUIET_S
|
||||||
self.current, self.voice_until = None, 0.0
|
self.current, self.voice_until = None, 0.0
|
||||||
self.turn_head(0, 0)
|
self.head_rest()
|
||||||
return True
|
return True
|
||||||
if action in ("pick", "put", "move_object"):
|
if action in ("pick", "put", "move_object"):
|
||||||
self.object_task(action, target)
|
self.object_task(action, target)
|
||||||
@@ -2513,9 +2564,8 @@ class Lumi:
|
|||||||
self.keep_listening()
|
self.keep_listening()
|
||||||
return
|
return
|
||||||
from tasks import fetch # the way it goes: route(), as the dashboard's Command box
|
from tasks import fetch # the way it goes: route(), as the dashboard's Command box
|
||||||
kind, data = route(text, self.markers, self.brain, lambda: self.fetch_status() == "holding" or
|
kind, data = route(text, self.markers, self.brain, self.held_now,
|
||||||
bool(safe(fetch.check_hand)), seen=lambda x: seeing.answer(x, self.lang, slow_line=mouth.say),
|
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())
|
||||||
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() # "stop", "stop, where are you going?": stop first, always
|
||||||
return
|
return
|
||||||
@@ -2531,6 +2581,14 @@ class Lumi:
|
|||||||
mouth.say(data)
|
mouth.say(data)
|
||||||
self.keep_listening()
|
self.keep_listening()
|
||||||
return
|
return
|
||||||
|
if HAND_EMPTY_SAID.search(text) and self.fetch_status() != "running": # "there is nothing in your hand"
|
||||||
|
held = self.held_now() # checked again (AI_1, the torso camera), never just agreed
|
||||||
|
log(f" told my hand is empty: checked, holding {held}")
|
||||||
|
self.brain.history.append((text, "ACTION: none -"))
|
||||||
|
self.fetch_say(*(("I still feel something in my hand.", "아직 손에 뭔가 있는 것 같아요.") if held else
|
||||||
|
("You're right, my hand is empty.", "맞아요, 손이 비어 있어요.")))
|
||||||
|
self.keep_listening()
|
||||||
|
return
|
||||||
if kind == "status": # what am I doing / where am I going
|
if kind == "status": # what am I doing / where am I going
|
||||||
en, ko = self.now_doing()
|
en, ko = self.now_doing()
|
||||||
log(f" status: {en}")
|
log(f" status: {en}")
|
||||||
@@ -2543,6 +2601,8 @@ class Lumi:
|
|||||||
return
|
return
|
||||||
if self.fetch_voice(text): # before the closing words: "thank you" while giving
|
if self.fetch_voice(text): # before the closing words: "thank you" while giving
|
||||||
return
|
return
|
||||||
|
if not (kind == "quick" and data and data[0] == "arm"):
|
||||||
|
self.reach_done(text) # "okay, thanks" with the hand held out: the arm back to look
|
||||||
place = consent_place(text, self.brain, self.markers)
|
place = consent_place(text, self.brain, self.markers)
|
||||||
if place: # "p3로 갈 수 있어요?" ... "그럼 가 보세요."
|
if place: # "p3로 갈 수 있어요?" ... "그럼 가 보세요."
|
||||||
self.go_offered(place)
|
self.go_offered(place)
|
||||||
@@ -2623,12 +2683,12 @@ class Lumi:
|
|||||||
log(f" quiet for {QUIET_S / 60:.0f} min (no greetings; \"Hi Lumi\" still works)")
|
log(f" quiet for {QUIET_S / 60:.0f} min (no greetings; \"Hi Lumi\" still works)")
|
||||||
self.quiet_until = time.time() + QUIET_S
|
self.quiet_until = time.time() + QUIET_S
|
||||||
self.current, self.voice_until = None, 0.0
|
self.current, self.voice_until = None, 0.0
|
||||||
self.turn_head(0, 0)
|
self.head_rest()
|
||||||
return
|
return
|
||||||
if head_["action"] in ("receive", "give", "place"): # the model read a hand request the rules missed
|
if head_["action"] in ("receive", "give", "place"): # the model read a hand request the rules missed
|
||||||
gen.close()
|
gen.close()
|
||||||
from tasks import fetch
|
from tasks import fetch
|
||||||
held = self.fetch_status() == "holding" or bool(safe(fetch.check_hand))
|
held = self.held_now()
|
||||||
self.brain.history.append((text, f"ACTION: {head_['action']} -"))
|
self.brain.history.append((text, f"ACTION: {head_['action']} -"))
|
||||||
if head_["action"] == "receive":
|
if head_["action"] == "receive":
|
||||||
self.receive_from_hand(brain_mod._mentions(text, self.markers).get("object"), held)
|
self.receive_from_hand(brain_mod._mentions(text, self.markers).get("object"), held)
|
||||||
@@ -2942,6 +3002,7 @@ class Lumi:
|
|||||||
"""One pass of the camera behaviour (see the module docstring)."""
|
"""One pass of the camera behaviour (see the module docstring)."""
|
||||||
self.modes.refresh()
|
self.modes.refresh()
|
||||||
self.poll_commands()
|
self.poll_commands()
|
||||||
|
self.reach_done() # the hand held out REACH_HOLD_S: back to look
|
||||||
self.publish_busy(self.doing())
|
self.publish_busy(self.doing())
|
||||||
if self.patrol and self.patrol.mode == "done" and not self.a.patrol:
|
if self.patrol and self.patrol.mode == "done" and not self.a.patrol:
|
||||||
self.patrol = None # a dashboard / voice trip has arrived
|
self.patrol = None # a dashboard / voice trip has arrived
|
||||||
@@ -2979,7 +3040,7 @@ class Lumi:
|
|||||||
# often still there, out of the frame (beside the arm): keep listening without the wake word
|
# often still there, out of the frame (beside the arm): keep listening without the wake word
|
||||||
# for a while, like a conversation started by voice. After "look left" the head stays there
|
# for a while, like a conversation started by voice. After "look left" the head stays there
|
||||||
if not self.look_held():
|
if not self.look_held():
|
||||||
self.turn_head(0, 0)
|
self.turn_head(0, head.HEAD_REST_PITCH)
|
||||||
self.voice_until = time.time() + VOICE_SESSION_S
|
self.voice_until = time.time() + VOICE_SESSION_S
|
||||||
self.last_activity, self.prompts = time.time(), 0
|
self.last_activity, self.prompts = time.time(), 0
|
||||||
return
|
return
|
||||||
@@ -2998,9 +3059,8 @@ class Lumi:
|
|||||||
self.voice_until = max(self.voice_until, time.time() + VOICE_SESSION_S)
|
self.voice_until = max(self.voice_until, time.time() + VOICE_SESSION_S)
|
||||||
return
|
return
|
||||||
if getattr(self, "looked_at", 0.0) and not self.look_held():
|
if getattr(self, "looked_at", 0.0) and not self.look_held():
|
||||||
log(f" nothing said for {LOOK_KEEP_S:.0f} s after a look: head ahead")
|
log(f" nothing said for {LOOK_HOLD_S:.0f} s after a look: head to rest")
|
||||||
self.looked_at = 0.0
|
self.head_rest()
|
||||||
self.turn_head(0, 0)
|
|
||||||
if self.voice_until:
|
if self.voice_until:
|
||||||
log("voice conversation over (silence): the wake word or a wave again")
|
log("voice conversation over (silence): the wake word or a wave again")
|
||||||
self.end_conversation(None, quiet=True) # Lumi never speaks unasked: no goodbye into a silence
|
self.end_conversation(None, quiet=True) # Lumi never speaks unasked: no goodbye into a silence
|
||||||
|
|||||||
+2
-1
@@ -108,7 +108,8 @@ Every value here is a constant at the top of its file, with a comment on what it
|
|||||||
| `assistant/steps.py` | `WAIT_ORDER_S` | 5 min | "do what they tell you": no instruction by then, the mission goes on with its rest |
|
| `assistant/steps.py` | `WAIT_ORDER_S` | 5 min | "do what they tell you": no instruction by then, the mission goes on with its rest |
|
||||||
| `tasks/fetch.py` | `RECEIVE_REACH_MM`, `RECEIVE_SHORT_MM`, `RECEIVE_MIN_MM` | 150, 100, 20 mm | "Take this from my hand" and "reach out to me": the hand moves at most this far from `give` towards the thing in the hand (or their hand), stops this far before it, leaves out a shorter move. Estimates |
|
| `tasks/fetch.py` | `RECEIVE_REACH_MM`, `RECEIVE_SHORT_MM`, `RECEIVE_MIN_MM` | 150, 100, 20 mm | "Take this from my hand" and "reach out to me": the hand moves at most this far from `give` towards the thing in the hand (or their hand), stops this far before it, leaves out a shorter move. Estimates |
|
||||||
| `tasks/fetch.py` | `REACH_BODY_MM` | 300 mm | "Reach out to me" with no hand of theirs seen: the hand stops this far before the person's body. Estimate |
|
| `tasks/fetch.py` | `REACH_BODY_MM` | 300 mm | "Reach out to me" with no hand of theirs seen: the hand stops this far before the person's body. Estimate |
|
||||||
| `assistant/lumi.py` | `REACH_FRONT_DEG` | 20° | "Reach out to me": a person further to the side is turned to first (Patrol) or asked to stand in front (Greeter). Estimate |
|
| `assistant/lumi.py` | `REACH_FRONT_DEG` | 20° | "Reach out to me": a person further to the side is turned to first with the waist (Patrol) or asked to stand in front (Greeter). Estimate |
|
||||||
|
| `assistant/lumi.py` | `REACH_HOLD_S` | 30 s | The hand stays held out this long after a reach without "thanks" / "okay", then the arm folds back to `look`. Estimate |
|
||||||
| `tasks/fetch.py` | `POINT_STEPS_MM` | 0, ±50, ±100 mm | "Put it here" with pointing: spot grid around the pointed point |
|
| `tasks/fetch.py` | `POINT_STEPS_MM` | 0, ±50, ±100 mm | "Put it here" with pointing: spot grid around the pointed point |
|
||||||
| `tasks/fetch.py` | `RECEIVE_DI_S` | 0.5 s | `receive`: the finger sensor (DI_1) must see something this long before Lumi asks the person to let go (the hand closes on their "okay") |
|
| `tasks/fetch.py` | `RECEIVE_DI_S` | 0.5 s | `receive`: the finger sensor (DI_1) must see something this long before Lumi asks the person to let go (the hand closes on their "okay") |
|
||||||
| `tasks/fetch.py` | `MOVE_SEGMENT_M` | 0.25 m | A mission `move` is driven in pieces this long; the way of the base and the arm is checked again before each (also what the base rolls on meanwhile, `JOY_HOLD_S` 0.5 s); the base does not stop between pieces |
|
| `tasks/fetch.py` | `MOVE_SEGMENT_M` | 0.25 m | A mission `move` is driven in pieces this long; the way of the base and the arm is checked again before each (also what the base rolls on meanwhile, `JOY_HOLD_S` 0.5 s); the base does not stop between pieces |
|
||||||
|
|||||||
+17
-10
@@ -115,7 +115,7 @@ HEAD_LOW_PITCH = -5.0 # head pitch for those checks and the search: its l
|
|||||||
HEAD_READS = 4 # head camera frames read per view (10 a second) ...
|
HEAD_READS = 4 # head camera frames read per view (10 a second) ...
|
||||||
HEAD_SAME_MM = 120.0 # ... an object counts when seen at least twice within this distance
|
HEAD_SAME_MM = 120.0 # ... an object counts when seen at least twice within this distance
|
||||||
WAIST_VEL = 20 # % of the waist's speed: the arm sweeps sideways
|
WAIST_VEL = 20 # % of the waist's speed: the arm sweeps sideways
|
||||||
HEAD_AHEAD = (0.0, 0.0) # head (yaw, pitch) deg before a drive to a place and after every task: looking ahead
|
HEAD_AHEAD = (0.0, head.HEAD_REST_PITCH) # head (yaw, pitch) deg before a drive to a place and after every task: ahead, at rest
|
||||||
# (search turns and short moves keep the head where the search turned it)
|
# (search turns and short moves keep the head where the search turned it)
|
||||||
OFFSET_TURN_DEG = 15.0 # a move that turned the base at least this much tells where the arm base is (arm_offset)
|
OFFSET_TURN_DEG = 15.0 # a move that turned the base at least this much tells where the arm base is (arm_offset)
|
||||||
WIDTH_NEAR_MM = 250.0 # mm from PICK_ZONE_CENTRE; a width measured further away is not trusted (the same tumbler:
|
WIDTH_NEAR_MM = 250.0 # mm from PICK_ZONE_CENTRE; a width measured further away is not trusted (the same tumbler:
|
||||||
@@ -1875,15 +1875,20 @@ def _busy():
|
|||||||
def _in_hand():
|
def _in_hand():
|
||||||
"""Is something in the hand, whatever the state file says? The torso depth camera first (skills.hand_sees: it
|
"""Is something in the hand, whatever the state file says? The torso depth camera first (skills.hand_sees: it
|
||||||
sees the place between the fingers); when it can't tell, the gripper's AI_1. AI_1 alone was wrong once: a cup
|
sees the place between the fingers); when it can't tell, the gripper's AI_1. AI_1 alone was wrong once: a cup
|
||||||
pulled out of the closed fingers left it reading "open" (2026-10-16)."""
|
pulled out of the closed fingers left it reading "open" (2026-10-16). Fingers fully shut (AI_1 above
|
||||||
|
gripper.EMPTY_AI) hold nothing, whatever the camera sees: with the arm held out it saw the person's hand there and
|
||||||
|
"closed on nothing" became "holding" (2026-10-23 17:40)."""
|
||||||
|
try:
|
||||||
|
g = gripper.state()
|
||||||
|
ai = bool(g["holding"])
|
||||||
|
if g.get("ai", [0.0])[0] > gripper.EMPTY_AI:
|
||||||
|
return False
|
||||||
|
except (ConnectionError, OSError, KeyError):
|
||||||
|
ai = None
|
||||||
try:
|
try:
|
||||||
seen = skills.hand_sees()
|
seen = skills.hand_sees()
|
||||||
except (skills.SkillError, ConnectionError, OSError, KeyError):
|
except (skills.SkillError, ConnectionError, OSError, KeyError):
|
||||||
seen = "unknown"
|
seen = "unknown"
|
||||||
try:
|
|
||||||
ai = bool(gripper.state()["holding"])
|
|
||||||
except (ConnectionError, OSError, KeyError):
|
|
||||||
ai = None
|
|
||||||
if seen == "unknown":
|
if seen == "unknown":
|
||||||
return bool(ai)
|
return bool(ai)
|
||||||
if ai is not None and ai != (seen == "object"):
|
if ai is not None and ai != (seen == "object"):
|
||||||
@@ -2411,8 +2416,8 @@ def _person_point():
|
|||||||
|
|
||||||
def reach(angle=0.0, say=None):
|
def reach(angle=0.0, say=None):
|
||||||
"""Hold the hand out to the person ("reach out to me", "손 내밀어"): first, when `angle` (deg, + left, waist
|
"""Hold the hand out to the person ("reach out to me", "손 내밀어"): first, when `angle` (deg, + left, waist
|
||||||
frame: the person tracker's) is not 0, a base turn on the spot to face them (_turn: Patrol only, the waist to the
|
frame: the person tracker's) is not 0, the waist turns to face them (_waist_to: Patrol only, its arm sweep
|
||||||
front, its arm sweep checked), then the arm along the pose graph to give
|
checked; past the waist's limits they are asked to stand in front), then the arm along the pose graph to give
|
||||||
(arm_route, every move checked), then at most RECEIVE_REACH_MM straight towards their hand or body
|
(arm_route, every move checked), then at most RECEIVE_REACH_MM straight towards their hand or body
|
||||||
(_person_point, _reach_to_hand). The arm stays out; "fold" brings it back to look."""
|
(_person_point, _reach_to_hand). The arm stays out; "fold" brings it back to look."""
|
||||||
if "give" not in motion.poses():
|
if "give" not in motion.poses():
|
||||||
@@ -2426,8 +2431,10 @@ def reach(angle=0.0, say=None):
|
|||||||
|
|
||||||
def run():
|
def run():
|
||||||
try:
|
try:
|
||||||
if angle and not _turn(angle + _waist_turn(), why="to the person"):
|
if angle: # the waist, not the base: the person stays where they are
|
||||||
raise FetchError(*TURN_TO_PERSON)
|
lo, hi = head.AXIS_LIMITS[1]
|
||||||
|
if not lo <= head.status()[1] + angle <= hi or not _waist_to(angle + _waist_turn()):
|
||||||
|
raise FetchError(*TURN_TO_PERSON)
|
||||||
_pose("give")
|
_pose("give")
|
||||||
_reach_to_hand(*_person_point())
|
_reach_to_hand(*_person_point())
|
||||||
_set(status="done", step="")
|
_set(status="done", step="")
|
||||||
|
|||||||
+10
-7
@@ -189,7 +189,7 @@ where = {"how": "unseen"} # what
|
|||||||
skills.locate = lambda xy, top, table, width, radius=None: \
|
skills.locate = lambda xy, top, table, width, radius=None: \
|
||||||
(where["how"], {"x": xy[0], "y": xy[1], "top_mm": top, "width_mm": width} if where["how"] == "here" else None)
|
(where["how"], {"x": xy[0], "y": xy[1], "top_mm": top, "width_mm": width} if where["how"] == "here" else None)
|
||||||
body = {"lift": 75.0}
|
body = {"lift": 75.0}
|
||||||
fetch.head.status = lambda: [body["lift"], -15.0, 0.0, 0.0]
|
fetch.head.status = lambda: [body["lift"], -15.0, *fetch.HEAD_AHEAD] # the head at rest
|
||||||
fetch.head.moveto = lambda pos, **kw: (calls.append(("lift", pos[0])), body.update(lift=pos[0]))
|
fetch.head.moveto = lambda pos, **kw: (calls.append(("lift", pos[0])), body.update(lift=pos[0]))
|
||||||
skills.arm.cmd = lambda *a, **kw: (_ for _ in ()).throw(AssertionError(f"real arm command in a test: {a}"))
|
skills.arm.cmd = lambda *a, **kw: (_ for _ in ()).throw(AssertionError(f"real arm command in a test: {a}"))
|
||||||
skills.ik_chain = lambda wp, j: [[n, p, [0] * 6, None] for n, p in wp]
|
skills.ik_chain = lambda wp, j: [[n, p, [0] * 6, None] for n, p in wp]
|
||||||
@@ -700,7 +700,7 @@ fetch.CALIB_FILE.write_text(json.dumps({"arm_yaw_in_base_deg": -86.2, "waist_deg
|
|||||||
waist = {"deg": -15.0}
|
waist = {"deg": -15.0}
|
||||||
real_status, real_move = fetch.head.status, fetch.head.moveto
|
real_status, real_move = fetch.head.status, fetch.head.moveto
|
||||||
real_blocked, real_find_any = fetch._sweep_blocked, fetch._find_any
|
real_blocked, real_find_any = fetch._sweep_blocked, fetch._find_any
|
||||||
fetch.head.status = lambda: [75.0, waist["deg"], 0.0, 0.0]
|
fetch.head.status = lambda: [75.0, waist["deg"], *fetch.HEAD_AHEAD]
|
||||||
fetch.head.moveto = lambda pos, **kw: waist.update(deg=pos[1])
|
fetch.head.moveto = lambda pos, **kw: waist.update(deg=pos[1])
|
||||||
fetch._sweep_blocked = lambda deg, what: round(fetch._waist_turn() + deg) in blocked # by where it would end
|
fetch._sweep_blocked = lambda deg, what: round(fetch._waist_turn() + deg) in blocked # by where it would end
|
||||||
waist["deg"], blocked = 45.0, {0}
|
waist["deg"], blocked = 45.0, {0}
|
||||||
@@ -922,8 +922,8 @@ ahead = lambda mm, side=0.0: [g0[0] + mm, g0[1] + side, g0[2]]
|
|||||||
scene["person_in_front"] = {"position_mm": ahead(900.0), "hands": {"left": {"position_mm": ahead(600.0, 100.0),
|
scene["person_in_front"] = {"position_mm": ahead(900.0), "hands": {"left": {"position_mm": ahead(600.0, 100.0),
|
||||||
"distance_m": 1.1}, "right": {"position_mm": ahead(400.0), "distance_m": 0.9}}}
|
"distance_m": 1.1}, "right": {"position_mm": ahead(400.0), "distance_m": 0.9}}}
|
||||||
turns = []
|
turns = []
|
||||||
real_turn = fetch._turn
|
real_waist_to = fetch._waist_to
|
||||||
fetch._turn = lambda deg, holding=False, why="": turns.append(deg) or deg < 90
|
fetch._waist_to = lambda deg: turns.append(deg) or deg < 90
|
||||||
|
|
||||||
|
|
||||||
def reached(angle=0.0):
|
def reached(angle=0.0):
|
||||||
@@ -947,13 +947,16 @@ assert st["status"] == "done" and poses()[-1] == "give" and not moves, (st, move
|
|||||||
scene["person_in_front"] = None # nobody seen: the hand at give
|
scene["person_in_front"] = None # nobody seen: the hand at give
|
||||||
st, moves = reached()
|
st, moves = reached()
|
||||||
assert st["status"] == "done" and poses()[-1] == "give" and not moves, (st, moves)
|
assert st["status"] == "done" and poses()[-1] == "give" and not moves, (st, moves)
|
||||||
st, moves = reached(40.0) # to the side (Patrol): the base turns first, by the
|
st, moves = reached(40.0) # to the side (Patrol): the waist turns first, by the
|
||||||
assert turns == [40.0 + fetch._waist_turn()] and poses()[-1] == "give", (turns, poses()) # waist's offset too
|
assert turns == [40.0 + fetch._waist_turn()] and poses()[-1] == "give", (turns, poses()) # waist's offset too
|
||||||
turns.clear()
|
turns.clear()
|
||||||
said.clear()
|
said.clear()
|
||||||
st, moves = reached(120.0) # the turn refused (charger, sweep): the arm stays
|
st, moves = reached(120.0) # the waist turn refused (sweep): the arm stays
|
||||||
assert st["status"] == "failed" and not poses() and said[-1] == fetch.TURN_TO_PERSON[0], (st, said)
|
assert st["status"] == "failed" and not poses() and said[-1] == fetch.TURN_TO_PERSON[0], (st, said)
|
||||||
fetch._turn = real_turn
|
turns.clear()
|
||||||
|
st, moves = reached(160.0) # past the waist's limit (-15 + 160 > 140): stand in front
|
||||||
|
assert st["status"] == "failed" and not turns and not poses() and said[-1] == fetch.TURN_TO_PERSON[0], (st, turns)
|
||||||
|
fetch._waist_to = real_waist_to
|
||||||
fetch._line_rows, fetch._scene = real_line_rows, real_scene
|
fetch._line_rows, fetch._scene = real_line_rows, real_scene
|
||||||
hand["front"] = False
|
hand["front"] = False
|
||||||
# the cup is in the hand but nobody says okay: the hand never closes (their fingers may be in it)
|
# the cup is in the hand but nobody says okay: the hand never closes (their fingers may be in it)
|
||||||
|
|||||||
+12
-2
@@ -25,7 +25,14 @@ PUT_BACK = ["put it back", "put it back where you found it", "return it to where
|
|||||||
"put back 해 줘", "제자리에 놔 줘", "제자리에 갖다 놓으시게", "원래 자리에 놓으십시오", "원위치에 놔 줘"]
|
"put back 해 줘", "제자리에 놔 줘", "제자리에 갖다 놓으시게", "원래 자리에 놓으십시오", "원위치에 놔 줘"]
|
||||||
REACH = ["extend your arm toward me", "hold your hand out", "reach out", "reach for my hand", "arm forward please",
|
REACH = ["extend your arm toward me", "hold your hand out", "reach out", "reach for my hand", "arm forward please",
|
||||||
"팔 뻗어 줘", "손 내밀어 줘", "손 쭉 내밀어 봐", "루미야 arm 뻗어 줘", "나한테 reach 해 볼래?"]
|
"팔 뻗어 줘", "손 내밀어 줘", "손 쭉 내밀어 봐", "루미야 arm 뻗어 줘", "나한테 reach 해 볼래?"]
|
||||||
FOLD = ["fold your arm", "tuck your arm in", "arm back home", "go back to your look pose", "팔 접어", "팔 원래대로 해 줘"]
|
FOLD = ["fold your arm", "tuck your arm in", "arm back home", "go back to your look pose", "팔 접어", "팔 원래대로 해 줘",
|
||||||
|
"take your hand back", "put your arm down", "arm back", "Lumi, arm back please", "back to look position",
|
||||||
|
"go back to look position", "go back to look pose", "Your look position.", "return to the look position",
|
||||||
|
"pull your hand back", "bring your arm back", "put your hand down", "lower your arm", "can you put your arm down?",
|
||||||
|
"손 내려", "손 내려 줘", "손 좀 내려 주세요", "손 거둬", "팔 거둬", "팔 내려 주실래요?", "팔 원위치", "루미야 팔 접어 줘",
|
||||||
|
"okay, 팔 내려", "take your arm back 해 줘"]
|
||||||
|
NOT_FOLD = ["don't take your hand back", "팔 내리지 마", "why did you put your arm down?", "hand back", "give it back",
|
||||||
|
"give me your hand", "손 내밀어"]
|
||||||
NOT_GIVE = ["don't give it to me yet", "give it to me after the talk", "when my mom comes, give it to her", "give me a break",
|
NOT_GIVE = ["don't give it to me yet", "give it to me after the talk", "when my mom comes, give it to her", "give me a break",
|
||||||
"give it a try", "give up", "she gave me that cup this morning", "I gave it to the guy at the booth",
|
"give it a try", "give up", "she gave me that cup this morning", "I gave it to the guy at the booth",
|
||||||
"can you give me directions to the subway?", "who will you give that to?", "give it to me, cancel",
|
"can you give me directions to the subway?", "who will you give that to?", "give it to me, cancel",
|
||||||
@@ -51,6 +58,9 @@ def main():
|
|||||||
for words, want in [(w, "reach") for w in REACH] + [(w, "fold") for w in FOLD]:
|
for words, want in [(w, "reach") for w in REACH] + [(w, "fold") for w in FOLD]:
|
||||||
if brain.intent(words, MARKERS) != ("arm", want):
|
if brain.intent(words, MARKERS) != ("arm", want):
|
||||||
bad.append((words, want, brain.intent(words, MARKERS)))
|
bad.append((words, want, brain.intent(words, MARKERS)))
|
||||||
|
for words in NOT_FOLD:
|
||||||
|
if brain.intent(words, MARKERS) == ("arm", "fold"):
|
||||||
|
bad.append((words, "not fold", brain.intent(words, MARKERS)))
|
||||||
for words in NOT_GIVE:
|
for words in NOT_GIVE:
|
||||||
if brain.held_give(words, MARKERS) or brain.held_place(words, MARKERS):
|
if brain.held_give(words, MARKERS) or brain.held_place(words, MARKERS):
|
||||||
bad.append((words, "no hand", brain.hand_request(words, True, None, MARKERS)))
|
bad.append((words, "no hand", brain.hand_request(words, True, None, MARKERS)))
|
||||||
@@ -65,7 +75,7 @@ def main():
|
|||||||
bad.append((words, "look center", brain.intent(words, MARKERS)))
|
bad.append((words, "look center", brain.intent(words, MARKERS)))
|
||||||
assert not bad, "\n".join(f"{t!r}: want {w}, got {g}" for t, w, g in bad)
|
assert not bad, "\n".join(f"{t!r}: want {w}, got {g}" for t, w, g in bad)
|
||||||
n = len(CALLS) * len(TAILS) * len(GIVE_EN + GIVE_KO) + len(CALLS) * (len(PUT_DOWN) + len(PUT_BACK)) + \
|
n = len(CALLS) * len(TAILS) * len(GIVE_EN + GIVE_KO) + len(CALLS) * (len(PUT_DOWN) + len(PUT_BACK)) + \
|
||||||
len(REACH) + len(FOLD) + len(NOT_GIVE) + 6
|
len(REACH) + len(FOLD) + len(NOT_FOLD) + len(NOT_GIVE) + 6
|
||||||
print(f"held hand ok ({n} cases)")
|
print(f"held hand ok ({n} cases)")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ assert brain.head_goal("right 200", 0, 0) == (-180.0, 0, "yaw")
|
|||||||
assert brain.head_goal("up 50", 0, 0) == (0, 35.0, "pitch")
|
assert brain.head_goal("up 50", 0, 0) == (0, 35.0, "pitch")
|
||||||
assert brain.head_goal("left small", 10, 0) == (25.0, 0, None)
|
assert brain.head_goal("left small", 10, 0) == (25.0, 0, None)
|
||||||
assert brain.head_goal("down", 20, 10) == (20, -5, None)
|
assert brain.head_goal("down", 20, 10) == (20, -5, None)
|
||||||
|
assert brain.head_goal("center", 30, 20) == (0, brain.head_hw.HEAD_REST_PITCH, None) == (0, -5.0, None) # rest: looking down
|
||||||
assert brain.head_goal("left", 40, 0) == (55.0, 0, None) and brain.head_goal("right", -40, 0) == (-55.0, 0, None) # "look left"
|
assert brain.head_goal("left", 40, 0) == (55.0, 0, None) and brain.head_goal("right", -40, 0) == (-55.0, 0, None) # "look left"
|
||||||
assert brain.head_goal("up", 0, 20) == (0, 30.0, None) and brain.head_goal("left", -40, 0) == (40, 0, None) # again: further
|
assert brain.head_goal("up", 0, 20) == (0, 30.0, None) and brain.head_goal("left", -40, 0) == (40, 0, None) # again: further
|
||||||
for said, want in {"Look at the left side.": "left", "Look at the right side.": "right", "Lumi, look at the left side.": "left",
|
for said, want in {"Look at the left side.": "left", "Look at the right side.": "right", "Lumi, look at the left side.": "left",
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
"""The live sequence of 2026-10-23 15:21-15:23, replayed with fakes: "give me a hand" / handshake words with an empty
|
"""The live sequence of 2026-10-23 15:21-15:23, replayed with fakes: "give me a hand" / handshake words with an empty
|
||||||
hand are arm reach (the rules, not the LLM's "I can't shake hands"), and a reach whose body move hangs ends at once on
|
hand are arm reach (the rules, not the LLM's "I can't shake hands"), and a reach whose body move hangs ends at once on
|
||||||
STOP, so the next "give me your hand" starts instead of "I'm busy with another task". No robot.
|
STOP, so the next "give me your hand" starts instead of "I'm busy with another task". And 2026-10-23 17:40-17:43:
|
||||||
|
"close your hand" on nothing is not holding (the camera saw the person's hand by the held-out arm), "there is nothing
|
||||||
|
in your hand" checks the hand again, and "okay, thank you" / a timeout folds the held-out arm. No robot.
|
||||||
|
|
||||||
.venv/bin/python tests/test_reach_live.py
|
.venv/bin/python tests/test_reach_live.py
|
||||||
"""
|
"""
|
||||||
@@ -57,4 +59,42 @@ hung.set() # the body answers again
|
|||||||
fetch.reach(0.0) # the next "give me your hand": starts, not "busy"
|
fetch.reach(0.0) # the next "give me your hand": starts, not "busy"
|
||||||
fetch._thread.join(2)
|
fetch._thread.join(2)
|
||||||
assert moved == ["give", "hand"] and fetch.state()["status"] == "done", (moved, fetch.state()["status"])
|
assert moved == ["give", "hand"] and fetch.state()["status"] == "done", (moved, fetch.state()["status"])
|
||||||
print(f"reach live ok ({len(REACH) + len(NOT_REACH)} wordings, stop during a hung body move)")
|
# ---------- closed on nothing is empty, whatever the camera sees ----------
|
||||||
|
grip = {"ai": [4153.0, 489.0], "holding": False} # the live close of 17:40:39
|
||||||
|
fetch.gripper.state = lambda: dict(grip)
|
||||||
|
fetch.skills.hand_sees = lambda: "object" # the person's hand by the held-out fingers
|
||||||
|
assert fetch._in_hand() is False
|
||||||
|
fetch._set(status="done", holding=True) # the stale "holding" of 17:41
|
||||||
|
assert fetch.check_hand() is False and not fetch.state()["holding"]
|
||||||
|
grip.update(ai=[3500.0, 489.0], holding=True) # closed on a cup: held
|
||||||
|
fetch.skills.hand_sees = lambda: "unknown"
|
||||||
|
assert fetch._in_hand() is True
|
||||||
|
|
||||||
|
# ---------- the person says the hand is empty; "okay, thank you" / a timeout folds a held-out arm ----------
|
||||||
|
from assistant import lumi
|
||||||
|
for t in ["There is nothing in your hand.", "your hand is empty", "you're not holding anything", "손에 아무것도 없어",
|
||||||
|
"손에 아무것도 없잖아요", "손 비었어"]:
|
||||||
|
assert lumi.HAND_EMPTY_SAID.search(t), t
|
||||||
|
for t in ["is there anything in your hand?", "what's in your hand", "give me your hand"]:
|
||||||
|
assert not lumi.HAND_EMPTY_SAID.search(t), t
|
||||||
|
L = lumi.Lumi.__new__(lumi.Lumi)
|
||||||
|
folds, status = [], {"now": "done"}
|
||||||
|
L.fetch_status = lambda: status["now"]
|
||||||
|
L.arm_pose = lambda target: folds.append(target) or True
|
||||||
|
for text, want in [("Okay, thank you.", True), ("okay thanks", True), ("고마워", True), ("됐어", True),
|
||||||
|
("what's the weather?", False), (None, False)]:
|
||||||
|
folds.clear()
|
||||||
|
L.reached_at = time.time()
|
||||||
|
assert L.reach_done(text) == want and folds == (["fold"] if want else []), (text, folds)
|
||||||
|
L.reached_at = time.time() - lumi.REACH_HOLD_S - 1 # nobody said anything: the timeout folds
|
||||||
|
folds.clear()
|
||||||
|
assert L.reach_done() and folds == ["fold"]
|
||||||
|
status["now"] = "running" # still reaching: not yet
|
||||||
|
L.reached_at, folds[:] = time.time() - lumi.REACH_HOLD_S - 1, []
|
||||||
|
assert not L.reach_done("thanks") and not folds
|
||||||
|
status["now"] = "failed" # the reach failed: the arm stays, no later fold
|
||||||
|
assert not L.reach_done("thanks") and not folds and not L.reached_at
|
||||||
|
L.reached_at = 0.0
|
||||||
|
status["now"] = "done"
|
||||||
|
assert not L.reach_done("thanks") and not folds # no reach out: "thanks" moves nothing
|
||||||
|
print(f"reach live ok ({len(REACH) + len(NOT_REACH)} wordings, stop during a hung body move, held state, auto fold)")
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ lumi.arm.cmd = lambda name, **a: dict(arm_state) if name == "get_robot_state" el
|
|||||||
|
|
||||||
L = lumi.Lumi.__new__(lumi.Lumi)
|
L = lumi.Lumi.__new__(lumi.Lumi)
|
||||||
L.lang, L.markers, L.current, L.patrol, L.vision, L.voice_angle = "en", M, None, None, None, 0.0
|
L.lang, L.markers, L.current, L.patrol, L.vision, L.voice_angle = "en", M, None, None, None, 0.0
|
||||||
L.turn_head = lambda *a: moved.append("head")
|
L.turn_head = lambda *a, **k: moved.append("head")
|
||||||
L.brain = types.SimpleNamespace(history=[])
|
L.brain = types.SimpleNamespace(history=[])
|
||||||
L.keep_listening = lambda: None
|
L.keep_listening = lambda: None
|
||||||
L.mission_running = lambda: False
|
L.mission_running = lambda: False
|
||||||
@@ -190,7 +190,7 @@ for patrol, angle, want in ((False, 35.0, None), (True, 35.0, [35.0]), (False, -
|
|||||||
reached.clear(), said.clear(), moved.clear()
|
reached.clear(), said.clear(), moved.clear()
|
||||||
got = L.reach_out(False)
|
got = L.reach_out(False)
|
||||||
if want is None: # nothing moves, not even the head
|
if want is None: # nothing moves, not even the head
|
||||||
assert got is None and not reached and said == [lumi.STAND_IN_FRONT_SAY[0]] and not moved, (angle, said)
|
assert got is None and not reached and said == [lumi.GREETER_FRONT_SAY[0]] and not moved, (angle, said)
|
||||||
else:
|
else:
|
||||||
assert got and reached == want and moved == ["head"], (patrol, angle, reached, moved)
|
assert got and reached == want and moved == ["head"], (patrol, angle, reached, moved)
|
||||||
L.vision = None # nobody seen, the voice's direction not trusted: ask
|
L.vision = None # nobody seen, the voice's direction not trusted: ask
|
||||||
@@ -200,8 +200,14 @@ L.voice_trusted, L.voice_angle, L.modes.patrol = True, -50.0, True # heard fro
|
|||||||
assert L.reach_out(False) and reached == [-50.0]
|
assert L.reach_out(False) and reached == [-50.0]
|
||||||
moved.clear(), reached.clear(), said.clear()
|
moved.clear(), reached.clear(), said.clear()
|
||||||
L.fetch_status = lambda: "holding"
|
L.fetch_status = lambda: "holding"
|
||||||
|
real_check, fetch.check_hand = fetch.check_hand, lambda: True # the hand checked: something is in it
|
||||||
assert lumi.Lumi.arm_pose(L, "reach") is None and moved == ["give"] and not reached # holding: hand it over
|
assert lumi.Lumi.arm_pose(L, "reach") is None and moved == ["give"] and not reached # holding: hand it over
|
||||||
assert lumi.Lumi.arm_pose(L, "open") is None and said == [lumi.brain_mod.REFUSE_OPEN[0]] # never dropped
|
assert lumi.Lumi.arm_pose(L, "open") is None and said == [lumi.brain_mod.REFUSE_OPEN[0]] # never dropped
|
||||||
|
fetch.check_hand = lambda: False # a stale "holding", the hand empty: it opens
|
||||||
|
real_open, lumi.gripper.open_ = lumi.gripper.open_, lambda: moved.append("open") or {}
|
||||||
|
said.clear(), moved.clear()
|
||||||
|
assert lumi.Lumi.arm_pose(L, "open") and moved == ["open"] and not said, (moved, said)
|
||||||
|
lumi.gripper.open_, fetch.check_hand = real_open, real_check
|
||||||
L.fetch_status = lambda: None
|
L.fetch_status = lambda: None
|
||||||
fetch.reach = real_reach
|
fetch.reach = real_reach
|
||||||
print(f"switches ok: {len(BASE)} base phrases refused with Greeter only, {len(IN_PLACE)} in place done; "
|
print(f"switches ok: {len(BASE)} base phrases refused with Greeter only, {len(IN_PLACE)} in place done; "
|
||||||
|
|||||||
@@ -177,6 +177,7 @@ for th in threading.enumerate(): # a wave sta
|
|||||||
th.join(10)
|
th.join(10)
|
||||||
assert track.greeted and said == [lumi.GREETING] and calls == [], calls
|
assert track.greeted and said == [lumi.GREETING] and calls == [], calls
|
||||||
fetch.STATE_FILE.write_text('{"status": "idle", "holding": true}')
|
fetch.STATE_FILE.write_text('{"status": "idle", "holding": true}')
|
||||||
|
hand["holding"] = True # the hand checked again: really held
|
||||||
said.clear()
|
said.clear()
|
||||||
assert L.wave(("Okay!", "네!")) is False and said == [wave.HOLDING[0]]
|
assert L.wave(("Okay!", "네!")) is False and said == [wave.HOLDING[0]]
|
||||||
L.lang = "ko"
|
L.lang = "ko"
|
||||||
@@ -184,6 +185,11 @@ said.clear()
|
|||||||
assert L.wave() is False and said == [wave.HOLDING[1]]
|
assert L.wave() is False and said == [wave.HOLDING[1]]
|
||||||
said.clear()
|
said.clear()
|
||||||
assert L.wave(quiet=True) is False and said == [] # a goodbye wave refused: no words about it
|
assert L.wave(quiet=True) is False and said == [] # a goodbye wave refused: no words about it
|
||||||
|
hand["holding"] = False # a stale "holding", the hand empty (2026-10-23
|
||||||
|
real_wave, wave.wave = wave.wave, lambda on_start=None: None # 17:43): checked again, not refused for holding
|
||||||
|
said.clear()
|
||||||
|
assert L.wave() is True and said == [] and not fetch.state()["holding"], said
|
||||||
|
wave.wave = real_wave
|
||||||
fetch.STATE_FILE.unlink()
|
fetch.STATE_FILE.unlink()
|
||||||
|
|
||||||
# ---------- "bye bye" to the person in view: a (quiet) wave beside the goodbye; else only the goodbye ----------
|
# ---------- "bye bye" to the person in view: a (quiet) wave beside the goodbye; else only the goodbye ----------
|
||||||
|
|||||||
Reference in New Issue
Block a user