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."""