get_output_bit_register
Retrieve the current value of a specific Boolean register from a Universal Robots collaborative robot by providing the robot's IP address and register index.
Instructions
获取指定IP机器人Bool寄存器的值, IP:机器人地址 index:寄存器下标,范围是[0,23]
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ip | Yes | ||
| index | Yes |
Implementation Reference
- This is the main handler function for the 'get_output_bit_register' tool. It is decorated with @mcp.tool(), which registers it as an MCP tool. The function checks the robot connection, retrieves the OutputBitRegister list from the robot model, and returns the value at the specified index. It handles connection failures and exceptions appropriately.@mcp.tool() def get_output_bit_register(ip: str, index: int): """获取指定IP机器人Bool寄存器的值, IP:机器人地址 index:寄存器下标,范围是[0,23]""" try: if '连接失败' in link_check(ip): return return_msg(f"与机器人的连接已断开。") bits = robotModle_list[ip].OutputBitRegister() logger.info(f"Bool寄存器{index}={bits[index]}") return return_msg(f"{bits[index]}") except Exception as e: logger.error(f"Bool寄存器的值获取失败: {str(e)}") return return_msg(f"Bool寄存器的值获取失败: {str(e)}")