movel_z
Control TCP movement along the Y-axis of a Universal Robot by specifying the IP address and desired distance in meters using the nUR MCP Server.
Instructions
命令指定IP机器人的TCP沿Y轴方向移动 IP:机器人地址 distance:移动距离(米)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| distance | Yes | ||
| ip | Yes |
Implementation Reference
- The handler function for the 'movel_z' tool. Decorated with @mcp.tool() for registration. Moves the robot TCP along the Z-axis (pose[2]) by the given distance, confirms execution, and returns status.@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) result = movelConfirm(ip, pose) cmd = 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)" 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)}")
- Helper function to confirm if the movel movement reached the target pose accurately.def movelConfirm(ip, pose): """ movel移动的结果确认 1:移动到位 2:移动结束,但是位置不准确 """ loop_flg = True count = 0 while loop_flg: time.sleep(1) current_pose = round_pose(robot_list[ip].get_actual_tcp_pose()) if right_pose_tcp(current_pose, pose): robot_list[ip].robotConnector.DashboardClient.ur_running() running = robot_list[ip].robotConnector.DashboardClient.last_respond if running == 'Program running: false': return 1 else: robot_list[ip].robotConnector.DashboardClient.ur_running() running = robot_list[ip].robotConnector.DashboardClient.last_respond if running == 'Program running: true': '''尚未移动完成''' continue else: '''移动完成''' count = count + 1 if count > 5: return 2