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
+6 -16
View File
@@ -147,8 +147,6 @@ input[type=color]{width:30px;height:28px;border:1px solid var(--line);border-rad
.mapitem span{flex:1}
.log{background:#04060a;border:1px solid var(--line);border-radius:9px;padding:9px 11px;height:calc(100vh - 430px);min-height:220px;overflow:auto;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:#b7c3d0;white-space:pre-wrap}
.note{font-size:12px;color:var(--muted);margin-top:6px}
#toast{position:fixed;left:50%;transform:translateX(-50%);bottom:16px;z-index:60;max-width:min(460px,calc(100vw - 32px));background:var(--panel2);border:1px solid var(--line);border-left:4px solid var(--bad);border-radius:10px;padding:9px 14px;box-shadow:0 8px 24px rgba(0,0,0,.45);display:none}
#toast.on{display:block;animation:in .2s}
@keyframes in{from{transform:translateY(8px);opacity:0}}
/* command dialog */
.modal{position:fixed;inset:0;z-index:45;background:rgba(0,0,0,.55);display:none;place-items:center;padding:16px}
@@ -350,20 +348,12 @@ input[type=color]{width:30px;height:28px;border:1px solid var(--line);border-rad
</div>
</div>
</div>
<div id="toast"></div>
<script>
const $ = id => document.getElementById(id);
let status = null, mapInfo = null;
const MAP_POLL_MS = 20000; // the marker list is read again this often
const TOAST_MS = 4000; // an error stays on screen this long
let toastTimer = 0;
function toast(msg) { // errors and refusals only; a new one replaces the old
note(msg);
const t = $("toast"); t.textContent = msg; t.classList.add("on");
clearTimeout(toastTimer); toastTimer = setTimeout(() => t.classList.remove("on"), TOAST_MS);
}
async function api(path, body) {
const r = await fetch(path, {method: body === undefined ? "GET" : "POST", headers: {"Content-Type": "application/json"},
body: body === undefined ? undefined : JSON.stringify(body)});
@@ -373,7 +363,7 @@ async function api(path, body) {
}
async function act(btn, fn) {
const old = btn && btn.innerHTML; if (btn) { btn.disabled = true; btn.textContent = "…"; }
try { return await fn(); } catch (e) { toast(e.message); }
try { return await fn(); } catch (e) { note(e.message); }
finally { if (btn) { btn.disabled = false; btn.innerHTML = old; } refreshStatus(); }
}
const fmt = (v, d = 0) => v === undefined || v === null ? "–" : (+v).toFixed(d);
@@ -518,8 +508,8 @@ function holdStart(btn) {
holdStop(true);
const axis = btn.dataset.axis, dir = +btn.dataset.dir;
btn.classList.add("on");
const send = () => api("/jog", {axis, direction: dir, speed: speedOf(axis)}).then(r => { if (r.error) toast(r.error); })
.catch(e => { toast(e.message); holdStop(); });
const send = () => api("/jog", {axis, direction: dir, speed: speedOf(axis)}).then(r => { if (r.error) note(r.error); })
.catch(e => { note(e.message); holdStop(); });
send(); holding = {btn, timer: setInterval(send, 150)};
}
function holdStop(silent) {
@@ -735,7 +725,7 @@ const destDD = Dropdown($("destDD"), "Choose one or more places…");
function selectDest(name) { destDD.set(name); }
$("goBtn").onclick = e => {
const stops = destDD.values, name = n => n === "home" ? "the dock" : n;
if (!stops.length) return toast("Choose a place first");
if (!stops.length) return note("Choose a place first");
if (stops.length === 1) return act(e.target, () => api("/agv/go", {marker: stops[0]}));
act(e.target, () => api("/agv/route", {markers: stops, pause: +$("pause").value || 0}));
};
@@ -764,7 +754,7 @@ $("askBtn").onclick = async e => {
$("askText").onkeydown = e => { if (e.key === "Enter") $("askBtn").click(); };
api("/volume").then(v => { $("vol").value = v.percent; $("volV").textContent = v.percent + " %"; });
$("vol").oninput = e => $("volV").textContent = e.target.value + " %";
$("vol").onchange = e => api("/volume", {percent: +e.target.value}).catch(x => toast(x.message));
$("vol").onchange = e => api("/volume", {percent: +e.target.value}).catch(x => note(x.message));
/* assistant modes: greeter (standing) and patrol (driving) */
let modes = {};
function paintModes(m) {
@@ -778,7 +768,7 @@ function paintModes(m) {
async function setModes(part, el) {
if (el) el.classList.add("busy");
try { paintModes(await api("/assistant/modes", part)); }
catch (e) { toast(e.message); }
catch (e) { note(e.message); }
finally { if (el) el.classList.remove("busy"); }
}
document.querySelectorAll(".mode").forEach(el => el.onclick = () => {