movel_z
Control robot movement along the Y-axis by specifying the robot's IP address and desired distance in meters for precise positioning.
Instructions
命令指定IP机器人的TCP沿Y轴方向移动 IP:机器人地址 distance:移动距离(米)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes | ||
| distance | Yes |
Implementation Reference
- The handler function for the 'movel_z' MCP tool. It connects to the UR robot at the given IP, retrieves the current TCP pose, adjusts the Z coordinate by the specified distance, executes a movel command, confirms the movement, and logs/generates a script representation of the command.@mcp.tool() def movel_z(ip: str, distance: float): """命令指定IP机器人的TCP沿Y轴方向移动 IP:机器人地址 distance:移动距离(米)""" try: if '连接失败' in link_check(ip): return return_msg(f"与机器人的连接已断开。") pose = robot_list[ip].get_actual_tcp_pose() pose[2] = pose[2] + distance robot_list[ip].movel(pose) time.sleep(1) result = movelConfirm(ip, pose) cmd = (f"def my_program():\n" f" movel(p[{'{:.4f}'.format(pose[0])},{'{:.4f}'.format(pose[1])},{'{:.4f}'.format(pose[2])},{'{:.4f}'.format(pose[3])},{'{:.4f}'.format(pose[4])},{'{:.4f}'.format(pose[5])},],0.5,0.25,0,0)\n" f"end\nmy_program()") logger.info(f"发送脚本:{cmd}") if result == 1: return return_msg(f"命令 {cmd} 已发送,移动完成。") else: return return_msg(f"命令 {cmd} 已发送,移动失败。") except Exception as e: logger.error(f"移动失败: {str(e)}") return return_msg(f"移动失败: {str(e)}")