Fix handles

This commit is contained in:
Junhan Chang
2025-06-16 08:03:06 +08:00
parent 7b04f3fa50
commit 5b9e13555c
6 changed files with 76 additions and 79 deletions

View File

@@ -50,12 +50,12 @@ requirements:
- robostack-staging::ros-humble-rosidl-default-generators - robostack-staging::ros-humble-rosidl-default-generators
- robostack-staging::ros-humble-std-msgs - robostack-staging::ros-humble-std-msgs
- robostack-staging::ros-humble-geometry-msgs - robostack-staging::ros-humble-geometry-msgs
- robostack-staging::ros2-distro-mutex=0.6.* - robostack-staging::ros2-distro-mutex=0.5.*
run: run:
- robostack-staging::ros-humble-action-msgs - robostack-staging::ros-humble-action-msgs
- robostack-staging::ros-humble-ros-workspace - robostack-staging::ros-humble-ros-workspace
- robostack-staging::ros-humble-rosidl-default-runtime - robostack-staging::ros-humble-rosidl-default-runtime
- robostack-staging::ros-humble-std-msgs - robostack-staging::ros-humble-std-msgs
- robostack-staging::ros-humble-geometry-msgs - robostack-staging::ros-humble-geometry-msgs
- robostack-staging::ros2-distro-mutex=0.6.* # - robostack-staging::ros2-distro-mutex=0.6.*
- sel(osx and x86_64): __osx >={{ MACOSX_DEPLOYMENT_TARGET|default('10.14') }} - sel(osx and x86_64): __osx >={{ MACOSX_DEPLOYMENT_TARGET|default('10.14') }}

View File

@@ -77,8 +77,7 @@
"z": 0 "z": 0
}, },
"config": { "config": {
"positions": 8, "positions": 8
"current_position": 1
}, },
"data": { "data": {
"valve_state": "Ready", "valve_state": "Ready",
@@ -98,8 +97,7 @@
"z": 0 "z": 0
}, },
"config": { "config": {
"positions": 8, "positions": 8
"current_position": 1
}, },
"data": { "data": {
"valve_state": "Ready", "valve_state": "Ready",
@@ -489,7 +487,7 @@
"children": [], "children": [],
"parent": "ComprehensiveProtocolStation", "parent": "ComprehensiveProtocolStation",
"type": "device", "type": "device",
"class": "gas_source.mock", "class": "container",
"position": { "position": {
"x": 650, "x": 650,
"y": 150, "y": 150,

View File

@@ -37,7 +37,10 @@
"z": 0 "z": 0
}, },
"config": { "config": {
"max_volume": 5000.0 "max_volume": 5000.0,
"size_x": 200.0,
"size_y": 200.0,
"size_z": 200.0
}, },
"data": { "data": {
"liquid": [ "liquid": [
@@ -71,7 +74,7 @@
"type": "device", "type": "device",
"class": "solenoid_valve.mock", "class": "solenoid_valve.mock",
"position": { "position": {
"x": 620.6111111111111, "x": 780,
"y": 171, "y": 171,
"z": 0 "z": 0
}, },
@@ -89,7 +92,7 @@
"type": "device", "type": "device",
"class": "vacuum_pump.mock", "class": "vacuum_pump.mock",
"position": { "position": {
"x": 620.6111111111111, "x": 500,
"y": 171, "y": 171,
"z": 0 "z": 0
}, },
@@ -107,7 +110,7 @@
"type": "device", "type": "device",
"class": "gas_source.mock", "class": "gas_source.mock",
"position": { "position": {
"x": 620.6111111111111, "x": 900,
"y": 171, "y": 171,
"z": 0 "z": 0
}, },

View File

@@ -48,14 +48,14 @@ solenoid_valve.mock:
feedback: {} feedback: {}
result: {} result: {}
handles: handles:
input:
- handler_key: fluid-input - handler_key: fluid-input
label: Fluid Input label: Fluid Input
data_type: fluid data_type: fluid
output: side: NORTH
- handler_key: fluid-output - handler_key: fluid-output
label: Fluid Output label: Fluid Output
data_type: fluid data_type: fluid
side: SOUTH
init_param_schema: init_param_schema:
type: object type: object
properties: properties:

View File

@@ -7,7 +7,7 @@
# 2. virtual_stirrer - 虚拟搅拌器 # 2. virtual_stirrer - 虚拟搅拌器
# 描述:机械连接设备,提供搅拌功能 # 描述:机械连接设备,提供搅拌功能
# 连接特性1个双向连接点bidirectional # 连接特性1个双向连接点undirected
# 数据类型mechanical机械连接 # 数据类型mechanical机械连接
# 3a. virtual_valve - 虚拟八通阀门 # 3a. virtual_valve - 虚拟八通阀门
@@ -32,12 +32,12 @@
# 6. virtual_heatchill - 虚拟加热/冷却器 # 6. virtual_heatchill - 虚拟加热/冷却器
# 描述:温控设备,容器直接放置在设备上进行温度控制 # 描述:温控设备,容器直接放置在设备上进行温度控制
# 连接特性1个双向连接点bidirectional # 连接特性1个双向连接点undirected
# 数据类型mechanical机械/物理接触连接) # 数据类型mechanical机械/物理接触连接)
# 7. virtual_transfer_pump - 虚拟转移泵(注射器式) # 7. virtual_transfer_pump - 虚拟转移泵(注射器式)
# 描述:注射器式转移泵,通过同一个口吸入和排出液体 # 描述:注射器式转移泵,通过同一个口吸入和排出液体
# 连接特性1个双向连接点bidirectional # 连接特性1个双向连接点undirected
# 数据类型fluid流体连接 # 数据类型fluid流体连接
# 8. virtual_column - 虚拟色谱柱 # 8. virtual_column - 虚拟色谱柱
@@ -83,7 +83,6 @@ virtual_pump:
success: success success: success
# 虚拟泵节点配置 - 具有多通道阀门特性根据valve_position可连接多个容器 # 虚拟泵节点配置 - 具有多通道阀门特性根据valve_position可连接多个容器
handles: handles:
input:
- handler_key: pump-inlet - handler_key: pump-inlet
label: Pump Inlet label: Pump Inlet
data_type: fluid data_type: fluid
@@ -91,14 +90,6 @@ virtual_pump:
data_source: handle data_source: handle
data_key: fluid_in data_key: fluid_in
description: "泵的进液口,连接源容器" description: "泵的进液口,连接源容器"
output:
- handler_key: pump-outlet-1
label: Outlet Port 1
data_type: fluid
io_type: source
data_source: executor
data_key: fluid_out_1
description: "阀门位置1的出液口"
schema: schema:
type: object type: object
properties: properties:
@@ -148,11 +139,11 @@ virtual_stirrer:
success: success success: success
# 虚拟搅拌器节点配置 - 机械连接设备,单一双向连接点 # 虚拟搅拌器节点配置 - 机械连接设备,单一双向连接点
handles: handles:
bidirectional:
- handler_key: stirrer-vessel - handler_key: stirrer-vessel
label: Vessel Connection label: Vessel Connection
data_type: mechanical data_type: mechanical
io_type: bidirectional side: SOUTH
io_type: undirected
data_source: handle data_source: handle
data_key: vessel data_key: vessel
description: "搅拌器的机械连接口,直接与反应容器连接提供搅拌功能" description: "搅拌器的机械连接口,直接与反应容器连接提供搅拌功能"
@@ -191,7 +182,6 @@ virtual_multiway_valve:
success: success success: success
# 八通阀门节点配置 - 1个输入口8个输出口可切换流向 # 八通阀门节点配置 - 1个输入口8个输出口可切换流向
handles: handles:
input:
- handler_key: multiway-valve-inlet - handler_key: multiway-valve-inlet
label: Valve Inlet label: Valve Inlet
data_type: fluid data_type: fluid
@@ -199,59 +189,66 @@ virtual_multiway_valve:
data_source: handle data_source: handle
data_key: fluid_in data_key: fluid_in
description: "八通阀门进液口,接收来源流体" description: "八通阀门进液口,接收来源流体"
output:
- handler_key: multiway-valve-port-1 - handler_key: multiway-valve-port-1
label: Port 1 label: 1
data_type: fluid data_type: fluid
side: NORTH
io_type: source io_type: source
data_source: executor data_source: executor
data_key: fluid_port_1 data_key: fluid_port_1
description: "八通阀门端口1position=1时流体从此口流出" description: "八通阀门端口1position=1时流体从此口流出"
- handler_key: multiway-valve-port-2 - handler_key: multiway-valve-port-2
label: Port 2 label: 2
data_type: fluid data_type: fluid
side: EAST
io_type: source io_type: source
data_source: executor data_source: executor
data_key: fluid_port_2 data_key: fluid_port_2
description: "八通阀门端口2position=2时流体从此口流出" description: "八通阀门端口2position=2时流体从此口流出"
- handler_key: multiway-valve-port-3 - handler_key: multiway-valve-port-3
label: Port 3 label: 3
data_type: fluid data_type: fluid
side: EAST
io_type: source io_type: source
data_source: executor data_source: executor
data_key: fluid_port_3 data_key: fluid_port_3
description: "八通阀门端口3position=3时流体从此口流出" description: "八通阀门端口3position=3时流体从此口流出"
- handler_key: multiway-valve-port-4 - handler_key: multiway-valve-port-4
label: Port 4 label: 4
data_type: fluid data_type: fluid
side: SOUTH
io_type: source io_type: source
data_source: executor data_source: executor
data_key: fluid_port_4 data_key: fluid_port_4
description: "八通阀门端口4position=4时流体从此口流出" description: "八通阀门端口4position=4时流体从此口流出"
- handler_key: multiway-valve-port-5 - handler_key: multiway-valve-port-5
label: Port 5 label: 5
data_type: fluid data_type: fluid
side: SOUTH
io_type: source io_type: source
data_source: executor data_source: executor
data_key: fluid_port_5 data_key: fluid_port_5
description: "八通阀门端口5position=5时流体从此口流出" description: "八通阀门端口5position=5时流体从此口流出"
- handler_key: multiway-valve-port-6
label: Port 6
data_type: fluid
io_type: source
data_source: executor
data_key: fluid_port_6
description: "八通阀门端口6position=6时流体从此口流出"
- handler_key: multiway-valve-port-7 - handler_key: multiway-valve-port-7
label: Port 7 label: 7
data_type: fluid data_type: fluid
side: WEST
io_type: source io_type: source
data_source: executor data_source: executor
data_key: fluid_port_7 data_key: fluid_port_7
description: "八通阀门端口7position=7时流体从此口流出" description: "八通阀门端口7position=7时流体从此口流出"
- handler_key: multiway-valve-port-8 - handler_key: multiway-valve-port-6
label: Port 8 label: 6
data_type: fluid data_type: fluid
side: WEST
io_type: source
data_source: executor
data_key: fluid_port_6
description: "八通阀门端口6position=6时流体从此口流出"
- handler_key: multiway-valve-port-8
label: 8
data_type: fluid
side: NORTH
io_type: source io_type: source
data_source: executor data_source: executor
data_key: fluid_port_8 data_key: fluid_port_8
@@ -299,11 +296,17 @@ virtual_solenoid_valve:
success: success success: success
# 电磁阀门节点配置 - 双向流通的开关型阀门,流动方向由泵决定 # 电磁阀门节点配置 - 双向流通的开关型阀门,流动方向由泵决定
handles: handles:
bidirectional: - handler_key: solenoid-valve-port-in
- handler_key: solenoid-valve-port label: in
label: Valve Port
data_type: fluid data_type: fluid
io_type: bidirectional io_type: undirected
data_source: handle
data_key: fluid_port
description: "电磁阀的双向流体口,开启时允许流体双向通过,关闭时完全阻断"
- handler_key: solenoid-valve-port-out
label: out
data_type: fluid
io_type: undirected
data_source: handle data_source: handle
data_key: fluid_port data_key: fluid_port
description: "电磁阀的双向流体口,开启时允许流体双向通过,关闭时完全阻断" description: "电磁阀的双向流体口,开启时允许流体双向通过,关闭时完全阻断"
@@ -354,22 +357,13 @@ virtual_centrifuge:
message: message message: message
# 虚拟离心机节点配置 - 单个样品处理设备,输入输出都是同一个样品容器 # 虚拟离心机节点配置 - 单个样品处理设备,输入输出都是同一个样品容器
handles: handles:
input:
- handler_key: centrifuge-sample - handler_key: centrifuge-sample
label: Sample Input label: Sample Input/Output
data_type: resource data_type: transport
io_type: target io_type: undirected
data_source: handle data_source: handle
data_key: vessel data_key: vessel
description: "需要离心的样品容器" description: "需要离心的样品容器"
output:
- handler_key: centrifuge-sample-out
label: Centrifuged Sample
data_type: resource
io_type: source
data_source: executor
data_key: vessel
description: "经过离心处理的样品容器"
schema: schema:
type: object type: object
properties: properties:
@@ -424,25 +418,26 @@ virtual_filter:
message: message message: message
# 虚拟过滤器节点配置 - 分离设备1个输入(原始样品)2个输出(滤液和滤渣) # 虚拟过滤器节点配置 - 分离设备1个输入(原始样品)2个输出(滤液和滤渣)
handles: handles:
input: - handler_key: filter-in
- handler_key: filter-sample-in label: Input
label: Sample Input data_type: fluid
data_type: resource side: NORTH
io_type: target io_type: target
data_source: handle data_source: handle
data_key: vessel data_key: vessel
description: "需要过滤的原始样品容器" description: "需要过滤的原始样品容器"
output:
- handler_key: filter-filtrate-out - handler_key: filter-filtrate-out
label: Filtrate Output label: Output
data_type: resource data_type: fluid
side: SOUTH
io_type: source io_type: source
data_source: executor data_source: executor
data_key: filtrate_vessel data_key: filtrate_vessel
description: "过滤后的滤液容器" description: "过滤后的滤液容器"
- handler_key: filter-residue-out - handler_key: filter-residue-out
label: Filter Residue label: Residue
data_type: resource data_type: resource
side: WEST
io_type: source io_type: source
data_source: executor data_source: executor
data_key: residue_vessel data_key: residue_vessel
@@ -502,11 +497,11 @@ virtual_heatchill:
success: success success: success
# 虚拟加热/冷却器节点配置 - 温控设备,单一双向连接点用于放置容器 # 虚拟加热/冷却器节点配置 - 温控设备,单一双向连接点用于放置容器
handles: handles:
bidirectional:
- handler_key: heatchill-vessel - handler_key: heatchill-vessel
label: Vessel Connection label: Connection
data_type: mechanical data_type: mechanical
io_type: bidirectional side: NORTH
io_type: undirected
data_source: handle data_source: handle
data_key: vessel data_key: vessel
description: "加热/冷却器的物理连接口,容器直接放置在设备上进行温度控制" description: "加热/冷却器的物理连接口,容器直接放置在设备上进行温度控制"
@@ -530,7 +525,7 @@ virtual_heatchill:
virtual_transfer_pump: virtual_transfer_pump:
description: Virtual Transfer Pump for TransferProtocol Testing (Syringe-style) description: Virtual Transfer Pump for TransferProtocol Testing (Syringe-style)
class: class:
module: unilabos.devices.virtual.virtual_transferpump:VirtualTransferPump module: unilabos.devices.virtual.virtual_transferpump:VirtualPump
type: python type: python
status_types: status_types:
status: String status: String
@@ -565,11 +560,11 @@ virtual_transfer_pump:
message: message message: message
# 注射器式转移泵节点配置 - 只有一个双向连接口,可吸入和排出液体 # 注射器式转移泵节点配置 - 只有一个双向连接口,可吸入和排出液体
handles: handles:
bidirectional: undirected:
- handler_key: syringe-port - handler_key: syringe-port
label: Syringe Port label: Syringe Port
data_type: fluid data_type: fluid
io_type: bidirectional io_type: undirected
data_source: handle data_source: handle
data_key: fluid_port data_key: fluid_port
description: "注射器式转移泵的唯一连接口,通过阀门切换实现吸入和排出" description: "注射器式转移泵的唯一连接口,通过阀门切换实现吸入和排出"
@@ -617,18 +612,18 @@ virtual_column:
message: message message: message
# 虚拟色谱柱节点配置 - 分离纯化设备1个样品输入口1个纯化产物输出口 # 虚拟色谱柱节点配置 - 分离纯化设备1个样品输入口1个纯化产物输出口
handles: handles:
input:
- handler_key: column-sample-inlet - handler_key: column-sample-inlet
label: Sample Input label: Sample Input
data_type: resource data_type: fluid
side: NORTH
io_type: target io_type: target
data_source: handle data_source: handle
data_key: from_vessel data_key: from_vessel
description: "需要纯化的样品输入口" description: "需要纯化的样品输入口"
output:
- handler_key: column-product-outlet - handler_key: column-product-outlet
label: Purified Product label: Purified Product
data_type: resource data_type: fluid
side: SOUTH
io_type: source io_type: source
data_source: executor data_source: executor
data_key: to_vessel data_key: to_vessel

View File

@@ -100,7 +100,7 @@ _action_mapping: Dict[Type, Dict[str, Any]] = {
# 添加Protocol action类型到映射 # 添加Protocol action类型到映射
for py_msgtype in imsg.__all__: for py_msgtype in imsg.__all__:
if py_msgtype not in _action_mapping and py_msgtype.endswith("Protocol"): if py_msgtype not in _action_mapping and (py_msgtype.endswith("Protocol") or py_msgtype.startswith("Protocol")):
try: try:
protocol_class = msg_converter_manager.get_class(f"unilabos.messages.{py_msgtype}") protocol_class = msg_converter_manager.get_class(f"unilabos.messages.{py_msgtype}")
action_name = py_msgtype.replace("Protocol", "") action_name = py_msgtype.replace("Protocol", "")
@@ -117,6 +117,7 @@ for py_msgtype in imsg.__all__:
"result": {k: k for k in action_type.Result().get_fields_and_field_types().keys()}, "result": {k: k for k in action_type.Result().get_fields_and_field_types().keys()},
} }
except Exception: except Exception:
traceback.print_exc()
logger.debug(f"Failed to load Protocol class: {py_msgtype}") logger.debug(f"Failed to load Protocol class: {py_msgtype}")
# Python到ROS消息转换器 # Python到ROS消息转换器