evaluation of expressions in roslaunch#707
evaluation of expressions in roslaunch#707rhaschke wants to merge 8 commits intoros:indigo-develfrom
Conversation
|
Can one of the admins verify this patch? |
|
I like the general idea, but I'm hesitant about the use of I'm planning to do something sort of similar, by adding boolean prefix operators in a manner that's similar to the existing substitution syntax, e.g.: It wouldn't get the completely general (in the sense of using Python arbitrarily) comparisons that you have here, but would it handle the use cases you have in mind? Maybe we could also add non-boolean operators, like |
|
@gerkey Your comment is very valid. We took some counter measures in xacro to forbid execution of arbitrary python code. I added the same measures here too. Regarding your alternative syntax: I'm always hesitant to reinvent the wheel. Python already does a great job in evaluating expressions and we should use it. Reimplementing that functionality will be error-prone and incomplete. |
|
@rhaschke That's interesting; I didn't know about the new Python eval support in xacro (ros/xacro#54). What you're proposing here isn't any worse or more dangerous than that. |
|
I added on top of @rhaschke's work in ubi-agni#1. |
…uation is done. Add True and False to the eval dictionary. Add test cases for Python evaluation.
Check for pyeval in arg tag parsing. Add test to demonstrate correct disabling of pyeval for arg tag parsing.
a3e1458 to
6bd2eee
Compare
|
@gerkey Thanks for extending this work with lots of tests. I can understand your caution regarding python evaluation, thus introducing the |
|
@rhaschke Regarding the inclusion of If |
|
Oh, I see; you must be on python3, which doesn't need the explicit inclusion: ...and python3 won't accept the explicit inclusion: So I guess that we need to condition the contents of |
|
Btw, in addition to being cautious with regard to Python evaluation, it occurred to me that without the ability to disable it, you wouldn't be able to assign certain string values to arguments, e.g.: That's a bad example, but there are likely some useful argument values that people want to use that happen to be legal Python expressions. |
|
Good example. In xacro, evaluation was explicitly triggered by Regarding the |
|
Do you think that we could extend this feature to encompass the functionality being sought in #382? If users could somehow refer to Edit: e.g., we could insert in the could be done in a manner similar to this: Hmm, then we'd also need to enable |
|
With regard to using the Thinking that proposal through:
|
|
Of course, defining python functions If we are going to introduce new syntax, we should maybe stick with the exising <include file="$(eval find(arg('robot')+'_description') + '/robots/upload_' + arg('robot') + '.launch')"/>This has several advantages:
Answering your questions:
<include file="$(eval find(arg('robot')+'_description'))/robots/upload_$(arg robot).launch"/>
|
|
I like the If concatenation causes parsing problems, then we can just document that you need to commit to computing an entire attribute value within one |
|
I will be happy to support on that implementation. It will increase the power of roslaunch significantly. |
|
Dear @gerkey, although I haven't seen a thumbs up from @dirk-thomas yet, I started to implement an initial version of the The extension branch https://github.com/ubi-agni/ros_comm/tree/implicit-arg-access comprises a simplification to allow implicit access to arg values. Hence, instead of writing What do you think about that implementation? |
|
@gerkey friendly ping. |
|
Discussion from today: let's do the implementation, as @rhaschke suggests, merge it into jade, then decide on other distros from there. |
|
@ros-pull-request-builder retest this please |
|
@rhaschke Is the new implementation of this feature ready for review, or still in progress? |
|
Closing in favor of #762. |
This is a rebase of PR #627 against recent indigo-devel.
The evaluation capabilities of roslaunch are currently rather limited.
Particularly, the conditionals of
if/unlesstags are only evaluated w.r.t. 0,1,true,false. Having more general expressions, e.g. general comparison ($(arg foo) == 'bar') would be great.The same applies for definition of
argvalues.This PR proposes a simple solution to both problems.
Instead of limiting the extensions to
ifunless_test()and_arg_tag(), but integrating them intoxmlloader.opt_attrs()one could enable expression evaluation for all attributes.