draw_circle
Command robots via IP to draw precise circles by specifying the center position, radius, and plane orientation. Supports horizontal or vertical planes for accurate robotic path planning.
Instructions
命令指定IP的机器人,给定圆心位置和半径,在水平或竖直方向画一个圆 center:圆心的TCP位置 r:半径(米) coordinate:圆所在的平面。z:圆形所在的平面与基座所在平面垂直,其它:圆形所在的平面与基座所在平面平行。默认值:z。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| center | Yes | ||
| coordinate | No | z | |
| ip | Yes | ||
| r | Yes |
Implementation Reference
- The draw_circle tool handler, decorated with @mcp.tool() for registration. It calculates four waypoints around the center based on radius and coordinate plane (z or other), constructs a UR script with movep and two movec commands to draw the circle, and sends it to the robot via RealTimeClient.SendProgram.@mcp.tool() def draw_circle(ip: str, center: dict, r: float, coordinate="z"): """命令指定IP的机器人,给定圆心位置和半径,在水平或竖直方向画一个圆 center:圆心的TCP位置 r:半径(米) coordinate:圆所在的平面。z:圆形所在的平面与基座所在平面垂直,其它:圆形所在的平面与基座所在平面平行。默认值:z。""" try: if '连接失败' in link_check(ip): return return_msg(f"与机器人的连接已断开。") wp_1 = [center[0], center[1], center[2], center[3], center[4], center[5]] wp_2 = [center[0], center[1], center[2], center[3], center[4], center[5]] wp_3 = [center[0], center[1], center[2], center[3], center[4], center[5]] wp_4 = [center[0], center[1], center[2], center[3], center[4], center[5]] cmd = '' if coordinate.lower() == "z": wp_1[2] = wp_1[2] + r wp_2[1] = wp_2[1] + r wp_3[2] = wp_3[2] - r wp_4[1] = wp_4[1] - r else: wp_1[0] = wp_1[0] - r wp_2[1] = wp_2[1] + r wp_3[0] = wp_3[0] + r wp_4[1] = wp_4[1] - r cmd = (f"movep(p{str(wp_1)}, a=1, v=0.25, r=0.025)\nmovec(p{str(wp_2)}, p{str(wp_3)}, a=1, v=0.25, " f"r=0.025, mode=0)\nmovec(p{str(wp_4)}, p{str(wp_1)}, a=1, v=0.25, r=0.025, mode=0)") robot_list[ip].robotConnector.RealTimeClient.SendProgram(cmd) return return_msg(f"命令已发送:{cmd}") except Exception as e: logger.error(f"命令发送失败: {str(e)}") return return_msg(f"命令发送失败: {str(e)}")
- src/nonead_universal_robots_mcp/server.py:613-613 (registration)The @mcp.tool() decorator registers the draw_circle function as an MCP tool.@mcp.tool()
- Input schema defined by function parameters (ip: str, center: dict, r: float, coordinate: str="z") and docstring describing their meanings.def draw_circle(ip: str, center: dict, r: float, coordinate="z"): """命令指定IP的机器人,给定圆心位置和半径,在水平或竖直方向画一个圆 center:圆心的TCP位置 r:半径(米) coordinate:圆所在的平面。z:圆形所在的平面与基座所在平面垂直,其它:圆形所在的平面与基座所在平面平行。默认值:z。"""