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

Using multiple launch files

asked 2021-02-27 05:23:34 -0500

mros gravatar image

Hi all,

I am using ROS Noetic. I want to ask about the best manner to using multiple launch files and execute them from one launcher. Suppose that I have three packages: package_1, package_2, package_3. Each of them has each own launch file. So, the way to run these files is to execute the launcher of package_2 and package_3 from the launcher of package_1.

Execute the nodes of the package_1 
 ....................................................
<include file="$(find package_2)/launch/package_2.launch"/>
<include file="$(find package_3)/launch/package_3.launch"/>

And to execute them:

roslaunch package_1 package_1.launch

So, it is the best way to do that?

Another question, please, the nodes of all packages will be executed sequentially as described in the launch file?

Thank you.

edit retag flag offensive close merge delete

Comments

1

As far as I understand nodes will NOT be executed sequentially. Launch files provide no guarantees, explicit or implicit, about launch order.

JackB gravatar image JackB  ( 2021-02-27 11:54:20 -0500 )edit
1

There is no gurantee on the order. But this might help you implement a workaround for your problem

teshansj gravatar image teshansj  ( 2021-02-27 13:28:18 -0500 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2021-03-04 15:17:35 -0500

Roberto Z. gravatar image

updated 2021-03-15 06:36:47 -0500

the nodes of all packages will be executed sequentially as described in the launch file?

Short answer is no, using only launch files there is no guarantee of sequencing/order of execution.

As described in this tutorial (very much worth reading): Roslaunch tips for large projects
Quote: "Roslaunch intentionally does not provide any control on the order or timing of node start up."

And from Jason M. O'Kane's Book "A Gentle Introduction to ROS":

An important fact about roslaunch—one that can be easy to forget—is that all of the nodes in a launch file are started at roughly the same time. As a result, you cannot be sure about the order in which the nodes will initialize themselves. Well-written ROS nodes don’t care about the order in which they and their siblings start up

Following in line with the previous quote I would recommend to verify if controlling the order in which you launch your nodes is the best solution to your sequencing problem.

Examples of alternative solution are:
- Keep publishing a message at a certain rate
- Tuning parameters, for instance a timeout parameter
- Wait for a single message to arrive on a topic
- Wait for a transform to be available
- Wait for a server to come up and then start a process
- Use 'latching' to send a message to any future subscribers that connect
- Use services to ensure that a single message is delivered

If you really need/want to time the launch moment of a node, one of these two might help:
- Use a Bash script to delay a .launch file start for a given number of seconds (or wait for the user input)
- Use the roslaunch Python API to fully control the process of launching ROS Nodes

Simple Bash scripts are easy to learn and implement. However delaying for a fixed amount of time is a bit of a trial and error process.

The roslaunch Python API gives you full control on starting and stopping nodes programmatically. If you additionally couple the roslaunch Python API with your own nodes custom services / actions and you can do pretty much everything with it.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2021-02-27 05:23:34 -0500

Seen: 2,898 times

Last updated: Mar 15 '21