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

rosbuild_add_roslaunch_check(..) and required arguments

asked 2013-08-31 08:20:01 -0500

gvdhoorn gravatar image

updated 2013-09-04 00:27:53 -0500

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).

edit retag flag offensive close merge delete

Comments

The simple solution is to provide a default parameter value. I presume you are not willing to do it that way.

joq gravatar image joq  ( 2013-09-04 16:40:34 -0500 )edit

@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.

gvdhoorn gravatar image gvdhoorn  ( 2013-09-04 21:37:39 -0500 )edit

I understand. Just checking.

joq gravatar image joq  ( 2013-09-05 08:11:08 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2013-09-17 22:01:52 -0500

gvdhoorn gravatar image

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.

edit flag offensive delete link more
2

answered 2014-02-02 10:21:37 -0500

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/mot...

edit flag offensive delete link more

Comments

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.

gvdhoorn gravatar image gvdhoorn  ( 2014-02-03 21:12:17 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-08-31 08:20:01 -0500

Seen: 631 times

Last updated: Feb 02 '14