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():
    share = get_package_share_directory('origincar_birdseye')
    birdseye_config = os.path.join(
        share,
        'config',
        'birdseye_defaults.yaml')
    synthetic_config = os.path.join(share, 'config', 'offline_camera.yaml')
    birdseye_overrides = os.path.join(
        share, 'config', 'offline_birdseye_overrides.yaml')
    return LaunchDescription([
        DeclareLaunchArgument(
            'birdseye_config',
            default_value=birdseye_config,
            description='Birdseye node ROS parameter YAML'),
        DeclareLaunchArgument(
            'synthetic_config',
            default_value=synthetic_config,
            description='Synthetic image publisher ROS parameter YAML'),
        Node(
            package='origincar_birdseye',
            executable='synthetic_camera_node',
            name='synthetic_camera_node',
            output='screen',
            parameters=[LaunchConfiguration('synthetic_config')]),
        Node(
            package='origincar_birdseye',
            executable='birdseye_node',
            name='birdseye_node',
            output='screen',
            parameters=[
                LaunchConfiguration('birdseye_config'),
                birdseye_overrides]),
    ])
