Tuck removed, dashboard arm card with wave and taught poses, markers refresh by themselves
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -15,8 +15,7 @@ from vision import head_cam
|
||||
fetch.STATE_FILE = Path(tempfile.mkdtemp()) / "lumi_task.json" # never the real /dev/shm file
|
||||
POSES = {"look": [0.0] * 6, "carry": [20.0, 0, 0, 0, 0, 0], "give": [40.0, 0, 0, 0, 0, 0],
|
||||
"wave_out": [0.0, -20, 0, 0, 0, 0], "wave_start": [0.0, -20, 20, 0, 0, 0],
|
||||
"wave": [0.0, -20, 20, 0, 20, 0], "ready": [0.0, 0, -20, 0, 0, 0],
|
||||
"tuck": [-20.0, 0, 0, 0, 0, 0]}
|
||||
"wave": [0.0, -20, 20, 0, 20, 0], "ready": [0.0, 0, -20, 0, 0, 0]}
|
||||
FAR = np.array([0.0, 0.0, 5000.0]) # the head far away: nothing near it
|
||||
head = {"centre": FAR}
|
||||
motion.poses = lambda: dict(POSES)
|
||||
@@ -84,7 +83,8 @@ use(POSES["give"])
|
||||
assert arm_route.goto("look") == ["carry", "look"] # after giving: give -> carry -> look
|
||||
assert arm_route.goto("give") == ["carry", "give"] # to give: look -> carry -> give
|
||||
use(POSES["wave"])
|
||||
assert arm_route.goto("tuck") == ["wave_start", "wave_out", "look", "tuck"] # fold: through look
|
||||
assert arm_route.goto("look") == ["wave_start", "wave_out", "look"] # fold: down to look
|
||||
assert not any("tuck" in e for e in arm_route.EDGES)
|
||||
use(POSES["look"])
|
||||
assert arm_route.goto("wave_start") == ["wave_out", "wave_start"] # up: never look -> wave_start directly
|
||||
assert {"look", "wave_start"} not in [set(e) for e in arm_route.EDGES]
|
||||
|
||||
+5
-5
@@ -140,7 +140,7 @@ fetch.motion.go = lambda name, *a, **k: (calls.append(("pose", name)), arm.updat
|
||||
fetch.motion.stop = lambda: calls.append(("arm stop",))
|
||||
real_move = fetch.arm_route.move
|
||||
fetch.arm_route.move = lambda seq, *a, **k: [fetch.motion.go(n) for n, _ in seq] # by name (poses share joints here)
|
||||
fetch.motion.poses = lambda: {"tuck": [0] * 6, "ready": [0] * 6, "carry": [3] * 6, "look": [0] * 6}
|
||||
fetch.motion.poses = lambda: {"ready": [0] * 6, "carry": [3] * 6, "look": [0] * 6}
|
||||
fetch.motion.tcp = lambda: [0.0] * 3 + tilt["rpy"] # the flange as the fake kine_forward says
|
||||
skills._joints = lambda: arm["j"]
|
||||
skills.FRESH_WAIT_S = 0.0 # never wait for the live camera files
|
||||
@@ -750,7 +750,7 @@ skills.find, skills.reachable_pick, where["how"] = real_find, fake_reachable, "u
|
||||
fetch._set(holding=False, status="idle")
|
||||
|
||||
# ---------- give: nobody takes it -> keep holding; a pull -> open ----------
|
||||
fetch.motion.poses = lambda: {"tuck": [0] * 6, "ready": [0] * 6, "carry": [3] * 6, "look": [0] * 6, "give": [-6] * 6}
|
||||
fetch.motion.poses = lambda: {"ready": [0] * 6, "carry": [3] * 6, "look": [0] * 6, "give": [-6] * 6}
|
||||
fetch.GIVE_WAIT_S = 0.3
|
||||
reset()
|
||||
st = run(fetch.start, ok)
|
||||
@@ -764,7 +764,7 @@ fetch.GIVE_WAIT_S = 5.0
|
||||
threading.Timer(0.2, fetch.release_now).start() # "thank you" / Release
|
||||
st = run(fetch.give)
|
||||
assert st["status"] == "done" and not st["holding"] and ("open",) in calls, (st, calls)
|
||||
fetch.motion.poses = lambda: {"tuck": [0] * 6, "ready": [0] * 6, "carry": [3] * 6, "look": [0] * 6}
|
||||
fetch.motion.poses = lambda: {"ready": [0] * 6, "carry": [3] * 6, "look": [0] * 6}
|
||||
|
||||
# ---------- another process holds it: give / place here take it over ----------
|
||||
reset()
|
||||
@@ -823,7 +823,7 @@ fetch._pose("carry")
|
||||
assert calls == [("pose", "carry")], calls
|
||||
fetch._pose("carry") # there already: no move
|
||||
assert calls == [("pose", "carry")], calls
|
||||
fetch.motion.poses = lambda: {"tuck": [0] * 6, "ready": [0] * 6, "carry": [3] * 6, "look": [0] * 6}
|
||||
fetch.motion.poses = lambda: {"ready": [0] * 6, "carry": [3] * 6, "look": [0] * 6}
|
||||
# ---------- place spots: the pick spot only while the base stands where it picked ----------
|
||||
seen_table = {"spots": None}
|
||||
skills.on_table = lambda spots, table: (seen_table.update(spots=list(spots), table=table), [s for s in spots if s[1] >= 680])[1]
|
||||
@@ -837,7 +837,7 @@ assert (-160.0, 600.0) not in tries and tries and seen_table["table"] == -402.0,
|
||||
fetch.place_spots({**held, "table": None}, (1.0, 2.0, 0.5), [cup_near])
|
||||
assert seen_table["table"] == -405.0 # from the other cup: -340 - 65
|
||||
# ---------- missions (docs/17): steps in order, moves checked, receive by the finger sensor ----------
|
||||
fetch.motion.poses = lambda: {"tuck": [0] * 6, "ready": [0] * 6, "carry": [3] * 6, "look": [0] * 6, "give": [-6] * 6}
|
||||
fetch.motion.poses = lambda: {"ready": [0] * 6, "carry": [3] * 6, "look": [0] * 6, "give": [-6] * 6}
|
||||
fetch.MOVE_SPEED, fetch.RECEIVE_DI_S, fetch.GIVE_POLL_S = 100.0, 0.05, 0.01
|
||||
real_state, real_close = fetch.gripper.state, fetch.gripper.close
|
||||
fetch.gripper.state = lambda: {**hand, "object_in_front": hand.get("front", False),
|
||||
|
||||
@@ -28,7 +28,7 @@ fetch._lift_to = lambda mm: None
|
||||
fetch._pose = lambda name, speed=None: calls.append(("pose", name))
|
||||
fetch._line_holding = lambda name: calls.append(("line", name))
|
||||
fetch._in_hand = lambda: hand["holding"]
|
||||
fetch.motion.poses = lambda: {"look": [0] * 6, "give": [0] * 6, "tuck": [0] * 6}
|
||||
fetch.motion.poses = lambda: {"look": [0] * 6, "give": [0] * 6}
|
||||
fetch.gripper.state = lambda: {"holding": hand["holding"], "closed": hand["holding"], "object_in_front": hand["front"]}
|
||||
fetch.gripper.open_ = lambda: (calls.append(("open",)), hand.update(holding=False), fetch.gripper.state())[-1]
|
||||
fetch.gripper.close = lambda wait=True: (calls.append(("close",)), hand.update(holding=hand["front"]),
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Self-check: a marker added on the base after the API started is in /map/info, /agv/markers and the assistant's
|
||||
list at once (api/server.py, robot/agv.py), with a fake base, no robot: python tests/test_map_info.py"""
|
||||
import time
|
||||
|
||||
from api import server
|
||||
from robot import agv
|
||||
|
||||
MARKS = {"home_dock": {"key": 11, "num": 1, "floor": 1, "pose": {"position": {"x": 0, "y": 0},
|
||||
"orientation": {"z": 0, "w": 1}}}}
|
||||
|
||||
|
||||
def fake(cmd, timeout=3.0):
|
||||
path = cmd.split("?")[0]
|
||||
if path == "/api/map/get_current_map":
|
||||
return {"results": {"map_name": "office", "floor": 1, "info": {"resolution": 0.05}}}
|
||||
if path in ("/api/markers/query_list", "/api/markers/query_brief"):
|
||||
return {"results": {n: dict(m) for n, m in MARKS.items()}}
|
||||
if path == "/api/map/list":
|
||||
return {"results": {"office": [1]}}
|
||||
raise AssertionError(cmd)
|
||||
|
||||
|
||||
agv.request = server.agv.request = fake
|
||||
names = lambda d: [m["name"] for m in d["markers"]]
|
||||
assert names(server.map_info()) == ["home_dock"]
|
||||
assert server.markers()["markers"] == ["home"] and agv.known_markers() == ["home"]
|
||||
|
||||
MARKS["p13"] = {"key": 0, "floor": 1, "pose": {"position": {"x": 1.0, "y": 2.0}, "orientation": {"z": 0, "w": 1}}}
|
||||
assert names(server.map_info()) == ["home_dock", "p13"] # the next page load sees it
|
||||
assert server.markers()["markers"] == ["home", "p13"]
|
||||
assert agv.known_markers(fresh=True) == ["home", "p13"] # a name not on the list: read again
|
||||
agv._known["t"] = time.time() - agv.MARKERS_FRESH_S - 1
|
||||
del MARKS["p13"]
|
||||
assert agv.known_markers() == ["home"] # and within MARKERS_FRESH_S anyway
|
||||
print("map info ok")
|
||||
+1
-1
@@ -196,7 +196,7 @@ assert steps.check(S("go p1 | place"), True, M) == []
|
||||
assert steps.check(S("receive cup | give"), False, M) == []
|
||||
assert steps.check(S("move forward 4"), False, M) # longer than MOVE_MAX_M
|
||||
assert steps.check(S("go p3,p99"), False, M) # not on the map
|
||||
assert steps.check(S("pick cup | arm fold"), False, M) # the cup would tip
|
||||
assert steps.check(S("pick cup | arm fold"), False, M) # not with a cup in the hand
|
||||
assert steps.check(S("arm open"), False, M) == []
|
||||
|
||||
# ---- read-back ----
|
||||
|
||||
Reference in New Issue
Block a user