XML launch `<include>` can pass implicit arguments
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with the ROS2 launch XML documentation and reproduce the supplied parent.launch.xml and child.launch.xml examples using ros2 launch. Trace how the include and arg elements handle an undeclared child argument, then determine whether the behavior is intentional and document or correct it so the expected result is explicit.
Written by the indexing model from the issue text.
Description
The ROS2 launch XML format documentation (http://design.ros2.org/articles/roslaunch_xml.html) states that:
<arg>Tag
The tag allows for launch file configuration via the command-line or when including it via an tag. Arguments are launch configuration variables just like the ones defined by tags. Arguments are limited to the scope of their definition and thus have to be explictly passed to included files if any.
If I understand the documentation correctly, if a launch file includes another with the <include> tag, the <arg> parameters are not passed to the other launch file implicitly.
So for example, with these 2 files:
<!-- parent.launch.xml -->
<launch>
<arg name="foo" default="there!"/>
<include file="child.launch.xml"/>
</launch>
<!-- child.launch.xml -->
<launch>
<arg name="foo"/>
<executable cmd="echo Hello $(var foo)" output="screen" shell="true" />
</launch>
We get an error if we try to launch the parent.launch.xml, because foo is not set for the included file:
$ ros2 launch parent.launch.xml
[INFO] [launch]: All log files can be found below /home/sig/.ros/log/2023-01-20-01-08-28-929056-vr-desktop-1016
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [launch]: Caught exception in launch (see debug for traceback): Included launch description missing required argument 'foo' (description: 'no description given'), given: []
So far so good.
However, if we change the child launch file to:
<!-- child.launch.xml -->
<launch>
<!-- <arg name="foo"/> -->
<executable cmd="echo Hello $(var foo)" output="screen" shell="true" />
</launch>
Then, not only no error occurs, but the argument is passed to the child launch file:
$ ros2 launch parent.launch.xml
[INFO] [launch]: All log files can be found below /home/sig/.ros/log/2023-01-20-01-08-16-842624-vr-desktop-961
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [echo-1]: process started with pid [972]
[INFO] [echo-1]: process has finished cleanly [pid 972]
[echo-1] Hello there!
Is it a bug? an undocumented feature?
Bug report
Required Info:
- Operating System:
- Ubuntu 20.04 (galactic) and 22.04 (humble)
- Installation type:
- binary
- Version or commit hash:
- N/A
- DDS implementation:
- N/A?
- Client library (if applicable):
- N/A
Steps to reproduce issue
Run ros2 launch parent.launch.xml with:
<!-- parent.launch.xml -->
<launch>
<arg name="foo" default="there!"/>
<include file="child.launch.xml"/>
</launch>
<!-- child.launch.xml -->
<launch>
<!-- <arg name="foo"/> -->
<executable cmd="echo Hello $(var foo)" output="screen" shell="true" />
</launch>
Expected behavior
Error because foo is undefined?
Actual behavior
The command outputs [echo-1] Hello there!, so not only foo is defined, but it is also passed implicitely from the parent file.
Additional information
- Dominant language
- Python
- Stars
- 156
- Forks
- 200
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ros2/launch
-
Use a relative target for the `latest` log symlink so it survives different absolute mount paths (host/Docker)Possibly taken @Old-Ding claimed this 139 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ros2/launch#978 · 1 reaction ·
Maintainers usually reply within 1 day
-
Add OpaqueFunction to list at docs.ros.orgMay be free again A pull request for this issue was closed without being merged. Openbug help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ros2/launch#826 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
[launch_testing] pytest>8.1 dropped the legacy "path" argument from its internal hooks on humblePossibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
ros2/launch#979 · 6 comments ·
Maintainers usually reply within 1 day
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
hive size:simple
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
backend enhancement priority:P3
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
geolens-io/geolens#4161 ·
Maintainers usually reply within 1 day