#!/usr/bin/env python3
# Copyright 2020 Gaitech Korea Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Author: Brighten Lee

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():
    default_config_locks = os.path.join(get_package_share_directory('twist_mux'),
                                        'config', 'twist_mux_locks.yaml')
    default_config_topics = os.path.join(get_package_share_directory('twist_mux'),
                                         'config', 'twist_mux_topics.yaml')
    default_config_joystick = os.path.join(get_package_share_directory('twist_mux'),
                                           'config', 'joystick.yaml')

    return LaunchDescription([
        DeclareLaunchArgument(
            'config_locks',
            default_value=default_config_locks,
            description='Default locks config file'),
        DeclareLaunchArgument(
            'config_topics',
            default_value=default_config_topics,
            description='Default topics config file'),
        DeclareLaunchArgument(
            'config_joy',
            default_value=default_config_joystick,
            description='Default joystick config file'),
        DeclareLaunchArgument(
            'cmd_vel_out',
            default_value='twist_mux/cmd_vel',
            description='cmd vel output topic'),
        Node(
            package='twist_mux',
            executable='twist_mux',
            output='screen',
            remappings={('/cmd_vel_out', LaunchConfiguration('cmd_vel_out'))},
            parameters=[
                LaunchConfiguration('config_locks'),
                LaunchConfiguration('config_topics'),
                LaunchConfiguration('config_joy')]
        ),

        Node(
            package='twist_mux',
            executable='twist_marker',
            output='screen',
            remappings={('/twist', LaunchConfiguration('cmd_vel_out'))},
            parameters=[{
                'frame_id': 'base_link',
                'scale': 1.0,
                'vertical_position': 2.0}])
            ])

[((27, 40, 27, 80), 'ament_index_python.packages.get_package_share_directory', 'get_package_share_directory', ({(27, 68, 27, 79): '"""twist_mux"""'}, {}), "('twist_mux')", False, 'from ament_index_python.packages import get_package_share_directory\n'), ((29, 41, 29, 81), 'ament_index_python.packages.get_package_share_directory', 'get_package_share_directory', ({(29, 69, 29, 80): '"""twist_mux"""'}, {}), "('twist_mux')", False, 'from ament_index_python.packages import get_package_share_directory\n'), ((31, 43, 31, 83), 'ament_index_python.packages.get_package_share_directory', 'get_package_share_directory', ({(31, 71, 31, 82): '"""twist_mux"""'}, {}), "('twist_mux')", False, 'from ament_index_python.packages import get_package_share_directory\n'), ((35, 8, 38, 52), 'launch.actions.DeclareLaunchArgument', 'DeclareLaunchArgument', (), '', False, 'from launch.actions import DeclareLaunchArgument\n'), ((39, 8, 42, 53), 'launch.actions.DeclareLaunchArgument', 'DeclareLaunchArgument', (), '', False, 'from launch.actions import DeclareLaunchArgument\n'), ((43, 8, 46, 55), 'launch.actions.DeclareLaunchArgument', 'DeclareLaunchArgument', (), '', False, 'from launch.actions import DeclareLaunchArgument\n'), ((47, 8, 50, 47), 'launch.actions.DeclareLaunchArgument', 'DeclareLaunchArgument', (), '', False, 'from launch.actions import DeclareLaunchArgument\n'), ((57, 16, 57, 51), 'launch.substitutions.LaunchConfiguration', 'LaunchConfiguration', ({(57, 36, 57, 50): '"""config_locks"""'}, {}), "('config_locks')", False, 'from launch.substitutions import LaunchConfiguration\n'), ((58, 16, 58, 52), 'launch.substitutions.LaunchConfiguration', 'LaunchConfiguration', ({(58, 36, 58, 51): '"""config_topics"""'}, {}), "('config_topics')", False, 'from launch.substitutions import LaunchConfiguration\n'), ((59, 16, 59, 49), 'launch.substitutions.LaunchConfiguration', 'LaunchConfiguration', ({(59, 36, 59, 48): '"""config_joy"""'}, {}), "('config_joy')", False, 'from launch.substitutions import LaunchConfiguration\n'), ((55, 41, 55, 75), 'launch.substitutions.LaunchConfiguration', 'LaunchConfiguration', ({(55, 61, 55, 74): '"""cmd_vel_out"""'}, {}), "('cmd_vel_out')", False, 'from launch.substitutions import LaunchConfiguration\n'), ((66, 35, 66, 69), 'launch.substitutions.LaunchConfiguration', 'LaunchConfiguration', ({(66, 55, 66, 68): '"""cmd_vel_out"""'}, {}), "('cmd_vel_out')", False, 'from launch.substitutions import LaunchConfiguration\n')]