Scope launch file dir/path locals to included launch file #862
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #618
Some context locals are set by
IncludeLaunchDescription
with the path to the launch file (current_launch_file_path
) and the path to the directory containing the launch file (current_launch_file_directory
). They can then be used through substitutions:ThisLaunchFile()
andThisLaunchFileDir()
, respectively. These only make sense in the included launch file itself, and these locals should not be set when not in a(n included) launch file, e.g., when in a launch script. That usually happens when calling the launch service manually, which is common in tests.The issue reported in #618 is that
IncludeLaunchDescription
doesn't reset the context locals to the previous values. This means that the two launch file location locals point to the included launch file even after theIncludeLaunchDescription
action in the parent launch file. See the reproducer in the original issue.The fix is to scope the two launch file location context locals to
IncludeLaunchDescription
. We also have to remove the context locals afterIncludeLaunchDescription
if it was included by a launch script (see test). Since there is no easy way/API to remove locals, I had to work around it a bit. I'm open to ideas to make that better.Note that the solution only scopes the two launch file location locals to
IncludeLaunchDescription
. Other locals are kept (see test), since included launch files are meant to act as if they were literally included in the parent launch file.