What is the intuition behind behavior of $(anon name) in launch file?
Framework: ROS1 Melodic using rospy
My understanding so far from reading the documentation and testing:
- The name specified in
rospy.init_node("Name1")
is applied only when rosrun is used to execute the script - In the case of roslaunch,
<node name="Name2"...>
always overrides the node name specified in the script
I would like to understand the intuition behind $(anon name)
.
If talker.py initializes node as- rospy.init_node("Name1", anonymous=True)
, I can run multiple rosrun
's and spawn multiple talkers.
In order to achieve similar behavior through a launch file, I tried to employ the anon
tag.
<launch>
<node name="$(anon foo)" pkg="rospy_tutorials" type="talker.py" />
<node name="$(anon foo)" pkg="rospy_tutorials" type="talker.py" />
</launch>
This launch file throws the error:
roslaunch file contains multiple nodes named [/foo_Nautilu5_275_3839872632107085818].
Please check all <node> 'name' attributes to make sure they are unique.
Also check that $(anon id) use different ids.
The traceback for the exception was written to the log file
What is the intuition behind such behavior? Should it not serve the same purpose as multiple rosrun
's?
P.S. This is my first question on this forum. I would be grateful to receive suggestions that improve the question.
References:
FYI As stated in the tutorial you linked to,
Why it does that......im not sure.... I think it is meant to work by anonymizing nodes across separate launch files, but not the same launch file launching the same node twice.
Right, I understand the cause of the error. I wanted to know the intuition behind designing it this way, i.e. the second part of your comment. It seems a little strange.