us final version

This commit is contained in:
2026-08-12 13:15:11 +09:00
commit 75e9bb8cf4
10 changed files with 947 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
import os
from dataclasses import dataclass
from pathlib import Path
from dotenv import load_dotenv
load_dotenv(Path(__file__).with_name(".env"))
@dataclass(frozen=True)
class Servo:
key: str
name: str
role: str
home: int
lo: int = 0
hi: int = 180
# Keep lo/hi in sync with LIMITS in robot_arm.ino
SERVOS = (
Servo("s1", "base", "rotates the whole arm left/right; lower = right, higher = left", home=50),
Servo("s2", "shoulder", "lifts the arm forward; 0 = folded back, 120 = reaching far out", home=0),
Servo("s3", "elbow", "bends the forearm; 140 = tucked in, 0 = fully extended", home=140),
Servo("s4", "wrist", "tilts the tip up/down", home=10),
)
HOME = tuple(s.home for s in SERVOS)
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY", "")
OPENAI_MODEL = os.getenv("OPENAI_MODEL", "gpt-5-mini")
OPENAI_REASONING_EFFORT = os.getenv("OPENAI_REASONING_EFFORT", "")
STT_LANGUAGE = os.getenv("STT_LANGUAGE", "en-US")
BAUD_RATE = int(os.getenv("BAUD_RATE", "9600"))
def clamp_pose(pose):
return tuple(max(s.lo, min(s.hi, int(round(a)))) for s, a in zip(SERVOS, pose))