ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Can we include launch file descriptions that are written in some other langauge?

asked 2022-01-25 02:06:43 -0500

Raza Rizvi gravatar image

Is there a possibility to include launch file description written in, for example, XML or YAML, into a launch file description written in Python?

For example, doing something like this in a Python launch file description?

def generate_launch_description():

   turtlesim_world_1 = IncludeLaunchDescription(
      PythonLaunchDescriptionSource([os.path.join(
         get_package_share_directory('launch_tutorial'), 'launch'),
         '/turtlesim_world_1.xml'])
      )

   return LaunchDescription([
      turtlesim_world_1,
   ])
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-04-12 13:49:30 -0500

omers gravatar image

Hi,

So after digging into the source code a little, I found there is a FrontendLaunchDescriptionSource class that can be used to include .yaml/.xml files inside a python launch file, example:

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

def generate_launch_description():
  return LaunchDescription([      
    Node(
        package='turtlesim',
        executable='mimic',
        name='mimic',
        remappings=[
            ('/input/pose', '/turtlesim1/turtle1/pose'),
            ('/output/cmd_vel', '/turtlesim2/turtle1/cmd_vel'),
        ]
    ),
    IncludeLaunchDescription(
        FrontendLaunchDescriptionSource(os.path.join(get_package_share_directory('rosbridge_server'), 'launch', 'rosbridge_websocket_launch.xml'))
    ),
  ])
edit flag offensive delete link more

Comments

This looks great! Have you tested it?

Raza Rizvi gravatar image Raza Rizvi  ( 2022-04-19 16:04:47 -0500 )edit

Yes tested and working

omers gravatar image omers  ( 2022-04-20 03:10:42 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2022-01-25 02:06:43 -0500

Seen: 88 times

Last updated: Jan 25 '22