add missing action clients

This commit is contained in:
wznln
2025-05-14 23:57:37 +08:00
parent 139fc2158c
commit 02425f89e9
2 changed files with 12 additions and 5 deletions

View File

@@ -19,10 +19,10 @@ class Registry:
self.registry_paths = DEFAULT_PATHS.copy() # 使用copy避免修改默认值
if registry_paths:
self.registry_paths.extend(registry_paths)
ResourceCreateFromOuter = self._replace_type_with_class(
self.ResourceCreateFromOuter = self._replace_type_with_class(
"ResourceCreateFromOuter", "host_node", f"动作 add_resource_from_outer"
)
ResourceCreateFromOuterEasy = self._replace_type_with_class(
self.ResourceCreateFromOuterEasy = self._replace_type_with_class(
"ResourceCreateFromOuterEasy", "host_node", f"动作 add_resource_from_outer_easy"
)
self.device_type_registry = {
@@ -46,7 +46,7 @@ class Registry:
"result": {
"success": "success"
},
"schema": ros_action_to_json_schema(ResourceCreateFromOuter)
"schema": ros_action_to_json_schema(self.ResourceCreateFromOuter)
},
"add_resource_from_outer_easy": {
"type": msg_converter_manager.search_class("ResourceCreateFromOuterEasy"),
@@ -64,7 +64,7 @@ class Registry:
"result": {
"success": "success"
},
"schema": ros_action_to_json_schema(ResourceCreateFromOuterEasy)
"schema": ros_action_to_json_schema(self.ResourceCreateFromOuterEasy)
}
}
},

View File

@@ -101,7 +101,14 @@ class HostNode(BaseROS2DeviceNode):
self.devices_names: Dict[str, str] = {device_id: self.namespace} # 存储设备名称和命名空间的映射
self.devices_instances: Dict[str, ROS2DeviceNode] = {} # 存储设备实例
self.device_machine_names: Dict[str, str] = {device_id: "本地", } # 存储设备ID到机器名称的映射
self._action_clients: Dict[str, ActionClient] = {} # 用来存储多个ActionClient实例
self._action_clients: Dict[str, ActionClient] = { # 为了方便了解实际的数据类型host的默认写好
"/devices/host_node/add_resource_from_outer_easy": ActionClient(
self, lab_registry.ResourceCreateFromOuterEasy, "/devices/host_node/add_resource_from_outer_easy", callback_group=self.callback_group
),
"/devices/host_node/add_resource_from_outer": ActionClient(
self, lab_registry.ResourceCreateFromOuter, "/devices/host_node/add_resource_from_outer", callback_group=self.callback_group
)
} # 用来存储多个ActionClient实例
self._action_value_mappings: Dict[str, Dict] = {} # 用来存储多个ActionClient的type, goal, feedback, result的变量名映射关系
self._goals: Dict[str, Any] = {} # 用来存储多个目标的状态
self._online_devices: Set[str] = {f"{self.namespace}/{device_id}"} # 用于跟踪在线设备