Rosanswers logo

Context: package with launchfile A, which includes launchfile B (from another package) and passes one required argument to B. This argument has no default value.

After adding a call to rosbuild_add_roslaunch_check(..) to the CMakeLists.txt, make test fails with:

    arg 'my_arg' is not defined. 

Arg xml is <arg name="my_arg_for_B" value="$(arg my_arg)"/>

It seems the test fails because the required argument (my_arg) isn't set when make test is called, so my_arg can't be passed on to included launchfile B.

Does anyone know of any way to provide values for required arguments when testing launchfiles?

I've found one approach / work around: set an environment variable using rosbuild_add_roslaunch_check(FILE var=val), check for this in launchfile A, and provide a default for my_arg if the environment variable is set. Example:

<arg name="my_arg" unless="$(optenv ROSBUILD_ROSLAUNCH_TESTING false)" />
<arg name="my_arg" if="$(optenv ROSBUILD_ROSLAUNCH_TESTING false)" default="" />

While this works (tests succeed, and in normal usage with roslaunch my_arg stays a required argument), I don't like it very much as I'd have to replicate this construct for every argument, in all my launchfiles. If possible, I'd like to avoid this.

This is somewhat related to 'rosbuild_add_roslaunch_check fails for included files using launch file arguments', but the OP in that question uses substitution arguments in the defaults for arguments.

Edit: I thought this was related to ros_comm/pull/276: Fix arg parsing when computing dependencies in roslaunch-check, but I get the same errors from rosbuild_add_roslaunch_check(..) after applying that patch (and using the resulting pkg in a chained workspace).

Originally posted by gvdhoorn on ROS Answers with karma: 86574 on 2013-08-31

Post score: 3

Original comments

Comment by joq on 2013-09-04:
The simple solution is to provide a default parameter value. I presume you are not willing to do it that way.

Comment by gvdhoorn on 2013-09-04:
@joq: yes, that is another work around. Although I have quite some args that do not have sensible defaults and some are even dangerous if not given a proper value. I like the fact my users get error messages about required arguments, as it means they are not using the launchfiles correctly.

Comment by joq on 2013-09-05:
I understand. Just checking.


2 Answers 2


Rosanswers logo

It would seem this is impossible at this time.

For the packages involved, I've resorted to removing the rosbuild_add_roslaunch_check(..) from the CMakeLists.txt for now.

Originally posted by gvdhoorn with karma: 86574 on 2013-09-17

This answer was ACCEPTED on the original site

Post score: 1


Rosanswers logo

I think I have a work around for launch check not supporting parameters. I’ve been going through the moveit and motoman launch files and realized that the more complicated launch files are really more like code in that they dynamically can changed based on the parameters that are passed in. Given that, I wondered if we should treat the launch check more like we treat unit tests. This is what I came up with: https://github.com/ros-industrial/motoman/blob/hydro/motoman_sia10d_support/test/launch_test.xml

Originally posted by sedwards with karma: 1601 on 2014-02-02

This answer was NOT ACCEPTED on the original site

Post score: 2

Original comments

Comment by gvdhoorn on 2014-02-03:
This is a nice way to work around this limitation. +1. See http://answers.ros.org/question/125676/roslaunch_add_file_check-and-build-dependencies/ for some additional discussion regarding this.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.