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:
@@ -48,14 +48,14 @@ def main(
|
||||
graph: Optional[Dict[str, Any]] = None,
|
||||
controllers_config: Dict[str, Any] = {},
|
||||
bridges: List[Any] = [],
|
||||
visual: str = "None",
|
||||
visual: str = "disable",
|
||||
resources_mesh_config: dict = {},
|
||||
args: List[str] = ["--log-level", "debug"],
|
||||
rclpy_init_args: List[str] = ["--log-level", "debug"],
|
||||
discovery_interval: float = 5.0,
|
||||
) -> None:
|
||||
"""主函数"""
|
||||
|
||||
rclpy.init(args=args)
|
||||
rclpy.init(args=rclpy_init_args)
|
||||
executor = rclpy.__executor = MultiThreadedExecutor()
|
||||
# 创建主机节点
|
||||
host_node = HostNode(
|
||||
@@ -96,11 +96,13 @@ def slave(
|
||||
graph: Optional[Dict[str, Any]] = None,
|
||||
controllers_config: Dict[str, Any] = {},
|
||||
bridges: List[Any] = [],
|
||||
args: List[str] = ["--log-level", "debug"],
|
||||
visual: str = "disable",
|
||||
resources_mesh_config: dict = {},
|
||||
rclpy_init_args: List[str] = ["--log-level", "debug"],
|
||||
) -> None:
|
||||
"""从节点函数"""
|
||||
if not rclpy.ok():
|
||||
rclpy.init(args=args)
|
||||
rclpy.init(args=rclpy_init_args)
|
||||
executor = rclpy.__executor
|
||||
if not executor:
|
||||
executor = rclpy.__executor = MultiThreadedExecutor()
|
||||
@@ -136,7 +138,7 @@ def slave(
|
||||
logger.info(f"Slave node info updated.")
|
||||
|
||||
rclient = n.create_client(ResourceAdd, "/resources/add")
|
||||
rclient.wait_for_service() # FIXME 可能一直等待,加一个参数
|
||||
rclient.wait_for_service()
|
||||
|
||||
request = ResourceAdd.Request()
|
||||
request.resources = [convert_to_ros_msg(Resource, resource) for resource in resources_config]
|
||||
|
||||
@@ -438,7 +438,7 @@ class BaseROS2DeviceNode(Node, Generic[T]):
|
||||
action_kwargs = convert_from_ros_msg_with_mapping(goal, action_value_mapping["goal"])
|
||||
self.lab_logger().debug(f"接收到原始目标: {action_kwargs}")
|
||||
|
||||
# 向Host查询物料当前状态
|
||||
# 向Host查询物料当前状态,如果是host本身的增加物料的请求,则直接跳过
|
||||
for k, v in goal.get_fields_and_field_types().items():
|
||||
if v in ["unilabos_msgs/Resource", "sequence<unilabos_msgs/Resource>"]:
|
||||
self.lab_logger().info(f"查询资源状态: Key: {k} Type: {v}")
|
||||
|
||||
@@ -101,9 +101,14 @@ class HostNode(BaseROS2DeviceNode):
|
||||
self.devices_instances: Dict[str, ROS2DeviceNode] = {} # 存储设备实例
|
||||
self.device_machine_names: Dict[str, str] = {device_id: "本地", } # 存储设备ID到机器名称的映射
|
||||
self._action_clients: Dict[str, ActionClient] = {} # 用来存储多个ActionClient实例
|
||||
self._action_value_mappings: Dict[str, Dict] = (
|
||||
{}
|
||||
) # 用来存储多个ActionClient的type, goal, feedback, result的变量名映射关系
|
||||
self._action_value_mappings: Dict[str, Dict] = {
|
||||
"add_resrouce": {
|
||||
"type": ResourceCreateFromOuter,
|
||||
"goal": {
|
||||
|
||||
}
|
||||
}
|
||||
} # 用来存储多个ActionClient的type, goal, feedback, result的变量名映射关系
|
||||
self._goals: Dict[str, Any] = {} # 用来存储多个目标的状态
|
||||
self._online_devices: Set[str] = set() # 用于跟踪在线设备
|
||||
self._last_discovery_time = 0.0 # 上次设备发现的时间
|
||||
|
||||
Reference in New Issue
Block a user