"""Launch file for saltybot_head_tracking (Issue #549)."""

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


def generate_launch_description() -> LaunchDescription:
    config = os.path.join(
        get_package_share_directory("saltybot_head_tracking"),
        "config",
        "head_tracking_params.yaml",
    )

    head_tracking_node = Node(
        package="saltybot_head_tracking",
        executable="head_tracking",
        name="head_tracking",
        parameters=[config],
        remappings=[
            # Remap if object detection publishes on a different topic
            # ("/saltybot/objects", "/saltybot/objects"),
        ],
        output="screen",
    )

    # Note: pair with saltybot_pan_tilt node.
    # pan_tilt_node subscribes to /saltybot/target_track (Point, pixel coords).
    # head_tracking publishes to /saltybot/gimbal/cmd (Point, angle degrees).
    # To bridge, remap pan_tilt's subscription:
    #   remappings=[("/saltybot/target_track", "/saltybot/gimbal/cmd")]
    # in the pan_tilt launch — or update pan_tilt to accept angle setpoints.

    return LaunchDescription([head_tracking_node])
