From 7e8dfc2dc5af5e66ac98ec4eda624771444b5922 Mon Sep 17 00:00:00 2001 From: Xuwznln <18435084+Xuwznln@users.noreply.github.com> Date: Mon, 13 Oct 2025 23:34:17 +0800 Subject: [PATCH] Fix children key error --- unilabos/resources/graphio.py | 2 +- unilabos/ros/nodes/resource_tracker.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unilabos/resources/graphio.py b/unilabos/resources/graphio.py index bb317393..c6780001 100644 --- a/unilabos/resources/graphio.py +++ b/unilabos/resources/graphio.py @@ -52,7 +52,7 @@ def canonicalize_nodes_data( if not node.get("type"): node["type"] = "device" print_status(f"Warning: Node {node.get('id', 'unknown')} missing 'type', defaulting to 'device'", "warning") - if not node.get("name"): + if node.get("name", None) is None: node["name"] = node.get("id") print_status(f"Warning: Node {node.get('id', 'unknown')} missing 'name', defaulting to {node['name']}", "warning") if not isinstance(node.get("position"), dict): diff --git a/unilabos/ros/nodes/resource_tracker.py b/unilabos/ros/nodes/resource_tracker.py index 3ad29c63..4ab31f0f 100644 --- a/unilabos/ros/nodes/resource_tracker.py +++ b/unilabos/ros/nodes/resource_tracker.py @@ -140,7 +140,7 @@ class ResourceDictInstance(object): def get_nested_dict(self) -> Dict[str, Any]: """获取资源实例的嵌套字典表示""" res_dict = self.res_content.model_dump(by_alias=True) - res_dict["children"] = {child.res_content.name: child.get_nested_dict() for child in self.children} + res_dict["children"] = {child.res_content.id: child.get_nested_dict() for child in self.children} res_dict["parent"] = self.res_content.parent_instance_name res_dict["position"] = self.res_content.position.position.model_dump() return res_dict