movel
Send TCP position commands to Universal Robots collaborative robots for linear motion control. Specify robot IP, target pose, acceleration, velocity, duration, and blend radius 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
- MCP tool handler for 'movel': executes linear motion to a target TCP pose on the specified UR robot IP, sends the command via robot.movel, waits, and confirms arrival 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 to confirm if the robot has reached the target TCP pose after a movel command by polling position 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 function to check if current TCP pose matches target pose within 10mm tolerance, used in movelConfirm.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 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