import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import ComposableNodeContainer
from launch_ros.descriptions import ComposableNode

def generate_launch_description():
    # 获取 yaml 文件的绝对路径
    config_file = os.path.join(
        get_package_share_directory('agv_calib_core'),
        'config',
        'brain_params.yaml'
    )

    # 建立多线程容器加载大脑组件 (MT 代表 Multi-Threaded Executor)
    container = ComposableNodeContainer(
        name='brain_container',
        namespace='',
        package='rclcpp_components',
        executable='component_container_mt', 
        composable_node_descriptions=[
            ComposableNode(
                package='agv_calib_core',
                plugin='agv_calib_core::BrainNode',
                name='brain_node',
                parameters=[config_file]  # 🚨 动态挂载 YAML 参数表！
            )
        ],
        output='screen',
    )
    return LaunchDescription([container])