mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-18 13:31:20 +00:00
Compare commits
60 Commits
5551fbf360
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13a6795657 | ||
|
|
53219d8b04 | ||
|
|
b1cdef9185 | ||
|
|
9854ed8c9c | ||
|
|
52544a2c69 | ||
|
|
5ce433e235 | ||
|
|
c7c14d2332 | ||
|
|
6fdd482649 | ||
|
|
d390236318 | ||
|
|
ed8ee29732 | ||
|
|
ffc583e9d5 | ||
|
|
f1ad0c9c96 | ||
|
|
8fa3407649 | ||
|
|
d3282822fc | ||
|
|
554bcade24 | ||
|
|
a662c75de1 | ||
|
|
931614fe64 | ||
|
|
d39662f65f | ||
|
|
acf5fdebf8 | ||
|
|
7f7b1c13c0 | ||
|
|
75f09034ff | ||
|
|
549a50220b | ||
|
|
4189a2cfbe | ||
|
|
48895a9bb1 | ||
|
|
891f126ed6 | ||
|
|
4d3475a849 | ||
|
|
b475db66df | ||
|
|
a625a86e3e | ||
|
|
37e0f1037c | ||
|
|
a242253145 | ||
|
|
448e0074b7 | ||
|
|
304827fc8d | ||
|
|
872b3d781f | ||
|
|
813400f2b4 | ||
|
|
b6dfe2b944 | ||
|
|
8807865649 | ||
|
|
5fc7eb7586 | ||
|
|
9bd72b48e1 | ||
|
|
42b78ab4c1 | ||
|
|
9645609a05 | ||
|
|
a2a827d7ac | ||
|
|
bb3ca645a4 | ||
|
|
37ee43d19a | ||
|
|
bc30f23e34 | ||
|
|
166d84afe1 | ||
|
|
1b43c53015 | ||
|
|
d4415f5a35 | ||
|
|
0260cbbedb | ||
|
|
7c440d10ab | ||
|
|
c85c49817d | ||
|
|
c70eafa5f0 | ||
|
|
b64466d443 | ||
|
|
ef3f24ed48 | ||
|
|
2a8e8d014b | ||
|
|
e0da1c7217 | ||
|
|
51d3e61723 | ||
|
|
6b5765bbf3 | ||
|
|
eb1f3fbe1c | ||
|
|
fb93b1cd94 | ||
|
|
9aeffebde1 |
@@ -1,6 +1,6 @@
|
|||||||
package:
|
package:
|
||||||
name: unilabos
|
name: unilabos
|
||||||
version: 0.10.11
|
version: 0.10.12
|
||||||
|
|
||||||
source:
|
source:
|
||||||
path: ../unilabos
|
path: ../unilabos
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ Uni-Lab-OS recommends using `mamba` for environment management. Choose the appro
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Create new environment
|
# Create new environment
|
||||||
mamba create -n unilab uni-lab::unilabos -c robostack-staging -c conda-forge
|
mamba create -n unilab python=3.11.11
|
||||||
|
mamba activate unilab
|
||||||
|
mamba install -n unilab uni-lab::unilabos -c robostack-staging -c conda-forge
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install Dev Uni-Lab-OS
|
## Install Dev Uni-Lab-OS
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ Uni-Lab-OS 建议使用 `mamba` 管理环境。根据您的操作系统选择适
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 创建新环境
|
# 创建新环境
|
||||||
mamba create -n unilab uni-lab::unilabos -c robostack-staging -c conda-forge
|
mamba create -n unilab python=3.11.11
|
||||||
|
mamba activate unilab
|
||||||
|
mamba install -n unilab uni-lab::unilabos -c robostack-staging -c conda-forge
|
||||||
```
|
```
|
||||||
|
|
||||||
2. 安装开发版 Uni-Lab-OS:
|
2. 安装开发版 Uni-Lab-OS:
|
||||||
|
|||||||
@@ -317,45 +317,6 @@ unilab --help
|
|||||||
|
|
||||||
如果所有命令都正常输出,说明开发环境配置成功!
|
如果所有命令都正常输出,说明开发环境配置成功!
|
||||||
|
|
||||||
### 开发工具推荐
|
|
||||||
|
|
||||||
#### IDE
|
|
||||||
|
|
||||||
- **PyCharm Professional**: 强大的 Python IDE,支持远程调试
|
|
||||||
- **VS Code**: 轻量级,配合 Python 扩展使用
|
|
||||||
- **Vim/Emacs**: 适合终端开发
|
|
||||||
|
|
||||||
#### 推荐的 VS Code 扩展
|
|
||||||
|
|
||||||
- Python
|
|
||||||
- Pylance
|
|
||||||
- ROS
|
|
||||||
- URDF
|
|
||||||
- YAML
|
|
||||||
|
|
||||||
#### 调试工具
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 安装调试工具
|
|
||||||
pip install ipdb pytest pytest-cov -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
|
|
||||||
|
|
||||||
# 代码质量检查
|
|
||||||
pip install black flake8 mypy -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
|
|
||||||
```
|
|
||||||
|
|
||||||
### 设置 pre-commit 钩子(可选)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 安装 pre-commit
|
|
||||||
pip install pre-commit -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
|
|
||||||
|
|
||||||
# 设置钩子
|
|
||||||
pre-commit install
|
|
||||||
|
|
||||||
# 手动运行检查
|
|
||||||
pre-commit run --all-files
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 验证安装
|
## 验证安装
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package:
|
package:
|
||||||
name: ros-humble-unilabos-msgs
|
name: ros-humble-unilabos-msgs
|
||||||
version: 0.10.11
|
version: 0.10.12
|
||||||
source:
|
source:
|
||||||
path: ../../unilabos_msgs
|
path: ../../unilabos_msgs
|
||||||
target_directory: src
|
target_directory: src
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package:
|
package:
|
||||||
name: unilabos
|
name: unilabos
|
||||||
version: "0.10.11"
|
version: "0.10.12"
|
||||||
|
|
||||||
source:
|
source:
|
||||||
path: ../..
|
path: ../..
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -4,7 +4,7 @@ package_name = 'unilabos'
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name=package_name,
|
name=package_name,
|
||||||
version='0.10.11',
|
version='0.10.12',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
install_requires=['setuptools'],
|
install_requires=['setuptools'],
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__version__ = "0.10.11"
|
__version__ = "0.10.12"
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class CommunicationClientFactory:
|
|||||||
"""
|
"""
|
||||||
if cls._client_cache is None:
|
if cls._client_cache is None:
|
||||||
cls._client_cache = cls.create_client(protocol)
|
cls._client_cache = cls.create_client(protocol)
|
||||||
logger.info(f"[CommunicationFactory] Created {type(cls._client_cache).__name__} client")
|
logger.trace(f"[CommunicationFactory] Created {type(cls._client_cache).__name__} client")
|
||||||
|
|
||||||
return cls._client_cache
|
return cls._client_cache
|
||||||
|
|
||||||
|
|||||||
@@ -159,9 +159,10 @@ def parse_args():
|
|||||||
def main():
|
def main():
|
||||||
"""主函数"""
|
"""主函数"""
|
||||||
# 解析命令行参数
|
# 解析命令行参数
|
||||||
args = parse_args()
|
parser = parse_args()
|
||||||
convert_argv_dashes_to_underscores(args)
|
convert_argv_dashes_to_underscores(parser)
|
||||||
args_dict = vars(args.parse_args())
|
args = parser.parse_args()
|
||||||
|
args_dict = vars(args)
|
||||||
|
|
||||||
# 环境检查 - 检查并自动安装必需的包 (可选)
|
# 环境检查 - 检查并自动安装必需的包 (可选)
|
||||||
if not args_dict.get("skip_env_check", False):
|
if not args_dict.get("skip_env_check", False):
|
||||||
@@ -220,17 +221,18 @@ def main():
|
|||||||
logger.info(f"Log level set to '{BasicConfig.log_level}' from config file.")
|
logger.info(f"Log level set to '{BasicConfig.log_level}' from config file.")
|
||||||
configure_logger(loglevel=BasicConfig.log_level, working_dir=working_dir)
|
configure_logger(loglevel=BasicConfig.log_level, working_dir=working_dir)
|
||||||
|
|
||||||
if args_dict["addr"] == "test":
|
if args.addr != parser.get_default("addr"):
|
||||||
|
if args.addr == "test":
|
||||||
print_status("使用测试环境地址", "info")
|
print_status("使用测试环境地址", "info")
|
||||||
HTTPConfig.remote_addr = "https://uni-lab.test.bohrium.com/api/v1"
|
HTTPConfig.remote_addr = "https://uni-lab.test.bohrium.com/api/v1"
|
||||||
elif args_dict["addr"] == "uat":
|
elif args.addr == "uat":
|
||||||
print_status("使用uat环境地址", "info")
|
print_status("使用uat环境地址", "info")
|
||||||
HTTPConfig.remote_addr = "https://uni-lab.uat.bohrium.com/api/v1"
|
HTTPConfig.remote_addr = "https://uni-lab.uat.bohrium.com/api/v1"
|
||||||
elif args_dict["addr"] == "local":
|
elif args.addr == "local":
|
||||||
print_status("使用本地环境地址", "info")
|
print_status("使用本地环境地址", "info")
|
||||||
HTTPConfig.remote_addr = "http://127.0.0.1:48197/api/v1"
|
HTTPConfig.remote_addr = "http://127.0.0.1:48197/api/v1"
|
||||||
else:
|
else:
|
||||||
HTTPConfig.remote_addr = args_dict.get("addr", "")
|
HTTPConfig.remote_addr = args.addr
|
||||||
|
|
||||||
# 设置BasicConfig参数
|
# 设置BasicConfig参数
|
||||||
if args_dict.get("ak", ""):
|
if args_dict.get("ak", ""):
|
||||||
@@ -327,6 +329,10 @@ def main():
|
|||||||
for ind, i in enumerate(resource_edge_info[::-1]):
|
for ind, i in enumerate(resource_edge_info[::-1]):
|
||||||
source_node: ResourceDict = nodes[i["source"]]
|
source_node: ResourceDict = nodes[i["source"]]
|
||||||
target_node: ResourceDict = nodes[i["target"]]
|
target_node: ResourceDict = nodes[i["target"]]
|
||||||
|
if "sourceHandle" not in source_node:
|
||||||
|
continue
|
||||||
|
if "targetHandle" not in target_node:
|
||||||
|
continue
|
||||||
source_handle = i["sourceHandle"]
|
source_handle = i["sourceHandle"]
|
||||||
target_handle = i["targetHandle"]
|
target_handle = i["targetHandle"]
|
||||||
source_handler_keys = [
|
source_handler_keys = [
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ class MessageProcessor:
|
|||||||
self.is_running = True
|
self.is_running = True
|
||||||
self.thread = threading.Thread(target=self._run, daemon=True, name="MessageProcessor")
|
self.thread = threading.Thread(target=self._run, daemon=True, name="MessageProcessor")
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
logger.info("[MessageProcessor] Started")
|
logger.trace("[MessageProcessor] Started")
|
||||||
|
|
||||||
def stop(self) -> None:
|
def stop(self) -> None:
|
||||||
"""停止消息处理线程"""
|
"""停止消息处理线程"""
|
||||||
@@ -939,7 +939,7 @@ class QueueProcessor:
|
|||||||
# 事件通知机制
|
# 事件通知机制
|
||||||
self.queue_update_event = threading.Event()
|
self.queue_update_event = threading.Event()
|
||||||
|
|
||||||
logger.info("[QueueProcessor] Initialized")
|
logger.trace("[QueueProcessor] Initialized")
|
||||||
|
|
||||||
def set_websocket_client(self, websocket_client: "WebSocketClient"):
|
def set_websocket_client(self, websocket_client: "WebSocketClient"):
|
||||||
"""设置WebSocket客户端引用"""
|
"""设置WebSocket客户端引用"""
|
||||||
@@ -954,7 +954,7 @@ class QueueProcessor:
|
|||||||
self.is_running = True
|
self.is_running = True
|
||||||
self.thread = threading.Thread(target=self._run, daemon=True, name="QueueProcessor")
|
self.thread = threading.Thread(target=self._run, daemon=True, name="QueueProcessor")
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
logger.info("[QueueProcessor] Started")
|
logger.trace("[QueueProcessor] Started")
|
||||||
|
|
||||||
def stop(self) -> None:
|
def stop(self) -> None:
|
||||||
"""停止队列处理线程"""
|
"""停止队列处理线程"""
|
||||||
@@ -1314,3 +1314,19 @@ class WebSocketClient(BaseCommunicationClient):
|
|||||||
logger.info(f"[WebSocketClient] Job {job_log} cancelled successfully")
|
logger.info(f"[WebSocketClient] Job {job_log} cancelled successfully")
|
||||||
else:
|
else:
|
||||||
logger.warning(f"[WebSocketClient] Failed to cancel job {job_log}")
|
logger.warning(f"[WebSocketClient] Failed to cancel job {job_log}")
|
||||||
|
|
||||||
|
def publish_host_ready(self) -> None:
|
||||||
|
"""发布host_node ready信号"""
|
||||||
|
if self.is_disabled or not self.is_connected():
|
||||||
|
logger.debug("[WebSocketClient] Not connected, cannot publish host ready signal")
|
||||||
|
return
|
||||||
|
|
||||||
|
message = {
|
||||||
|
"action": "host_node_ready",
|
||||||
|
"data": {
|
||||||
|
"status": "ready",
|
||||||
|
"timestamp": time.time(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
self.message_processor.send_message(message)
|
||||||
|
logger.info("[WebSocketClient] Host node ready signal published")
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class WSConfig:
|
|||||||
|
|
||||||
# HTTP配置
|
# HTTP配置
|
||||||
class HTTPConfig:
|
class HTTPConfig:
|
||||||
remote_addr = "http://127.0.0.1:48197/api/v1"
|
remote_addr = "https://uni-lab.bohrium.com/api/v1"
|
||||||
|
|
||||||
|
|
||||||
# ROS配置
|
# ROS配置
|
||||||
|
|||||||
0
unilabos/devices/laiyu_liquid_test/__init__.py
Normal file
0
unilabos/devices/laiyu_liquid_test/__init__.py
Normal file
0
unilabos/devices/liquid_handling/laiyu/__init__.py
Normal file
0
unilabos/devices/liquid_handling/laiyu/__init__.py
Normal file
@@ -989,6 +989,18 @@ class LiquidHandlerAbstract(LiquidHandlerMiddleware):
|
|||||||
else:
|
else:
|
||||||
dis_vols = [float(v) for v in dis_vols]
|
dis_vols = [float(v) for v in dis_vols]
|
||||||
|
|
||||||
|
# 统一混合次数为标量,防止数组/列表与 int 比较时报错
|
||||||
|
if mix_times is not None and not isinstance(mix_times, (int, float)):
|
||||||
|
try:
|
||||||
|
mix_times = mix_times[0] if len(mix_times) > 0 else None
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
mix_times = next(iter(mix_times))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if mix_times is not None:
|
||||||
|
mix_times = int(mix_times)
|
||||||
|
|
||||||
# 识别传输模式
|
# 识别传输模式
|
||||||
num_sources = len(sources)
|
num_sources = len(sources)
|
||||||
num_targets = len(targets)
|
num_targets = len(targets)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
import uuid
|
||||||
from typing import Any, List, Dict, Optional, Tuple, TypedDict, Union, Sequence, Iterator, Literal
|
from typing import Any, List, Dict, Optional, Tuple, TypedDict, Union, Sequence, Iterator, Literal
|
||||||
|
|
||||||
from pylabrobot.liquid_handling import (
|
from pylabrobot.liquid_handling import (
|
||||||
@@ -856,7 +857,30 @@ class PRCXI9300Api:
|
|||||||
|
|
||||||
def _raw_request(self, payload: str) -> str:
|
def _raw_request(self, payload: str) -> str:
|
||||||
if self.debug:
|
if self.debug:
|
||||||
return " "
|
# 调试/仿真模式下直接返回可解析的模拟 JSON,避免后续 json.loads 报错
|
||||||
|
try:
|
||||||
|
req = json.loads(payload)
|
||||||
|
method = req.get("MethodName")
|
||||||
|
except Exception:
|
||||||
|
method = None
|
||||||
|
|
||||||
|
data: Any = True
|
||||||
|
if method in {"AddSolution"}:
|
||||||
|
data = str(uuid.uuid4())
|
||||||
|
elif method in {"AddWorkTabletMatrix", "AddWorkTabletMatrix2"}:
|
||||||
|
data = {"Success": True, "Message": "debug mock"}
|
||||||
|
elif method in {"GetErrorCode"}:
|
||||||
|
data = ""
|
||||||
|
elif method in {"RemoveErrorCodet", "Reset", "Start", "LoadSolution", "Pause", "Resume", "Stop"}:
|
||||||
|
data = True
|
||||||
|
elif method in {"GetStepStateList", "GetStepStatus", "GetStepState"}:
|
||||||
|
data = []
|
||||||
|
elif method in {"GetLocation"}:
|
||||||
|
data = {"X": 0, "Y": 0, "Z": 0}
|
||||||
|
elif method in {"GetResetStatus"}:
|
||||||
|
data = False
|
||||||
|
|
||||||
|
return json.dumps({"Success": True, "Msg": "debug mock", "Data": data})
|
||||||
with contextlib.closing(socket.socket()) as sock:
|
with contextlib.closing(socket.socket()) as sock:
|
||||||
sock.settimeout(self.timeout)
|
sock.settimeout(self.timeout)
|
||||||
sock.connect((self.host, self.port))
|
sock.connect((self.host, self.port))
|
||||||
|
|||||||
@@ -174,35 +174,6 @@ bioyond_dispensing_station:
|
|||||||
title: query_resource_by_name参数
|
title: query_resource_by_name参数
|
||||||
type: object
|
type: object
|
||||||
type: UniLabJsonCommand
|
type: UniLabJsonCommand
|
||||||
auto-transfer_materials_to_reaction_station:
|
|
||||||
feedback: {}
|
|
||||||
goal: {}
|
|
||||||
goal_default:
|
|
||||||
target_device_id: null
|
|
||||||
transfer_groups: null
|
|
||||||
handles: {}
|
|
||||||
placeholder_keys: {}
|
|
||||||
result: {}
|
|
||||||
schema:
|
|
||||||
description: ''
|
|
||||||
properties:
|
|
||||||
feedback: {}
|
|
||||||
goal:
|
|
||||||
properties:
|
|
||||||
target_device_id:
|
|
||||||
type: string
|
|
||||||
transfer_groups:
|
|
||||||
type: array
|
|
||||||
required:
|
|
||||||
- target_device_id
|
|
||||||
- transfer_groups
|
|
||||||
type: object
|
|
||||||
result: {}
|
|
||||||
required:
|
|
||||||
- goal
|
|
||||||
title: transfer_materials_to_reaction_station参数
|
|
||||||
type: object
|
|
||||||
type: UniLabJsonCommand
|
|
||||||
auto-workflow_sample_locations:
|
auto-workflow_sample_locations:
|
||||||
feedback: {}
|
feedback: {}
|
||||||
goal: {}
|
goal: {}
|
||||||
@@ -620,56 +591,6 @@ bioyond_dispensing_station:
|
|||||||
title: DispenStationSolnPrep
|
title: DispenStationSolnPrep
|
||||||
type: object
|
type: object
|
||||||
type: DispenStationSolnPrep
|
type: DispenStationSolnPrep
|
||||||
transfer_materials_to_reaction_station:
|
|
||||||
feedback: {}
|
|
||||||
goal:
|
|
||||||
target_device_id: target_device_id
|
|
||||||
transfer_groups: transfer_groups
|
|
||||||
goal_default:
|
|
||||||
target_device_id: ''
|
|
||||||
transfer_groups: ''
|
|
||||||
handles: {}
|
|
||||||
placeholder_keys:
|
|
||||||
target_device_id: unilabos_devices
|
|
||||||
result: {}
|
|
||||||
schema:
|
|
||||||
description: 将配液站完成的物料(溶液、样品等)转移到指定反应站的堆栈库位。支持配置多组转移任务,每组包含物料名称、目标堆栈和目标库位。
|
|
||||||
properties:
|
|
||||||
feedback: {}
|
|
||||||
goal:
|
|
||||||
properties:
|
|
||||||
target_device_id:
|
|
||||||
description: 目标反应站设备ID(从设备列表中选择,所有转移组都使用同一个目标设备)
|
|
||||||
type: string
|
|
||||||
transfer_groups:
|
|
||||||
description: 转移任务组列表,每组包含物料名称、目标堆栈和目标库位,可以添加多组
|
|
||||||
items:
|
|
||||||
properties:
|
|
||||||
materials:
|
|
||||||
description: 物料名称(手动输入,系统将通过RPC查询验证)
|
|
||||||
type: string
|
|
||||||
target_sites:
|
|
||||||
description: 目标库位(手动输入,如"A01")
|
|
||||||
type: string
|
|
||||||
target_stack:
|
|
||||||
description: 目标堆栈名称(手动输入,如"堆栈1左")
|
|
||||||
type: string
|
|
||||||
required:
|
|
||||||
- materials
|
|
||||||
- target_stack
|
|
||||||
- target_sites
|
|
||||||
type: object
|
|
||||||
type: array
|
|
||||||
required:
|
|
||||||
- target_device_id
|
|
||||||
- transfer_groups
|
|
||||||
type: object
|
|
||||||
result: {}
|
|
||||||
required:
|
|
||||||
- goal
|
|
||||||
title: transfer_materials_to_reaction_station参数
|
|
||||||
type: object
|
|
||||||
type: UniLabJsonCommand
|
|
||||||
wait_for_multiple_orders_and_get_reports:
|
wait_for_multiple_orders_and_get_reports:
|
||||||
feedback: {}
|
feedback: {}
|
||||||
goal:
|
goal:
|
||||||
|
|||||||
@@ -45,10 +45,13 @@ def canonicalize_nodes_data(
|
|||||||
print_status(f"{len(nodes)} Resources loaded:", "info")
|
print_status(f"{len(nodes)} Resources loaded:", "info")
|
||||||
|
|
||||||
# 第一步:基本预处理(处理graphml的label字段)
|
# 第一步:基本预处理(处理graphml的label字段)
|
||||||
for node in nodes:
|
outer_host_node_id = None
|
||||||
|
for idx, node in enumerate(nodes):
|
||||||
if node.get("label") is not None:
|
if node.get("label") is not None:
|
||||||
node_id = node.pop("label")
|
node_id = node.pop("label")
|
||||||
node["id"] = node["name"] = node_id
|
node["id"] = node["name"] = node_id
|
||||||
|
if node["id"] == "host_node":
|
||||||
|
outer_host_node_id = idx
|
||||||
if not isinstance(node.get("config"), dict):
|
if not isinstance(node.get("config"), dict):
|
||||||
node["config"] = {}
|
node["config"] = {}
|
||||||
if not node.get("type"):
|
if not node.get("type"):
|
||||||
@@ -76,7 +79,8 @@ def canonicalize_nodes_data(
|
|||||||
if k not in ["id", "uuid", "name", "description", "schema", "model", "icon", "parent_uuid", "parent", "type", "class", "position", "config", "data", "children", "pose"]:
|
if k not in ["id", "uuid", "name", "description", "schema", "model", "icon", "parent_uuid", "parent", "type", "class", "position", "config", "data", "children", "pose"]:
|
||||||
v = node.pop(k)
|
v = node.pop(k)
|
||||||
node["config"][k] = v
|
node["config"][k] = v
|
||||||
|
if outer_host_node_id is not None:
|
||||||
|
nodes.pop(outer_host_node_id)
|
||||||
# 第二步:处理parent_relation
|
# 第二步:处理parent_relation
|
||||||
id2idx = {node["id"]: idx for idx, node in enumerate(nodes)}
|
id2idx = {node["id"]: idx for idx, node in enumerate(nodes)}
|
||||||
for parent, children in parent_relation.items():
|
for parent, children in parent_relation.items():
|
||||||
@@ -93,7 +97,7 @@ def canonicalize_nodes_data(
|
|||||||
|
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
try:
|
try:
|
||||||
print_status(f"DeviceId: {node['id']}, Class: {node['class']}", "info")
|
# print_status(f"DeviceId: {node['id']}, Class: {node['class']}", "info")
|
||||||
# 使用标准化方法
|
# 使用标准化方法
|
||||||
resource_instance = ResourceDictInstance.get_resource_instance_from_dict(node)
|
resource_instance = ResourceDictInstance.get_resource_instance_from_dict(node)
|
||||||
known_nodes[node["id"]] = resource_instance
|
known_nodes[node["id"]] = resource_instance
|
||||||
@@ -280,10 +284,18 @@ def modify_to_backend_format(data: list[dict[str, Any]]) -> list[dict[str, Any]]
|
|||||||
edge["sourceHandle"] = port[source]
|
edge["sourceHandle"] = port[source]
|
||||||
elif "source_port" in edge:
|
elif "source_port" in edge:
|
||||||
edge["sourceHandle"] = edge.pop("source_port")
|
edge["sourceHandle"] = edge.pop("source_port")
|
||||||
|
else:
|
||||||
|
typ = edge.get("type")
|
||||||
|
if typ == "communication":
|
||||||
|
continue
|
||||||
if target in port:
|
if target in port:
|
||||||
edge["targetHandle"] = port[target]
|
edge["targetHandle"] = port[target]
|
||||||
elif "target_port" in edge:
|
elif "target_port" in edge:
|
||||||
edge["targetHandle"] = edge.pop("target_port")
|
edge["targetHandle"] = edge.pop("target_port")
|
||||||
|
else:
|
||||||
|
typ = edge.get("type")
|
||||||
|
if typ == "communication":
|
||||||
|
continue
|
||||||
edge["id"] = f"reactflow__edge-{source}-{edge['sourceHandle']}-{target}-{edge['targetHandle']}"
|
edge["id"] = f"reactflow__edge-{source}-{edge['sourceHandle']}-{target}-{edge['targetHandle']}"
|
||||||
for key in ["source_port", "target_port"]:
|
for key in ["source_port", "target_port"]:
|
||||||
if key in edge:
|
if key in edge:
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.lab_logger().error(f"更新资源uuid失败: {e}")
|
self.lab_logger().error(f"更新资源uuid失败: {e}")
|
||||||
self.lab_logger().error(traceback.format_exc())
|
self.lab_logger().error(traceback.format_exc())
|
||||||
self.lab_logger().debug(f"资源更新结果: {response}")
|
self.lab_logger().trace(f"资源更新结果: {response}")
|
||||||
|
|
||||||
async def get_resource(self, resources_uuid: List[str], with_children: bool = True) -> ResourceTreeSet:
|
async def get_resource(self, resources_uuid: List[str], with_children: bool = True) -> ResourceTreeSet:
|
||||||
"""
|
"""
|
||||||
@@ -1164,7 +1164,6 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
|||||||
execution_error = traceback.format_exc()
|
execution_error = traceback.format_exc()
|
||||||
break
|
break
|
||||||
|
|
||||||
##### self.lab_logger().info(f"准备执行: {action_kwargs}, 函数: {ACTION.__name__}")
|
|
||||||
time_start = time.time()
|
time_start = time.time()
|
||||||
time_overall = 100
|
time_overall = 100
|
||||||
future = None
|
future = None
|
||||||
@@ -1172,35 +1171,36 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
|||||||
# 将阻塞操作放入线程池执行
|
# 将阻塞操作放入线程池执行
|
||||||
if asyncio.iscoroutinefunction(ACTION):
|
if asyncio.iscoroutinefunction(ACTION):
|
||||||
try:
|
try:
|
||||||
##### self.lab_logger().info(f"异步执行动作 {ACTION}")
|
self.lab_logger().trace(f"异步执行动作 {ACTION}")
|
||||||
future = ROS2DeviceNode.run_async_func(ACTION, trace_error=False, **action_kwargs)
|
def _handle_future_exception(fut: Future):
|
||||||
|
|
||||||
def _handle_future_exception(fut):
|
|
||||||
nonlocal execution_error, execution_success, action_return_value
|
nonlocal execution_error, execution_success, action_return_value
|
||||||
try:
|
try:
|
||||||
action_return_value = fut.result()
|
action_return_value = fut.result()
|
||||||
|
if isinstance(action_return_value, BaseException):
|
||||||
|
raise action_return_value
|
||||||
execution_success = True
|
execution_success = True
|
||||||
except Exception as e:
|
except Exception as _:
|
||||||
execution_error = traceback.format_exc()
|
execution_error = traceback.format_exc()
|
||||||
error(
|
error(
|
||||||
f"异步任务 {ACTION.__name__} 报错了\n{traceback.format_exc()}\n原始输入:{action_kwargs}"
|
f"异步任务 {ACTION.__name__} 报错了\n{traceback.format_exc()}\n原始输入:{action_kwargs}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
future = ROS2DeviceNode.run_async_func(ACTION, trace_error=False, **action_kwargs)
|
||||||
future.add_done_callback(_handle_future_exception)
|
future.add_done_callback(_handle_future_exception)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
execution_error = traceback.format_exc()
|
execution_error = traceback.format_exc()
|
||||||
execution_success = False
|
execution_success = False
|
||||||
self.lab_logger().error(f"创建异步任务失败: {traceback.format_exc()}")
|
self.lab_logger().error(f"创建异步任务失败: {traceback.format_exc()}")
|
||||||
else:
|
else:
|
||||||
##### self.lab_logger().info(f"同步执行动作 {ACTION}")
|
self.lab_logger().trace(f"同步执行动作 {ACTION}")
|
||||||
future = self._executor.submit(ACTION, **action_kwargs)
|
future = self._executor.submit(ACTION, **action_kwargs)
|
||||||
|
|
||||||
def _handle_future_exception(fut):
|
def _handle_future_exception(fut: Future):
|
||||||
nonlocal execution_error, execution_success, action_return_value
|
nonlocal execution_error, execution_success, action_return_value
|
||||||
try:
|
try:
|
||||||
action_return_value = fut.result()
|
action_return_value = fut.result()
|
||||||
execution_success = True
|
execution_success = True
|
||||||
except Exception as e:
|
except Exception as _:
|
||||||
execution_error = traceback.format_exc()
|
execution_error = traceback.format_exc()
|
||||||
error(
|
error(
|
||||||
f"同步任务 {ACTION.__name__} 报错了\n{traceback.format_exc()}\n原始输入:{action_kwargs}"
|
f"同步任务 {ACTION.__name__} 报错了\n{traceback.format_exc()}\n原始输入:{action_kwargs}"
|
||||||
@@ -1305,7 +1305,7 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
|||||||
get_result_info_str(execution_error, execution_success, action_return_value),
|
get_result_info_str(execution_error, execution_success, action_return_value),
|
||||||
)
|
)
|
||||||
|
|
||||||
##### self.lab_logger().info(f"动作 {action_name} 完成并返回结果")
|
self.lab_logger().trace(f"动作 {action_name} 完成并返回结果")
|
||||||
return result_msg
|
return result_msg
|
||||||
|
|
||||||
return execute_callback
|
return execute_callback
|
||||||
@@ -1540,17 +1540,29 @@ class ROS2DeviceNode:
|
|||||||
这个类封装了设备类实例和ROS2节点的功能,提供ROS2接口。
|
这个类封装了设备类实例和ROS2节点的功能,提供ROS2接口。
|
||||||
它不继承设备类,而是通过代理模式访问设备类的属性和方法。
|
它不继承设备类,而是通过代理模式访问设备类的属性和方法。
|
||||||
"""
|
"""
|
||||||
|
@staticmethod
|
||||||
|
async def safe_task_wrapper(trace_callback, func, **kwargs):
|
||||||
|
try:
|
||||||
|
if callable(trace_callback):
|
||||||
|
trace_callback(await func(**kwargs))
|
||||||
|
return await func(**kwargs)
|
||||||
|
except Exception as e:
|
||||||
|
if callable(trace_callback):
|
||||||
|
trace_callback(e)
|
||||||
|
return e
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_async_func(cls, func, trace_error=True, **kwargs) -> Task:
|
def run_async_func(cls, func, trace_error=True, inner_trace_callback=None, **kwargs) -> Task:
|
||||||
def _handle_future_exception(fut):
|
def _handle_future_exception(fut: Future):
|
||||||
try:
|
try:
|
||||||
fut.result()
|
ret = fut.result()
|
||||||
|
if isinstance(ret, BaseException):
|
||||||
|
raise ret
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error(f"异步任务 {func.__name__} 报错了")
|
error(f"异步任务 {func.__name__} 获取结果失败")
|
||||||
error(traceback.format_exc())
|
error(traceback.format_exc())
|
||||||
|
|
||||||
future = rclpy.get_global_executor().create_task(func(**kwargs))
|
future = rclpy.get_global_executor().create_task(ROS2DeviceNode.safe_task_wrapper(inner_trace_callback, func, **kwargs))
|
||||||
if trace_error:
|
if trace_error:
|
||||||
future.add_done_callback(_handle_future_exception)
|
future.add_done_callback(_handle_future_exception)
|
||||||
return future
|
return future
|
||||||
|
|||||||
@@ -289,6 +289,12 @@ class HostNode(BaseROS2DeviceNode):
|
|||||||
self.lab_logger().info("[Host Node] Host node initialized.")
|
self.lab_logger().info("[Host Node] Host node initialized.")
|
||||||
HostNode._ready_event.set()
|
HostNode._ready_event.set()
|
||||||
|
|
||||||
|
# 发送host_node ready信号到所有桥接器
|
||||||
|
for bridge in self.bridges:
|
||||||
|
if hasattr(bridge, "publish_host_ready"):
|
||||||
|
bridge.publish_host_ready()
|
||||||
|
self.lab_logger().debug(f"Host ready signal sent via {bridge.__class__.__name__}")
|
||||||
|
|
||||||
def _send_re_register(self, sclient):
|
def _send_re_register(self, sclient):
|
||||||
sclient.wait_for_service()
|
sclient.wait_for_service()
|
||||||
request = SerialCommand.Request()
|
request = SerialCommand.Request()
|
||||||
@@ -712,7 +718,7 @@ class HostNode(BaseROS2DeviceNode):
|
|||||||
feedback_callback=lambda feedback_msg: self.feedback_callback(item, action_id, feedback_msg),
|
feedback_callback=lambda feedback_msg: self.feedback_callback(item, action_id, feedback_msg),
|
||||||
goal_uuid=goal_uuid_obj,
|
goal_uuid=goal_uuid_obj,
|
||||||
)
|
)
|
||||||
future.add_done_callback(lambda future: self.goal_response_callback(item, action_id, future))
|
future.add_done_callback(lambda f: self.goal_response_callback(item, action_id, f))
|
||||||
|
|
||||||
def goal_response_callback(self, item: "QueueItem", action_id: str, future) -> None:
|
def goal_response_callback(self, item: "QueueItem", action_id: str, future) -> None:
|
||||||
"""目标响应回调"""
|
"""目标响应回调"""
|
||||||
@@ -723,9 +729,11 @@ class HostNode(BaseROS2DeviceNode):
|
|||||||
|
|
||||||
self.lab_logger().info(f"[Host Node] Goal {action_id} ({item.job_id}) accepted")
|
self.lab_logger().info(f"[Host Node] Goal {action_id} ({item.job_id}) accepted")
|
||||||
self._goals[item.job_id] = goal_handle
|
self._goals[item.job_id] = goal_handle
|
||||||
goal_handle.get_result_async().add_done_callback(
|
goal_future = goal_handle.get_result_async()
|
||||||
lambda future: self.get_result_callback(item, action_id, future)
|
goal_future.add_done_callback(
|
||||||
|
lambda f: self.get_result_callback(item, action_id, f)
|
||||||
)
|
)
|
||||||
|
goal_future.result()
|
||||||
|
|
||||||
def feedback_callback(self, item: "QueueItem", action_id: str, feedback_msg) -> None:
|
def feedback_callback(self, item: "QueueItem", action_id: str, feedback_msg) -> None:
|
||||||
"""反馈回调"""
|
"""反馈回调"""
|
||||||
@@ -794,6 +802,7 @@ class HostNode(BaseROS2DeviceNode):
|
|||||||
# 存储结果供 HTTP API 查询
|
# 存储结果供 HTTP API 查询
|
||||||
try:
|
try:
|
||||||
from unilabos.app.web.controller import store_job_result
|
from unilabos.app.web.controller import store_job_result
|
||||||
|
|
||||||
if goal_status == GoalStatus.STATUS_CANCELED:
|
if goal_status == GoalStatus.STATUS_CANCELED:
|
||||||
store_job_result(job_id, status, return_info, {})
|
store_job_result(job_id, status, return_info, {})
|
||||||
else:
|
else:
|
||||||
@@ -1148,12 +1157,11 @@ class HostNode(BaseROS2DeviceNode):
|
|||||||
响应对象,包含查询到的资源
|
响应对象,包含查询到的资源
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
from unilabos.app.web import http_client
|
|
||||||
data = json.loads(request.command)
|
data = json.loads(request.command)
|
||||||
if "uuid" in data and data["uuid"] is not None:
|
if "uuid" in data and data["uuid"] is not None:
|
||||||
http_req = http_client.resource_tree_get([data["uuid"]], data["with_children"])
|
http_req = self.bridges[-1].resource_tree_get([data["uuid"]], data["with_children"])
|
||||||
elif "id" in data and data["id"].startswith("/"):
|
elif "id" in data and data["id"].startswith("/"):
|
||||||
http_req = http_client.resource_get(data["id"], data["with_children"])
|
http_req = self.bridges[-1].resource_get(data["id"], data["with_children"])
|
||||||
else:
|
else:
|
||||||
raise ValueError("没有使用正确的物料 id 或 uuid")
|
raise ValueError("没有使用正确的物料 id 或 uuid")
|
||||||
response.response = json.dumps(http_req["data"])
|
response.response = json.dumps(http_req["data"])
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import inspect
|
||||||
import traceback
|
import traceback
|
||||||
import uuid
|
import uuid
|
||||||
from pydantic import BaseModel, field_serializer, field_validator
|
from pydantic import BaseModel, field_serializer, field_validator
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
from typing import List, Tuple, Any, Dict, Literal, Optional, cast, TYPE_CHECKING, Union
|
from typing import List, Tuple, Any, Dict, Literal, Optional, cast, TYPE_CHECKING, Union
|
||||||
|
|
||||||
|
from unilabos.resources.plr_additional_res_reg import register
|
||||||
from unilabos.utils.log import logger
|
from unilabos.utils.log import logger
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
@@ -153,7 +155,7 @@ class ResourceDictInstance(object):
|
|||||||
res_dict = self.res_content.model_dump(by_alias=True)
|
res_dict = self.res_content.model_dump(by_alias=True)
|
||||||
res_dict["children"] = {child.res_content.id: child.get_plr_nested_dict() for child in self.children}
|
res_dict["children"] = {child.res_content.id: child.get_plr_nested_dict() for child in self.children}
|
||||||
res_dict["parent"] = self.res_content.parent_instance_name
|
res_dict["parent"] = self.res_content.parent_instance_name
|
||||||
res_dict["position"] = self.res_content.position.position.model_dump()
|
res_dict["position"] = self.res_content.pose.position.model_dump()
|
||||||
del res_dict["pose"]
|
del res_dict["pose"]
|
||||||
return res_dict
|
return res_dict
|
||||||
|
|
||||||
@@ -429,9 +431,9 @@ class ResourceTreeSet(object):
|
|||||||
Returns:
|
Returns:
|
||||||
List[PLRResource]: PLR 资源实例列表
|
List[PLRResource]: PLR 资源实例列表
|
||||||
"""
|
"""
|
||||||
|
register()
|
||||||
from pylabrobot.resources import Resource as PLRResource
|
from pylabrobot.resources import Resource as PLRResource
|
||||||
from pylabrobot.utils.object_parsing import find_subclass
|
from pylabrobot.utils.object_parsing import find_subclass
|
||||||
import inspect
|
|
||||||
|
|
||||||
# 类型映射
|
# 类型映射
|
||||||
TYPE_MAP = {"plate": "Plate", "well": "Well", "deck": "Deck", "container": "RegularContainer"}
|
TYPE_MAP = {"plate": "Plate", "well": "Well", "deck": "Deck", "container": "RegularContainer"}
|
||||||
@@ -459,9 +461,9 @@ class ResourceTreeSet(object):
|
|||||||
"size_y": res.config.get("size_y", 0),
|
"size_y": res.config.get("size_y", 0),
|
||||||
"size_z": res.config.get("size_z", 0),
|
"size_z": res.config.get("size_z", 0),
|
||||||
"location": {
|
"location": {
|
||||||
"x": res.position.position.x,
|
"x": res.pose.position.x,
|
||||||
"y": res.position.position.y,
|
"y": res.pose.position.y,
|
||||||
"z": res.position.position.z,
|
"z": res.pose.position.z,
|
||||||
"type": "Coordinate",
|
"type": "Coordinate",
|
||||||
},
|
},
|
||||||
"rotation": {"x": 0, "y": 0, "z": 0, "type": "Rotation"},
|
"rotation": {"x": 0, "y": 0, "z": 0, "type": "Rotation"},
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "device",
|
"type": "device",
|
||||||
"class": "syringepump.runze",
|
"class": "syringe_pump_with_valve.runze.SY03B-T08",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 620.6111111111111,
|
"x": 620.6111111111111,
|
||||||
"y": 171,
|
"y": 171,
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 430.4087301587302,
|
"x": 430.4087301587302,
|
||||||
"y": 428,
|
"y": 428,
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 295.36944444444447,
|
"x": 295.36944444444447,
|
||||||
"y": 428,
|
"y": 428,
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 165.36944444444444,
|
"x": 165.36944444444444,
|
||||||
"y": 428,
|
"y": 428,
|
||||||
@@ -165,7 +165,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 165.36944444444444,
|
"x": 165.36944444444444,
|
||||||
"y": 428,
|
"y": 428,
|
||||||
@@ -189,7 +189,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 35,
|
"x": 35,
|
||||||
"y": 428,
|
"y": 428,
|
||||||
@@ -213,7 +213,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 698.1111111111111,
|
"x": 698.1111111111111,
|
||||||
"y": 428,
|
"y": 428,
|
||||||
@@ -255,7 +255,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "device",
|
"type": "device",
|
||||||
"class": "syringepump.runze",
|
"class": "syringe_pump_with_valve.runze.SY03B-T08",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1195.611507936508,
|
"x": 1195.611507936508,
|
||||||
"y": 686,
|
"y": 686,
|
||||||
@@ -279,7 +279,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1587.703373015873,
|
"x": 1587.703373015873,
|
||||||
"y": 1172.5,
|
"y": 1172.5,
|
||||||
@@ -299,7 +299,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "device",
|
"type": "device",
|
||||||
"class": "separator_controller",
|
"class": "separator.homemade",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1624.4027777777778,
|
"x": 1624.4027777777778,
|
||||||
"y": 665.5,
|
"y": 665.5,
|
||||||
@@ -320,7 +320,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1614.404365079365,
|
"x": 1614.404365079365,
|
||||||
"y": 948,
|
"y": 948,
|
||||||
@@ -340,7 +340,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1915.7035714285714,
|
"x": 1915.7035714285714,
|
||||||
"y": 665.5,
|
"y": 665.5,
|
||||||
@@ -360,7 +360,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1785.7035714285714,
|
"x": 1785.7035714285714,
|
||||||
"y": 665.5,
|
"y": 665.5,
|
||||||
@@ -384,7 +384,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 2054.0650793650793,
|
"x": 2054.0650793650793,
|
||||||
"y": 665.5,
|
"y": 665.5,
|
||||||
@@ -408,7 +408,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "device",
|
"type": "device",
|
||||||
"class": "syringepump.runze",
|
"class": "syringe_pump_with_valve.runze.SY03B-T08",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1630.6527777777778,
|
"x": 1630.6527777777778,
|
||||||
"y": 448.5,
|
"y": 448.5,
|
||||||
@@ -432,7 +432,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "device",
|
"type": "device",
|
||||||
"class": "rotavap",
|
"class": "rotavap.one",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1339.7031746031746,
|
"x": 1339.7031746031746,
|
||||||
"y": 968.5,
|
"y": 968.5,
|
||||||
@@ -453,7 +453,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1339.7031746031746,
|
"x": 1339.7031746031746,
|
||||||
"y": 1152,
|
"y": 1152,
|
||||||
@@ -473,7 +473,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 909.722619047619,
|
"x": 909.722619047619,
|
||||||
"y": 948,
|
"y": 948,
|
||||||
@@ -493,7 +493,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 867.972619047619,
|
"x": 867.972619047619,
|
||||||
"y": 1152,
|
"y": 1152,
|
||||||
@@ -513,7 +513,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 742.722619047619,
|
"x": 742.722619047619,
|
||||||
"y": 948,
|
"y": 948,
|
||||||
@@ -533,7 +533,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1206.722619047619,
|
"x": 1206.722619047619,
|
||||||
"y": 948,
|
"y": 948,
|
||||||
@@ -553,7 +553,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"class": null,
|
"class": "container",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1148.222619047619,
|
"x": 1148.222619047619,
|
||||||
"y": 1152,
|
"y": 1152,
|
||||||
@@ -573,7 +573,7 @@
|
|||||||
"children": [],
|
"children": [],
|
||||||
"parent": "YugongStation",
|
"parent": "YugongStation",
|
||||||
"type": "device",
|
"type": "device",
|
||||||
"class": "syringepump.runze",
|
"class": "syringe_pump_with_valve.runze.SY03B-T08",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 1469.7031746031746,
|
"x": 1469.7031746031746,
|
||||||
"y": 968.5,
|
"y": 968.5,
|
||||||
|
|||||||
@@ -162,8 +162,9 @@ def configure_logger(loglevel=None, working_dir=None):
|
|||||||
"""
|
"""
|
||||||
# 获取根日志记录器
|
# 获取根日志记录器
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
|
root_logger.setLevel(TRACE_LEVEL)
|
||||||
# 设置日志级别
|
# 设置日志级别
|
||||||
|
numeric_level = logging.DEBUG
|
||||||
if loglevel is not None:
|
if loglevel is not None:
|
||||||
if isinstance(loglevel, str):
|
if isinstance(loglevel, str):
|
||||||
# 将字符串转换为logging级别
|
# 将字符串转换为logging级别
|
||||||
@@ -173,12 +174,8 @@ def configure_logger(loglevel=None, working_dir=None):
|
|||||||
numeric_level = getattr(logging, loglevel.upper(), None)
|
numeric_level = getattr(logging, loglevel.upper(), None)
|
||||||
if not isinstance(numeric_level, int):
|
if not isinstance(numeric_level, int):
|
||||||
print(f"警告: 无效的日志级别 '{loglevel}',使用默认级别 DEBUG")
|
print(f"警告: 无效的日志级别 '{loglevel}',使用默认级别 DEBUG")
|
||||||
numeric_level = logging.DEBUG
|
|
||||||
else:
|
else:
|
||||||
numeric_level = loglevel
|
numeric_level = loglevel
|
||||||
root_logger.setLevel(numeric_level)
|
|
||||||
else:
|
|
||||||
root_logger.setLevel(logging.DEBUG) # 默认级别
|
|
||||||
|
|
||||||
# 移除已存在的处理器
|
# 移除已存在的处理器
|
||||||
for handler in root_logger.handlers[:]:
|
for handler in root_logger.handlers[:]:
|
||||||
@@ -186,7 +183,7 @@ def configure_logger(loglevel=None, working_dir=None):
|
|||||||
|
|
||||||
# 创建控制台处理器
|
# 创建控制台处理器
|
||||||
console_handler = logging.StreamHandler()
|
console_handler = logging.StreamHandler()
|
||||||
console_handler.setLevel(root_logger.level) # 使用与根记录器相同的级别
|
console_handler.setLevel(numeric_level) # 使用与根记录器相同的级别
|
||||||
|
|
||||||
# 使用自定义的颜色格式化器
|
# 使用自定义的颜色格式化器
|
||||||
color_formatter = ColoredFormatter()
|
color_formatter = ColoredFormatter()
|
||||||
@@ -206,7 +203,7 @@ def configure_logger(loglevel=None, working_dir=None):
|
|||||||
|
|
||||||
# 创建文件处理器
|
# 创建文件处理器
|
||||||
file_handler = logging.FileHandler(log_filepath, encoding="utf-8")
|
file_handler = logging.FileHandler(log_filepath, encoding="utf-8")
|
||||||
file_handler.setLevel(root_logger.level)
|
file_handler.setLevel(TRACE_LEVEL)
|
||||||
|
|
||||||
# 使用不带颜色的格式化器
|
# 使用不带颜色的格式化器
|
||||||
file_formatter = ColoredFormatter(use_colors=False)
|
file_formatter = ColoredFormatter(use_colors=False)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
|
||||||
<package format="3">
|
<package format="3">
|
||||||
<name>unilabos_msgs</name>
|
<name>unilabos_msgs</name>
|
||||||
<version>0.10.11</version>
|
<version>0.10.12</version>
|
||||||
<description>ROS2 Messages package for unilabos devices</description>
|
<description>ROS2 Messages package for unilabos devices</description>
|
||||||
<maintainer email="changjh@pku.edu.cn">Junhan Chang</maintainer>
|
<maintainer email="changjh@pku.edu.cn">Junhan Chang</maintainer>
|
||||||
<maintainer email="18435084+Xuwznln@users.noreply.github.com">Xuwznln</maintainer>
|
<maintainer email="18435084+Xuwznln@users.noreply.github.com">Xuwznln</maintainer>
|
||||||
|
|||||||
Reference in New Issue
Block a user