fix resource_get in action

This commit is contained in:
Junhan Chang
2025-10-17 11:18:47 +08:00
committed by Xuwznln
parent d4415f5a35
commit 1b43c53015
3 changed files with 9 additions and 3 deletions

View File

@@ -943,7 +943,7 @@ class BaseROS2DeviceNode(Node, Generic[T]):
queried_resources = [] queried_resources = []
for resource_data in resource_inputs: for resource_data in resource_inputs:
r = SerialCommand.Request() r = SerialCommand.Request()
r.command = json.dumps({"id": resource_data["id"], "with_children": True}) r.command = json.dumps({"id": resource_data["id"], "uuid": resource_data.get("uuid", None), "with_children": True})
# 发送请求并等待响应 # 发送请求并等待响应
response: SerialCommand_Response = await self._resource_clients[ response: SerialCommand_Response = await self._resource_clients[
"resource_get" "resource_get"

View File

@@ -1070,7 +1070,12 @@ class HostNode(BaseROS2DeviceNode):
""" """
try: try:
data = json.loads(request.command) data = json.loads(request.command)
http_req = self.bridges[-1].resource_get(data["id"], data["with_children"]) if "uuid" in data and data["uuid"] is not None:
http_req = self.bridges[-1].resource_tree_get([data["uuid"]], data["with_children"])
elif "id" in data and data["id"].startswith("/"):
http_req = self.bridges[-1].resource_get(data["id"], data["with_children"])
else:
raise ValueError("没有使用正确的物料 id 或 uuid")
response.response = json.dumps(http_req["data"]) response.response = json.dumps(http_req["data"])
return response return response
except Exception as e: except Exception as e:

View File

@@ -232,8 +232,9 @@ class ROS2WorkstationNode(BaseROS2DeviceNode):
resource_id = ( resource_id = (
protocol_kwargs[k]["id"] if v == "unilabos_msgs/Resource" else protocol_kwargs[k][0]["id"] protocol_kwargs[k]["id"] if v == "unilabos_msgs/Resource" else protocol_kwargs[k][0]["id"]
) )
resource_uuid = protocol_kwargs[k].get("uuid", None)
r = SerialCommand_Request() r = SerialCommand_Request()
r.command = json.dumps({"id": resource_id, "with_children": True}) r.command = json.dumps({"id": resource_id, "uuid": resource_uuid, "with_children": True})
# 发送请求并等待响应 # 发送请求并等待响应
response: SerialCommand_Response = await self._resource_clients[ response: SerialCommand_Response = await self._resource_clients[
"resource_get" "resource_get"