
import os

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


def generate_launch_description():
    # TODO(wjwwood): Use a substitution to find share directory once this is implemented in launch
    urdf = os.path.join(get_package_share_directory('dummy_robot_bringup'),
                        'launch', 'single_rrbot.urdf')
    return LaunchDescription([
        Node(package='dummy_map_server', node_executable='dummy_map_server', output='screen'),
        Node(package='robot_state_publisher', node_executable='robot_state_publisher',
             output='screen', arguments=[urdf]),
        Node(package='dummy_sensors', node_executable='dummy_joint_states', output='screen'),
        Node(package='dummy_sensors', node_executable='dummy_laser', output='screen')
    ])


import os

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


def generate_launch_description():
    pkg_share = FindPackageShare('dummy_robot_bringup').find('dummy_robot_bringup')
    urdf_file = os.path.join(pkg_share, 'launch', 'single_rrbot.urdf')
    with open(urdf_file, 'r') as infp:
        robot_desc = infp.read()
    rsp_params = {'robot_description': robot_desc}

    return LaunchDescription([
        Node(package='dummy_map_server', node_executable='dummy_map_server', output='screen'),
        Node(package='robot_state_publisher', node_executable='robot_state_publisher_node',
             output='screen', parameters=[rsp_params]),
        Node(package='dummy_sensors', node_executable='dummy_joint_states', output='screen'),
        Node(package='dummy_sensors', node_executable='dummy_laser', output='screen')
    ])

Switch dummy_robot_bringup to use parameter for rsp.
Switch dummy_robot_bringup to use parameter for rsp.

Signed-off-by: Chris Lalancette <281cd07d7578d97c83271fbbf2faddb83ab3791c@openrobotics.org>

  
  import os
  
- from ament_index_python.packages import get_package_share_directory
  from launch import LaunchDescription
  from launch_ros.actions import Node
+ from launch_ros.substitutions import FindPackageShare
  
  
  def generate_launch_description():
-     # TODO(wjwwood): Use a substitution to find share directory once this is implemented in launch
-     urdf = os.path.join(get_package_share_directory('dummy_robot_bringup'),
-                         'launch', 'single_rrbot.urdf')
+     pkg_share = FindPackageShare('dummy_robot_bringup').find('dummy_robot_bringup')
+     urdf_file = os.path.join(pkg_share, 'launch', 'single_rrbot.urdf')
+     with open(urdf_file, 'r') as infp:
+         robot_desc = infp.read()
+     rsp_params = {'robot_description': robot_desc}
+ 
      return LaunchDescription([
          Node(package='dummy_map_server', node_executable='dummy_map_server', output='screen'),
-         Node(package='robot_state_publisher', node_executable='robot_state_publisher',
+         Node(package='robot_state_publisher', node_executable='robot_state_publisher_node',
-              output='screen', arguments=[urdf]),
+              output='screen', parameters=[rsp_params]),
          Node(package='dummy_sensors', node_executable='dummy_joint_states', output='screen'),
          Node(package='dummy_sensors', node_executable='dummy_laser', output='screen')
      ])
  
Switch dummy_robot_bringup to use parameter for rsp.
## Code Before:

import os

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


def generate_launch_description():
    # TODO(wjwwood): Use a substitution to find share directory once this is implemented in launch
    urdf = os.path.join(get_package_share_directory('dummy_robot_bringup'),
                        'launch', 'single_rrbot.urdf')
    return LaunchDescription([
        Node(package='dummy_map_server', node_executable='dummy_map_server', output='screen'),
        Node(package='robot_state_publisher', node_executable='robot_state_publisher',
             output='screen', arguments=[urdf]),
        Node(package='dummy_sensors', node_executable='dummy_joint_states', output='screen'),
        Node(package='dummy_sensors', node_executable='dummy_laser', output='screen')
    ])

## Instruction:
Switch dummy_robot_bringup to use parameter for rsp.
## Code After:

import os

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


def generate_launch_description():
    pkg_share = FindPackageShare('dummy_robot_bringup').find('dummy_robot_bringup')
    urdf_file = os.path.join(pkg_share, 'launch', 'single_rrbot.urdf')
    with open(urdf_file, 'r') as infp:
        robot_desc = infp.read()
    rsp_params = {'robot_description': robot_desc}

    return LaunchDescription([
        Node(package='dummy_map_server', node_executable='dummy_map_server', output='screen'),
        Node(package='robot_state_publisher', node_executable='robot_state_publisher_node',
             output='screen', parameters=[rsp_params]),
        Node(package='dummy_sensors', node_executable='dummy_joint_states', output='screen'),
        Node(package='dummy_sensors', node_executable='dummy_laser', output='screen')
    ])
