mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-14 13:14:39 +00:00
fix resource_get in action
This commit is contained in:
@@ -943,7 +943,7 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
||||
queried_resources = []
|
||||
for resource_data in resource_inputs:
|
||||
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[
|
||||
"resource_get"
|
||||
|
||||
@@ -1070,7 +1070,12 @@ class HostNode(BaseROS2DeviceNode):
|
||||
"""
|
||||
try:
|
||||
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"])
|
||||
return response
|
||||
except Exception as e:
|
||||
|
||||
@@ -232,8 +232,9 @@ class ROS2WorkstationNode(BaseROS2DeviceNode):
|
||||
resource_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.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[
|
||||
"resource_get"
|
||||
|
||||
Reference in New Issue
Block a user