Wave swings back to back, gentler joint acceleration

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 18:19:17 +09:00
co-authored by Claude Opus 5.5
parent 9864344307
commit 417bfcade7
4 changed files with 60 additions and 20 deletions
+22 -3
View File
@@ -160,10 +160,12 @@ class QueueArm(FakeArm):
self.on_poll()
if self.queue:
self.j = self.queue.pop(0)
return {"joint_actual_position": list(self.j), "inpos": not self.queue}
return {"joint_actual_position": list(self.j), "inpos": getattr(self, "inpos_always", False) or not self.queue}
if name == "stop_program":
self.queue.clear()
return {"errorCode": "0"}
if name == "get_motion_state":
return {"queue": len(self.queue), "active_queue": len(self.queue), "errorCode": "0"}
return super().__call__(name, **a)
def moves(self):
@@ -178,7 +180,7 @@ fake = arm.cmd = QueueArm(POSES["look"])
assert arm_route.goto("wave_start") == ["wave_out", "wave_start"] and fake.j == POSES["wave_start"]
route = motion.JOINT_SPEED[arm_route.SPEED]
keys = {"relFlag", "jointPosition", "speed", "accel"} # no tol: never blended
assert fake.moves() == [(route, route * motion.ACCEL_FACTOR, keys)] * 2, fake.moves()
assert fake.moves() == [(route, route * motion.JOINT_ACCEL_FACTOR, keys)] * 2, fake.moves()
assert order(fake) == ["joint_move", "get_data", "joint_move", "get_data"], order(fake)
arrived = [e for e in fake.log if e[0] == "get_data"][0][4]
second = [e for e in fake.log if e[0] == "joint_move"][1][4]
@@ -187,7 +189,7 @@ fake = arm.cmd = QueueArm(POSES["look"])
arm_route.goto("wave_start", holding=True)
hold = motion.JOINT_SPEED[arm_route.HOLD_SPEED]
assert order(fake) == ["joint_move", "get_data", "joint_move", "get_data"], order(fake)
assert fake.moves() == [(hold, hold * motion.ACCEL_FACTOR, keys)] * 2 and hold < route, fake.moves()
assert fake.moves() == [(hold, hold * motion.JOINT_ACCEL_FACTOR, keys)] * 2 and hold < route, fake.moves()
# STOP while a move is sent, while the arm runs it, or while it stands between two: stopped, nothing more sent
fake = arm.cmd = QueueArm(POSES["look"], on_move=lambda k: k == 1 and motion.stop())
@@ -215,6 +217,23 @@ except motion.MotionError as e:
motion.SETTLE_S = 0.05
# queued (the wave's swings): all sent before any poll, the wait ends only at the end with the queue empty, though
# the arm passes the last pose before (inpos there too)
a_, b_ = POSES["wave_start"], POSES["wave"]
fake = arm.cmd = QueueArm(a_)
fake.inpos_always = True
motion.move_path([(b_, "normal"), (a_, "normal"), (b_, "normal"), (a_, "normal")], queued=True)
assert order(fake)[:5] == ["joint_move"] * 4 + ["get_data"] and fake.queue == [] and fake.j == a_, order(fake)
assert order(fake).count("get_data") >= 4, order(fake)
fake = arm.cmd = QueueArm(a_, on_move=lambda k: k == 2 and motion.stop()) # STOP while they are sent
try:
motion.move_path([(b_, "normal"), (a_, "normal"), (b_, "normal"), (a_, "normal")], queued=True)
raise AssertionError("went on after STOP")
except motion.MotionError as e:
names = [e_[0] for e_ in fake.log]
assert str(e) == "stopped" and names[-1] == "stop_program" and fake.queue == [] and "get_data" not in names, names
class SlowArm(QueueArm):
"""Runs the queued moves at `deg_s` (wall clock), far below the speed asked; `stall_at`: stops there for good."""
+3 -3
View File
@@ -90,14 +90,14 @@ a.sent.clear()
a.j = list(swing) # stopped at wave: back to wave_start, then swings
wave.wave()
assert a.sent == [top] + [swing, top] * wave.SWINGS, a.sent
names = [] # every move to a stop, then the next; the way up
names = [] # the way up as goto, move by move; then the swings
arm.cmd = lambda name, **k: (names.append((name, k.get("speed"), "tol" in k)), a(name, **k))[1] # as goto
a.j = list(LOOK)
wave.wave()
sent = [e for e in names if e[0] in ("joint_move", "get_data")]
route, swing_s = motion.JOINT_SPEED[arm_route.SPEED], motion.JOINT_SPEED[wave.SWING_SPEED]
assert sent == [x for v in [route] * 2 + [swing_s] * 2 * wave.SWINGS
for x in (("joint_move", v, False), ("get_data", None, False))], sent
assert sent == [("joint_move", route, False), ("get_data", None, False)] * 2 + \
[("joint_move", swing_s, False)] * 2 * wave.SWINGS + [("get_data", None, False)], sent # swings back to back
assert wave.SWING_SPEED == "normal"
arm.cmd = a
a.j = list(top)