You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run as node ~test:=a to see the problem. Running with node ~test:=a __name:=t works as expected, because explicit name setting disables the anonymous node behavior.
Please note that running the node via roslaunch and name="$(anon node)" would not trigger this issue as it does not actually trigger the anonymous init option of the node (it directly generates a random name which is passed to the node in __name:= remap).
For comparison, here is the Python code that works correctly:
When I launch a node from CLI via rosrun and do not set any name, the nodes with anonymous flag generate a random name.
If I pass a local topic remap (
~input:=test
), rospy correctly remaps this topic, while roscpp does not.The problem seems to be in this part of this_node code:
ros_comm/clients/roscpp/src/libros/this_node.cpp
Lines 120 to 170 in 842f0f0
It first sets
name_
to theinit_node()
argument, possibly replaces it with__name
remap, and then it callsnames::init()
.However,
names::init()
callsnames::resolve()
, which in turn callsthis_node::getName()
:ros_comm/clients/roscpp/src/libros/names.cpp
Lines 167 to 170 in 842f0f0
But the name in
this_node
is only the non-anonymous one - the anonymizing part is appended only afternames::init()
finishes.Minimal code showing the problem is this:
run as
node ~test:=a
to see the problem. Running withnode ~test:=a __name:=t
works as expected, because explicit name setting disables the anonymous node behavior.Please note that running the node via roslaunch and
name="$(anon node)"
would not trigger this issue as it does not actually trigger the anonymous init option of the node (it directly generates a random name which is passed to the node in__name:=
remap).For comparison, here is the Python code that works correctly:
The solution would be calling
names::init()
once more after the name mangling is finished. Would that be okay?The text was updated successfully, but these errors were encountered: