0
$\begingroup$

Rosanswers logo

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


Originally posted by kensley on ROS Answers with karma: 81 on 2014-12-04

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Answered this - I created a node (roslaunch.core.Node) and passed through the args there. Then simply subprocess launched it. This bypasses the launch file, but is fine because you can pass through args from the frontend elements.


Originally posted by kensley with karma: 81 on 2014-12-08

This answer was ACCEPTED on the original site

Post score: 4

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.