How to pass private parameters to multiple instances of node?
I have created a package containing a rospy node that I wish to be able to launch from arbitrary other packages with custom arguments with each launch
eg. myex.py
#!/usr/bin/env python
import rospy
foo = rospy.get_param("foo")
print str(foo)
In a launch file somewhere else:
<launch>
<node pkg="min_ex" name="node_name" type="myex.py" output="screen">
<param name="foo" type="int" value="5"/>
</node>
</launch>
This always returns KeyError: 'foo'
Adding "~" to the beginning of the param name in both or either of the launch or .py does not make a difference.
rosparam list shows me that foo is being published on mylib1/foo
So How can I get the node to access the parameter without having to know about the namespace in which it has been launched? I want to be able to create many instantiations of the same node using different parameters.
Code example to show my problem:
#!/usr/bin/env python
import rospy
foo = rospy.get_param("~foo")
print str(foo)
launch file:
<launch>
<node pkg="min_ex" name="node_name" type="myex.py" output="screen">
<param name="~foo" type="int" value="5"/>
</node>
</launch>
re: MWE in 'mini workspace': we don't need a workspace. The two files are sufficient.