launch
ros
yaml
ROS yaml launch
ROS / ros eco / launch
Minimal
launch :
- node :
pkg : demo_nodes_cpp
exec : talker
- node :
pkg : demo_nodes_cpp
exec : listener
parameters
launch :
- node :
pkg : "ros_gz_image"
exec : "image_bridge"
output : screen
args :
"/camera/image"
param :
- name : use_sim_time
value : true
- name : camera.image.compressed.jpeg_quality
value : 75
let
Create a local variable for reuse within the launch file.
Cannot be overridden from the command line.
launch :
- let :
name : model_path
value : $(find-pkg-share yaml_launch)/models
- executable :
cmd : echo $(var model_path)
output : screen
Argument
Define an argument that can be overridden via the command line when launching
basic
launch :
- arg :
name : simple_arg
- executable :
cmd : echo $(var simple_arg)
output : screen
ros2 launch yaml_launch arg_example.launch.yaml simple_arg:= "hello world"
with default
arg_example_default.launch.yaml launch :
- arg :
name : simple_arg
default : Hello, YAML Launch!
description : An example argument with a default value.
- executable :
cmd : echo $(var simple_arg)
output : screen
# list arguments
ros2 launch yaml_launch arg_example_default.launch.yaml -s
#usage
ros2 launch yaml_launch arg_example_default.launch.yaml
with multiple choice
launch :
- arg :
name : arg_with_choices
default : choice_1
choice : [ value : choice_1 , value : choice_2 , value : choice_3 ]
- executable :
cmd : echo $(var arg_with_choices)
output : screen
ros2 launch yaml_launch arg_example_default.launch.yaml arg_with_choices:= choice_2
# raise exception
ros2 launch yaml_launch arg_example_default.launch.yaml arg_with_choices:= choice_20
Include
launch/include.launch.yaml launch :
- include :
file : "$(find-pkg-share yaml_launch)/launch/arg_example.launch.yaml"
arg :
- name : "simple_arg"
value : "data from include"
launch/arg_example.launch.yaml launch :
- arg :
name : simple_arg
- executable :
cmd : echo $(var simple_arg)
output : screen