Add hand-raised patrol routes with greeting stops and round counts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+3
-1
@@ -229,6 +229,8 @@ input[type=color]{width:30px;height:28px;border:1px solid var(--line);border-rad
|
||||
<div class="card box">
|
||||
<h3>Go to</h3>
|
||||
<div class="row"><div class="dd" id="destDD"></div><button class="btn primary" id="goBtn">Go ➜</button></div>
|
||||
<div class="opts"><label class="toggle"><input type="checkbox" id="loop"> Loop</label>
|
||||
<label class="toggle"><input type="number" id="rounds" value="0" min="0" max="99" style="width:56px"> times (0 = ∞)</label></div>
|
||||
<div class="row"><button class="btn grow" id="dockBtn">⌂ Dock</button><button class="btn danger grow" id="cancelBtn">Cancel drive</button></div>
|
||||
</div>
|
||||
|
||||
@@ -726,7 +728,7 @@ $("goBtn").onclick = e => {
|
||||
const stops = destDD.values, name = n => n === "home" ? "the dock" : n;
|
||||
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}));
|
||||
act(e.target, () => api("/agv/route", {markers: stops, pause: +$("pause").value || 0, loop: $("loop").checked, rounds: +$("rounds").value || 0}));
|
||||
};
|
||||
$("dockBtn").onclick = e => act(e.target, () => api("/agv/go", {marker: "home"}));
|
||||
$("cancelBtn").onclick = e => act(e.target, () => api("/agv/cancel", {}));
|
||||
|
||||
+6
-1
@@ -281,6 +281,9 @@ def go(body: GoBody):
|
||||
class RouteBody(BaseModel):
|
||||
markers: list[str] = Field(examples=[["p1", "p3", "home"]], min_length=1)
|
||||
pause: float = Field(1.0, ge=0, le=60, description="seconds to wait at each marker")
|
||||
loop: bool = Field(False, description="there and back again (a, b, c, b, a, ...); needs the assistant "
|
||||
"(Greeter / Patrol on)")
|
||||
rounds: int = Field(0, ge=0, le=99, description="with loop: this many times there and back, 0 = until stopped")
|
||||
|
||||
|
||||
class RouteRunner:
|
||||
@@ -333,8 +336,10 @@ def go_route(body: RouteBody):
|
||||
if unknown:
|
||||
raise HTTPException(400, f"unknown markers {unknown}; markers: {names}")
|
||||
if assistant_pids():
|
||||
send_to_assistant("route", markers=body.markers, pause=body.pause)
|
||||
send_to_assistant("route", markers=body.markers, pause=body.pause, loop=body.loop, rounds=body.rounds)
|
||||
return {"ok": True, "route": body.markers, "by": "assistant"}
|
||||
if body.loop:
|
||||
raise HTTPException(409, SWITCHES_OFF)
|
||||
held_to_look()
|
||||
_route.start(body.markers, body.pause)
|
||||
return {"ok": True, "route": body.markers, "by": "api"}
|
||||
|
||||
Reference in New Issue
Block a user