Files
2026-08-12 13:15:11 +09:00

62 lines
1.3 KiB
Python

from config import HOME
# The three moves the old firmware had baked in, rewritten as keyframes.
# They double as examples for the LLM and as an offline fallback.
PUSH = [
((50, 0, 0, 10), 300),
((50, 120, 60, 10), 300),
((50, 120, 60, 10), 2000),
(HOME, 1000),
]
SPIN = [
((50, 80, 60, 60), 300),
((180, 80, 60, 60), 1000),
((0, 80, 60, 60), 1350),
((180, 80, 60, 60), 1350),
((0, 80, 60, 60), 1350),
((180, 80, 60, 60), 1350),
((50, 80, 60, 60), 1000),
((50, 80, 60, 60), 2000),
(HOME, 1000),
]
PENALTY = [
((50, 0, 0, 10), 300),
((50, 0, 0, 10), 500),
((50, 120, 0, 10), 150),
((50, 120, 0, 10), 2000),
(HOME, 1000),
]
GO_HOME = [(HOME, 1000)]
EXAMPLES = {
"push": PUSH,
"spin around": SPIN,
"penalty kick": PENALTY,
}
KEYWORDS = [
(("push",), "push", PUSH),
(("spin", "spend"), "spin", SPIN),
(("penalty", "kick"), "penalty", PENALTY),
(("home", "reset", "처음", "홈"), "home", GO_HOME),
]
STOP_WORDS = ("stop", "halt", "freeze", "정지", "멈춰", "스톱")
def is_stop(text):
t = text.lower()
return any(w in t for w in STOP_WORDS)
def match_keyword(text):
t = text.lower()
for words, label, steps in KEYWORDS:
if any(w in t for w in words):
return label, steps
return None