#!/usr/bin/env python3

from launch import LaunchDescription
from launch_ros.actions import Node
from launch.substitutions import PathJoinSubstitution
from launch_ros.substitutions import FindPackageShare


def generate_launch_description():
    """Launch obstacle memory node with configuration."""

    package_share_dir = FindPackageShare("saltybot_obstacle_memory")
    config_file = PathJoinSubstitution(
        [package_share_dir, "config", "obstacle_memory.yaml"]
    )

    obstacle_memory_node = Node(
        package="saltybot_obstacle_memory",
        executable="obstacle_memory",
        name="obstacle_memory",
        output="screen",
        parameters=[config_file],
        remappings=[
            ("/scan", "/saltybot/scan"),
            ("/odom", "/odom"),
        ],
    )

    return LaunchDescription([
        obstacle_memory_node,
    ])
