"""uwb_logger.launch.py — Launch UWB position logger (Issue #634)."""

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


def generate_launch_description() -> LaunchDescription:
    pkg_dir = get_package_share_directory("saltybot_uwb_logger")
    params_file = os.path.join(pkg_dir, "config", "uwb_logger_params.yaml")

    return LaunchDescription([
        DeclareLaunchArgument("log_dir", default_value="~/uwb_logs"),
        Node(
            package="saltybot_uwb_logger",
            executable="uwb_logger",
            name="uwb_logger",
            parameters=[
                params_file,
                {"log_dir": LaunchConfiguration("log_dir")},
            ],
            output="screen",
            emulate_tty=True,
        ),
    ])
