movel
Send TCP position commands to Universal Robots to move the tool center point linearly to specified coordinates with adjustable speed, acceleration, and blending parameters.
Instructions
发送新的TCP位置到指定IP的机器人,使TCP移动到指定位置,移动期间TCP作直线移动。 IP:机器人地址 pose:TCP位置 a:加速度(米每平方秒) v:速度(米每秒) t:移动时长(秒) r:交融半径(米)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes | ||
| pose | Yes | ||
| a | No | ||
| v | No | ||
| t | No | ||
| r | No |
Implementation Reference
- The primary handler for the MCP 'movel' tool. It connects to the robot, sends the movel command via robot_list[ip].movel(), waits, and confirms completion using movelConfirm.@mcp.tool() def movel(ip: str, pose: list, a=1, v=1, t=0, r=0): """发送新的TCP位置到指定IP的机器人,使TCP移动到指定位置,移动期间TCP作直线移动。 IP:机器人地址 pose:TCP位置 a:加速度(米每平方秒) v:速度(米每秒) t:移动时长(秒) r:交融半径(米)""" try: if '连接失败' in link_check(ip): return return_msg(f"与机器人的连接已断开。") cmd = f"movel(p{pose},{a},{v},{t},{r})" logger.info(f"发送脚本:{cmd}") robot_list[ip].movel(pose, a, v, t, r) time.sleep(1) result = movelConfirm(ip, pose) if result == 1: return return_msg(f"命令 {cmd} 已发送,移动完成。") else: return return_msg(f"命令 {cmd} 已发送,移动失败。") except Exception as e: logger.error(f"发送新的TCP位置到指定IP的机器人失败: {str(e)}") return return_msg(f"发送新的TCP位置到指定IP的机器人: {str(e)}")
- Helper function called by the movel handler to verify if the robot has reached the target TCP pose after the move, checking position accuracy and program state.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
- Helper utility used in movelConfirm to check if current TCP pose matches target within 10mm tolerance on X,Y,Z.def right_pose_tcp(current_pose_1, pose): """tcp位置是否一致的校验,这里允许10mm的误差""" if pose[0] + 0.010 >= current_pose_1[0] >= pose[0] - 0.010: if pose[1] + 0.010 >= current_pose_1[1] >= pose[1] - 0.010: if pose[2] + 0.010 >= current_pose_1[2] >= pose[2] - 0.010: return True return False
- Helper to round pose coordinates to 3 decimal places, used in movelConfirm for comparison.def round_pose(pose): """给坐标取近似值,精确到三位小数""" pose[0] = round(pose[0], 3) pose[1] = round(pose[1], 3) pose[2] = round(pose[2], 3) pose[3] = round(pose[3], 3) pose[4] = round(pose[4], 3) pose[5] = round(pose[5], 3) return pose
- src/nonead_universal_robots_mcp/server.py:579-579 (registration)The @mcp.tool() decorator registers the movel function as an MCP tool.@mcp.tool()