Skip to main content
Glama
nonead

nUR MCP Server

by nonead

movel_x

Control robot movement by specifying TCP motion along the X-axis. Provide robot IP address and distance in meters to execute precise linear movement commands for industrial automation.

Instructions

命令指定IP机器人的TCP沿X轴方向移动 IP:机器人地址 distance:移动距离(米)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ipYes
distanceYes

Implementation Reference

  • The handler function for the 'movel_x' MCP tool. It connects to the UR robot via IP, retrieves current TCP pose, adjusts the X coordinate by the given distance, executes movel command, confirms completion using movelConfirm helper, and logs/generates a script representation of the command.
    @mcp.tool()
    def movel_x(ip: str, distance: float):
        """命令指定IP机器人的TCP沿X轴方向移动
        IP:机器人地址
        distance:移动距离(米)"""
        try:
            if '连接失败' in link_check(ip):
                return return_msg(f"与机器人的连接已断开。")
            pose = robot_list[ip].get_actual_tcp_pose()
            pose[0] = pose[0] + distance
            robot_list[ip].movel(pose)
            time.sleep(1)
            result = movelConfirm(ip, pose)
            cmd = (f"def my_program():\n"
                   f"  movel(p[{'{:.4f}'.format(pose[0])},{'{:.4f}'.format(pose[1])},{'{:.4f}'.format(pose[2])},{'{:.4f}'.format(pose[3])},{'{:.4f}'.format(pose[4])},{'{:.4f}'.format(pose[5])},],0.5,0.25,0,0)\n"
                   f"end\nmy_program()")
            logger.info(f"发送脚本:{cmd}")
            if result == 1:
                return return_msg(f"命令 {cmd} 已发送,移动完成。")
            else:
                return return_msg(f"命令 {cmd} 已发送,移动失败。")
        except Exception as e:
            logger.error(f"移动失败: {str(e)}")
            return return_msg(f"移动失败: {str(e)}")
  • The @mcp.tool() decorator registers the movel_x function as an MCP tool, using the function name 'movel_x' and its type hints/docstring for schema.
    @mcp.tool()
  • Helper function movelConfirm used by movel_x to verify if the linear move has completed successfully within position tolerance.
    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 round_pose used indirectly via movelConfirm to round pose coordinates 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
  • Helper function right_pose_tcp used by movelConfirm to check if actual 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

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