Improve head resting pose and keep the head where it was asked to look
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -535,7 +535,7 @@ $("driveStop").onclick = () => { holdStop(); api("/jog/stop", {}); api("/agv/can
|
|||||||
$("driveSpeed").oninput = e => $("driveSpeedV").textContent = e.target.value + " %";
|
$("driveSpeed").oninput = e => $("driveSpeedV").textContent = e.target.value + " %";
|
||||||
$("bodySpeed").oninput = e => $("bodySpeedV").textContent = e.target.value + " %";
|
$("bodySpeed").oninput = e => $("bodySpeedV").textContent = e.target.value + " %";
|
||||||
$("armSpeed").oninput = e => $("armSpeedV").textContent = e.target.value + " %";
|
$("armSpeed").oninput = e => $("armSpeedV").textContent = e.target.value + " %";
|
||||||
$("headCentre").onclick = e => act(e.target, () => api("/head/turn", {yaw: 0, pitch: 0}));
|
$("headCentre").onclick = e => act(e.target, () => api("/head/turn", {yaw: 0, pitch: -5}));
|
||||||
|
|
||||||
/* ---------- map ---------- */
|
/* ---------- map ---------- */
|
||||||
const cv = $("map"), ctx = cv.getContext("2d");
|
const cv = $("map"), ctx = cv.getContext("2d");
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import urllib.request
|
|||||||
BODY = "http://192.168.10.90:5000/api/extaxis"
|
BODY = "http://192.168.10.90:5000/api/extaxis"
|
||||||
YAW_LIMIT = 60.0 # deg; we keep the head well inside its +-180 range
|
YAW_LIMIT = 60.0 # deg; we keep the head well inside its +-180 range
|
||||||
PITCH_RANGE = (-5.0, 35.0) # deg, hardware range
|
PITCH_RANGE = (-5.0, 35.0) # deg, hardware range
|
||||||
|
HEAD_REST_PITCH = PITCH_RANGE[0] # deg; the head's rest: its lowest, looking down (+pitch = up), so sitting people
|
||||||
|
# and near things are in view. Every "head back / ahead" uses it; yaw rests at 0
|
||||||
VEL = 40 # speed ratio %, 1-100 (was 15: too slow to follow a visitor)
|
VEL = 40 # speed ratio %, 1-100 (was 15: too slow to follow a visitor)
|
||||||
ACC = 40 # acceleration ratio %, 1-100
|
ACC = 40 # acceleration ratio %, 1-100
|
||||||
# Temporary (2026-10-20): the head camera's cable is too short, a higher lift pulls it out. Back to 250 mm (what
|
# Temporary (2026-10-20): the head camera's cable is too short, a higher lift pulls it out. Back to 250 mm (what
|
||||||
|
|||||||
+8
-1
@@ -279,7 +279,7 @@ def _run(see, say, people):
|
|||||||
v = w = 0.0
|
v = w = 0.0
|
||||||
done, target, stats = threading.Event(), [None], {"head": None, "head_ms": None}
|
done, target, stats = threading.Event(), [None], {"head": None, "head_ms": None}
|
||||||
head.owners = (threading.current_thread(),)
|
head.owners = (threading.current_thread(),)
|
||||||
person = Person()
|
person, head_thread = Person(), None
|
||||||
try:
|
try:
|
||||||
got = see() # where they are now: prepare() may turn the waist
|
got = see() # where they are now: prepare() may turn the waist
|
||||||
sig = got[3] if got else None
|
sig = got[3] if got else None
|
||||||
@@ -382,6 +382,13 @@ def _run(see, say, people):
|
|||||||
_joy(0.0, 0.0)
|
_joy(0.0, 0.0)
|
||||||
except (ConnectionError, OSError):
|
except (ConnectionError, OSError):
|
||||||
pass # one command lasts 0.5 s: the base stops anyway
|
pass # one command lasts 0.5 s: the base stops anyway
|
||||||
|
if head_thread is not None: # the head back to rest (ahead, looking down) once its own
|
||||||
|
head_thread.join(HEAD_TIMEOUT_S) # move has ended: overlapping movetos hang the body API
|
||||||
|
try:
|
||||||
|
head.moveto([*head.status()[:2], 0.0, head.HEAD_REST_PITCH], vel=HEAD_VEL, acc=HEAD_VEL,
|
||||||
|
timeout=HEAD_TIMEOUT_S)
|
||||||
|
except (ConnectionError, OSError, ValueError, KeyError) as e:
|
||||||
|
fetch.log(f"follow: head error {e!r}")
|
||||||
head.owners = ()
|
head.owners = ()
|
||||||
fetch.log("follow: ended")
|
fetch.log("follow: ended")
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ fetch.head_cam.base_from_head = lambda yaw, pitch: None #
|
|||||||
fetch.objects.latest = lambda camera="torso": {"age_s": None, "objects": [], "head_pose": None}
|
fetch.objects.latest = lambda camera="torso": {"age_s": None, "objects": [], "head_pose": None}
|
||||||
fetch.camview.want = lambda name: None
|
fetch.camview.want = lambda name: None
|
||||||
fetch.head.moveto = lambda *a, **kw: (_ for _ in ()).throw(AssertionError("real head / lift move in a test"))
|
fetch.head.moveto = lambda *a, **kw: (_ for _ in ()).throw(AssertionError("real head / lift move in a test"))
|
||||||
fetch.head.status = lambda: [75.0, -15.0, 0.0, 0.0]
|
fetch.head.status = lambda: [75.0, -15.0, *fetch.HEAD_AHEAD] # the head at rest
|
||||||
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}"))
|
||||||
say = lambda en, ko: said.append(en)
|
say = lambda en, ko: said.append(en)
|
||||||
P = lambda **k: k
|
P = lambda **k: k
|
||||||
|
|||||||
@@ -304,7 +304,8 @@ yaws = [m[4] for m in body.moves if m[1] == "follow head"]
|
|||||||
assert body.overlaps == 0 and len(yaws) >= 3, (body.overlaps, len(yaws))
|
assert body.overlaps == 0 and len(yaws) >= 3, (body.overlaps, len(yaws))
|
||||||
assert max(yaws) > 20.0 and min(yaws) >= -follow.HEAD_STEP_DEG, yaws # left, toward them
|
assert max(yaws) > 20.0 and min(yaws) >= -follow.HEAD_STEP_DEG, yaws # left, toward them
|
||||||
assert abs(yaws[-1]) < 15.0, yaws[-1] # back toward 0
|
assert abs(yaws[-1]) < 15.0, yaws[-1] # back toward 0
|
||||||
assert math.degrees(w.th) > 120.0 and all(m[5] == follow.HEAD_PITCH for m in body.moves), math.degrees(w.th)
|
assert math.degrees(w.th) > 120.0 and all(m[5] == follow.HEAD_PITCH for m in body.moves[:-1]), math.degrees(w.th)
|
||||||
|
assert body.moves[-1][4:] == (0.0, head.HEAD_REST_PITCH), body.moves[-1] # after it: back to rest
|
||||||
print(f"walk behind: head up to {max(yaws):.0f} deg, base turned {math.degrees(w.th):.0f} deg, {len(yaws)} head moves")
|
print(f"walk behind: head up to {max(yaws):.0f} deg, base turned {math.degrees(w.th):.0f} deg, {len(yaws)} head moves")
|
||||||
|
|
||||||
# live 2026-10-21: "follow me" from a person at 0.54 m, -80 deg, the head turned to them; prepare() turned the head
|
# live 2026-10-21: "follow me" from a person at 0.54 m, -80 deg, the head turned to them; prepare() turned the head
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ def fresh(said, deg, yaw=10.0):
|
|||||||
L.patrol, L.chain_stop, L.sorry_at = None, threading.Event(), 0.0
|
L.patrol, L.chain_stop, L.sorry_at = None, threading.Event(), 0.0
|
||||||
L.warm_llm = lambda: None
|
L.warm_llm = lambda: None
|
||||||
L.det_yaw = lambda: yaw
|
L.det_yaw = lambda: yaw
|
||||||
L.turn_head = lambda *a: done.append(("head", a))
|
L.turn_head = lambda *a, **k: done.append(("head", a))
|
||||||
L.answer = lambda text: heard.append(text)
|
L.answer = lambda text: heard.append(text)
|
||||||
L.fetch_say = lambda en, ko: done.append(("say", en))
|
L.fetch_say = lambda en, ko: done.append(("say", en))
|
||||||
L.keep_listening = lambda: None
|
L.keep_listening = lambda: None
|
||||||
|
|||||||
@@ -237,4 +237,34 @@ for text in ("I am standing or sitting.", "Am I sitting or standing?", "It looks
|
|||||||
assert lumi.claimed_name("I'm James.") == "james"
|
assert lumi.claimed_name("I'm James.") == "james"
|
||||||
assert "only when they clearly tell you their name" in brain_mod.SYSTEM
|
assert "only when they clearly tell you their name" in brain_mod.SYSTEM
|
||||||
|
|
||||||
|
# the head rests looking down (lowest pitch): every "head back" sends HEAD_REST_PITCH, never pitch 0
|
||||||
|
src = open(lumi.__file__).read()
|
||||||
|
assert "turn_head(0, 0)" not in src and "head.HEAD_REST_PITCH" in src
|
||||||
|
assert lumi.LOOK["center"] == (0, lumi.head.HEAD_REST_PITCH) and lumi.head.HEAD_REST_PITCH == lumi.head.PITCH_RANGE[0]
|
||||||
|
|
||||||
|
# a look asked for is held: automatic head moves wait until LOOK_HOLD_S of silence, a goodbye or a stop word
|
||||||
|
moves = []
|
||||||
|
real_status, real_turn = lumi.head.status, lumi.head.turn
|
||||||
|
lumi.head.status = lambda: [50.0, 0.0, 0.0, 20.0]
|
||||||
|
lumi.head.turn = lambda yaw, pitch=None, **k: moves.append((yaw, pitch))
|
||||||
|
H = lumi.Lumi.__new__(lumi.Lumi)
|
||||||
|
H.looked_at, H.last_activity = time.time(), time.time() # "look up" just now
|
||||||
|
H.turn_head(30.0) # toward a speaker: waits
|
||||||
|
H.turn_head(0, lumi.head.HEAD_REST_PITCH) # back to rest: waits
|
||||||
|
H.looked_at = H.last_activity = time.time() - lumi.LOOK_HOLD_S + 1 # still inside the hold
|
||||||
|
H.turn_head(0, lumi.head.HEAD_REST_PITCH)
|
||||||
|
time.sleep(0.2)
|
||||||
|
assert moves == [] and H.look_held(), moves
|
||||||
|
H.turn_head(10.0, 10, force=True) # an order still moves it
|
||||||
|
H.looked_at = H.last_activity = time.time() - lumi.LOOK_HOLD_S - 1 # 35 s of silence: rest
|
||||||
|
H.turn_head(0, lumi.head.HEAD_REST_PITCH)
|
||||||
|
time.sleep(0.2)
|
||||||
|
assert moves == [(10.0, 10), (0, lumi.head.HEAD_REST_PITCH)] and not H.look_held(), moves
|
||||||
|
moves.clear()
|
||||||
|
H.looked_at = H.last_activity = time.time()
|
||||||
|
H.head_rest() # a goodbye / stop word ends the hold
|
||||||
|
time.sleep(0.2)
|
||||||
|
assert moves == [(0, lumi.head.HEAD_REST_PITCH)] and H.looked_at == 0.0, moves
|
||||||
|
lumi.head.status, lumi.head.turn = real_status, real_turn
|
||||||
|
|
||||||
print("ok: wake words, waves, no greeting to passers-by or during tasks, answers never cut, names")
|
print("ok: wake words, waves, no greeting to passers-by or during tasks, answers never cut, names")
|
||||||
|
|||||||
Reference in New Issue
Block a user