How is the node name decided between node name initialized in python script vs the one mentioned in launch file

When launching a program from a launch file, which is the node that is initialised? is it the node mentioned in the python script using rospy.init_node("Node_created_from_python_script") or is it the one mentioned in the launch file as

<node pkg="package_name" type="" name="Name_of_initialising_node" output="screen">

The python script is launched by the package “my_package”, as below:

#! /usr/bin/env python
import rospy

print("Node Created")

The launch file of package my_package is launch_file.launch is as below:

<node pkg="my_package" type="" name="Node_created_from_launch_node" output="screen">

Upon running the launch file launch_file.launch , we get successful file output as:


 * /rosdistro: noetic
 * /rosversion: 1.15.9

    Node_created_from_launch_node (my_package/


process[Node_created_from_launch_node-1]: started with pid [12186]
Node Created

Upon running the command rosnode list, the following output is received:

rosnode list

From above we see that the Node created has the node name mentioned in the launch file (/Node_created_from_launch_node) and not the node name mentioned in the python script (/Node_created_from_python_script).

***1. Where did the (/Node_created_from_python_script) disappear to? ***
2. Why is the launch node name given priority over the python script node name?

3 posts were split to a new topic: How to perform motion planning using Python in ros

Interesting experiment and good question!

You have already found out from your experiment that the node name specified in the launch file wins. Maybe the one specified in the python file is just ignored, or is made to sit on the bench, or is even sent to /dev/null, but it really doesn’t matter. Once you specify the node name in the launch file, it takes precedence.

For one, it’s so that you can have control over the name of the node, especially if you are launching third-party packages (where you don’t have access to the code). It’s a design decision made by the ROS team, for our good.

1 Like

Thank you @bayodesegun for clearing up the concepts. The support from fellow users is really commendable