mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
fix: running logic
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
"teaching_carrier"
|
"teaching_carrier"
|
||||||
],
|
],
|
||||||
"parent": "PLR_STATION",
|
"parent": "PLR_STATION",
|
||||||
"type": "device",
|
"type": "deck",
|
||||||
"class": "OTDeck",
|
"class": "OTDeck",
|
||||||
"position": {
|
"position": {
|
||||||
"x": 0,
|
"x": 0,
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ def start_backend(
|
|||||||
|
|
||||||
backend_thread = threading.Thread(
|
backend_thread = threading.Thread(
|
||||||
target=main if not without_host else slave,
|
target=main if not without_host else slave,
|
||||||
args=(devices_config, resources_config, graph, controllers_config, bridges)
|
args=(devices_config, resources_config, graph, controllers_config, bridges),
|
||||||
|
name="backend_thread",
|
||||||
|
daemon=True,
|
||||||
)
|
)
|
||||||
backend_thread.start()
|
backend_thread.start()
|
||||||
logger.info(f"Backend {backend} started.")
|
logger.info(f"Backend {backend} started.")
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import argparse
|
import argparse
|
||||||
|
import asyncio
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import threading
|
import threading
|
||||||
@@ -125,7 +128,7 @@ def main():
|
|||||||
print_unilab_banner(args_dict)
|
print_unilab_banner(args_dict)
|
||||||
|
|
||||||
# 注册表
|
# 注册表
|
||||||
registry_dict = build_registry(args_dict["registry_path"])
|
build_registry(args_dict["registry_path"])
|
||||||
|
|
||||||
|
|
||||||
if args_dict["graph"] is not None:
|
if args_dict["graph"] is not None:
|
||||||
@@ -180,14 +183,17 @@ def main():
|
|||||||
enable_rviz=True
|
enable_rviz=True
|
||||||
elif args_dict["visual"] == "web":
|
elif args_dict["visual"] == "web":
|
||||||
enable_rviz=False
|
enable_rviz=False
|
||||||
resource_visualization = ResourceVisualization(devices_and_resources, args_dict["resources_config"],registry_dict,enable_rviz=enable_rviz)
|
resource_visualization = ResourceVisualization(devices_and_resources, args_dict["resources_config"] ,enable_rviz=enable_rviz)
|
||||||
devices_config_add = add_resource_mesh_manager_node(resource_visualization.resource_model, args_dict["resources_config"])
|
devices_config_add = add_resource_mesh_manager_node(resource_visualization.resource_model, args_dict["resources_config"])
|
||||||
args_dict["devices_config"] = {**args_dict["devices_config"], **devices_config_add}
|
args_dict["devices_config"] = {**args_dict["devices_config"], **devices_config_add}
|
||||||
|
|
||||||
server_thread = threading.Thread(target=start_server)
|
|
||||||
server_thread.start()
|
|
||||||
start_backend(**args_dict)
|
start_backend(**args_dict)
|
||||||
|
|
||||||
|
from unilabos.ros.nodes.base_device_node import ROS2DeviceNode
|
||||||
|
while ROS2DeviceNode.get_loop() is None:
|
||||||
|
time.sleep(0.1)
|
||||||
|
asyncio.set_event_loop(ROS2DeviceNode.get_loop())
|
||||||
resource_visualization.start()
|
resource_visualization.start()
|
||||||
|
start_server()
|
||||||
else:
|
else:
|
||||||
start_backend(**args_dict)
|
start_backend(**args_dict)
|
||||||
start_server()
|
start_server()
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ class MQTTClient:
|
|||||||
self.client.on_disconnect = self._on_disconnect
|
self.client.on_disconnect = self._on_disconnect
|
||||||
|
|
||||||
def _on_log(self, client, userdata, level, buf):
|
def _on_log(self, client, userdata, level, buf):
|
||||||
logger.info(f"[MQTT] log: {buf}")
|
# logger.info(f"[MQTT] log: {buf}")
|
||||||
|
pass
|
||||||
|
|
||||||
def _on_connect(self, client, userdata, flags, rc, properties=None):
|
def _on_connect(self, client, userdata, flags, rc, properties=None):
|
||||||
logger.info("[MQTT] Connected with result code " + str(rc))
|
logger.info("[MQTT] Connected with result code " + str(rc))
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ from launch_ros.actions import Node as nd
|
|||||||
import xacro
|
import xacro
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
from unilabos.registry.registry import lab_registry
|
||||||
|
|
||||||
|
|
||||||
class ResourceVisualization:
|
class ResourceVisualization:
|
||||||
def __init__(self, device: dict, resource: dict, registry: dict, enable_rviz: bool = True):
|
def __init__(self, device: dict, resource: dict, enable_rviz: bool = True):
|
||||||
"""初始化资源可视化类
|
"""初始化资源可视化类
|
||||||
|
|
||||||
该类用于将设备和资源的3D模型可视化展示。通过解析设备和资源的配置信息,
|
该类用于将设备和资源的3D模型可视化展示。通过解析设备和资源的配置信息,
|
||||||
@@ -24,9 +26,10 @@ class ResourceVisualization:
|
|||||||
self.launch_description = LaunchDescription()
|
self.launch_description = LaunchDescription()
|
||||||
self.resource_dict = resource
|
self.resource_dict = resource
|
||||||
self.resource_model = {}
|
self.resource_model = {}
|
||||||
self.resource_type = ['plate', 'container']
|
self.resource_type = ['deck', 'plate', 'container']
|
||||||
self.mesh_path = Path(__file__).parent.absolute()
|
self.mesh_path = Path(__file__).parent.absolute()
|
||||||
self.enable_rviz = enable_rviz
|
self.enable_rviz = enable_rviz
|
||||||
|
registry = lab_registry
|
||||||
|
|
||||||
self.srdf_str = '''
|
self.srdf_str = '''
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
OTDeck:
|
|
||||||
description: Opentrons deck 3d model
|
|
||||||
model:
|
|
||||||
type: device
|
|
||||||
mesh: opentrons_liquid_handler
|
|
||||||
@@ -2,6 +2,7 @@ import copy
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
import time
|
||||||
from typing import Optional, Dict, Any, List
|
from typing import Optional, Dict, Any, List
|
||||||
|
|
||||||
import rclpy
|
import rclpy
|
||||||
@@ -66,7 +67,7 @@ def main(
|
|||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
input()
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
def slave(
|
def slave(
|
||||||
@@ -120,7 +121,7 @@ def slave(
|
|||||||
logger.info(f"Slave resource added.")
|
logger.info(f"Slave resource added.")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
input()
|
time.sleep(1)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user