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
+14
View File
@@ -7,10 +7,13 @@
import json
import socket
import sys
import time
import uuid
AGV = ("192.168.10.10", 31001)
DOCK_FALLBACK = "충전위치로" # dock marker name on the old map; on any map the type-11 marker is used
MARKERS_FRESH_S = 5.0 # known_markers() reads the list again after this long: a new map is seen within it
_known = {"t": 0.0, "names": []}
def request(command, timeout=3.0):
@@ -53,6 +56,17 @@ def markers():
return ["home" if n == dock else n for n in names]
def known_markers(fresh=False):
"""markers(), read again when older than MARKERS_FRESH_S or when fresh (a name was not on the list); the last
list while the base does not answer."""
if fresh or time.time() - _known["t"] > MARKERS_FRESH_S:
try:
_known.update(names=markers(), t=time.time())
except OSError: # ConnectionError and socket.timeout are OSErrors
pass
return _known["names"]
def go(marker):
"""Start driving to a marker. Returns (ok, message)."""
marker = (dock_marker() or DOCK_FALLBACK) if marker == "home" else marker
+4 -13
View File
@@ -1,7 +1,7 @@
"""Run a Cobo π program on the arm over the controller's TCP command port 10001 (no SDK).
"""The arm controller's TCP command port 10001 (JSON, no SDK): commands, Cobo π programs.
Programs are started through manipulation/arm_route.py (only from `look`).
python robot/arm.py # state
python robot/arm.py run # play hand_shaking.jks once and wait
python robot/arm.py stop
"""
import json
@@ -10,7 +10,6 @@ import sys
import time
CONTROLLER = ("192.168.10.90", 10001)
WAVE = "hand_shaking.jks"
# The controller now and then closes the connection without a reply (seen on get_data, get_program_state,
# kine_inverse, stop_program, moveL, set_digital_output). Commands that only read are asked again, and so are those
# that set an absolute value: moves to an absolute target (relFlag 0) and setting an output; sent twice they do the
@@ -59,7 +58,7 @@ def program_state():
return cmd("get_program_state").get("programState")
def start(program=WAVE):
def start(program):
"""Load (if needed) and start a program; returns at once."""
if (cmd("get_loaded_program").get("programName") or "").lower() != program.lower():
if cmd("load_program", programName=program).get("errorCode") != "0":
@@ -74,15 +73,7 @@ def stop():
if __name__ == "__main__":
what = sys.argv[1] if len(sys.argv) > 1 else "state"
if what == "run":
if not ready():
sys.exit("arm not ready (power/enable off, or a program is running)")
start()
time.sleep(0.5)
while program_state() != "idle":
time.sleep(0.3)
print("done")
elif what == "stop":
if what == "stop":
print(stop())
else:
print(cmd("get_robot_state"), program_state(), cmd("get_loaded_program").get("programName"))
+1 -3
View File
@@ -6,7 +6,7 @@ Every move is checked before it is sent: joint limits with a margin, and for lin
and return early with an error when STOP was pressed or the controller stopped the arm.
python robot/motion.py # joints, TCP, named poses
python robot/motion.py go tuck [normal] # move to a named pose (slow by default)
python manipulation/arm_route.py goto look # to a named pose: only along the pose graph, checked
python robot/motion.py teach ready # save the arm's current joints as a named pose (move it in Cobo π first)
python robot/motion.py line 0 0 30 # straight TCP move by dx dy dz mm (base frame), slow
python robot/motion.py stop
@@ -229,8 +229,6 @@ if __name__ == "__main__":
print("tcp ", [round(v, 1) for v in tcp()])
for k, v in poses().items():
print(f"pose {k:8s}", v)
elif a[0] == "go":
print(go(a[1], a[2] if len(a) > 2 else "slow"))
elif a[0] == "teach":
print(a[1], teach(a[1]))
elif a[0] == "line":