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:
2026-10-21 18:52:34 +09:00
co-authored by Claude Opus 5.5
parent c444d64306
commit fe8319bc95
12 changed files with 89 additions and 49 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ All of Lumi's parts share one network, the **robot LAN** (`192.168.10.x`). It ha
| What | Address | For |
|---|---|---|
| **Dashboard** | http://192.168.10.240:8100/view | Everyday use: cameras, map, Greeter / Patrol, STOP |
| **Dashboard** | http://192.168.10.240:8100/view | Everyday use: cameras, map (markers added on the base show within 20 s), arm poses and Wave, Greeter / Patrol, STOP |
| **Robot API** (Swagger) | http://192.168.10.240:8100/docs | Every endpoint of this software with "Try it out": status, base, body, arm, gripper, skills, tasks, cameras, assistant |
| API health | http://192.168.10.240:8100/health | `{"ok": true}` while the API runs |
| Camera picture | http://192.168.10.240:8100/camera/torso.jpg (or `head.jpg`) | Latest frame of one camera; `/camera/<name>.mjpg` is a live stream |
+22 -11
View File
@@ -75,7 +75,6 @@ input:focus,select:focus{border-color:var(--accent)}
.pad{display:grid;grid-template-columns:repeat(3,1fr);gap:5px}
.pad .btn{height:38px;padding:0;font-size:15px;display:grid;place-items:center}
.pad .c{font-size:13px}
.qa{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:8px}
.field{display:flex;gap:6px;margin-bottom:8px}
.field input{flex:1;min-width:0}
.field .btn{width:52px;padding:0;display:grid;place-items:center;font-size:12.5px}
@@ -237,14 +236,14 @@ input[type=color]{width:30px;height:28px;border:1px solid var(--line);border-rad
</div>
<div class="card box">
<h3>Arm pose</h3>
<h3>Arm</h3>
<div class="row"><select id="poseSel" class="grow"></select><select id="poseSpeed"><option value="slow">Slow</option><option value="normal">Normal</option><option value="route">Fast</option></select>
<button class="btn primary" id="poseGo">Move ➜</button></div>
<div class="row"><button class="btn grow" id="waveBtn">Wave</button></div>
</div>
<div class="card box">
<h3>Quick actions</h3>
<div class="qa"><button class="btn primary" id="waveBtn">Wave</button><button class="btn" id="tuckBtn">Fold arm</button></div>
<div class="field"><input type="text" id="sayText" placeholder="Say something (EN / 한국어)"><button class="btn" id="sayBtn" title="Say it aloud">Say</button></div>
<div class="field"><input type="text" id="askText" placeholder="Ask Lumi a question"><button class="btn" id="askBtn" title="Ask Lumi">Ask</button></div>
<div class="answer" id="answer"></div>
@@ -357,6 +356,7 @@ input[type=color]{width:30px;height:28px;border:1px solid var(--line);border-rad
<script>
const $ = id => document.getElementById(id);
let status = null, mapInfo = null;
const MAP_POLL_MS = 20000; // the marker list is read again this often
function toast(msg, kind = "") {
if (kind === "err") return note(msg);
@@ -549,14 +549,17 @@ $("headCentre").onclick = e => act(e.target, null, () => api("/head/turn", {yaw:
/* ---------- map ---------- */
const cv = $("map"), ctx = cv.getContext("2d");
let mapLayer = null, view = null, drag = null; // view: {s: screen px per map px, x0, y0: map px at the canvas corner}
function paintMarkers() {
$("mapName").textContent = mapInfo.map_name; $("mapTag").textContent = mapInfo.map_name;
markerNames = mapInfo.markers.filter(m => m.name !== mapInfo.main_dock).map(m => m.name) // further docks too
.sort((x, y) => x.localeCompare(y, undefined, {numeric: true}));
destDD.setItems(markerNames);
renderMapList();
}
async function loadMap() {
try {
mapInfo = await api("/map/info");
$("mapName").textContent = mapInfo.map_name; $("mapTag").textContent = mapInfo.map_name;
markerNames = mapInfo.markers.filter(m => m.name !== mapInfo.main_dock).map(m => m.name) // further docks too
.sort((x, y) => x.localeCompare(y, undefined, {numeric: true}));
destDD.setItems(markerNames);
renderMapList();
paintMarkers();
const img = new Image();
img.onload = () => { mapLayer = recolor(img); view = null; drawMap(); };
img.src = "/map/image?t=" + Date.now();
@@ -664,6 +667,16 @@ $("maplist").onclick = e => {
.then(() => setTimeout(loadMap, 8000));
};
loadMap();
const sameMap = (a, b) => ["map_name", "floor", "width", "height", "resolution", "origin_x", "origin_y"].every(k => a[k] === b[k]);
setInterval(async () => { // markers added on the base, a map switched there: seen within MAP_POLL_MS
if (!mapInfo) return loadMap();
try {
const m = await api("/map/info");
if (!sameMap(m, mapInfo)) return loadMap();
if (JSON.stringify(m) === JSON.stringify(mapInfo)) return;
mapInfo = m; paintMarkers(); drawMap();
} catch (e) {}
}, MAP_POLL_MS);
/* ---------- actions ---------- */
function Dropdown(el, placeholder) { // styled multi-select: click stops in the order to visit them
@@ -728,9 +741,7 @@ $("goBtn").onclick = e => {
$("dockBtn").onclick = e => act(e.target, "Driving to the dock", () => api("/agv/go", {marker: "home"}));
$("cancelBtn").onclick = e => act(e.target, "Drive cancelled", () => api("/agv/cancel", {}));
$("waveBtn").onclick = e => act(e.target, "Waving", () => api("/arm/wave", {}));
const tuck = e => { if (confirm("Fold the arm to the drive pose (slow)?")) act(e.target, "Folding the arm", () => api("/arm/tuck", {})); };
$("tuckBtn").onclick = tuck;
const POSE_ORDER = ["look", "carry", "ready", "give", "tuck"]; // the rest (taught later) follow by name
const POSE_ORDER = ["look", "carry", "give", "ready", "wave_out", "wave_start", "wave"]; // the rest (taught later) follow by name
api("/arm/poses").then(ps => {
const names = Object.keys(ps).sort((a, b) => ((POSE_ORDER.indexOf(a) + 1) || 99) - ((POSE_ORDER.indexOf(b) + 1) || 99) || a.localeCompare(b));
$("poseSel").innerHTML = names.map(n => `<option>${esc(n)}</option>`).join("");
+6 -10
View File
@@ -100,7 +100,7 @@ def start_assistant(no_arm=False, no_drive=False):
BUSY_FILE = Path("/dev/shm/lumi_busy.json") # written by lumi.py: {"busy": skill | follow | drive | wave | null}
BUSY_MSG = "Busy with a task. Pause or stop it first."
_waving = threading.Event() # /arm/wave runs here
_posing = threading.Event() # /arm/pose, /arm/tuck run here
_posing = threading.Event() # /arm/pose runs here
def running_now():
@@ -359,7 +359,8 @@ def body_move(body: BodyBody):
(round(p, 2) for p in head.status())))}
@app.post("/arm/wave", tags=["arm"], summary="Wave from look along the checked route (manipulation/wave.py, slow)")
@app.post("/arm/wave", tags=["arm"], summary="Wave, checked first (manipulation/wave.py): look -> wave_out -> "
"wave_start, the swings, stays at wave_start")
def arm_wave():
robot_free(manual=True)
_waving.set()
@@ -756,11 +757,6 @@ def arm_run(body: ProgramBody):
return {"ok": True, "program": body.program}
@app.post("/arm/tuck", tags=["arm"], summary="Fold the arm beside the column along the pose graph (slow)")
def arm_tuck():
return arm_pose(PoseBody(name="tuck"))
class PoseBody(BaseModel):
name: str = Field(examples=["look"], description="a pose of the pose graph (manipulation/arm_route.py)")
speed: str = Field(arm_route.SPEED, description="slow / normal / route (empty hand; holding: always slow)")
@@ -785,9 +781,9 @@ def _motion(fn, *args, **kw):
raise HTTPException(409, str(e))
@app.get("/arm/poses", tags=["arm"], summary="Named arm poses (deg): tuck + taught ones")
@app.get("/arm/poses", tags=["arm"], summary="The taught poses of the pose graph (deg)")
def arm_poses():
return motion.poses()
return arm_route.graph()
@app.post("/arm/pose", tags=["arm"], summary="Go to a named pose along the pose graph (every joint move checked first; "
@@ -795,7 +791,7 @@ def arm_poses():
def arm_pose(body: PoseBody):
if body.speed not in motion.JOINT_SPEED:
raise HTTPException(400, f"speed: {', '.join(motion.JOINT_SPEED)}")
if body.name not in motion.poses():
if body.name not in arm_route.graph():
raise HTTPException(404, f"no pose {body.name}")
robot_free(manual=True)
_posing.set()
+5 -3
View File
@@ -1520,7 +1520,7 @@ class Lumi:
self.keep_listening()
def arm_pose(self, target):
"""'reach': the Cobo π program ARM_REACH_PROGRAM (record it once), only from look; 'fold': tuck along the
"""'reach': the Cobo π program ARM_REACH_PROGRAM (record it once), only from look; 'fold': to look 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"):
@@ -1530,7 +1530,7 @@ class Lumi:
try:
if target == "fold":
holding = self.fetch_status() == "holding"
seq = arm_route.plan("tuck", holding=holding)
seq = arm_route.plan(arm_route.HOME, holding=holding)
threading.Thread(target=safe, args=(arm_route.move, seq, None, holding), daemon=True).start()
else:
arm_route.start_program(ARM_REACH_PROGRAM)
@@ -1999,7 +1999,9 @@ class Lumi:
mouth.say(done[target][0] if en else done[target][1])
ok = self.arm_pose(target)
if ok:
if target not in done:
if target == "fold":
mouth.say("Okay." if en else "네.")
elif target not in done:
mouth.say("Here you go." if en else "여기요.")
elif ok is False:
mouth.say("Sorry, I haven't learned that arm movement yet." if en else "죄송해요, 그 팔 동작은 아직 못 배웠어요.")
+4 -4
View File
@@ -2,8 +2,8 @@
moves.
give - carry - look - wave_out - wave_start - wave
| \\
ready tuck
|
ready
`look` is where every arm action starts (picks and puts go out from it and come back to it, skills.py). From any
pose of the graph the arm goes to another along the graph, one joint move per edge. An arm at no pose (after free
@@ -36,7 +36,7 @@ from vision import calib, head_cam
HOME = "look" # every arm action starts here
EDGES = (("give", "carry"), ("carry", "look"), ("look", "wave_out"), ("wave_out", "wave_start"),
("wave_start", "wave"), ("look", "ready"), ("look", "tuck")) # the only joint moves between named poses (both ways)
("wave_start", "wave"), ("look", "ready")) # the only joint moves between named poses (both ways)
SPEED = "route" # motion.JOINT_SPEED of the moves along the graph, empty hand
HOLD_SPEED = "slow" # ... with something in the hand
AT_POSE_DEG = 3.0 # deg; the arm is at a pose when every joint is this close (where, programs)
@@ -44,7 +44,7 @@ EXACT_DEG = 1.0 # deg; further than this from the nearest p
JOIN_DEG = 20.0 # deg; an arm at no pose joins the graph only this close to one (every joint)
PATH_POINTS = 21 # points checked (kine_forward) on every joint move
HEAD_CLEAR_MM = 250.0 # mm the gripper keeps from the head's turning centre. Estimate: the head camera
# is 102 mm from it, the head's size is not measured. `look` keeps 327 mm, tuck 266
# is 102 mm from it, the head's size is not measured. `look` keeps 327 mm
NEVER_RUN = ("hand_shaking.jks",) # Cobo π programs not started any more
# Why the arm does not move, (English, Korean)
+4 -8
View File
@@ -23,7 +23,6 @@ from robot import arm
ROOT = Path(__file__).resolve().parents[1] # the project folder
POSES_FILE = ROOT / "data" / "arm_poses.json"
TUCK = [179.3, -88.6, -13.9, -15.8, -14.5, -121.3] # deg, arm folded beside the column (fits doorways)
LIMITS = [360, 125, 130, 360, 120, 360] # deg, ± factory range per joint (docs/01_HARDWARE.md)
LIMIT_MARGIN = 5.0 # deg kept away from every limit
JOINT_SPEED = {"slow": 10.0, "normal": 25.0, "route": 40.0} # deg/s; route: empty-hand pose-graph moves (estimate)
@@ -73,20 +72,17 @@ def tcp():
def poses():
"""Named poses: tuck plus everything taught."""
"""Named poses: everything taught."""
try:
taught = json.loads(POSES_FILE.read_text())
return json.loads(POSES_FILE.read_text())
except FileNotFoundError:
taught = {}
return {"tuck": TUCK, **taught}
return {}
def teach(name):
"""Save the current joints as pose `name`."""
if name == "tuck":
raise MotionError("tuck is fixed in motion.py")
check(j := [round(v, 2) for v in joints()])
taught = {k: v for k, v in poses().items() if k != "tuck"}
taught = poses()
taught[name] = j
POSES_FILE.write_text(json.dumps(taught, indent=1))
return j
+2 -2
View File
@@ -2238,8 +2238,8 @@ def _arm(pose):
skills._held.clear()
_set(holding=False)
log(f"gripper {pose}: {st}")
elif pose == "fold":
_pose("tuck")
elif pose == "fold": # the arm's home
_pose(LOOK_POSE)
elif pose == "reach": # the hand held out, as for a hand-over
if "give" not in motion.poses():
raise FetchError("I haven't learned how to reach out yet.")
+3 -3
View File
@@ -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
View File
@@ -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),
+1 -1
View File
@@ -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"]),
+35
View File
@@ -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
View File
@@ -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 ----