mirror of
https://github.com/dptech-corp/Uni-Lab-OS.git
synced 2025-12-17 13:01:12 +00:00
fix startup
add ResourceCreateFromOuter.action
This commit is contained in:
@@ -1,30 +1,24 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import json
|
||||
import threading
|
||||
import time
|
||||
from copy import deepcopy
|
||||
|
||||
import yaml
|
||||
from copy import deepcopy
|
||||
import threading
|
||||
|
||||
import rclpy
|
||||
from unilabos.ros.nodes.resource_tracker import DeviceNodeResourceTracker
|
||||
|
||||
# 首先添加项目根目录到路径
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
ilabos_dir = os.path.dirname(os.path.dirname(current_dir))
|
||||
if ilabos_dir not in sys.path:
|
||||
sys.path.append(ilabos_dir)
|
||||
unilabos_dir = os.path.dirname(os.path.dirname(current_dir))
|
||||
if unilabos_dir not in sys.path:
|
||||
sys.path.append(unilabos_dir)
|
||||
|
||||
from unilabos.config.config import load_config, BasicConfig, _update_config_from_env
|
||||
from unilabos.config.config import load_config, BasicConfig
|
||||
from unilabos.utils.banner_print import print_status, print_unilab_banner
|
||||
from unilabos.device_mesh.resource_visalization import ResourceVisualization
|
||||
from unilabos.ros.nodes.presets.joint_republisher import JointRepublisher
|
||||
from unilabos.ros.nodes.presets.resource_mesh_manager import ResourceMeshManager
|
||||
from rclpy.executors import MultiThreadedExecutor
|
||||
|
||||
|
||||
def parse_args():
|
||||
@@ -83,9 +77,9 @@ def parse_args():
|
||||
)
|
||||
parser.add_argument(
|
||||
"--visual",
|
||||
choices=["rviz", "web","None"],
|
||||
default="rviz",
|
||||
help="选择可视化工具: 'rviz' 或 'web' 或 'None',默认'rviz'",
|
||||
choices=["rviz", "web", "disable"],
|
||||
default="disable",
|
||||
help="选择可视化工具: rviz, web",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
@@ -137,7 +131,7 @@ def main():
|
||||
# 注册表
|
||||
build_registry(args_dict["registry_path"])
|
||||
|
||||
|
||||
devices_and_resources = None
|
||||
if args_dict["graph"] is not None:
|
||||
import unilabos.resources.graphio as graph_res
|
||||
graph_res.physical_setup_graph = (
|
||||
@@ -186,23 +180,21 @@ def main():
|
||||
mqtt_client.start()
|
||||
args_dict["resources_mesh_config"] = {}
|
||||
|
||||
if args_dict["visual"] != "None":
|
||||
if args_dict["visual"] == "rviz":
|
||||
enable_rviz=True
|
||||
elif args_dict["visual"] == "web":
|
||||
enable_rviz=False
|
||||
resource_visualization = ResourceVisualization(devices_and_resources, args_dict["resources_config"] ,enable_rviz=enable_rviz)
|
||||
|
||||
args_dict["resources_mesh_config"] = resource_visualization.resource_model
|
||||
# 将joint_republisher和resource_mesh_manager添加进 main_slave_run.py中
|
||||
|
||||
start_backend(**args_dict)
|
||||
server_thread = threading.Thread(target=start_server)
|
||||
server_thread.start()
|
||||
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||
resource_visualization.start()
|
||||
while True:
|
||||
time.sleep(1)
|
||||
if args_dict["visual"] != "disable":
|
||||
enable_rviz = args_dict["visual"] == "rviz"
|
||||
if devices_and_resources is not None:
|
||||
resource_visualization = ResourceVisualization(devices_and_resources, args_dict["resources_config"] ,enable_rviz=enable_rviz)
|
||||
args_dict["resources_mesh_config"] = resource_visualization.resource_model
|
||||
start_backend(**args_dict)
|
||||
server_thread = threading.Thread(target=start_server)
|
||||
server_thread.start()
|
||||
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||
resource_visualization.start()
|
||||
while True:
|
||||
time.sleep(1)
|
||||
else:
|
||||
start_backend(**args_dict)
|
||||
start_server()
|
||||
else:
|
||||
start_backend(**args_dict)
|
||||
start_server()
|
||||
|
||||
Reference in New Issue
Block a user