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

Revision history [back]

click to hide/show revision 1
initial version

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:
- Tuning parameters, for instace 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

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

The first method is easy to learn and implement, but delaying for a fixed amount of time is a bit of a trial and error process.

The latter method 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.

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 instace 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 processprocess
- 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:
- You can delay a .launch file start for a given number of seconds (or wait for the user input) using Use a Bash script
- You can fully control the process of launching ROS Nodes using
to delay a .launch file start for a given number of seconds (or wait for the user input)
- Use
the roslaunch Python API

The first method is to fully control the process of launching ROS Nodes

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

The latter method 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.