From 9c515a252a5c80b17f5c62dac3e01a9470eac553 Mon Sep 17 00:00:00 2001 From: Xuwznln <18435084+Xuwznln@users.noreply.github.com> Date: Tue, 10 Jun 2025 02:55:29 +0800 Subject: [PATCH] create_resource --- unilabos/ros/nodes/base_device_node.py | 25 +++++++++++++++---------- unilabos/ros/nodes/presets/host_node.py | 5 +++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/unilabos/ros/nodes/base_device_node.py b/unilabos/ros/nodes/base_device_node.py index dcf0759..d7a51fd 100644 --- a/unilabos/ros/nodes/base_device_node.py +++ b/unilabos/ros/nodes/base_device_node.py @@ -368,16 +368,21 @@ class BaseROS2DeviceNode(Node, Generic[T]): # 如果driver自己就有assign的方法,那就使用driver自己的assign方法 if hasattr(self.driver_instance, "create_resource"): create_resource_func = getattr(self.driver_instance, "create_resource") - create_resource_func( - resource_tracker=self.resource_tracker, - resources=request.resources, - bind_parent_id=bind_parent_id, - bind_location=location, - liquid_input_slot=LIQUID_INPUT_SLOT, - liquid_type=ADD_LIQUID_TYPE, - liquid_volume=LIQUID_VOLUME, - slot_on_deck=slot, - ) + try: + ret = create_resource_func( + resource_tracker=self.resource_tracker, + resources=request.resources, + bind_parent_id=bind_parent_id, + bind_location=location, + liquid_input_slot=LIQUID_INPUT_SLOT, + liquid_type=ADD_LIQUID_TYPE, + liquid_volume=LIQUID_VOLUME, + slot_on_deck=slot, + ) + res.response = serialize_result_info("", True, ret) + except Exception as e: + traceback.print_exc() + res.response = serialize_result_info(traceback.format_exc(), False, {}) return res # 接下来该根据bind_parent_id进行assign了,目前只有plr可以进行assign,不然没有办法输入到物料系统中 resource = self.resource_tracker.figure_resource({"name": bind_parent_id}) diff --git a/unilabos/ros/nodes/presets/host_node.py b/unilabos/ros/nodes/presets/host_node.py index a869b13..6ad88e1 100644 --- a/unilabos/ros/nodes/presets/host_node.py +++ b/unilabos/ros/nodes/presets/host_node.py @@ -342,6 +342,7 @@ class HostNode(BaseROS2DeviceNode): bind_locations: list[Point], other_calling_params: list[str], ): + responses = [] for resource, device_id, bind_parent_id, bind_location, other_calling_param in zip( resources, device_ids, bind_parent_ids, bind_locations, other_calling_params ): @@ -367,8 +368,8 @@ class HostNode(BaseROS2DeviceNode): ensure_ascii=False, ) response = sclient.call(request) - pass - pass + responses.append(response) + return responses def create_resource( self,