Robotics StackExchange | Archived questions

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

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 subprocess.call the AMCL node or otherwise the gmapping node. Moreover, this way prevents me to add parameters directely to the call.

Asked by davidem on 2019-11-01 12:11:18 UTC

Comments

Answers

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.

Asked by jschornak on 2019-11-04 23:06:03 UTC

Comments