Support for OptionalDeclareLaunchArguments

Open
#946 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
cli

Research direction

Start with DeclareLaunchArgument and the included launch-description argument validation shown in the error. Reproduce the YAML-parameter case without default_value, then compare it with the unset workaround. Done means an optional declaration can be omitted without failure while a CLI-provided value can still override the loaded parameter.

Written by the indexing model from the issue text.

Description

enhancement
Description

Currently need to set default_value='foo' or get the following error.

[ERROR] [launch]: Caught exception in launch (see debug for traceback): Included launch description missing required argument 'bar' (description: 'no description given'), given: [foo]
Motivation

Basically I have parameter yaml file I'm loading. And I want to be able to override via the cli. But I can't easily have it override since the DeclareLaunchArgument gives the above error when there is no default.

Design / Implementation Considerations

Maybe some sort of subclass of DeclareLaunchArgument which is OptionalDeclareLaunchArgument which takes an action to execute if a value is passed at cli but, otherwise does nothing?

Additional Information

I got around this with making a canonical unset default but it is inelegant.

DeclareLaunchArgument('bar', default_value='__unset__')
IfCondition(PythonExpression(["'", bar, "' != '__unset__'"]))
Dominant language
Python
Stars
156
Forks
200
Avg merge
2d 11h
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ros2/launch

All issues in ros2/launch

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.