"""Launch file for cmd_vel_mux_node."""

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


def generate_launch_description():
    """Generate launch description for cmd_vel multiplexer."""
    # Package directory
    pkg_dir = get_package_share_directory("saltybot_cmd_vel_mux")

    # Parameters
    config_file = os.path.join(pkg_dir, "config", "mux_config.yaml")

    # Declare launch arguments
    return LaunchDescription(
        [
            DeclareLaunchArgument(
                "config_file",
                default_value=config_file,
                description="Path to configuration YAML file",
            ),
            # cmd_vel multiplexer node
            Node(
                package="saltybot_cmd_vel_mux",
                executable="cmd_vel_mux_node",
                name="cmd_vel_mux",
                output="screen",
                parameters=[LaunchConfiguration("config_file")],
            ),
        ]
    )
