<reponame>RoboticsLabURJC/2021-tfg-carlos-caminero
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import Node

def generate_launch_description():
    darknet_ros_share_dir = get_package_share_directory('darknet_ros')
    network_param_file = darknet_ros_share_dir + '/config/yolov4-tiny.yaml'
    follow_person_share_dir = get_package_share_directory('follow_person')
    
    darknet_ros_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([darknet_ros_share_dir + '/launch/darknet_ros.launch.py']),
            launch_arguments={'network_param_file': network_param_file}.items()
    )
    
    camera_node = Node(
        package="v4l2_camera",
        node_executable="v4l2_camera_node",
        parameters=[
            {'video_device'     : "/dev/video0"},
        ])
    
    follow_person = Node(
        package="follow_person",
        node_executable="follow_person_main"
        output="screen"
    )

    return LaunchDescription([
        darknet_ros_launch,
        # if you want to disable camera node, remove the following line.
        camera_node,
    ])


from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from launch_ros.actions import Node

def generate_launch_description():
    darknet_ros_share_dir = get_package_share_directory('darknet_ros')
    network_param_file = darknet_ros_share_dir + '/config/yolov4-tiny.yaml'
    follow_person_share_dir = get_package_share_directory('follow_person')
    
    darknet_ros_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource([darknet_ros_share_dir + '/launch/darknet_ros.launch.py']),
            launch_arguments={'network_param_file': network_param_file}.items()
    )
    
    camera_node = Node(
        package="v4l2_camera",
        node_executable="v4l2_camera_node",
        parameters=[
            {'video_device'     : "/dev/video0"},
        ])
    
    follow_person = Node(
        package="follow_person",
        node_executable="follow_person_main"
        output="screen"
    )

    return LaunchDescription([
        darknet_ros_launch,
        # if you want to disable camera node, remove the following line.
        camera_node,
    ])
# if you want to disable camera node, remove the following line.