mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
Add high-level PLR functions Add Laiyu/Zhida driver support Fix ROS node discovery issues Add hostname and resource query support Fix ROS message conversion logic Support configuration via environment variables * Update README and MQTTClient for installation instructions and code improvements * feat: 支持local_config启动 add: 增加对crt path的说明,为传入config.py的相对路径 move: web component * add: registry description * add 3d visualization * 完成在main中启动设备可视化 完成在main中启动设备可视化,并输出物料ID:mesh的对应关系resource_model 添加物料模型管理类,遍历物料与resource_model,完成TF数据收集 * 完成TF发布 * 修改模型方向,在yaml中添加变换属性 * 添加物料tf变化时,发送topic到前端 另外修改了物料初始化的方法,防止在tf还未发布时提前建立物料模型与发布话题 * 添加关节发布节点与物料可视化节点进入unilab * 使用json启动plr与3D模型仿真 * feat: node_info_update srv fix: OTDeck cant create * close #12 feat: slave node registry * feat: show machine name fix: host node registry not uploaded * feat: add hplc registry * feat: add hplc registry * fix: hplc status typo * fix: devices/ * 完成启动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 * fix: device.class possible null * fix: HPLC additions with online service * fix: slave mode spin not working * fix: slave mode spin not working * 修复rviz位置问题, 修复rviz位置问题, 在无tf变动时减缓发送频率 在backend中添加物料跟随方法 * feat: 多ProtocolNode 允许子设备ID相同 feat: 上报发现的ActionClient feat: Host重启动,通过discover机制要求slaveNode重新注册,实现信息及时上报 * feat: 支持env设置config * fix: running logic * fix: running logic * fix: missing ot * 在main中直接初始化republisher和物料的mesh节点 * 将joint_republisher和resource_mesh_manager添加进 main_slave_run.py中 * Device visualization (#14) * 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中 --------- Co-authored-by: zhangshixiang <@zhangshixiang> Co-authored-by: wznln <18435084+Xuwznln@users.noreply.github.com> * fix: missing hostname in devices_names fix: upload_file for model file * fix: missing paho-mqtt package bump version to 0.9.0 * fix startup add ResourceCreateFromOuter.action * fix type hint * update actions * update actions * host node add_resource_from_outer fix cmake list * pass device config to device class * add: bind_parent_ids to resource create action fix: message convert string * fix: host node should not be re_discovered * feat: resource tracker support dict * feat: add more necessary params * feat: fix boolean null in registry action data * feat: add outer resource * 编写mesh添加action * feat: append resource * add action * feat: vis 2d for plr * fix * fix: browser on rviz * fix: cloud bridge error fallback to local * fix: salve auto run rviz * 初始化两个plate * 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> * fix: multi channel * fix: aspirate * fix: aspirate * fix: aspirate * fix: aspirate * 提交 * fix: jobadd * fix: jobadd * fix: msg converter * tijiao --------- Co-authored-by: Harvey Que <Q-Query@outlook.com> Co-authored-by: zhangshixiang <@zhangshixiang> Co-authored-by: q434343 <73513873+q434343@users.noreply.github.com>
92 lines
3.4 KiB
Python
92 lines
3.4 KiB
Python
from typing import Dict, Any, Optional, Type, TypeVar
|
||
|
||
from unilabos.ros.msgs.message_converter import (
|
||
get_msg_type,
|
||
get_action_type,
|
||
)
|
||
from unilabos.ros.nodes.base_device_node import init_wrapper, ROS2DeviceNode
|
||
|
||
# 定义泛型类型变量
|
||
T = TypeVar("T")
|
||
|
||
|
||
# noinspection PyMissingConstructor
|
||
class ROS2DeviceNodeWrapper(ROS2DeviceNode):
|
||
def __init__(self, device_id: str, *args, **kwargs):
|
||
pass
|
||
|
||
|
||
def ros2_device_node(
|
||
cls: Type[T],
|
||
device_config: Optional[Dict[str, Any]] = None,
|
||
status_types: Optional[Dict[str, Any]] = None,
|
||
action_value_mappings: Optional[Dict[str, Any]] = None,
|
||
hardware_interface: Optional[Dict[str, Any]] = None,
|
||
print_publish: bool = False,
|
||
children: Optional[Dict[str, Any]] = None,
|
||
) -> Type[ROS2DeviceNodeWrapper]:
|
||
"""Create a ROS2 Node class for a device class with properties and actions.
|
||
|
||
Args:
|
||
cls: 要封装的设备类
|
||
status_types: 需要发布的状态和传感器信息,每个(PROP: TYPE),PROP应该匹配cls.PROP或cls.get_PROP(),
|
||
TYPE应该是ROS2消息类型。默认为{}。
|
||
device_config: 初始化时的config。
|
||
action_value_mappings: 设备动作。默认为{}。
|
||
每个(ACTION: {'type': CMD_TYPE, 'goal': {FIELD: PROP}, 'feedback': {FIELD: PROP}, 'result': {FIELD: PROP}}),
|
||
hardware_interface: 硬件接口配置。默认为{"name": "hardware_interface", "write": "send_command", "read": "read_data", "extra_info": []}。
|
||
print_publish: 是否打印发布信息。默认为False。
|
||
children: 物料/子节点信息。
|
||
|
||
Returns:
|
||
Type: 封装了设备类的ROS2节点类。
|
||
"""
|
||
# 从属性中自动发现可发布状态
|
||
if status_types is None:
|
||
status_types = {}
|
||
if device_config is None:
|
||
device_config = {}
|
||
if action_value_mappings is None:
|
||
action_value_mappings = {}
|
||
if hardware_interface is None:
|
||
hardware_interface = {
|
||
"name": "hardware_interface",
|
||
"write": "send_command",
|
||
"read": "read_data",
|
||
"extra_info": [],
|
||
}
|
||
|
||
for k, v in cls.__dict__.items():
|
||
if not k.startswith("_") and isinstance(v, property):
|
||
# noinspection PyUnresolvedReferences
|
||
property_type = v.fget.__annotations__.get("return", str)
|
||
get_method_name = f"get_{k}"
|
||
set_method_name = f"set_{k}"
|
||
|
||
if k not in status_types and hasattr(cls, get_method_name):
|
||
status_types[k] = get_msg_type(property_type)
|
||
|
||
if f"set_{k}" not in action_value_mappings and hasattr(cls, set_method_name):
|
||
action_value_mappings[f"set_{k}"] = get_action_type(property_type)
|
||
# 创建一个包装类来返回ROS2DeviceNode
|
||
wrapper_class_name = f"ROS2NodeWrapper4{cls.__name__}"
|
||
ROS2DeviceNodeWrapper = type(
|
||
wrapper_class_name,
|
||
(ROS2DeviceNode,),
|
||
{
|
||
"__init__": lambda self, *args, **kwargs: init_wrapper(
|
||
self,
|
||
driver_class=cls,
|
||
device_config=device_config,
|
||
status_types=status_types,
|
||
action_value_mappings=action_value_mappings,
|
||
hardware_interface=hardware_interface,
|
||
print_publish=print_publish,
|
||
children=children,
|
||
*args,
|
||
**kwargs,
|
||
),
|
||
},
|
||
)
|
||
return ROS2DeviceNodeWrapper
|