Ask Your Question
0

Is it possible to launch multiple nodes from different packages in ROS2 (Crystal)?

asked 2019-06-11 08:19:48 -0500

SkandaNR gravatar image

Hello,

I have 5 ros2 packages and each package contains one or two nodes. Is it possible to launch all nodes from different packages at once? If possible how I can do it? are there any git repo with examples for this?

Thanks in advance

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2019-06-12 14:01:25 -0500

igorrecioh gravatar image

Hi SkandaNR!

Yes, you can launch nodes from different packages in ROS2. I would recommend to check an example of this here.

The example is from Acutronic Robotics' MARA robot. It is one of the packages used to launch MARA in simulation.

Hope it helps!

edit flag offensive delete link more

Comments

thank you for the reference. after adding a launch package with generate_launch_description function to return the description, how can one use it to actually launch multiple nodes?

SkandaNR gravatar imageSkandaNR ( 2019-06-13 02:59:06 -0500 )edit

Not sure if I have understood your question, but to launch the nodes included in the launch file you should use:

ros2 launch [package] [name_of_the_launch_file]

For the MARA example it should be: ros2 launch mara_gazebo mara.launch.py

igorrecioh gravatar imageigorrecioh ( 2019-06-13 03:17:29 -0500 )edit

I am sorry, I was not very clear. In the MARA example, find_package(urdf REQUIRED) and ament_export_dependencies(urdf) are used´in the launch CMake. urdf is found inside another package MARA_description. I have the following folder structure: -ros2_ws

           |- state_machine     
                    |- state_machine_pkg
                          |- state_machine_node.py
                          |- __init__.py
                    |- setup.py
                    |- package.xml
           |- launch
                    |- launch
                          |- sm.launch.py
                    |- CMakeList.txt
                    |- package.xml

I get cmake error if I use ament_export_dependencies(state_machine_pkg) and find_package(state_machine_pkg REQUIRED). I have just taken the exact CMake and xml files from MARA example and just changed urdf to state_machine_pkg.

SkandaNR gravatar imageSkandaNR ( 2019-06-13 04:07:12 -0500 )edit

I understand now. Would you please provide somewhere (Github or Gist) your code and CMakeLists?? That would help me to see where is the problem ;)

igorrecioh gravatar imageigorrecioh ( 2019-06-13 04:11:53 -0500 )edit

I can see that your code is in Python so there is no reason to use CMakeLists.txt in this case

igorrecioh gravatar imageigorrecioh ( 2019-06-13 04:35:49 -0500 )edit

are you saying to use setup.py ?

SkandaNR gravatar imageSkandaNR ( 2019-06-13 04:41:58 -0500 )edit

Keep the CMakeLists.txt but delete the ament_export_depencies(state_machine) line and try again.

Remember compiling: colcon build --merge-install

igorrecioh gravatar imageigorrecioh ( 2019-06-13 04:50:17 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-06-11 08:19:48 -0500

Seen: 20 times

Last updated: Jun 11