create_resource

This commit is contained in:
Xuwznln
2025-06-10 02:55:29 +08:00
parent ea5e7a5ce2
commit 9c515a252a
2 changed files with 18 additions and 12 deletions

View File

@@ -368,16 +368,21 @@ class BaseROS2DeviceNode(Node, Generic[T]):
# 如果driver自己就有assign的方法那就使用driver自己的assign方法 # 如果driver自己就有assign的方法那就使用driver自己的assign方法
if hasattr(self.driver_instance, "create_resource"): if hasattr(self.driver_instance, "create_resource"):
create_resource_func = getattr(self.driver_instance, "create_resource") create_resource_func = getattr(self.driver_instance, "create_resource")
create_resource_func( try:
resource_tracker=self.resource_tracker, ret = create_resource_func(
resources=request.resources, resource_tracker=self.resource_tracker,
bind_parent_id=bind_parent_id, resources=request.resources,
bind_location=location, bind_parent_id=bind_parent_id,
liquid_input_slot=LIQUID_INPUT_SLOT, bind_location=location,
liquid_type=ADD_LIQUID_TYPE, liquid_input_slot=LIQUID_INPUT_SLOT,
liquid_volume=LIQUID_VOLUME, liquid_type=ADD_LIQUID_TYPE,
slot_on_deck=slot, 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 return res
# 接下来该根据bind_parent_id进行assign了目前只有plr可以进行assign不然没有办法输入到物料系统中 # 接下来该根据bind_parent_id进行assign了目前只有plr可以进行assign不然没有办法输入到物料系统中
resource = self.resource_tracker.figure_resource({"name": bind_parent_id}) resource = self.resource_tracker.figure_resource({"name": bind_parent_id})

View File

@@ -342,6 +342,7 @@ class HostNode(BaseROS2DeviceNode):
bind_locations: list[Point], bind_locations: list[Point],
other_calling_params: list[str], other_calling_params: list[str],
): ):
responses = []
for resource, device_id, bind_parent_id, bind_location, other_calling_param in zip( 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 resources, device_ids, bind_parent_ids, bind_locations, other_calling_params
): ):
@@ -367,8 +368,8 @@ class HostNode(BaseROS2DeviceNode):
ensure_ascii=False, ensure_ascii=False,
) )
response = sclient.call(request) response = sclient.call(request)
pass responses.append(response)
pass return responses
def create_resource( def create_resource(
self, self,