"""gesture.launch.py — Launch gesture_node for multi-camera gesture recognition (Issue #140)."""

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
from launch_ros.actions import Node
from launch_ros.substitutions import FindPackageShare


def generate_launch_description() -> LaunchDescription:
    pkg = FindPackageShare("saltybot_social")
    params_file = PathJoinSubstitution([pkg, "config", "gesture_params.yaml"])

    return LaunchDescription([
        DeclareLaunchArgument(
            "params_file",
            default_value=params_file,
            description="Path to gesture_node parameter YAML",
        ),
        DeclareLaunchArgument(
            "process_fps",
            default_value="10.0",
            description="Target gesture detection rate (Hz)",
        ),
        DeclareLaunchArgument(
            "model_complexity",
            default_value="0",
            description="MediaPipe model complexity: 0=lite, 1=full, 2=heavy",
        ),
        DeclareLaunchArgument(
            "pose_enabled",
            default_value="true",
            description="Enable MediaPipe Pose body-gesture detection",
        ),
        DeclareLaunchArgument(
            "hands_enabled",
            default_value="true",
            description="Enable MediaPipe Hands hand-gesture detection",
        ),
        DeclareLaunchArgument(
            "enabled_gestures",
            default_value="",
            description="Comma-separated gesture allowlist; empty = all",
        ),
        DeclareLaunchArgument(
            "min_confidence",
            default_value="0.60",
            description="Minimum detection confidence threshold",
        ),
        Node(
            package="saltybot_social",
            executable="gesture_node",
            name="gesture_node",
            output="screen",
            parameters=[
                LaunchConfiguration("params_file"),
                {
                    "process_fps":       LaunchConfiguration("process_fps"),
                    "model_complexity":  LaunchConfiguration("model_complexity"),
                    "pose_enabled":      LaunchConfiguration("pose_enabled"),
                    "hands_enabled":     LaunchConfiguration("hands_enabled"),
                    "enabled_gestures":  LaunchConfiguration("enabled_gestures"),
                    "min_confidence":    LaunchConfiguration("min_confidence"),
                },
            ],
        ),
    ])
