"""
MQTT 模拟器节点启动文件

使用方法:
    ros2 launch mqtt_simulator mqtt_simulator.launch.py
"""

from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
import os


def generate_launch_description():
    """
    生成启动描述
    """
    # 获取包目录和配置文件路径
    pkg_share = get_package_share_directory('mqtt_simulator')
    config_file = os.path.join(pkg_share, 'config', 'simulator.yaml')

    # 创建节点
    mqtt_simulator_node = Node(
        package='mqtt_simulator',
        executable='mqtt_simulator',
        name='mqtt_simulator_node',
        output='screen',
        parameters=[{
            'config_file': config_file,
        }],
        remappings=[],
    )

    # 返回启动描述
    return LaunchDescription([
        mqtt_simulator_node
    ])
