-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug report: error when combining/nesting GroupAction, IncludeLaunchDescription and TimerAction with launch arguments #825
Comments
Have you seen and played with the launch/launch/launch/actions/group_action.py Lines 40 to 73 in f31c1ff
|
If I change the GroupAction to my_group_action = GroupAction(
actions=[nested_launch],
scoped = False,
) it works. I still don't understand why. Could you explain a bit more about the concepts of I understand the concept as followed: With the default settings (scoped=True and forwarding=True) the actions inside should be in its own scope, so that e.g. setting environment variables inside the GroupAction has no effect outside. Because of forwarding, you should still have access (read access?) to everything, that was defined outside of the GroupAction. Are these assumptions correct? This would not explain the error and it should work with the default settings, right? |
I'm sorry, I haven't had time to properly dig into this. I'm hoping to do it by tomorrow. |
Sorry again for the delay. So I believe your understanding of the I believe this a bug -- or at least a not-well-defined case -- with
If I do something similar for the launch context's launch configurations, then your original launch file works, without needing diff --git a/launch/launch/actions/timer_action.py b/launch/launch/actions/timer_action.py
index ac9049c..863a07d 100644
--- a/launch/launch/actions/timer_action.py
+++ b/launch/launch/actions/timer_action.py
@@ -139,6 +139,7 @@ class TimerAction(Action):
def handle(self, context: LaunchContext) -> Optional[SomeEntitiesType]:
"""Handle firing of timer."""
context.extend_locals(self.__context_locals)
+ context.launch_configurations.update(self.__context_launch_configuration)
return self.__actions
def cancel(self) -> None:
@@ -191,6 +192,7 @@ class TimerAction(Action):
# Capture the current context locals so the yielded actions can make use of them too.
self.__context_locals = dict(context.get_locals_as_dict()) # Capture a copy
+ self.__context_launch_configuration = dict(context.launch_configurations) # Capture a copy
context.asyncio_loop.create_task(self._wait_to_fire_event(context))
# By default, the 'shutdown' event will cause timers to cancel so they don't hold up the I think this fix makes sense, but let me double-check and add a test, too. |
@M-Schroeder see #836. If you could give it a try and let me know if it works for you and if the changes to the |
I tried the corresponding changes in ROS2 humble and it now works for me. Your explanation makes sense and the proposed behavior seems more intuitive. (Unfortunately, I am not familiar enough with this repo to understand everything of the code and your changes) |
I have a nested launch structure. In one launch file, I used
TimerAction
to launch a Node with a time delay. This launch file is included in another launch file usingIncludeLaunchDescription
. If thisIncludeLaunchDescription
is used directly, it works. If it is again nested inside aGroupAction
, it gives me an error.Minimal example:
main_launch.py
has following content:nested_launch.py
has following content:Error
Both launch files are in the same folder, I launch it with
ros2 launch ./main_launch.py
and get the following error:(Similar behavior can be seen, if the launch files are properly organised in packages.)
Debugging in the upper level launch files was quite confusing, since putting something in a GroupAction shouldn't change its behavior much (from my understanding).
How it works
It works, if the
main_launch.py
instead ends withIt also works, if alternatively you don't use
TimerAction
innested_launch.py
or if you have everything within one launch file. It seems to be a problem with this combination.System
Ubuntu 22.04.5 LTS
ROS2 humble
The text was updated successfully, but these errors were encountered: