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


def generate_launch_description():
    config_dir = PathJoinSubstitution(
        [FindPackageShare('saltybot_velocity_smoother'), 'config']
    )
    config_file = PathJoinSubstitution([config_dir, 'velocity_smoother_config.yaml'])

    velocity_smoother = Node(
        package='saltybot_velocity_smoother',
        executable='velocity_smoother_node',
        name='velocity_smoother',
        output='screen',
        parameters=[config_file],
        remappings=[
            ('/odom', '/odom'),
            ('/odom_smooth', '/odom_smooth'),
        ],
    )

    return LaunchDescription([
        velocity_smoother,
    ])