mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-18 05:21:19 +00:00
Device visualization (#22)
* add 3d visualization * 完成在main中启动设备可视化 完成在main中启动设备可视化,并输出物料ID:mesh的对应关系resource_model 添加物料模型管理类,遍历物料与resource_model,完成TF数据收集 * 完成TF发布 * 修改模型方向,在yaml中添加变换属性 * 添加物料tf变化时,发送topic到前端 另外修改了物料初始化的方法,防止在tf还未发布时提前建立物料模型与发布话题 * 添加关节发布节点与物料可视化节点进入unilab * 使用json启动plr与3D模型仿真 * 完成启动OT并联动rviz * add 3d visualization * 完成在main中启动设备可视化 完成在main中启动设备可视化,并输出物料ID:mesh的对应关系resource_model 添加物料模型管理类,遍历物料与resource_model,完成TF数据收集 * 完成TF发布 * 修改模型方向,在yaml中添加变换属性 * 添加物料tf变化时,发送topic到前端 另外修改了物料初始化的方法,防止在tf还未发布时提前建立物料模型与发布话题 * 添加关节发布节点与物料可视化节点进入unilab * 使用json启动plr与3D模型仿真 * 完成启动OT并联动rviz * 修复rviz位置问题, 修复rviz位置问题, 在无tf变动时减缓发送频率 在backend中添加物料跟随方法 * fix: running logic * fix: running logic * fix: missing ot * 在main中直接初始化republisher和物料的mesh节点 * 将joint_republisher和resource_mesh_manager添加进 main_slave_run.py中 * 编写mesh添加action * add action * fix * fix: browser on rviz * fix: cloud bridge error fallback to local * fix: salve auto run rviz * 初始化两个plate --------- Co-authored-by: zhangshixiang <@zhangshixiang> Co-authored-by: wznln <18435084+Xuwznln@users.noreply.github.com>
This commit is contained in:
0
unilabos/device_mesh/__init__.py
Normal file
0
unilabos/device_mesh/__init__.py
Normal file
@@ -10,7 +10,7 @@ from unilabos.registry.registry import lab_registry
|
||||
|
||||
|
||||
class ResourceVisualization:
|
||||
def __init__(self, device: dict, resource: list, enable_rviz: bool = True):
|
||||
def __init__(self, device: dict, resource: dict, enable_rviz: bool = True):
|
||||
"""初始化资源可视化类
|
||||
|
||||
该类用于将设备和资源的3D模型可视化展示。通过解析设备和资源的配置信息,
|
||||
@@ -18,13 +18,13 @@ class ResourceVisualization:
|
||||
|
||||
Args:
|
||||
device (dict): 设备配置字典,包含设备的类型、位置等信息
|
||||
resource (list): 资源配置列表,包含资源的类型、位置等信息
|
||||
resource (dict): 资源配置字典,包含资源的类型、位置等信息
|
||||
registry (dict): 注册表字典,包含设备和资源类型的注册信息
|
||||
enable_rviz (bool, optional): 是否启用RViz可视化. Defaults to True.
|
||||
"""
|
||||
self.launch_service = LaunchService()
|
||||
self.launch_description = LaunchDescription()
|
||||
self.resource_list = resource
|
||||
self.resource_dict = resource
|
||||
self.resource_model = {}
|
||||
self.resource_type = ['deck', 'plate', 'container']
|
||||
self.mesh_path = Path(__file__).parent.absolute()
|
||||
@@ -64,11 +64,12 @@ class ResourceVisualization:
|
||||
self.resource_model[node['id']] = {
|
||||
'mesh': f"{str(self.mesh_path)}/resources/{model_config['mesh']}",
|
||||
'mesh_tf': model_config['mesh_tf']}
|
||||
if model_config['children_mesh'] is not None:
|
||||
self.resource_model[f"{node['id']}_"] = {
|
||||
'mesh': f"{str(self.mesh_path)}/resources/{model_config['children_mesh']}",
|
||||
'mesh_tf': model_config['children_mesh_tf']
|
||||
}
|
||||
if 'children_mesh' in model_config:
|
||||
if model_config['children_mesh'] is not None:
|
||||
self.resource_model[f"{node['id']}_"] = {
|
||||
'mesh': f"{str(self.mesh_path)}/resources/{model_config['children_mesh']}",
|
||||
'mesh_tf': model_config['children_mesh_tf']
|
||||
}
|
||||
elif model_config['type'] == 'device':
|
||||
new_include = etree.SubElement(self.root, f"{{{xacro_uri}}}include")
|
||||
new_include.set("filename", f"{str(self.mesh_path)}/devices/{model_config['mesh']}/macro_device.xacro")
|
||||
@@ -76,6 +77,7 @@ class ResourceVisualization:
|
||||
new_dev.set("parent_link", "world")
|
||||
new_dev.set("mesh_path", str(self.mesh_path))
|
||||
new_dev.set("device_name", node["id"]+"_")
|
||||
new_dev.set("station_name", node["parent"]+'_')
|
||||
new_dev.set("x",str(float(node["position"]["x"])/1000))
|
||||
new_dev.set("y",str(float(node["position"]["y"])/1000))
|
||||
new_dev.set("z",str(float(node["position"]["z"])/1000))
|
||||
|
||||
Reference in New Issue
Block a user