"""
Launch gesture recognition node.

Typical usage:
  ros2 launch saltybot_gesture_recognition gesture_recognition.launch.py
"""

from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description():
    """Generate launch description for gesture recognition node."""

    # Declare launch arguments
    camera_topic_arg = DeclareLaunchArgument(
        'camera_topic',
        default_value='/camera/color/image_raw',
        description='RGB camera topic',
    )
    confidence_arg = DeclareLaunchArgument(
        'confidence_threshold',
        default_value='0.7',
        description='Detection confidence threshold (0-1)',
    )
    publish_hz_arg = DeclareLaunchArgument(
        'publish_hz',
        default_value='15.0',
        description='Publication rate (Hz, target 10+ fps)',
    )
    max_distance_arg = DeclareLaunchArgument(
        'max_distance_m',
        default_value='5.0',
        description='Maximum gesture recognition range (meters)',
    )
    gpu_arg = DeclareLaunchArgument(
        'enable_gpu',
        default_value='true',
        description='Use GPU acceleration (Jetson Orin)',
    )

    # Gesture recognition node
    gesture_node = Node(
        package='saltybot_gesture_recognition',
        executable='gesture_node',
        name='gesture_recognition',
        output='screen',
        parameters=[
            {'camera_topic': LaunchConfiguration('camera_topic')},
            {'confidence_threshold': LaunchConfiguration('confidence_threshold')},
            {'publish_hz': LaunchConfiguration('publish_hz')},
            {'max_distance_m': LaunchConfiguration('max_distance_m')},
            {'enable_gpu': LaunchConfiguration('gpu_arg')},
        ],
    )

    return LaunchDescription(
        [
            camera_topic_arg,
            confidence_arg,
            publish_hz_arg,
            max_distance_arg,
            gpu_arg,
            gesture_node,
        ]
    )
