修改根据新的物料格式,修改可视化

This commit is contained in:
zhangshixiang
2025-12-10 15:10:53 +08:00
parent 896f287d92
commit 8ba911bb55
2 changed files with 16 additions and 9 deletions

View File

@@ -128,14 +128,21 @@ class ResourceVisualization:
new_dev.set("device_name", node["id"]+"_") new_dev.set("device_name", node["id"]+"_")
# if node["parent"] is not None: # if node["parent"] is not None:
# new_dev.set("station_name", node["parent"]+'_') # new_dev.set("station_name", node["parent"]+'_')
if "position" in node:
new_dev.set("x",str(float(node["position"]["position"]["x"])/1000)) new_dev.set("x",str(float(node["position"]["position"]["x"])/1000))
new_dev.set("y",str(float(node["position"]["position"]["y"])/1000)) new_dev.set("y",str(float(node["position"]["position"]["y"])/1000))
new_dev.set("z",str(float(node["position"]["position"]["z"])/1000)) new_dev.set("z",str(float(node["position"]["position"]["z"])/1000))
if "rotation" in node["config"]: if "rotation" in node["config"]:
new_dev.set("rx",str(float(node["config"]["rotation"]["x"]))) new_dev.set("rx",str(float(node["config"]["rotation"]["x"])))
new_dev.set("ry",str(float(node["config"]["rotation"]["y"]))) new_dev.set("ry",str(float(node["config"]["rotation"]["y"])))
new_dev.set("r",str(float(node["config"]["rotation"]["z"]))) new_dev.set("r",str(float(node["config"]["rotation"]["z"])))
if "pose" in node:
new_dev.set("x",str(float(node["pose"]["position"]["x"])/1000))
new_dev.set("y",str(float(node["pose"]["position"]["y"])/1000))
new_dev.set("z",str(float(node["pose"]["position"]["z"])/1000))
new_dev.set("rx",str(float(node["pose"]["rotation"]["x"])))
new_dev.set("ry",str(float(node["pose"]["rotation"]["y"])))
new_dev.set("r",str(float(node["pose"]["rotation"]["z"])))
if "device_config" in node["config"]: if "device_config" in node["config"]:
for key, value in node["config"]["device_config"].items(): for key, value in node["config"]["device_config"].items():
new_dev.set(key, str(value)) new_dev.set(key, str(value))

View File

@@ -203,9 +203,9 @@ class ResourceMeshManager(BaseROS2DeviceNode):
continue continue
# 提取位置信息并转换单位 # 提取位置信息并转换单位
position = { position = {
"x": float(resource_config['position']['position']['x'])/1000, "x": float(resource_config['pose']['position']['x'])/1000,
"y": float(resource_config['position']['position']['y'])/1000, "y": float(resource_config['pose']['position']['y'])/1000,
"z": float(resource_config['position']['position']['z'])/1000 "z": float(resource_config['pose']['position']['z'])/1000
} }
rotation_dict = { rotation_dict = {
@@ -214,8 +214,8 @@ class ResourceMeshManager(BaseROS2DeviceNode):
"z": 0 "z": 0
} }
if 'rotation' in resource_config['position']: if 'rotation' in resource_config['pose']:
rotation_dict = resource_config['position']['rotation'] rotation_dict = resource_config['pose']['rotation']
# 从欧拉角转换为四元数 # 从欧拉角转换为四元数
q = quaternion_from_euler( q = quaternion_from_euler(