ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ros2 launchfiles: how to launch nodes that are in the same executable?

asked 2019-10-04 04:55:44 -0500

buschbapti gravatar image

updated 2019-10-04 10:05:38 -0500

Hello all,

I am trying to launch three nodes that are in the same executable to enable intra process communication. In the launchfile I need to create start actions for each of them using:

  visualizer_node = launch_ros.actions.LifecycleNode(
        node_name='visualizer',
        package='modulo_core', node_executable="modulo_core_test_cartesian", output='screen')

  robot_interface_node = launch_ros.actions.LifecycleNode(
        node_name='robot_interface',
        package='modulo_core', node_executable="modulo_core_test_cartesian", output='screen')

  motion_generator_node = launch_ros.actions.LifecycleNode(
        node_name='motion_generator',
        package='modulo_core', node_executable="modulo_core_test_cartesian", output='screen')

As those are lifecycle nodes the rest is just to configure and activate them. The problem with that approach is that it will start the executable modulo_core_test_cartesian 3 times, resulting in 3 versions of the node conflicting. See the output of ros2 node list:

/launch_ros
/motion_generator
/motion_generator
/motion_generator
/robot_interface
/robot_interface
/robot_interface
/transform_listener_impl_561d275bf460
/transform_listener_impl_561d279b2de0
/transform_listener_impl_561d27d1d390
/transform_listener_impl_563539d7e980
/transform_listener_impl_56353a0e9080
/transform_listener_impl_56353a60d5a0
/transform_listener_impl_5648cc1556a0
/transform_listener_impl_5648cc54f770
/transform_listener_impl_5648cc8b9f00
/visualizer
/visualizer
/visualizer

I don't know how to properly handle this. I have read about compositions on the wiki but I am not sure this will allow me intra process communication. Any ideas on the proper method?

Thanks in advance.

edit retag flag offensive close merge delete

Comments

Please note: ROS Answers does not support markdown, so three backticks do not start (or end) a code block.

gvdhoorn gravatar image gvdhoorn  ( 2019-10-04 06:30:52 -0500 )edit

Oh sorry for that. Good to know thanks

buschbapti gravatar image buschbapti  ( 2019-10-04 06:36:09 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2019-10-04 10:08:32 -0500

buschbapti gravatar image

As I believed, the current implementation does not allow this. I have raised this as an issue on github and it was confirmed (see https://github.com/ros2/rclcpp/issues...).

So for reference, it seems the only way for now is to use compositions as in https://github.com/ros2/demos/blob/ma...

There should be a possibility to add intra process communication using composition.

edit flag offensive delete link more
0

answered 2019-10-04 05:59:41 -0500

Dmitriy gravatar image

updated 2019-10-04 06:04:50 -0500

I guess if you launch executable it will run everything you wrote there, without determining which node to start. So you should write three different executables for each node or one executable with parameter - in that case your executable will run single desired node depending on parameter value.

EDIT. I don't remember what actually node_name parameter do, but I can imagine it replaces names of each node you launch with this launch_ros.actions.LifecycleNode. I.e.

visualizer_node = launch_ros.actions.LifecycleNode( node_name='visualizer', package='modulo_core', node_executable="modulo_core_test_cartesian", output='screen')

runs three nodes called /visualizer.

edit flag offensive delete link more

Comments

Thanks for your reply but I think that is not an option... Otherwise how can we use intra process communication? If nodes are in different executables or executed in a different processes then this feature is lost. Is this a case that can't be handled at the current stage of development?

buschbapti gravatar image buschbapti  ( 2019-10-04 06:04:53 -0500 )edit

Check this: https://index.ros.org//doc/ros2/Tutor...

I do think you just don't need to provide node_name argument in launch file. But yes, they run two nodes with just one executable.

Dmitriy gravatar image Dmitriy  ( 2019-10-04 06:08:38 -0500 )edit

Thanks for the link this is exactly what I am doing in the executable and it correctly runs the 3 nodes. But here they don't use a launchfile. They directly use ros2 run which works fine for me as well. Problem is as the nodes I am using are lifecycle nodes I have to configure and activate them by hand afterwards which is very annoying. That is why I would like to put everything in a single launch file. Your suggestion to not use node_name does not seem to work:

ERROR] [launch]: Caught exception in launch (see debug for traceback): Caught exception when trying to load file of format [py]: __init__() missing 1 required keyword-only argument: 'node_name'

buschbapti gravatar image buschbapti  ( 2019-10-04 06:21:40 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-10-04 04:55:15 -0500

Seen: 1,803 times

Last updated: Oct 04 '19