How to set args with python roslaunch
Hey all,
I have an rqt GUI that needs to launch a local rosnode. So I pulled in the python roslaunch lib and I can successfully kickoff the roslaunch file. However, I'd like to be able to set some arguments, ones you would normally pass to the roslaunch file in the cli.
Python code:
nodes = {}
rlf = os.path.join(roslib.packages.get_pkg_dir(self.backend_package), 'launch/{}'.format(self.backend_launch_filename))
rlc = ROSLaunchConfig()
rlxl = XmlLoader(resolve_anon=False)
rlxl.load(rlf, rlc, verbose=False)
for node in roslaunch.node_args.get_node_list(rlc):
nodes[node] = roslaunch.node_args.get_node_args(node, [rlf])
for key in nodes:
self.processes[key] = subprocess.Popen(nodes[key])
print 'Launching {0} with PID {1}'.format(key, self.processes[key].pid)
Roslaunch file:
<?xml version="1.0"?>
<launch>
<arg name="name" default="$(anon backend)" />
<arg name="remoteip" default="localhost" />
<!-- name node (and topic) after parameter file -->
<node name="$(arg name)" pkg="my_backend" type="backend" args="-i $(arg remoteip)" output="screen">
<rosparam command="load" file="$(find my_backend)/launch/blacklist.yaml" />
</node>
</launch>
You can see in the roslaunch file there is an arg for remoteip. Anyone have an idea how to set that value with my python implementation?
Thanks