"""Launch file for Sound Effects node."""

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


def generate_launch_description():
    """Generate launch description."""
    package_dir = get_package_share_directory("saltybot_sound_effects")
    config_file = str(Path(package_dir) / "config" / "sound_config.yaml")

    # Launch arguments
    config_arg = DeclareLaunchArgument(
        "config_file",
        default_value=config_file,
        description="Path to sound effects configuration file",
    )

    # Sound Effects node
    sound_node = Node(
        package="saltybot_sound_effects",
        executable="sound_effects_node",
        name="sound_effects",
        parameters=[
            {
                "config_file": LaunchConfiguration("config_file"),
            }
        ],
        output="screen",
    )

    return LaunchDescription([config_arg, sound_node])
