Specify the order in which nodes should start up in ROS2 launch file [closed]
Hi everyone,
I have a launch file which starts up my entire ROS2 application. This includes a planner node, a GUI node, a database node, and a vision node, amongst other things. What I observe most of the time is that even though my GUI node has started, I have to wait quite some time for the database node to come online. Is there a way I could specify the order in which the nodes should start?
I tried to edit the order in which I pushed them into the LaunchDescription object, but that did not really affect much.
I illustrate my problem with an example below:
import os
import yaml
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration, Command
from launch.launch_description_sources import PythonLaunchDescriptionSource
from ament_index_python.packages import get_package_share_directory
from launch.launch_context import LaunchContext
from typing import List
def generate_launch_description():
# Static TF (to emulate the TF between world and end-effector)
static_tf = Node(package='tf2_ros',
executable='static_transform_publisher',
name='static_transform_publisher',
output='log',
arguments=['0.0', '0.0', '1.0', '1.57', '0.0', '0.0', 'world', 'link8'])
# HMI node
gui_node = Node(
package="my_awesome_application",
executable="ros2_hmi_node",
output="screen"
)
# database node
db_node = Node(
package="my_awesome_db",
executable="ros2_db_node",
output="screen"
)
return LaunchDescription([static_tf, gui_node, db_node])
Let's say that I want my database node to start up first, and the GUI node should not start until the database is up and running. Do you guys have any idea on how/if I can enforce that in the launch file?
Thanks for the help!