"""personal_space.launch.py -- Launch personal space respector (Issue #310).

Usage:
  ros2 launch saltybot_social personal_space.launch.py
  ros2 launch saltybot_social personal_space.launch.py personal_space_m:=1.0 backup_speed:=0.15
"""

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


def generate_launch_description():
    pkg = get_package_share_directory("saltybot_social")
    cfg = os.path.join(pkg, "config", "personal_space_params.yaml")

    return LaunchDescription([
        DeclareLaunchArgument("personal_space_m", default_value="0.8",
                              description="Minimum comfortable distance (m)"),
        DeclareLaunchArgument("backup_speed",     default_value="0.1",
                              description="Retreat linear speed (m/s)"),

        Node(
            package="saltybot_social",
            executable="personal_space_node",
            name="personal_space_node",
            output="screen",
            parameters=[
                cfg,
                {
                    "personal_space_m": LaunchConfiguration("personal_space_m"),
                    "backup_speed":     LaunchConfiguration("backup_speed"),
                },
            ],
        ),
    ])
