mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-14 13:14:39 +00:00
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import threading
|
|
|
|
from unilabos.utils import logger
|
|
|
|
|
|
# 根据选择的 backend 启动相应的功能
|
|
def start_backend(
|
|
backend: str,
|
|
devices_config: dict = {},
|
|
resources_config: dict = {},
|
|
graph=None,
|
|
controllers_config: dict = {},
|
|
bridges=[],
|
|
without_host: bool = False,
|
|
**kwargs
|
|
):
|
|
if backend == "ros":
|
|
# 假设 ros_main, simple_main, automancer_main 是不同 backend 的启动函数
|
|
from unilabos.ros.main_slave_run import main, slave # 如果选择 'ros' 作为 backend
|
|
elif backend == 'simple':
|
|
# 这里假设 simple_backend 和 automancer_backend 是你定义的其他两个后端
|
|
# from simple_backend import main as simple_main
|
|
pass
|
|
elif backend == 'automancer':
|
|
# from automancer_backend import main as automancer_main
|
|
pass
|
|
else:
|
|
raise ValueError(f"Unsupported backend: {backend}")
|
|
|
|
backend_thread = threading.Thread(
|
|
target=main if not without_host else slave,
|
|
args=(devices_config, resources_config, graph, controllers_config, bridges)
|
|
)
|
|
backend_thread.start()
|
|
logger.info(f"Backend {backend} started.")
|