setup_multi_robot_coordination
Configure multiple industrial robots to work together by specifying robot IDs and collaboration modes like sequential, parallel, synchronous, or hierarchical.
Instructions
设置多机器人协同工作环境
参数:
- robot_ids: 参与协同的机器人ID列表
- collaboration_mode: 协作模式,可选值包括"sequential", "parallel", "synchronous", "hierarchical"
返回:
- 成功或失败的消息
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| robot_ids | Yes | ||
| collaboration_mode | No | parallel |
Implementation Reference
- The handler function decorated with @mcp.tool(), implementing the setup_multi_robot_coordination tool. It initializes multi-robot coordination by registering connected robots and setting the collaboration mode using the AdvancedMultiRobotCoordinator instance.def setup_multi_robot_coordination(robot_ids: list, collaboration_mode: str = "parallel"): """ 设置多机器人协同工作环境 参数: - robot_ids: 参与协同的机器人ID列表 - collaboration_mode: 协作模式,可选值包括"sequential", "parallel", "synchronous", "hierarchical" 返回: - 成功或失败的消息 """ try: if multi_robot_coordinator is None: return return_msg("多机器人协调器未初始化") # 映射协作模式字符串到枚举值 mode_map = { "sequential": CollaborationMode.SEQUENTIAL, "parallel": CollaborationMode.PARALLEL, "synchronous": CollaborationMode.SYNCHRONOUS, "hierarchical": CollaborationMode.HIERARCHICAL } if collaboration_mode not in mode_map: return return_msg(f"不支持的协作模式: {collaboration_mode}") # 注册机器人到协调器 for robot_id in robot_ids: # 检查机器人是否已连接 if robot_id in robot_list and robot_list[robot_id].robotConnector.RTDE.isRunning(): multi_robot_coordinator.register_robot(robot_id) logger.info(f"机器人 {robot_id} 已注册到协调器") else: return return_msg(f"机器人 {robot_id} 未连接或不可用") # 设置协作模式 multi_robot_coordinator.set_collaboration_mode(mode_map[collaboration_mode]) return return_msg(f"多机器人协同环境设置成功,协作模式: {collaboration_mode}") except Exception as e: logger.error(f"设置多机器人协同环境失败: {str(e)}") return return_msg(f"设置多机器人协同环境失败: {str(e)}")
- src/nonead_universal_robots_mcp/server.py:821-821 (registration)The @mcp.tool() decorator registers the function as an MCP tool.def setup_multi_robot_coordination(robot_ids: list, collaboration_mode: str = "parallel"):
- Initializes the global multi_robot_coordinator instance used by the tool, along with other modules.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