Substitutions do not work with `RegisterEventHandler`?
Open
Nobody has claimed this yet.
bug
help wanted
- Dominant language
- Python
- Stars
- 155
- Forks
- 182
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 6
Description
Bug report
Required Info:
- Operating System:
- Ubuntu 20.04
- Installation type:
- package
- Version or commit hash:
- 0.10.5-1focal.20210423.000156
- DDS implementation:
- default
- Client library (if applicable):
- N/A
Steps to reproduce issue
cd $ROS_WORKSPACE
git clone https://github.com/galou/launch_bug.git src/launch_bug
colcon build
ros2 launch launch_bug delayed_launch.launch.py
Expected behavior
empty.launch.py should be launched after 1s.
Actual behavior
[INFO] [pause_node-1]: process started with pid [134112]
[INFO] [pause_node-1]: process has finished cleanly [pid 134112]
Task exception was never retrieved
future: <Task finished name='Task-7' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:274> exception=SubstitutionFailure('ThisLaunchFileDir used outside of a launch file (in a script)')>
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 276, in _process_one_event
await self.__process_event(next_event)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 296, in __process_event
visit_all_entities_and_collect_futures(entity, self.__context))
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
sub_entities = entity.visit(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
return self.execute(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/include_launch_description.py", line 125, in execute
launch_description = self.__launch_description_source.get_launch_description(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_source.py", line 81, in get_launch_description
perform_substitutions(context, self.__location)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in perform_substitutions
return ''.join([context.perform_substitution(sub) for sub in subs])
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/perform_substitutions_impl.py", line 26, in <listcomp>
return ''.join([context.perform_substitution(sub) for sub in subs])
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_context.py", line 197, in perform_substitution
return substitution.perform(self)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/substitutions/this_launch_file_dir.py", line 56, in perform
raise SubstitutionFailure(
launch.substitutions.substitution_failure.SubstitutionFailure: ThisLaunchFileDir used outside of a launch file (in a script)
Additional information
Defining the launch description without event handler as:
launch_description = LaunchDescription(
[
pause_node,
included_launch_description,
],
)
and removing the event handler works.
Contributor 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.
Research direction
Start with the reproducible launch_bug example, especially delayed_launch.launch.py and empty.launch.py, and run the provided colcon build and ros2 launch commands. Trace how RegisterEventHandler handles IncludeLaunchDescription and the ThisLaunchFileDir substitution; done means empty.launch.py launches after 1 second without the reported SubstitutionFailure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100