"""Launch file for LED Controller 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_led_controller")
    config_file = str(Path(package_dir) / "config" / "led_config.yaml")

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

    # LED Controller node
    led_node = Node(
        package="saltybot_led_controller",
        executable="led_controller_node",
        name="led_controller",
        parameters=[
            {
                "config_file": LaunchConfiguration("config_file"),
            }
        ],
        output="screen",
    )

    return LaunchDescription([config_arg, led_node])
