Arm moves only along checked poses; any marker name of the active map

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 16:54:22 +09:00
co-authored by Claude Opus 5.5
parent 775b32bc52
commit a50fdc9c0d
19 changed files with 880 additions and 277 deletions
+18 -4
View File
@@ -1,9 +1,11 @@
"""Run a Cobo π program on the Lumi arm over the controller's TCP command port (10001).
No JAKA SDK needed; works from any computer on the robot network.
No JAKA SDK needed; works from any computer on the robot network. A program starts only with the arm at `look`
(data/arm_poses.json, every joint within AT_LOOK_DEG), as on the robot (manipulation/arm_route.py); hand_shaking
never (it hit the head, 2026-10-21).
python3 tools/arm_program.py state # power/enable, loaded program, program state
python3 tools/arm_program.py run hand_shaking # load the program and play it once, wait until done
python3 tools/arm_program.py run arm_reach # load the program and play it once, wait until done
python3 tools/arm_program.py stop # stop the running program
Ctrl+C while a program runs stops it.
@@ -12,8 +14,12 @@ import json
import socket
import sys
import time
from pathlib import Path
CONTROLLER = ("192.168.10.90", 10001)
POSES_FILE = Path(__file__).resolve().parents[1] / "data" / "arm_poses.json"
AT_LOOK_DEG = 3.0 # deg; every joint this close to `look` (J1 / J4 / J6 also ± 360)
NEVER_RUN = ("hand_shaking.jks",)
def cmd(name, **args):
@@ -44,6 +50,14 @@ def run(program):
sys.exit(f"A program is {st['program']}; stop it first (python3 tools/arm_program.py stop).")
name = program if program.endswith(".jks") else program + ".jks"
if name.lower() in NEVER_RUN:
sys.exit(f"{name} is not used any more (it hit the head); the wave is manipulation/wave.py.")
look = json.loads(POSES_FILE.read_text())["look"]
now = cmd("get_joint_pos")["joint_pos"]
off = max(min(abs(n - l - k) for k in ((-360, 0, 360) if i in (0, 3, 5) else (0,)))
for i, (n, l) in enumerate(zip(now, look)))
if off > AT_LOOK_DEG:
sys.exit(f"The arm is {off:.0f} deg from look: programs start only from look.")
if (st["loaded"] or "").lower() != name.lower():
r = cmd("load_program", programName=name)
print("load_program:", r.get("errorCode"), r.get("errorMsg"))
@@ -65,14 +79,14 @@ def run(program):
def main():
if len(sys.argv) < 2 or sys.argv[1] not in ("state", "run", "stop"):
if len(sys.argv) < 2 or sys.argv[1] not in ("state", "run", "stop") or sys.argv[1] == "run" and len(sys.argv) < 3:
sys.exit(__doc__)
if sys.argv[1] == "state":
print(state())
elif sys.argv[1] == "stop":
print("stop_program:", cmd("stop_program"))
else:
run(sys.argv[2] if len(sys.argv) > 2 else "hand_shaking")
run(sys.argv[2])
if __name__ == "__main__":