Keep drive log distances current after markers change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-03 18:48:33 +09:00
co-authored by Claude Opus 5.5
parent d0606c2426
commit 87832a5d5b
+5 -9
View File
@@ -71,18 +71,14 @@ class DriveLog:
def marker_positions(): def marker_positions():
"""f(name) -> (x, y) of a marker on the current map; re-read when a name is not known yet.""" """f(name) -> (x, y) of a marker on the current map, read on every call (a marker moved or a new map applies at
cache = {} once; called only per log line)."""
def xy(name): def xy(name):
if name not in cache:
try: try:
for n, m in (agv.request("/api/markers/query_list").get("results") or {}).items(): m = (agv.request("/api/markers/query_list").get("results") or {}).get(name)
cache[n] = (m["pose"]["position"]["x"], m["pose"]["position"]["y"]) return (m["pose"]["position"]["x"], m["pose"]["position"]["y"]) if m else None
except (ConnectionError, OSError, KeyError): except (ConnectionError, OSError, KeyError):
pass return None
cache.setdefault(name, None) # a map point's generated name: no marker
return cache[name]
return xy return xy