Arm moves only along checked poses; any marker name of the active map
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+43
-15
@@ -86,6 +86,7 @@ from robot import motion
|
||||
from audio import mouth
|
||||
from audio import sing
|
||||
from robot import nav
|
||||
from manipulation import arm_route
|
||||
from manipulation import skills
|
||||
from manipulation import wave as wave_mod
|
||||
from assistant import web
|
||||
@@ -662,7 +663,6 @@ class Lumi:
|
||||
def __init__(self, args):
|
||||
self.a = args
|
||||
self.brain = Brain()
|
||||
self.markers = agv.markers()
|
||||
self.current = None # the track we are talking with
|
||||
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
|
||||
@@ -691,6 +691,15 @@ class Lumi:
|
||||
self.vision = None if args.no_camera else Vision(args.camera)
|
||||
log(f"markers: {self.markers}")
|
||||
|
||||
@property
|
||||
def markers(self):
|
||||
"""The active map's marker names (agv.known_markers: a new map is seen within seconds)."""
|
||||
return self._markers if getattr(self, "_markers", None) is not None else agv.known_markers()
|
||||
|
||||
@markers.setter
|
||||
def markers(self, names): # a fixed list (self-checks)
|
||||
self._markers = names
|
||||
|
||||
# ---------- actions ----------
|
||||
def turn_head(self, yaw=None, pitch=None):
|
||||
def run():
|
||||
@@ -1318,8 +1327,9 @@ class Lumi:
|
||||
got, unread, by = read
|
||||
if unread:
|
||||
log(f" mission: unread {unread} ({by})")
|
||||
self.fetch_say(f"Sorry, I didn't understand: {', '.join(unread)}. Please say it again.",
|
||||
"죄송해요, 일부를 이해하지 못했어요. 다시 말씀해 주세요.")
|
||||
problem = brain_mod.place_problem(" ".join(unread), self.markers) # "go to booth" with two booths
|
||||
self.fetch_say(*(problem or (f"Sorry, I didn't understand: {', '.join(unread)}. Please say it again.",
|
||||
"죄송해요, 일부를 이해하지 못했어요. 다시 말씀해 주세요.")))
|
||||
self.keep_listening()
|
||||
return True
|
||||
log(f" mission ({by}): {got}")
|
||||
@@ -1501,7 +1511,7 @@ class Lumi:
|
||||
mouth.say(done[0] if en else done[1])
|
||||
except skills.SkillError as e:
|
||||
log(f" {action} {target}: {e}")
|
||||
mouth.say(str(e) if en else "죄송해요, 지금은 할 수 없어요.")
|
||||
mouth.say(e.args[0] if en else e.args[1] if len(e.args) > 1 else "죄송해요, 지금은 할 수 없어요.")
|
||||
except (motion.MotionError, ConnectionError, OSError) as e:
|
||||
log(f" {action} {target} stopped: {e}")
|
||||
mouth.say("I stopped my arm." if en else "팔을 멈췄어요.")
|
||||
@@ -1510,19 +1520,26 @@ class Lumi:
|
||||
self.keep_listening()
|
||||
|
||||
def arm_pose(self, target):
|
||||
"""'reach': the Cobo π program ARM_REACH_PROGRAM (record it once); 'fold': the folded drive pose;
|
||||
'open' / 'close': the gripper."""
|
||||
"""'reach': the Cobo π program ARM_REACH_PROGRAM (record it once), only from look; 'fold': tuck along the
|
||||
pose graph (arm_route, checked first, moved in the background); 'open' / 'close': the gripper. True when
|
||||
started, False when not learned, None when refused (the reason is said)."""
|
||||
if target in ("open", "close"):
|
||||
st = safe(gripper.open_ if target == "open" else gripper.close)
|
||||
log(f" gripper {target}: {st}")
|
||||
return st is not None
|
||||
if target == "fold":
|
||||
return safe(lambda: motion.go("tuck", wait=False)) is not None
|
||||
try:
|
||||
arm.start(ARM_REACH_PROGRAM)
|
||||
if target == "fold":
|
||||
seq = arm_route.plan("tuck", holding=self.fetch_status() == "holding")
|
||||
threading.Thread(target=safe, args=(arm_route.move, seq), daemon=True).start()
|
||||
else:
|
||||
arm_route.start_program(ARM_REACH_PROGRAM)
|
||||
return True
|
||||
except arm_route.RouteError as e:
|
||||
log(f" arm {target} refused: {e.args[0]}")
|
||||
self.fetch_say(*e.args)
|
||||
return None
|
||||
except Exception as e:
|
||||
log(f" arm reach: {e} (record {ARM_REACH_PROGRAM} in Cobo pi)")
|
||||
log(f" arm {target}: {e}" + (f" (record {ARM_REACH_PROGRAM} in Cobo pi)" if target == "reach" else ""))
|
||||
return False
|
||||
|
||||
# ---------- dashboard commands, trips ----------
|
||||
@@ -1893,12 +1910,22 @@ class Lumi:
|
||||
mouth.say("Sorry, driving is switched off." if en else "죄송해요, 지금은 이동할 수 없어요.")
|
||||
return
|
||||
self.start_trip(place)
|
||||
mouth.say(f"Okay, I'm going to {place}." if en else f"네, {place}로 갈게요.")
|
||||
name = brain_mod.place_said(place)
|
||||
mouth.say(f"Okay, I'm going to {name}." if en else f"네, {name}로 갈게요.")
|
||||
self.keep_listening()
|
||||
|
||||
def quick_command(self, text):
|
||||
"""A command the keyword rules recognise for sure: confirm with a ready phrase and act, no LLM wait."""
|
||||
rule = brain_mod.intent(text, self.markers)
|
||||
if not rule and brain_mod.place_problem(text, self.markers):
|
||||
agv.known_markers(fresh=True) # not on the list: the map may have just changed
|
||||
rule = brain_mod.intent(text, self.markers)
|
||||
problem = not rule and brain_mod.place_problem(text, self.markers)
|
||||
if problem:
|
||||
log(f" place: {problem[0]}")
|
||||
mouth.say(problem[0] if self.lang == "en" else problem[1])
|
||||
self.keep_listening()
|
||||
return True
|
||||
if rule and rule[0] in MOVING_ACTIONS and self.mission_running():
|
||||
self.fetch_say("Sorry, I'm on a task right now. I can help you when I've finished.",
|
||||
"죄송해요, 지금 다른 일을 하고 있어요. 끝나면 도와드릴게요.")
|
||||
@@ -1969,15 +1996,16 @@ class Lumi:
|
||||
done = {"open": ("Okay, opening my hand.", "네, 손을 펼게요."), "close": ("Okay, closing my hand.", "네, 손을 쥘게요.")}
|
||||
if target in done:
|
||||
mouth.say(done[target][0] if en else done[target][1])
|
||||
if self.arm_pose(target):
|
||||
ok = self.arm_pose(target)
|
||||
if ok:
|
||||
if target not in done:
|
||||
mouth.say("Here you go." if en else "여기요.")
|
||||
else:
|
||||
elif ok is False:
|
||||
mouth.say("Sorry, I haven't learned that arm movement yet." if en else "죄송해요, 그 팔 동작은 아직 못 배웠어요.")
|
||||
return True
|
||||
self.start_trip(target) # go_to: start driving, then say so
|
||||
name = "my charging dock" if target == "home" else target
|
||||
mouth.say(f"Okay, I'm going to {name}." if en else ("네, 충전소로 갈게요." if target == "home" else f"네, {target}로 갈게요."))
|
||||
name = "my charging dock" if target == "home" else brain_mod.place_said(target)
|
||||
mouth.say(f"Okay, I'm going to {name}." if en else ("네, 충전소로 갈게요." if target == "home" else f"네, {name}로 갈게요."))
|
||||
self.current, self.voice_until = None, 0.0
|
||||
return True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user