from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node


def generate_launch_description():
    image_topic_arg = DeclareLaunchArgument(
        'image_topic',
        default_value='/image',
        description='Input raw image topic.'
    )
    camera_info_topic_arg = DeclareLaunchArgument(
        'camera_info_topic',
        default_value='/camera_info',
        description='Input camera info topic.'
    )
    image_rect_topic_arg = DeclareLaunchArgument(
        'image_rect_topic',
        default_value='/image_rect',
        description='Output rectified image topic.'
    )

    rectify_node = Node(
        package='image_proc',
        executable='rectify_node',
        name='rectify_node',
        output='screen',
        remappings=[
            ('image', LaunchConfiguration('image_topic')),
            ('camera_info', LaunchConfiguration('camera_info_topic')),
            ('image_rect', LaunchConfiguration('image_rect_topic')),
        ],
    )

    return LaunchDescription([
        image_topic_arg,
        camera_info_topic_arg,
        image_rect_topic_arg,
        rectify_node,
    ])
