@@ -241,24 +241,49 @@ You can also set the parameter in a launch file, but first you will need to add
241241Inside the ``dev_ws/src/cpp_parameters/ `` directory, create a new directory called ``launch ``.
242242In there, create a new file called ``cpp_parameters_launch.py ``
243243
244- .. code-block :: Python
245-
246- from launch import LaunchDescription
247- from launch_ros.actions import Node
248-
249- def generate_launch_description ():
250- return LaunchDescription([
251- Node(
252- package = " cpp_parameters" ,
253- node_executable = " parameter_node" ,
254- node_name = " custom_parameter_node" ,
255- output = " screen" ,
256- emulate_tty = True ,
257- parameters = [
258- {" my_parameter" : " earth" }
259- ]
260- )
261- ])
244+ .. tabs ::
245+
246+ .. group-tab :: Foxy and newer
247+
248+ .. code-block :: Python
249+
250+ from launch import LaunchDescription
251+ from launch_ros.actions import Node
252+
253+ def generate_launch_description ():
254+ return LaunchDescription([
255+ Node(
256+ package = " cpp_parameters" ,
257+ executable = " parameter_node" ,
258+ name = " custom_parameter_node" ,
259+ output = " screen" ,
260+ emulate_tty = True ,
261+ parameters = [
262+ {" my_parameter" : " earth" }
263+ ]
264+ )
265+ ])
266+
267+ .. group-tab :: Before Foxy
268+
269+ .. code-block :: Python
270+
271+ from launch import LaunchDescription
272+ from launch_ros.actions import Node
273+
274+ def generate_launch_description ():
275+ return LaunchDescription([
276+ Node(
277+ package = " cpp_parameters" ,
278+ node_executable = " parameter_node" ,
279+ node_name = " custom_parameter_node" ,
280+ output = " screen" ,
281+ emulate_tty = True ,
282+ parameters = [
283+ {" my_parameter" : " earth" }
284+ ]
285+ )
286+ ])
262287
263288 Here you can see that we set ``my_parameter `` to ``earth `` when we launch our node ``parameter_node ``.
264289By adding the two lines below, we ensure our output is printed in our console.
0 commit comments