private params in launch file
Hi
From what understand about launch file, <param>
defined in <node>
are private to that <node>
. But the behaviour of my launch file doesn't look right to me. Here is the content of the launch file:
<arg name="num" default="2"/>
<param name="~num_drones" value="$(arg num)"/>
<node name="A" pkg="drone_core" type="drone.py">
<param name="local_name_leaked" value="leaked"/>
</node>
<node name="B" pkg="drone_simulator" type="sim.py">
<param name="local_name" value="debug"/>
</node>
Here are what rosparam list returned for A and B
/A/local_name_leaked
/A/num_drones
/B/local_name
/B/local_name_leaked
/B/num_drones
So my question is, why would "local_name_leaked" show up under /B namespace?
I'm using Jade.
Thanks
===========================
Update 1
I've narrowed down the cause. I'm reposting the full launch file for clairty
<?xml version="1.0" encoding="utf-8"?>
<launch>
<param name="~num_drones" value="2"/>
<!--param name="num_drones_local" value="2"/-->
<node name="A" pkg="drone_core" type="drone.py">
<param name="local_name_leaked" value="leaked" />
</node>
<node name="B" pkg="drone_simulator" type="sim.py">
<param name="local_name" value="debug"/>
</node>
</launch>
With this <param name="~num_drones" value="2"/>
, I get:
PARAMETERS
* /A/local_name_leaked: leaked
* /A/num_drones: 2
* /B/local_name: debug
* /B/local_name_leaked: leaked
* /B/num_drones: 2
* /rosdistro: jade
* /rosversion: 1.11.21
With this <param name="num_drones_local" value="2"/>
I get:
PARAMETERS
* /A/local_name_leaked: leaked
* /B/local_name: debug
* /num_drones_local: 2
* /rosdistro: jade
* /rosversion: 1.11.21
Notice one has "~num_drones", one has "num_drones".
I was assuming <param name="~num_drones" value="2"/>
would create private param in any sub sequence declaration of <node>
block. But is that allowed? It seems to do that, but also cause any parameter declared inside <node>
block to "leak" to sub sequence <node>
blocks.
Are you sure these parameters are being set by your launch file? Parameters persist on the roscore, so these might be left over from a previous launch file. Some nodes also set parameters, so it's possible that node B is setting this parameter.
roslaunch will print all of the parameters that it will set at startup; you should be able to see it setting (or not setting) this parameter as part of its output.
Because of character limits in reply box, I've updated the original post with my findings