getNamespace returns double slash
Hello everybody, I am experiencing a weird error. Considering a launch file where I launch a node in either of the two following ways
<node name="velocity_control" pkg="uav_velocity_control" type="ControlNode" ns="vtol" output="screen"/>
or
<group ns="vtol">
<node name="velocity_control" pkg="uav_velocity_control" type="ControlNode" output="screen"/>
</group>
In my node I have the following line of code
ros::Subscriber sub = n.subscribe(ros::this_node::getNamespace() + "/attitude", queue_size, callbackAngularVelocities);
However if I print the obtained topic name
std::cout << ros::this_node::getNamespace() << "/attitude" << std::endl;
I obtain
//vtol/attitude
I cannot understand this behaviour. I temporarily solved hardcoding the namespace in the node, but I believe you understand the importance of setting the namespaces in the launch file.
Thank you very much
Andrea
can you please answer :https://answers.ros.org/question/306197/getnamespace-returns-incorrect-namespace/
@debonair: that is not how this works.
The issue in OP, which is a duplicate slash, same as what https://answers.ros.org/question/3061... is asking, seems to be a bug. I posted some info in the same link.