--- waypoint_streaming_replay.py.bak_gripstate 2026-10-19 20:05:28.534634122 +0900 +++ waypoint_streaming_replay.py 2026-10-19 20:05:28.210634137 +0900 @@ -54,6 +54,8 @@ FIRST_MOVE_SETTLE_SEC = 3.0 # 先頭姿勢に着いたあとの待ち GRIPPER_SPEED = 50 # set_gripper_state の速度(v2 と同値) GRIPPER_DWELL_SEC = 1.5 # 把持/離し後の待ち(v2 と同値) +GRIP_VALUE = 20 # close の押し込み保持目標値。run_pick_place.py(DAY261)と同値。 + # set_gripper_state(1) は位置で止まり握り続けないため運搬中に抜ける(DAY259。2026-10-18 の再生でも再確認) STREAM_INTERVAL_SEC = 0.1 # ストリーミング 1 tick の周期(v2 interval_sec と同値) # 軌道合成:tick あたり最大 STEP_DEG_PER_TICK° まで進める線形補間。 @@ -171,9 +173,13 @@ for s in seq: if s["kind"] == "gripper": n_grippers += 1 - state = 0 if s["action"] == "open" else 1 - print(" [STEP {:>2}] GRIPPER {} set_gripper_state({}, {}) + sleep({:.1f}s)".format( - step_no, s["action"].upper(), state, GRIPPER_SPEED, GRIPPER_DWELL_SEC)) + # close は押し込み保持(set_gripper_value)、open は従来どおり state(0) + if s["action"] == "close": + cmd_str = "set_gripper_value({}, {})".format(GRIP_VALUE, GRIPPER_SPEED) + else: + cmd_str = "set_gripper_state(0, {})".format(GRIPPER_SPEED) + print(" [STEP {:>2}] GRIPPER {} {} + sleep({:.1f}s)".format( + step_no, s["action"].upper(), cmd_str, GRIPPER_DWELL_SEC)) else: print(" [STEP {:>2}] MOVE → {} segment {} → {}".format( step_no, s["to_name"], s["from_name"], s["to_name"])) @@ -309,13 +315,23 @@ for s in seq: if s["kind"] == "gripper": action = s["action"] - state = 1 if action == "close" else 0 - print("[STEP {:>2}] GRIPPER {} → set_gripper_state({}, {})".format( - step_no, action.upper(), state, GRIPPER_SPEED)) + # DAY261: close は set_gripper_value(GRIP_VALUE) で押し込み保持に切替 + # (閉じ切り state(1) は位置で止まり運搬中に抜ける・DAY259)。 + # open は従来どおり set_gripper_state(0)。 + is_close = (action == "close") + if is_close: + cmd_str = "set_gripper_value({}, {})".format(GRIP_VALUE, GRIPPER_SPEED) + else: + cmd_str = "set_gripper_state(0, {})".format(GRIPPER_SPEED) + print("[STEP {:>2}] GRIPPER {} → {}".format( + step_no, action.upper(), cmd_str)) try: - mc.set_gripper_state(state, GRIPPER_SPEED) + if is_close: + mc.set_gripper_value(GRIP_VALUE, GRIPPER_SPEED) + else: + mc.set_gripper_state(0, GRIPPER_SPEED) except Exception as e: - print("[WPSR] [WARN] set_gripper_state で例外: {}".format(e)) + print("[WPSR] [WARN] {} で例外: {}".format(cmd_str, e)) print("[STEP {:>2}] gripper dwell {}s(v2 play と同値)".format( step_no, GRIPPER_DWELL_SEC)) time.sleep(GRIPPER_DWELL_SEC)