-
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 or feature? PushRosNamespace is not forwarded to managed actions #743
Comments
This issue has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/simple-launch-approaching-event-handling/34715/1 |
This was discussed in a meeting and is believed to be working as expected, even if not ergonomic. As a quick work around you could: from launch_ros.actions import Node
from launch import LaunchDescription
from launch.actions import RegisterEventHandler
from launch.event_handlers import OnProcessStart
from launch.actions import GroupAction
from launch_ros.actions import PushRosNamespace
def generate_launch_description():
talker_ns = 'some_ns'
# runs in namespace
talker = Node(package='demo_nodes_cpp', executable='talker', name='talker',
namespace = talker_ns)
event = OnProcessStart(target_action=talker,
on_start=[Node(package='demo_nodes_cpp', executable='listener',
- name = 'handled_listener')])
+ name = 'handled_listener', namespace = talker_ns)])
handler = RegisterEventHandler(event)
# handler runs in namespace but resulting listener will not
handled_listener = GroupAction([PushRosNamespace(talker_ns), handler])
# runs in namespace
base_listener = GroupAction([PushRosNamespace(talker_ns), Node(package='demo_nodes_cpp', executable='listener',name='base_listener')])
return LaunchDescription([talker, handled_listener, base_listener]) Original code example:
With diff adding namepace arg to second handled listener
But also if this is for classroom use for simple cases of launching nodes you could try the XML launch file support, as I mentioned in the discourse thread. |
Yes, agreed. Just to add a bit more context, these groups are evaluated lazily, but at the time they are needed. So in the original example, the GroupAction used in Besides explicitly adding in the namespace as @moriarty showed, you could also use the GroupAction in the |
Thanks, I get that the namespace of the handled node has to be explicit, either through a namespace argument or a GroupAction. |
Hi,
It appears that actions that are somehow managed (not added to the
LaunchDescription
explicitly but through some event or composition) do not inherit properties of their manager.Here is an example, where
GroupAction
OnProcessStart
event which is itself inside aGroupAction
pushing the correct namespaceThe first listener gets the topic fine while the other one is run outside the namespace of its own
EventHandler
.It may not be a bug but the logic is somehow hard to process.
The text was updated successfully, but these errors were encountered: