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:
FAILURE:
[launch/A.launch]:
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.