movel
Control TCP movement of Universal Robots by sending new positions via IP. Specify acceleration, speed, duration, and blend radius for precise linear motion control.
Instructions
发送新的TCP位置到指定IP的机器人,使TCP移动到指定位置,移动期间TCP作直线移动。 IP:机器人地址 pose:TCP位置 a:加速度(米每平方秒) v:速度(米每秒) t:移动时长(秒) r:交融半径(米)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | No | ||
| ip | Yes | ||
| pose | Yes | ||
| r | No | ||
| t | No | ||
| v | No |
Implementation Reference
- The main handler function for the MCP tool 'movel'. It connects to the UR robot, executes the linear move command using robot.movel(), confirms completion with movelConfirm, and returns status.@mcp.tool() def movel(ip: str, pose: dict, 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"与机器人的连接已断开。") robot_list[ip].movel(pose, a, v, t, r) result = movelConfirm(ip, pose) cmd = f"movel(p{pose},{a},{v},{t},{r})" 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 used by movel to confirm motion completion by polling TCP pose accuracy and program running status.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 to round pose coordinates to 3 decimal places, used in confirmation checks.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
- Helper to check if current TCP pose matches target within 10mm tolerance.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 check and establish robot connection if needed, used at start of movel.def link_check(ip): """检查连接状态,若连接断开或不存在,则建立连接""" if robot_list.get(ip, "unknown") == "unknown" or not robot_list[ ip].robotConnector.RTDE.isRunning(): return connect_ur(ip) return '连接成功'