Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Add pass_all_args attr to include tag#710

Merged
dirk-thomas merged 1 commit intoindigo-develfrom
add_pass_all_args
Mar 2, 2016
Merged

Add pass_all_args attr to include tag#710
dirk-thomas merged 1 commit intoindigo-develfrom
add_pass_all_args

Conversation

@gerkey
Copy link
Copy Markdown
Contributor

@gerkey gerkey commented Dec 1, 2015

Add a new attribute, pass_all_args, to the include tag. It's a bool, with default of false. E.g.:

<arg name="foo" value="bar"/>
<arg name="bat" value="bang"/>

<!-- Pass down foo=bar and bat=bang -->
<include file="foo.launch" pass_all_args="true"/>

<!-- Pass down foo=override and bat=bang -->
<include file="foo.launch" pass_all_args="true">
  <arg name="foo" value="override"/>
</include>

<!-- The existing syntax can still be used to explicitly pass down foo=bar and bat=bang -->
<include file="foo.launch" pass_all_args="false">
  <arg name="foo" value="bar"/>
  <arg name="bat" value="bang"/>
</include>

If false, then nothing changes from existing behavior.

If true, then all args set in the current context are added to the child context that is created for processing the included file. You can do this instead of explicitly listing each argument that you want to pass down.

Notes on behavior when pass_all_args="true":

  • In the case that the parent passes down a value for an arg that is defined as constant in the child, then the child's value is used.
  • If an <arg> tag explicitly passes down an argument that is also set in the parent, then that explicit value overrides.

@gerkey gerkey force-pushed the add_pass_all_args branch 2 times, most recently from 4239a43 to 73a9430 Compare December 1, 2015 01:42
@scpeters
Copy link
Copy Markdown
Contributor

scpeters commented Dec 9, 2015

Wow, this sounds amazing. Lots of gazebo_ros launch files are missing parameters because they all have to be manually defined

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see expectations for include_arg or if_test in the test file, even though they are set below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only setting those (https://github.com/ros/ros_comm/blob/add_pass_all_args/tools/roslaunch/test/xml/test-arg-all.xml#L6-L7) because they're required in the included file, which I'm reusing from another test (https://github.com/ros/ros_comm/blob/add_pass_all_args/tools/roslaunch/test/xml/test-arg-include.xml#L4-L5), where they're used for a different testing purpose. I could test their values here, but I feel that that case (passing an arg that is required in an included file) is already covered by testing the value of the required arg.

@dirk-thomas
Copy link
Copy Markdown
Member

Does the patch result in no exception being thrown in the following case anymore:

  • first.xml has a set of arguments (but not grounded)
  • first.xmlincludes second.xml with pass_all_args="True" and grounded="foo"
  • second.xml defines an argument grounded with a fixed value

If that is the case I think it would be good to preserve the exception.

@dirk-thomas
Copy link
Copy Markdown
Member

Beside my previous comment the patch looks good to me (merge pending the decision into which ROS distro this and followup changes should be released).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value "not_set" is the same as the upstream test-arg-include.xml. Should we use a different value here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this would affect the test for /notall_optional/include_test/p2_test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm rethinking this...

@scpeters
Copy link
Copy Markdown
Contributor

One feature that just occurred to me and may be related to the exception that @dirk-thomas mentioned:

Base launch file with optional parameters:

<launch>
  <arg name="param1" default="this_is_optional" />
...
  <arg name="paramN" default="this_is_optional" />
</launch>

If I want to create a derived launch file without redefining all the optional parameters and duplicating their default values, can I do:

<launch>
  <include ns="all" file="base.launch" pass_all_args="true">
    <param20>gazebo_world_name.world</param20>
  </include>
</launch>

and then specify param10:="--verbose" when I invoke it from the command-line? That would be really helpful, but maybe that's the exception that @dirk-thomas wants to keep?

I think this should work fine.

@gerkey
Copy link
Copy Markdown
Contributor Author

gerkey commented Dec 10, 2015

@scpeters, your test case should work fine. Did you try it?

@scpeters
Copy link
Copy Markdown
Contributor

No, I didn't test it. Sorry for the noise.

@scpeters
Copy link
Copy Markdown
Contributor

Sorry I didn't understand @dirk-thomas 's comment, but now I do.

@gerkey
Copy link
Copy Markdown
Contributor Author

gerkey commented Dec 10, 2015

@dirk-thomas, I understand the motivation behind your desire to have that exception behavior, and I would go further to say that it would be nice to always throw an exception in the case that the parent launch file explicitly sets an arg while including a file that sets the same arg constant, whether or not pass_all_args was enabled for that include, and whether or not that arg was set in the parent.

That is, ideally, it would only be legal to attempt to pass an arg to a child that sets the same arg constant in the case that the passing is implicit, via pass_all_args.

However, I don't see a way to implement that behavior without making intrusive changes into how roslaunch passes arguments from parent to child. We'd need to carry with each argument how it was set (implicitly via pass_all_args or explicitly in the include). Given that what we're talking about is stricter error-checking in a pretty narrow use case, I don't think that it's worth the risk of making those changes to get that exception behavior. (I also don't think that the lack of that exception behavior is sufficient to justify rejecting this PR.)

For future reference, I added a test that checks for that exception behavior, commented out for now: https://github.com/ros/ros_comm/blob/add_pass_all_args/tools/roslaunch/test/unit/test_xmlloader.py#L1040-L1053.

It is very good that you brought up this point, as I found a nasty bug while investigating the question, and added more tests as a result: https://github.com/ros/ros_comm/blob/add_pass_all_args/tools/roslaunch/test/unit/test_xmlloader.py#L1020-L1037.

@ros-pull-request-builder
Copy link
Copy Markdown
Member

Test passed.
Refer to this link for build results: http://jenkins.ros.org/job/_pull_request-indigo-ros_comm/456/

@dirk-thomas
Copy link
Copy Markdown
Member

@ros/ros_team Please review and state your opinion to merge this into Indigo and Jade.

@gerkey
Copy link
Copy Markdown
Contributor Author

gerkey commented Dec 16, 2015

Having written it, I can't review it, but I vote to merge into both distros. It's a new feature that has no effect unless explicitly enabled, and I feel confident in both the characterization of the behavior and the coverage of the test suite.

However, I can appreciate the general stability argument for Indigo, in which case we can just put it in Jade.

@gerkey
Copy link
Copy Markdown
Contributor Author

gerkey commented Feb 1, 2016

Result from today: merge to indigo and jade.

@scpeters
Copy link
Copy Markdown
Contributor

scpeters commented Feb 8, 2016

Some tests failed. Are those flaky tests? Can the builds be re-triggered?

@dirk-thomas
Copy link
Copy Markdown
Member

The two failing roswtf tests are due to ros/catkin#777 and will pass once that fix is available in a released catkin package.

If there are more failing tests that is likely due to the patch.

@dirk-thomas
Copy link
Copy Markdown
Member

@ros-pull-request-builder retest this please

@dirk-thomas
Copy link
Copy Markdown
Member

And squashed.

dirk-thomas added a commit that referenced this pull request Mar 2, 2016
Add pass_all_args attr to include tag
@dirk-thomas dirk-thomas merged commit 1dba858 into indigo-devel Mar 2, 2016
@dirk-thomas dirk-thomas deleted the add_pass_all_args branch March 2, 2016 23:54
@dirk-thomas
Copy link
Copy Markdown
Member

@gerkey Please update the ROS wiki in the near future to document this new argument and comment here with a link to the diff.

@gerkey
Copy link
Copy Markdown
Contributor Author

gerkey commented Mar 9, 2016

Docs updated!

http://wiki.ros.org/roslaunch/XML/include

@dirk-thomas
Copy link
Copy Markdown
Member

Thank you. I added the version number to it in case anyone wants to check: http://wiki.ros.org/action/diff/roslaunch/XML/include?action=diff&rev1=6&rev2=7

@gerkey
Copy link
Copy Markdown
Contributor Author

gerkey commented Mar 9, 2016

Awesome, thanks. I wanted to do that, but didn't know which version it would appear in.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants