ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

run a node based on logic clause on a .launch file

asked 2019-11-01 12:11:18 -0600

davidem gravatar image

I am running ROS Melodic.
I have saved, through gmapping, a map of an environment in a .yaml file.

I would like to run the AMCL node only if that map is present on the file system (as it can be moved, for reasons non-pertaining to this question) otherwise re-run gmapping.
I am aware of the if-unless logic that the .launch file offer, but I can't figure out a way of using it in this case, admitting that it is possible.

Right now what I'm doing is very very naive, but works for the most part, and that is running a Python node that checks the FS and if it finds the map's .yaml file, runs via the AMCL node or otherwise the gmapping node. Moreover, this way prevents me to add parameters directely to the call.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-11-04 22:06:03 -0600

jschornak gravatar image

updated 2019-11-04 22:06:26 -0600

I don't think it's possible to do exactly what you need using launch XML syntax.

You might want to investigate the roslaunch Python API. As of Lunar it supports passing command line arguments to launch files, which should let you add parameters to nodes.

Here's a ROS Answers post from 2017 (before the roslaunch API supported arguments) with some additional info on alternate approaches.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-11-01 12:11:18 -0600

Seen: 235 times

Last updated: Nov 04 '19