mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
feat: show machine name
fix: host node registry not uploaded
This commit is contained in:
@@ -12,6 +12,7 @@ from unilabos.app.web.utils.action_utils import get_action_info
|
||||
# 存储 ROS 节点信息的全局变量
|
||||
ros_node_info = {"online_devices": {}, "device_topics": {}, "device_actions": {}}
|
||||
|
||||
|
||||
def get_ros_node_info() -> Dict[str, Any]:
|
||||
"""获取 ROS 节点信息,包括设备节点、发布的状态和动作
|
||||
|
||||
@@ -35,6 +36,13 @@ def update_ros_node_info() -> Dict[str, Any]:
|
||||
|
||||
try:
|
||||
from unilabos.ros.nodes.base_device_node import registered_devices
|
||||
from unilabos.ros.nodes.presets.host_node import HostNode
|
||||
|
||||
# 尝试获取主机节点实例
|
||||
host_node = HostNode.get_instance(0)
|
||||
device_machine_names = {}
|
||||
if host_node:
|
||||
device_machine_names = host_node.device_machine_names
|
||||
|
||||
for device_id, device_info in registered_devices.items():
|
||||
# 设备基本信息
|
||||
@@ -42,6 +50,7 @@ def update_ros_node_info() -> Dict[str, Any]:
|
||||
"node_name": device_info["node_name"],
|
||||
"namespace": device_info["namespace"],
|
||||
"uuid": device_info["uuid"],
|
||||
"machine_name": device_machine_names.get(device_id, "本地"),
|
||||
}
|
||||
|
||||
# 设备话题(状态)信息
|
||||
@@ -55,10 +64,7 @@ def update_ros_node_info() -> Dict[str, Any]:
|
||||
}
|
||||
|
||||
# 设备动作信息
|
||||
result["device_actions"][device_id] = {
|
||||
k: get_action_info(v, k)
|
||||
for k, v in device_info["actions"].items()
|
||||
}
|
||||
result["device_actions"][device_id] = {k: get_action_info(v, k) for k, v in device_info["actions"].items()}
|
||||
# 更新全局变量
|
||||
ros_node_info = result
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user