Follow: head tracks round to ±180 and the base turns after it; speed matches the walk; dashboard errors only in the bell

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 15:45:27 +09:00
co-authored by Claude Opus 5.5
parent e7a264012a
commit c4d9b07558
3 changed files with 63 additions and 17 deletions
+51
View File
@@ -460,6 +460,57 @@ assert follow._pick(gone, None, lambda: cand, p, (0.0, 0.0, 0.0), list(blue), ti
assert follow._pick(gone, None, lambda: cand, p, (0.0, 0.0, 0.0), None, time.time())[1] is not None
print("re-lock by clothes: ok")
# walks slowly (0.2 m/s): the base goes as slowly, ~1 m behind, no stop-and-go
said.clear()
w = World(person=(1.5, 0.0), walk=(0.2, 0.0), walk_s=10.0)
follow.start(w.see, say)
time.sleep(8.0)
assert follow.running() and not said, said
follow.stop()
assert wait_end(0.5)
vs, jump = steady(w.cmds, 4.0, 7.8)
assert 0.12 < min(vs) and max(vs) < 0.3 and jump <= step, (min(vs), max(vs), jump)
assert abs(w.dist[-1] - follow.FOLLOW_GAP_M) < 0.25, w.dist[-1]
print(f"slow walk: {min(vs):.2f}-{max(vs):.2f} m/s, gap {w.dist[-1]:.2f} m")
# walks past the robot's side to behind it (1.2 m/s, 1.0 m to the left), head camera only: the head stays on them
# past 90 deg, the base turns on the spot toward them (sweep checked) and follows again; never "lost"
said.clear()
body.moves.clear()
turn_max, follow.TURN_MAX_RS = follow.TURN_MAX_RS, 0.25 # a base slower than the head
w = World(path=lambda t: (2.0 - 1.4 * min(t, 3.0), 1.0), fov=True)
follow.start(w.see, say)
time.sleep(14.0)
follow.TURN_MAX_RS = turn_max
assert follow.running() and not said, said
follow.stop()
assert wait_end(0.5)
yaws = [m[4] for m in body.moves if m[1] == "follow head"]
assert max(yaws) > 90.0 and all(abs(y) <= 180.0 for y in yaws), yaws # past the side
assert all(abs(b - a) < 90.0 for a, b in zip(yaws, yaws[1:])), yaws # never swung round
assert math.degrees(w.th) > 120.0 and w.dist[-1] < follow.FOLLOW_GAP_M + 0.4, (math.degrees(w.th), w.dist[-1])
print(f"past the side to behind: head up to {max(yaws):.0f} deg, base turned {math.degrees(w.th):.0f} deg, "
f"gap {w.dist[-1]:.2f} m")
# right behind: the angle flips between +179 and -179; the head and the base keep one side
said.clear()
body.moves.clear()
flip = [0]
def behind():
flip[0] += 1
return 2.0, 179.0 if flip[0] % 2 else -179.0, 0.0, None
follow.start(behind, say)
time.sleep(0.6)
follow.stop()
assert wait_end(0.5)
yaws = [m[4] for m in body.moves if m[1] == "follow head"]
assert yaws and all(y > 0 for y in yaws[1:]), yaws
print("right behind: one side")
# lumi: act("stop") ends following; follow_me locks onto the person talking, refuses when it must
lumi.agv.cancel = lumi.skills.cancel = lumi.arm.stop = lambda: None
w = World(person=(3.0, 0.0))