Package Summary

Tags No category tags.
Version 0.9.6
License Apache License 2.0
Build type AMENT_PYTHON
Use RECOMMENDED

Repository Summary

Checkout URI https://github.com/ros2/launch.git
VCS Type git
VCS Version eloquent
Last Updated 2020-01-21
Dev Status DEVELOPED
CI status No Continuous Integration
Released RELEASED
Package Tags No category tags.
Contributing Help Wanted (0)
Good First Issues (0)
Pull Requests to Review (0)

Package Description

YAML frontend for the launch package.

Additional Links

No additional links.

Maintainers

  • Ivan Paunovic

Authors

No additional authors.

launch_yaml

This package provides an abstraction of the YAML tree.

YAML front-end mapping rules

Accessing yaml attributes

When having an YAML file like:

tag:
    value1: '2'
    value2: 2
    value3: 2.0

If the entity e is wrapping tag, the following statement will be true:

e.get_attr('value1') == '2'
e.get_attr('value2', data_type=int) == 2
e.get_attr('value3', data_type=float) == 2.0

By default, get_attr returns an string and it does type checking. The following code will raise a TypeError:

e.get_attr('value1', data_type=int)
e.get_attr('value2', data_type=float)
e.get_attr('value3')

Allowed types are: - scalar types: str, int, float, bool - lists: Can be uniform like List[int], or non-uniform like List[Union[str, int]], List (same as list). In any case, the members should be of one of the scalar types. - An union of both any of the above. e.g.: Union[List[int], int]. - The list of entities type: List[Entity] (see below).

List is the usual object from the typing package. data_type can also be set to None, which works in the same way as passing:

Union[int, float, bool, list, str]

For checking if an attribute exists, use optional argument:

value = e.get_attr('value', optional=True)
if value is not None:
    do_something(value)

With optional=False (default), AttributeError is raised if it is not found.

Accessing attributes that are also an Entity:

In this yaml:

executable:
    cmd: ls
    env:
        - name: a
        - value: '100'
        - name: b
        - value: 'stuff'

The env children could be accessed doing:

env = e.get_attr('env', data_type=List[Entity])
len(env) == 2
env[0].get_attr('name') == 'a'
env[0].get_attr('value') == '100'
env[1].get_attr('name') == 'b'
env[1].get_attr('value') == 'stuff'

In these cases, e.env is a list of entities, that can be accessed in the same abstract way.

Accessing children:

All the children can be directly accessed. e.g.:

group:
    - executable:
        cmd: ls
    - executable:
        cmd: ps

e.children

or:

group:
    scoped: False
    children:
        - executable:
            cmd: ls
        - executable:
            cmd: ps

e.children

It returns a list of launch_xml.Entity wrapping each of the xml children. In the example, the list has two Entity objects wrapping each of the executable tags.

Built-in substitutions

See this document.

CHANGELOG

Changelog for package launch_yaml

0.9.6 (2020-01-21)

0.9.5 (2019-11-13)

0.9.4 (2019-11-08)

0.9.3 (2019-10-23)

0.9.2 (2019-10-23)

  • install resource marker file for packages (#341)
  • Contributors: Dirk Thomas

0.9.1 (2019-09-25)

0.9.0 (2019-09-18)

  • install package manifest (#330)
  • Add frontend module in launch, launch_xml and launch_yaml packages (#226)
  • Contributors: Dirk Thomas, ivanpauno

Wiki Tutorials

See ROS Wiki Tutorials for more details.

Source Tutorials

Not currently indexed.

Package Dependencies

System Dependencies

Dependant Packages

Launch files

No launch files found

Messages

No message files found.

Services

No service files found

Plugins

No plugins found.

Recent questions tagged launch_yaml at answers.ros.org