Turn the waist with the arm on a hand-over, recover stopped picks and improve follow tracking

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-29 15:55:03 +09:00
co-authored by Claude Opus 5.5
parent 390ec9db99
commit e8d651da49
24 changed files with 728 additions and 200 deletions
+3 -5
View File
@@ -253,8 +253,7 @@ input[type=color]{width:30px;height:28px;border:1px solid var(--line);border-rad
<small>Standing: greets people who come close, talks, answers "Hi Lumi"</small></div><div class="switch"></div></div>
<div class="mode" id="modePatrol" data-mode="patrol"><div class="txt"><b>Patrol</b>
<small>Driving: stops for people on the way, talks, then drives on</small></div><div class="switch"></div></div>
<div class="opts" style="margin:8px 0 0"><label class="toggle"><input type="checkbox" id="useArm" checked> Wave when asked</label>
<label class="toggle"><input type="checkbox" id="useDrive" checked> Come when called</label></div>
<div class="opts" style="margin:8px 0 0"><label class="toggle"><input type="checkbox" id="useArm" checked> Wave when asked</label></div>
</div>
</div>
</main>
@@ -760,7 +759,7 @@ let modes = {};
function paintModes(m) {
modes = m;
$("modeGreeter").classList.toggle("on", !!m.greeter); $("modePatrol").classList.toggle("on", !!m.patrol);
$("useArm").checked = m.wave !== false; $("useDrive").checked = m.drive !== false;
$("useArm").checked = m.wave !== false;
const on = [m.greeter && "greeter", m.patrol && "patrol"].filter(Boolean);
$("asTag").textContent = on.length ? (m.running ? "● " : "starting… ") + on.join(" + ") : "off";
$("asTag").className = "tag " + (on.length && m.running ? "live" : "");
@@ -776,7 +775,6 @@ document.querySelectorAll(".mode").forEach(el => el.onclick = () => {
setModes({[k]: on}, el);
});
$("useArm").onchange = e => setModes({wave: e.target.checked});
$("useDrive").onchange = e => setModes({drive: e.target.checked});
api("/assistant/modes").then(paintModes);
setInterval(() => api("/assistant/modes").then(paintModes).catch(() => {}), 3000);
$("stopAll").onclick = e => { holdStop(); act(e.target, () => api("/stop", {})); };
@@ -854,7 +852,7 @@ async function refreshLog() {
const state = !st.running ? '<b style="color:var(--muted)">not running</b>' : st.stuck ? '<b style="color:var(--bad)">STUCK</b>'
: st.log_age_s > 90 ? '<b style="color:var(--warn)">quiet (no log for ' + Math.round(st.log_age_s) + ' s)</b>' : '<b style="color:var(--ok)">running</b>';
$("stat").innerHTML = `<span>Assistant</span><div>${state}${st.pids.length ? " · pid " + st.pids.join(", ") : ""}</div>
<span>Modes</span><div>greeter ${st.modes.greeter ? "on" : "off"} · patrol ${st.modes.patrol ? "on" : "off"} · wave ${st.modes.wave ? "on" : "off"} · come ${st.modes.drive ? "on" : "off"}</div>
<span>Modes</span><div>greeter ${st.modes.greeter ? "on" : "off"} · patrol ${st.modes.patrol ? "on" : "off"} · wave ${st.modes.wave ? "on" : "off"}</div>
<span>Uptime</span><div>${up}</div><span>Cameras</span><div>${st.camera_service ? cams : '<b style="color:var(--bad)">camera service not running</b>'}</div>
${task ? `<span>Task</span><div><b style="color:var(--${task.status === "failed" ? "bad" : task.status === "running" ? "ok" : "muted"})">${esc(task.status)}</b>${task.step ? " · " + esc(task.step) : ""}${task.holding ? " · holding" : ""}</div>` : ""}
<span>Last line</span><div style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis">${esc((robot ? lg.lines.slice(-1)[0] : st.last_line) || "–")}</div>`;
+7 -8
View File
@@ -69,12 +69,13 @@ def assistant_pids():
MODES_FILE = Path("/dev/shm/lumi_modes.json")
CMD_FILE = Path("/dev/shm/lumi_cmd.json")
CALIB_FILE = Path("/dev/shm/lumi_calib.json")
DEFAULT_MODES = {"greeter": False, "patrol": False, "wave": True, "drive": True}
DEFAULT_MODES = {"greeter": False, "patrol": False, "wave": True}
def read_modes():
try:
return {**DEFAULT_MODES, **json.loads(MODES_FILE.read_text())}
d = json.loads(MODES_FILE.read_text())
return {k: d.get(k, v) for k, v in DEFAULT_MODES.items()} # keys no longer used (e.g. "drive") are dropped
except (FileNotFoundError, ValueError):
return dict(DEFAULT_MODES)
@@ -86,10 +87,10 @@ def send_to_assistant(cmd, **args):
os.replace(tmp, CMD_FILE)
def start_assistant(no_arm=False, no_drive=False):
def start_assistant(no_arm=False):
if assistant_pids():
return None
args = [str(VENV_PY), str(ROOT / "assistant" / "lumi.py")] + ["--no-arm"] * no_arm + ["--no-drive"] * no_drive
args = [str(VENV_PY), str(ROOT / "assistant" / "lumi.py")] + ["--no-arm"] * no_arm
log = open(CONSOLE_LOG, "a")
log.write(f"\n===== {time.strftime('%Y-%m-%d %H:%M:%S')} start: {' '.join(args[1:])}\n")
log.flush()
@@ -214,7 +215,6 @@ class StartBody(BaseModel):
once: bool = Field(True, description="drive the route once (true) or loop it forever (false)")
pause: float = Field(1.0, ge=0, le=60, description="seconds to wait at each marker")
no_arm: bool = False
no_drive: bool = False
# ---------- status ----------
@@ -420,7 +420,7 @@ def assistant_start(body: StartBody):
if unknown:
raise HTTPException(400, f"unknown markers {unknown}; markers: {names}")
args += ["--patrol", body.patrol, "--pause", str(body.pause)] + ["--once"] * body.once
args += ["--no-arm"] * body.no_arm + ["--no-drive"] * body.no_drive
args += ["--no-arm"] * body.no_arm
log = open(CONSOLE_LOG, "a")
log.write(f"\n===== {time.strftime('%Y-%m-%d %H:%M:%S')} start: {' '.join(args[1:])}\n")
log.flush()
@@ -1390,10 +1390,9 @@ class ModesBody(BaseModel):
greeter: bool | None = Field(None, description="standing: greet people who come close, talk, wake word")
patrol: bool | None = Field(None, description="driving anywhere: stop for people in the way, talk, drive on")
wave: bool | None = Field(None, description="wave when asked")
drive: bool | None = Field(None, description='allow "come here" and voice "go to"')
@app.get("/assistant/modes", tags=["assistant"], summary="Greeter / patrol / wave / drive switches")
@app.get("/assistant/modes", tags=["assistant"], summary="Greeter / patrol / wave switches")
def modes_get():
return {**read_modes(), "running": bool(assistant_pids())}