@@ -39,13 +39,15 @@ Each launch file performs the following actions:
3939
4040 from launch import LaunchDescription
4141 from launch.actions import DeclareLaunchArgument
42- from launch.actions import IncludeLaunchDescription
4342 from launch.actions import GroupAction
43+ from launch.actions import IncludeLaunchDescription
4444 from launch.launch_description_sources import PythonLaunchDescriptionSource
4545 from launch.substitutions import LaunchConfiguration
4646 from launch.substitutions import TextSubstitution
4747 from launch_ros.actions import Node
48- from launch_ros.actions import PushROSNamespace
48+ from launch_ros.actions import PushRosNamespace
49+ from launch_xml.launch_description_sources import XMLLaunchDescriptionSource
50+ from launch_yaml.launch_description_sources import YAMLLaunchDescriptionSource
4951
5052
5153 def generate_launch_description ():
@@ -60,8 +62,14 @@ Each launch file performs the following actions:
6062 background_b_launch_arg = DeclareLaunchArgument(
6163 " background_b" , default_value = TextSubstitution(text = " 0" )
6264 )
63- chatter_ns_launch_arg = DeclareLaunchArgument(
64- " chatter_ns" , default_value = TextSubstitution(text = " my/chatter/ns" )
65+ chatter_py_ns_launch_arg = DeclareLaunchArgument(
66+ " chatter_py_ns" , default_value = TextSubstitution(text = " chatter/py/ns" )
67+ )
68+ chatter_xml_ns_launch_arg = DeclareLaunchArgument(
69+ " chatter_xml_ns" , default_value = TextSubstitution(text = " chatter/xml/ns" )
70+ )
71+ chatter_yaml_ns_launch_arg = DeclareLaunchArgument(
72+ " chatter_yaml_ns" , default_value = TextSubstitution(text = " chatter/yaml/ns" )
6573 )
6674
6775 # include another launch file
@@ -71,11 +79,11 @@ Each launch file performs the following actions:
7179 get_package_share_directory(' demo_nodes_cpp' ),
7280 ' launch/topics/talker_listener_launch.py' ))
7381 )
74- # include another launch file in the chatter_ns namespace
75- launch_include_with_namespace = GroupAction(
82+ # include a Python launch file in the chatter_py_ns namespace
83+ launch_py_include_with_namespace = GroupAction(
7684 actions = [
7785 # push_ros_namespace to set namespace of included nodes
78- PushROSNamespace( ' chatter_ns ' ),
86+ PushRosNamespace( ' chatter_py_ns ' ),
7987 IncludeLaunchDescription(
8088 PythonLaunchDescriptionSource(
8189 os.path.join(
@@ -85,51 +93,84 @@ Each launch file performs the following actions:
8593 ]
8694 )
8795
96+ # include a xml launch file in the chatter_xml_ns namespace
97+ launch_xml_include_with_namespace = GroupAction(
98+ actions = [
99+ # push_ros_namespace to set namespace of included nodes
100+ PushRosNamespace(' chatter_xml_ns' ),
101+ IncludeLaunchDescription(
102+ XMLLaunchDescriptionSource(
103+ os.path.join(
104+ get_package_share_directory(' demo_nodes_cpp' ),
105+ ' launch/topics/talker_listener_launch.xml' ))
106+ ),
107+ ]
108+ )
109+
110+ # include a yaml launch file in the chatter_yaml_ns namespace
111+ launch_yaml_include_with_namespace = GroupAction(
112+ actions = [
113+ # push_ros_namespace to set namespace of included nodes
114+ PushRosNamespace(' chatter_yaml_ns' ),
115+ IncludeLaunchDescription(
116+ YAMLLaunchDescriptionSource(
117+ os.path.join(
118+ get_package_share_directory(' demo_nodes_cpp' ),
119+ ' launch/topics/talker_listener_launch.yaml' ))
120+ ),
121+ ]
122+ )
123+
88124 # start a turtlesim_node in the turtlesim1 namespace
89125 turtlesim_node = Node(
90- package = ' turtlesim' ,
91- namespace = ' turtlesim1' ,
92- executable = ' turtlesim_node' ,
93- name = ' sim'
94- )
126+ package = ' turtlesim' ,
127+ namespace = ' turtlesim1' ,
128+ executable = ' turtlesim_node' ,
129+ name = ' sim'
130+ )
95131
96132 # start another turtlesim_node in the turtlesim2 namespace
97133 # and use args to set parameters
98134 turtlesim_node_with_parameters = Node(
99- package = ' turtlesim' ,
100- namespace = ' turtlesim2' ,
101- executable = ' turtlesim_node' ,
102- name = ' sim' ,
103- parameters = [{
104- " background_r" : LaunchConfiguration(' background_r' ),
105- " background_g" : LaunchConfiguration(' background_g' ),
106- " background_b" : LaunchConfiguration(' background_b' ),
107- }]
108- )
135+ package = ' turtlesim' ,
136+ namespace = ' turtlesim2' ,
137+ executable = ' turtlesim_node' ,
138+ name = ' sim' ,
139+ parameters = [{
140+ " background_r" : LaunchConfiguration(' background_r' ),
141+ " background_g" : LaunchConfiguration(' background_g' ),
142+ " background_b" : LaunchConfiguration(' background_b' ),
143+ }]
144+ )
109145
110146 # perform remap so both turtles listen to the same command topic
111147 forward_turtlesim_commands_to_second_turtlesim_node = Node(
112- package = ' turtlesim' ,
113- executable = ' mimic' ,
114- name = ' mimic' ,
115- remappings = [
116- (' /input/pose' , ' /turtlesim1/turtle1/pose' ),
117- (' /output/cmd_vel' , ' /turtlesim2/turtle1/cmd_vel' ),
118- ]
119- )
148+ package = ' turtlesim' ,
149+ executable = ' mimic' ,
150+ name = ' mimic' ,
151+ remappings = [
152+ (' /input/pose' , ' /turtlesim1/turtle1/pose' ),
153+ (' /output/cmd_vel' , ' /turtlesim2/turtle1/cmd_vel' ),
154+ ]
155+ )
120156
121157 return LaunchDescription([
122158 background_r_launch_arg,
123159 background_g_launch_arg,
124160 background_b_launch_arg,
125- chatter_ns_launch_arg,
161+ chatter_py_ns_launch_arg,
162+ chatter_xml_ns_launch_arg,
163+ chatter_yaml_ns_launch_arg,
126164 launch_include,
127- launch_include_with_namespace,
165+ launch_py_include_with_namespace,
166+ launch_xml_include_with_namespace,
167+ launch_yaml_include_with_namespace,
128168 turtlesim_node,
129169 turtlesim_node_with_parameters,
130170 forward_turtlesim_commands_to_second_turtlesim_node,
131171 ])
132172
173+
133174 .. group-tab :: XML
134175
135176 .. code-block :: xml
@@ -138,35 +179,49 @@ Each launch file performs the following actions:
138179
139180 <launch >
140181
141- <!-- args that can be set from the command line or a default will be used -->
142- <arg name =" background_r" default =" 0" />
143- <arg name =" background_g" default =" 255" />
144- <arg name =" background_b" default =" 0" />
145- <arg name =" chatter_ns" default =" my/chatter/ns" />
146-
147- <!-- include another launch file -->
148- <include file =" $(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.py" />
149- <!-- include another launch file in the chatter_ns namespace-->
150- <group >
151- <!-- push_ros_namespace to set namespace of included nodes -->
152- <push_ros_namespace namespace =" $(var chatter_ns)" />
153- <include file =" $(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.py" />
154- </group >
155-
156- <!-- start a turtlesim_node in the turtlesim1 namespace -->
157- <node pkg =" turtlesim" exec =" turtlesim_node" name =" sim" namespace =" turtlesim1" />
158- <!-- start another turtlesim_node in the turtlesim2 namespace
159- and use args to set parameters -->
160- <node pkg =" turtlesim" exec =" turtlesim_node" name =" sim" namespace =" turtlesim2" >
161- <param name =" background_r" value =" $(var background_r)" />
162- <param name =" background_g" value =" $(var background_g)" />
163- <param name =" background_b" value =" $(var background_b)" />
164- </node >
165- <!-- perform remap so both turtles listen to the same command topic -->
166- <node pkg =" turtlesim" exec =" mimic" name =" mimic" >
167- <remap from =" /input/pose" to =" /turtlesim1/turtle1/pose" />
168- <remap from =" /output/cmd_vel" to =" /turtlesim2/turtle1/cmd_vel" />
169- </node >
182+ <!-- args that can be set from the command line or a default will be used -->
183+ <arg name =" background_r" default =" 0" />
184+ <arg name =" background_g" default =" 255" />
185+ <arg name =" background_b" default =" 0" />
186+ <arg name =" chatter_py_ns" default =" chatter/py/ns" />
187+ <arg name =" chatter_xml_ns" default =" chatter/xml/ns" />
188+ <arg name =" chatter_yaml_ns" default =" chatter/yaml/ns" />
189+
190+ <!-- include another launch file -->
191+ <include file =" $(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.py" />
192+ <!-- include a Python launch file in the chatter_py_ns namespace-->
193+ <group >
194+ <!-- push_ros_namespace to set namespace of included nodes -->
195+ <push_ros_namespace namespace =" $(var chatter_py_ns)" />
196+ <include file =" $(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.py" />
197+ </group >
198+ <!-- include a xml launch file in the chatter_xml_ns namespace-->
199+ <group >
200+ <!-- push_ros_namespace to set namespace of included nodes -->
201+ <push_ros_namespace namespace =" $(var chatter_xml_ns)" />
202+ <include file =" $(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.xml" />
203+ </group >
204+ <!-- include a yaml launch file in the chatter_yaml_ns namespace-->
205+ <group >
206+ <!-- push_ros_namespace to set namespace of included nodes -->
207+ <push_ros_namespace namespace =" $(var chatter_yaml_ns)" />
208+ <include file =" $(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.yaml" />
209+ </group >
210+
211+ <!-- start a turtlesim_node in the turtlesim1 namespace -->
212+ <node pkg =" turtlesim" exec =" turtlesim_node" name =" sim" namespace =" turtlesim1" />
213+ <!-- start another turtlesim_node in the turtlesim2 namespace
214+ and use args to set parameters -->
215+ <node pkg =" turtlesim" exec =" turtlesim_node" name =" sim" namespace =" turtlesim2" >
216+ <param name =" background_r" value =" $(var background_r)" />
217+ <param name =" background_g" value =" $(var background_g)" />
218+ <param name =" background_b" value =" $(var background_b)" />
219+ </node >
220+ <!-- perform remap so both turtles listen to the same command topic -->
221+ <node pkg =" turtlesim" exec =" mimic" name =" mimic" >
222+ <remap from =" /input/pose" to =" /turtlesim1/turtle1/pose" />
223+ <remap from =" /output/cmd_vel" to =" /turtlesim2/turtle1/cmd_vel" />
224+ </node >
170225 </launch >
171226
172227 .. group-tab :: YAML
@@ -188,21 +243,41 @@ Each launch file performs the following actions:
188243 name : " background_b"
189244 default : " 0"
190245 - arg :
191- name : " chatter_ns"
192- default : " my/chatter/ns"
246+ name : " chatter_py_ns"
247+ default : " chatter/py/ns"
248+ - arg :
249+ name : " chatter_xml_ns"
250+ default : " chatter/xml/ns"
251+ - arg :
252+ name : " chatter_yaml_ns"
253+ default : " chatter/yaml/ns"
193254
194255
195256 # include another launch file
196257 - include :
197258 file : " $(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.py"
198259
199- # include another launch file in the chatter_ns namespace
260+ # include a Python launch file in the chatter_py_ns namespace
200261 - group :
201262 - push_ros_namespace :
202- namespace : " $(var chatter_ns )"
263+ namespace : " $(var chatter_py_ns )"
203264 - include :
204265 file : " $(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.py"
205266
267+ # include a xml launch file in the chatter_xml_ns namespace
268+ - group :
269+ - push_ros_namespace :
270+ namespace : " $(var chatter_xml_ns)"
271+ - include :
272+ file : " $(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.xml"
273+
274+ # include a yaml launch file in the chatter_yaml_ns namespace
275+ - group :
276+ - push_ros_namespace :
277+ namespace : " $(var chatter_yaml_ns)"
278+ - include :
279+ file : " $(find-pkg-share demo_nodes_cpp)/launch/topics/talker_listener_launch.yaml"
280+
206281 # start a turtlesim_node in the turtlesim1 namespace
207282 - node :
208283 pkg : " turtlesim"
0 commit comments