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


def generate_launch_description():
    pkg_dir = get_package_share_directory('saltybot_bag_recorder')
    config_file = os.path.join(pkg_dir, 'config', 'bag_recorder.yaml')

    bag_recorder_node = Node(
        package='saltybot_bag_recorder',
        executable='bag_recorder',
        name='bag_recorder',
        parameters=[config_file],
        output='screen',
        respawn=True,
        respawn_delay=5,
    )

    return LaunchDescription([
        bag_recorder_node,
    ])
