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
+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()