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


def generate_launch_description():
    default_cfg = os.path.join(
        get_package_share_directory('um982_driver'), 'config', 'um982.yaml')
    cfg = LaunchConfiguration('config')

    return LaunchDescription([
        DeclareLaunchArgument('config', default_value=default_cfg,
                              description='파라미터 yaml 경로'),
        Node(
            package='um982_driver',
            executable='um982_driver_node',
            name='um982_driver',
            output='screen',
            parameters=[cfg],
        ),
    ])

# NTRIP 자격증명은 config yaml 에 넣거나(리포에 평문 커밋 지양), 실행 시 덮어쓰기:
#   ros2 launch um982_driver um982_driver.launch.py
#   ros2 run   um982_driver um982_driver_node --ros-args \
#       --params-file <cfg>.yaml -p ntrip_user:=<id> -p ntrip_pass:=<pw>
