Node naming and running. rospy.init_node() and .launch file nodes.
Hello everyone
For learning purposes I have created a simple launch file and simple python scripts. This is my launch file
<launch>
<node name="rf_sim_node_1" pkg="rf_trilateration" type="rf_sim_node.py" args="5,5"/>
<node name="rf_sim_node_2" pkg="rf_trilateration" type="rf_sim_node.py" args="-5,-5"/>
<node name="rf_sim_node_3" pkg="rf_trilateration" type="rf_sim_node.py" args="-5,5"/>
<node name="rf_sim_node_4" pkg="rf_trilateration" type="rf_sim_node.py" args="5,-5"/>
<node name="rf_trilateration_service" pkg="rf_trilateration" type="rf_trilateration_server.py"/>
</launch>
and this is the rf_sim_node.py
#!/usr/bin/env python
import rospy
def start_server():
rospy.init_node("rf_node", anonymous=True)
rospy.spin()
if __name__ == "__main__":
start_server()
When I launch my file with roslaunch
$rosnode list
gives out this
/rf_sim_node_1
/rf_sim_node_2
/rf_sim_node_3
/rf_sim_node_4
/rf_trilateration_service
/rosout
Now I am wondering what does rospy.init_node does actually do?. I was expecting to see "rf_node-14 " kinda nodes but end up wtih the node names from the launching file.
What if I make multiple calls to rospy.init_node() will I get new nodes or am I doing something wrong. I read at rospy documentation that I should only call this once but why is the nodes name defined or created at creation of process ?