execute_collaborative_task
Execute collaborative robot tasks by providing a task ID to coordinate multiple industrial robots through voice or text commands.
Instructions
执行多机器人协同任务
参数:
- task_id: 任务ID
返回:
- 执行结果
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes |
Implementation Reference
- The core handler function for the 'execute_collaborative_task' tool, decorated with @mcp.tool() for automatic registration. It invokes the multi_robot_coordinator to execute the task identified by task_id and handles errors.@mcp.tool() def execute_collaborative_task(task_id: str): """ 执行多机器人协同任务 参数: - task_id: 任务ID 返回: - 执行结果 """ try: if multi_robot_coordinator is None: return return_msg("多机器人协调器未初始化") # 执行任务 result = multi_robot_coordinator.execute_task(task_id) return return_msg(f"协同任务执行结果: {result}") except Exception as e: logger.error(f"执行协同任务失败: {str(e)}") return return_msg(f"执行协同任务失败: {str(e)}")
- Initialization function called in main() that creates the AdvancedMultiRobotCoordinator instance assigned to the global multi_robot_coordinator used by the tool handler.def initialize_extended_modules(): """初始化所有扩展模块""" global multi_robot_coordinator, advanced_trajectory_planner global advanced_data_recorder, advanced_data_analyzer try: # 初始化多机器人协调器 multi_robot_coordinator = AdvancedMultiRobotCoordinator() logger.info("高级多机器人协调器初始化成功") # 初始化高级轨迹规划器 advanced_trajectory_planner = AdvancedTrajectoryPlanner() logger.info("高级轨迹规划器初始化成功") # 初始化高级数据记录器 advanced_data_recorder = AdvancedDataRecorder() logger.info("高级数据记录器初始化成功") # 获取数据分析器实例(单例) advanced_data_analyzer = get_data_analyzer() logger.info("高级数据分析器初始化成功") return True except Exception as e: logger.error(f"初始化扩展模块失败: {str(e)}") return False
- src/nonead_universal_robots_mcp/server.py:895-895 (registration)The @mcp.tool() decorator on the handler function serves as the tool registration mechanism in the FastMCP framework.@mcp.tool()
- Docstring providing the input schema (task_id: str) and output description for the tool.""" 执行多机器人协同任务 参数: - task_id: 任务ID 返回: - 执行结果 """
- Import of AdvancedMultiRobotCoordinator class used to instantiate the coordinator.from URBasic.advanced_multi_robot_coordinator import AdvancedMultiRobotCoordinator, CollaborationMode