Skip to content

Commit

Permalink
Make roslaunch-check respect if/unless attribute on <include> (#998)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepurvis committed Feb 24, 2017
1 parent d298d4a commit 2d94db2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tools/roslaunch/resources/example.launch
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,7 @@
<!-- more compact import syntax -->
<include ns="included2" file="$(find roslaunch)/resources/example-include.launch" />

<!-- Pass over an include with an if-attribute that evaluates to false. -->
<arg name="dont_include_me" value="false" />
<include if="$(arg dont_include_me)" file="does/not/exist.launch" />
</launch>
13 changes: 11 additions & 2 deletions tools/roslaunch/src/roslaunch/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

import rospkg

from .loader import convert_value
from .substitution_args import resolve_args

NAME="roslaunch-deps"
Expand Down Expand Up @@ -98,11 +99,11 @@ def _parse_arg(tag, context):
name = tag.attributes['name'].value
if tag.attributes.has_key('if'):
val = resolve_args(tag.attributes['if'].value, context)
if val == '1' or val == 'true':
if convert_value(val, 'bool'):
return (name, _get_arg_value(tag, context))
elif tag.attributes.has_key('unless'):
val = resolve_args(tag.attributes['unless'].value, context)
if val == '0' or val == 'false':
if not convert_value(val, 'bool'):
return (name, _get_arg_value(tag, context))
else:
return (name, _get_arg_value(tag, context))
Expand Down Expand Up @@ -142,6 +143,14 @@ def _parse_launch(tags, launch_file, file_deps, verbose, context):
(name, val) = v
context['arg'][name] = val
elif tag.tagName == 'include':
if tag.attributes.has_key('if'):
val = resolve_args(tag.attributes['if'].value, context)
if not convert_value(val, 'bool'):
continue
elif tag.attributes.has_key('unless'):
val = resolve_args(tag.attributes['unless'].value, context)
if convert_value(val, 'bool'):
continue
try:
sub_launch_file = resolve_args(tag.attributes['file'].value, context)
except KeyError as e:
Expand Down

0 comments on commit 2d94db2

Please sign in to comment.