mirror of
https://github.com/deepmodeling/Uni-Lab-OS
synced 2026-03-27 14:33:05 +00:00
feat: 升级Resource消息系统,增加uuid和klass字段
Resource.msg新增uuid和klass字段支持ResourceDictInstance完整序列化, message_converter增加Resource消息与Python dict的双向转换, workstation和base_device_node增加资源同步相关功能。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -340,8 +340,17 @@ class ROS2WorkstationNode(BaseROS2DeviceNode):
|
||||
) # type: ignore
|
||||
raw_data = json.loads(response.response)
|
||||
tree_set = ResourceTreeSet.from_raw_dict_list(raw_data)
|
||||
target = tree_set.dump()
|
||||
protocol_kwargs[k] = target[0][0] if v == "unilabos_msgs/Resource" else target
|
||||
|
||||
# 传递 ResourceDictInstance(保留树结构),不再调用 dump() 扁平化
|
||||
if v == "unilabos_msgs/Resource":
|
||||
# 单个资源:取第一棵树的根节点
|
||||
root_instance = tree_set.trees[0].root_node if tree_set.trees else None
|
||||
protocol_kwargs[k] = root_instance.get_plr_nested_dict() if root_instance else protocol_kwargs[k]
|
||||
else:
|
||||
# 多个资源:取每棵树的根节点
|
||||
protocol_kwargs[k] = [
|
||||
tree.root_node.get_plr_nested_dict() for tree in tree_set.trees
|
||||
]
|
||||
except Exception as ex:
|
||||
self.lab_logger().error(f"查询资源失败: {k}, 错误: {ex}\n{traceback.format_exc()}")
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user