Skip to content

ROS yaml launch

ROS / ros eco / launch


Minimal

1
2
3
4
5
6
7
8
9
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.
1
2
3
4
5
6
7
8
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

1
2
3
4
5
6
7
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
1
2
3
4
5
6
7
8
9
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
1
2
3
4
5
# 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
1
2
3
4
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
1
2
3
4
5
6
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
1
2
3
4
5
6
7
launch:
- arg:
    name: simple_arg

- executable:
    cmd: echo $(var simple_arg)
    output: screen