Improve place names in typed commands, give wording and approaches that are blocked

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 19:03:25 +09:00
co-authored by Claude Opus 5.5
parent 27182df965
commit 1b3f4568e1
8 changed files with 47 additions and 11 deletions
+8 -4
View File
@@ -1749,7 +1749,7 @@ def _as_place(name):
_OBJ_ADJ = rf"(?:(?:{_COL}|작은|큰|왼쪽|오른쪽|가까운|먼|제일|가장)\s*)*+" # possessive: no backtracking
_AT_OBJ_EN = rf"\b(?:{_OBJ})s?,? (?:that'?s |that is |which is |sitting |lying |standing |left )?(?:on|at|by|near) (?:the )?$"
_AT_OBJ_KO = (rf"\s*(?:(?:위|쪽)\s*)?(?:에|의)\s*(?:(?:있는|있던|놓인|놓여\s*있는|둔|올려\s*둔|올려진|올라간|올라가\s*있는)\s*)?"
_AT_OBJ_KO = (rf"\s*(?:(?:테이블|탁자|책상|table)\s*)?(?:(?:위|쪽)\s*)?(?:에|의)\s*(?:(?:있는|있던|놓인|놓여\s*있는|둔|올려\s*둔|올려진|올라간|올라가\s*있는)\s*)?"
rf"{_OBJ_ADJ}(?:{_OBJ})|\s*(?:(?:에|의)\s*)?(?:있는|있던|놓인|놓여\s*있는|둔)\s*(?:거|것|걸)")
# ^ where the thing is ("the cup on p2", "p2에 있는 빨간 컵", "피원 컵", "p1의 컵"): the source, not where it goes
@@ -1768,14 +1768,18 @@ def _mentions(text, markers):
for m in re.finditer(_place_re(markers), t):
before, after, place = t[:m.start()], t[m.end():], _resolve(m, markers)
if re.search(r"\bfrom (the )?$", before) or re.match(r"\s*에서", after) \
or (re.search(r"\b(go|drive|head|come) (over )?to (the )?$", before) # "go to p1 and get the cup"
or (re.search(r"\b(go|drive|head|come) (over )?(to )?(the )?$", before) # "go (to) p1 and get the cup"
and re.match(r"\s*(,|and|then)\s*(get|fetch|take|pick|grab|bring)", after)) \
or (re.match(r"\s+(?:까지\s*)?가서", after) and objs and m.start() < objs[-1].start()) \
or re.search(_AT_OBJ_EN, before) or re.match(_AT_OBJ_KO, after) \
or (re.match(rf"\s+{_OBJ_ADJ}(?:{_OBJ})", after) and not re.search(r"\b(to|into|onto) (the )?$", before)):
# ^ "the cup on p2", "p2에 있는 컵", "피원 컵을", "p1 red cup bring me"
out["source"] = _as_place(place)
elif re.search(r"\b(to|into) (the )?$|\b(bring|fetch|give|get)( it| that| this)? $", before) \
or re.match(r"\s*(으로|로|에다|에|한테)(?!서)", after) or place == "here":
or re.search(r"\b(go|drive|head|walk|carry it|take it|bring it)( over)? (the )?$", before) \
or re.match(r"\s*(?:(?:포인트|point|지점|테이블|탁자|책상)\s*(?:위\s*)?)?(으로|로|에다|에|한테)(?!서)", after) or place == "here" \
or re.match(r"\s+(?:까지\s*)?(?:가(?:서|요|\s*줘|\s*주세요)?|이동)(?![가-힣])", after):
# ^ "and go exit point", "exit 가서", "exit 까지 가 줘": a drive there, said without "to" / 로
out["dest"] = _as_place(place)
for m in re.finditer(r"\bfrom (?:the )?([a-z]+)", t): # "from the kitchen": a place not on the map
if not re.match(_place_re(markers), t[m.start(1):]) and "source" not in out:
@@ -1787,7 +1791,7 @@ def _mentions(text, markers):
if m.start() > after_obj and "dest" not in out and not re.match(rf"{_TABLE}|{_place_re(markers)}", t[m.start(1):]) \
and m.group(1) not in ("put", "place", "hold", "give", "keep", "bring", "leave"):
out["dest"] = None
if "dest" not in out and re.search(r"\b(bring|get|fetch|give) (it |that |this )?(to )?me\b|\bto me\b|가져와|가지고 ?와|갖다 ?줘|가져다 ?(?:줘|주세요|줄래)", t):
if "dest" not in out and re.search(r"\b(bring|get|fetch|give) (it |that |this )?(to )?me\b|\bto me\b|가져와|가지고 ?와|갖고 ?와|갖다 ?줘|가져다 ?(?:줘|주세요|줄래)", t):
out["dest"] = "here"
if "dest" not in out and (re.search(r"\b(?:bring|fetch)(?:ing)?\b", t) and isinstance(out.get("source"), dict)
and not re.search(r"\b(?:to|for) (?!me\b|us\b)\w", t)
+8 -2
View File
@@ -1412,7 +1412,8 @@ def _en(s, last=False):
if d == "place":
return "put it down" if not s["on"] else f"put it on {_on_words(s['on'])}"
if d == "give":
return f"hand it to {s['person']}" if s.get("person") else "hand it over"
return f"hand it to {s['person']}" if s.get("person") else "give it to the person there" if s.get("_away") \
else "give it to you"
if d == "hold":
return "hold it"
return {"reach": "reach out my arm", "fold": "fold my arm", "open": "open my hand", "close": "close my hand"}[s["pose"]]
@@ -1455,7 +1456,7 @@ def _ko(s, last=False):
if d == "give":
if s.get("person"):
return f"{s['person']}께 건네드리고" if s["person"].endswith("님") else f"{s['person']}에게 건네주고"
return "건네주고"
return "거기 있는 분께 건네주고" if s.get("_away") else "건네주고"
if d == "hold":
return "들고 있고"
return {"reach": "팔을 뻗고", "fold": "팔을 접고", "open": "손을 펴고", "close": "손을 쥐고"}[s["pose"]]
@@ -1476,6 +1477,11 @@ def describe(steps, lang="en"):
"""'Take the cup, drive 0.5 m forward, turn right and drive 1 m, then put it on the table.'"""
if not steps:
return ""
away, marked = False, []
for s in steps: # a give after a drive away is to the person there, else to the one asking
away = s["to"] != "here" if s["do"] == "go" else away or s["do"] == "move"
marked.append({**s, "_away": away} if s["do"] == "give" else s)
steps = marked
if lang == "ko":
parts = [_ko(s, i == len(steps) - 1) for i, s in enumerate(steps)]
return " ".join(parts[:-1] + [_will(parts[-1][:-1]) + "."])
+5 -1
View File
@@ -26,7 +26,11 @@ def cmd(name, **args):
tries = RETRIES if again else 1
for i in range(tries):
try:
return _send(name, args)
r = _send(name, args)
if name in READ_ONLY and r.get("cmdName", name) != name and i < tries - 1:
time.sleep(RETRY_S) # another command's reply (get_data to get_joint_pos, seen): ask again
continue
return r
except (ConnectionError, OSError):
if i == tries - 1:
raise
+14 -1
View File
@@ -1179,6 +1179,19 @@ def _straight_clear(dist, speed=None, stop=True):
return free
def _straight_went(dist):
"""_straight_clear, but the distance the base pose really went (m): a base that stood still (its own obstacle
stop, 2026-10-26: the same +0.15 m "driven" three times, the cup never nearer) counts as blocked."""
x0, y0, th0 = agv.pose()
driven = _straight_clear(dist)
x, y, _ = agv.pose()
real = abs((x - x0) * math.cos(th0) + (y - y0) * math.sin(th0))
if driven >= MOVED_CHECK_M and real < MOVED_MIN_PART * driven:
log(f"the base went {real:.2f} m of {driven:.2f} m driven: another way")
return real
return driven
def rolling_lead(speed):
"""How far (m) the base can roll on at `speed` (m/s or a function) after its last joy_control command."""
return (speed() if callable(speed) else speed or AXIS_SPEED) * JOY_HOLD_S
@@ -1203,7 +1216,7 @@ def _approach(obj, yaw, tried, goal=PICK_ZONE_CENTRE, holding=False):
turned = abs(turn) < TURN_MIN_DEG or _turn(turn, holding, why="to face it")
if turned:
turn = 0.0
if turned and (abs(s) < PROBE_STEP_M or _straight_clear(s) >= PROBE_STEP_M):
if turned and (abs(s) < PROBE_STEP_M or _straight_went(s) >= PROBE_STEP_M):
return # else the turn or the straight way is blocked: go round
x, y, th = agv.pose()
world = np.array([x, y]) + _rot(math.degrees(th)) @ to_base((obj["x"], obj["y"]), yaw, t)
+2 -2
View File
@@ -214,12 +214,12 @@ READ_BACK = {
"go stage | turn -360": ("Go to stage, then turn all the way around to the right.",
"stage 위치로 가고 오른쪽으로 한 바퀴 돌게요."),
"pick cup | place": ("Take the cup, then put it down.", "컵을 집고 테이블에 놓을게요."),
"pick cup | give": ("Take the cup, then hand it over.", "컵을 집고 건네줄게요."), # "컵 가져다 줘"
"pick cup | give": ("Take the cup, then give it to you.", "컵을 집고 건네줄게요."), # "컵 가져다 줘"
"pick cup | go booth_2 | give James | go here":
("Take the cup, go to booth 2, hand it to James, then come back here.",
"컵을 집고 booth 2 위치로 가고 James에게 건네주고 여기로 돌아올게요."),
"go stage | pick cup | go here | give":
("Go to stage, take the cup, come back here, then hand it over.",
("Go to stage, take the cup, come back here, then give it to you.",
"stage 위치로 가고 컵을 집고 여기로 돌아오고 건네줄게요."),
"go table_front | wait 30 | go home":
("Go to table front, wait 30 seconds, then go to my dock.",
+4
View File
@@ -681,6 +681,10 @@ fetch.DRIVE_START_S, fetch.agv.status = real_start, real_agv_status
t0 = time.time()
fetch._straight(0.01, 1.0)
assert time.time() - t0 < 0.2 and skills.moved_at["torso"] > t0, skills.moved_at
# ... a straight approach the base pose did not follow (its own obstacle stop) counts as blocked: another way
fetch.MOVED_CHECK_M = 0.1
assert fetch._straight_went(0.2) == 0.0
fetch.MOVED_CHECK_M = float("inf")
# ---------- measure-axis pairs each object once: two cups before, one after ----------
b2 = [{"name": "cup", "x": -211.5, "y": 1332.0}, {"name": "cup", "x": 9.0, "y": 1301.0}]
+5
View File
@@ -56,6 +56,11 @@ FETCH = {
"bring the cup from p2 to Minsu": ("cup", None, P("p2"), None, "hold"),
"p2에서 컵 가져다가 민수한테 줘": ("cup", None, P("p2"), None, "hold"),
"빨간 옷 입은 여자분께 컵 갖다 드려": ("cup", None, "here", None, "hold"),
# the place said without "to" / 로 (the dashboard, 2026-10-26): a drive there with it, or the way to the thing
"take the cup and go p5": ("cup", None, "here", P("p5"), "hold"),
"take the cup from p1 and go p5": ("cup", None, P("p1"), P("p5"), "hold"),
"컵 들고 p5 가서 기다려": ("cup", None, "here", P("p5"), "hold"),
"p2 가서 컵 가져와": ("cup", None, P("p2"), "here", "hold"),
}
bad = []
for text, want in FETCH.items():
+1 -1
View File
@@ -217,7 +217,7 @@ assert steps.describe(s, "en") == ("Take the cup, drive 0.5 m forward, turn righ
"then put it on the table."), steps.describe(s, "en")
assert steps.describe(S("go p3,p5,p7 | hold"), "en") == "Go to one of p3, p5 or p7, then hold it."
assert steps.describe(S("go final | give | say Anvar says hello"), "en") == \
'Go to final, hand it over, then say "Anvar says hello".'
'Go to final, give it to the person there, then say "Anvar says hello".'
assert steps.describe(s, "ko")
print("steps ok")