Ask Your Question
1

How to set args with python roslaunch

asked 2014-12-04 11:35:53 -0500

kensley gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2014-12-08 13:04:09 -0500

kensley gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2014-12-04 11:35:53 -0500

Seen: 3,098 times

Last updated: Dec 08 '14