fix: slave mode spin not working

This commit is contained in:
wznln
2025-04-30 15:48:33 +08:00
parent 2d034f728a
commit 7a51b2adc1
2 changed files with 6 additions and 2 deletions

View File

@@ -2,11 +2,9 @@ import copy
import json
import os
import threading
import traceback
from typing import Optional, Dict, Any, List
import rclpy
from rclpy.callback_groups import ReentrantCallbackGroup
from unilabos_msgs.msg import Resource # type: ignore
from unilabos_msgs.srv import ResourceAdd, SerialCommand # type: ignore
from rclpy.executors import MultiThreadedExecutor
@@ -67,6 +65,9 @@ def main(
thread = threading.Thread(target=executor.spin, daemon=True, name="host_executor_thread")
thread.start()
while True:
input()
def slave(
devices_config: Dict[str, Any] = {},
@@ -120,6 +121,8 @@ def slave(
response = rclient.call_async(request).result()
logger.info(f"Slave resource added.")
while True:
input()
if __name__ == "__main__":
main()

View File

@@ -225,6 +225,7 @@ class PyLabRobotCreator(DeviceClassCreator[T]):
from unilabos.ros.nodes.base_device_node import ROS2DeviceNode
ROS2DeviceNode.run_async_func(getattr(self.device_instance, "setup")).add_done_callback(lambda x: logger.debug(f"PyLabRobot设备实例 {self.device_instance} 设置完成"))
class ProtocolNodeCreator(DeviceClassCreator[T]):
"""
ProtocolNode设备类创建器