Skip to main content
Glama

draw_square

Draw a square with specified origin point and side length for Universal Robots control, supporting horizontal or vertical orientation in different coordinate planes.

Instructions

给定起点位置和边长,在水平或竖直方向画一个正方形 origin:画正方形时TCP的起点位置 border:边长(米) coordinate:圆所在的平面。z:圆形所在的平面与基座所在平面垂直,其它:圆形所在的平面与基座所在平面平行。默认值:z。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipYes
originYes
borderYes
coordinateNoz

Implementation Reference

  • The handler function for the draw_square MCP tool. It constructs waypoints for a square based on the origin, border length, and coordinate plane (z or other), generates a URScript program using movel commands to trace the square, and sends it to the robot via RealTimeClient.SendProgram.
    @mcp.tool()
    def draw_square(ip: str, origin: list, border: float, coordinate="z"):
        """给定起点位置和边长,在水平或竖直方向画一个正方形
            origin:画正方形时TCP的起点位置
            border:边长(米)
            coordinate:圆所在的平面。z:圆形所在的平面与基座所在平面垂直,其它:圆形所在的平面与基座所在平面平行。默认值:z。
            """
        try:
            if '连接失败' in link_check(ip):
                return return_msg(f"与机器人的连接已断开。")
            wp_1 = [origin[0], origin[1], origin[2], origin[3], origin[4], origin[5]]
            wp_2 = [origin[0], origin[1], origin[2], origin[3], origin[4], origin[5]]
            wp_3 = [origin[0], origin[1], origin[2], origin[3], origin[4], origin[5]]
            if coordinate.lower() == "z":
                wp_1[1] = wp_1[1] + border
    
                wp_2[1] = wp_2[1] + border
                wp_2[2] = wp_2[2] - border
    
                wp_3[2] = wp_3[2] - border
    
            else:
                wp_1[1] = wp_1[1] + border
    
                wp_2[1] = wp_2[1] + border
                wp_2[0] = wp_2[0] + border
    
                wp_3[0] = wp_3[0] + border
    
            cmd = (f"def my_program():\n"
                   f"  movel(p{str(origin)}, a=1, v=0.25)\n"
                   f"  movel(p{str(wp_1)}, a=1, v=0.25)\n"
                   f"  movel(p{str(wp_2)}, a=1, v=0.25)\n"
                   f"  movel(p{str(wp_3)}, a=1, v=0.25)\n"
                   f"  movel(p{str(origin)}, a=1, v=0.25)\nend\nmy_program()")
            logger.info(f"draw_square 发送脚本:\n{cmd}")
            robot_list[ip].robotConnector.RealTimeClient.SendProgram(cmd)
            time.sleep(1)
            return return_msg(f"命令已发送:{cmd}")
        except Exception as e:
            logger.error(f"命令发送失败: {str(e)}")
            return return_msg(f"命令发送失败: {str(e)}")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nonead/nUR_MCP_SERVER'

If you have feedback or need assistance with the MCP directory API, please join our Discord server