"""obstacle_detect.launch.py — RealSense depth obstacle detection (Issue #611)."""

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_share = get_package_share_directory('saltybot_obstacle_detect')
    default_params = os.path.join(pkg_share, 'config', 'obstacle_detect_params.yaml')

    params_arg = DeclareLaunchArgument(
        'params_file',
        default_value=default_params,
        description='Path to obstacle_detect_params.yaml',
    )

    obstacle_detect_node = Node(
        package='saltybot_obstacle_detect',
        executable='obstacle_detect',
        name='obstacle_detect',
        output='screen',
        parameters=[LaunchConfiguration('params_file')],
    )

    return LaunchDescription([params_arg, obstacle_detect_node])
