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

evaluation of expressions in roslaunch#762

Closed
rhaschke wants to merge 8 commits intoros:indigo-develfrom
ubi-agni:implicit-arg-access
Closed

evaluation of expressions in roslaunch#762
rhaschke wants to merge 8 commits intoros:indigo-develfrom
ubi-agni:implicit-arg-access

Conversation

@rhaschke
Copy link
Copy Markdown
Contributor

@rhaschke rhaschke commented Mar 9, 2016

This replaces PR #707, providing a first proof-of-concept implementation of a generic $(eval ...) substitution arg as discussed in #707.

Unfortunately, the new resolve method cannot be seamlessly integrated into the existing resolve_args mechanism (as suggested by @gerkey), because the existing code uses the simple parser in _collect_args, which cannot handle parentheses within $(xxx ) expressions. Hence, I handle $(eval ...) expressions in a specific fashion before resorting to the other resolve args.
For a similar reason, $(eval ) substitution args can only be handled if they span the whole string.

The branch https://github.com/ubi-agni/ros_comm/tree/roslaunch-eval provides a basic implementation.
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
$(eval arg('my_arg') == 42)
one can directly write:
$(eval my_arg == 42)

What do you think about that implementation?

@dirk-thomas
Copy link
Copy Markdown
Member

@gerkey Can you please review this.

Due to the advanced time I think we should not merge this into Jade but into Kinetic only. If it works there it can always be backported.

@gerkey
Copy link
Copy Markdown
Contributor

gerkey commented Mar 28, 2016

@rhaschke This looks good, thanks. I'm torn about the shortcut on args. It's certainly less typing, but should we be worried about name collisions with other symbols in Python? If there's any risk of the automatic substitution doing the wrong thing, I'd rather just force people to write arg('foo') in full.

Other than that issue, +1 from me. The implementation is clear and the test suite is good.

@dirk-thomas Agreed on targeting kinetic now, and considering a backport later once we have more experience with it. There's one failure on Jenkins with this branch, but it looks very unrelated: http://build.ros.org/job/Kpr__ros_comm__ubuntu_xenial_amd64/14/testReport/test_bag/TestRosbag/test_get_compression_info/. Is that a known flaky test?

- showing precedence of substitution functions over args
- redefinition of builtin symbols

def __getitem__(self, key):
try:
return self._functions[key]
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.

substitution functions take precedence over implicit argument usage

@rhaschke
Copy link
Copy Markdown
Contributor Author

@gerkey Indeed the automatic substitution might overwrite existing symbols. However, evaluation of substitions functions (arg, anon, find, etc) already takes precedence over implicit argument usage (as pointed out above and verified with an additional unittest).
There might be interference with the four builtin python symbols (True, False, true, false) that can be redefined by the user. Currently, there are no other exposed python symbols that could be redefined.
To resolve that issue, we could:

  • warn the user about name collisions
  • or silently give precedence to builtin symbols again

I would prefer the latter option, which I already implemented in 1c9d7a0.

@gerkey
Copy link
Copy Markdown
Contributor

gerkey commented Apr 4, 2016

lgtm

Can you please re-target for kinetic and then we'll consider it for merging?

@rhaschke
Copy link
Copy Markdown
Contributor Author

rhaschke commented Apr 5, 2016

Retargeting for kinetic

@arthurnunesq
Copy link
Copy Markdown

Is there any chance of this feature being backport to indigo?

@dirk-thomas
Copy link
Copy Markdown
Member

Larger feature like this is commonly not backported since the chance of regressions is outweighing the desire for stability for a ROS distro which has been released for over 2.5 years.

@cpagravel
Copy link
Copy Markdown

We're using very ugly work-arounds for this missing feature at the robotics startup I'm working at. If it means anything, I'd really like to have this feature on our system without having to move to Kinetic. String comparisons would make really be a big help to make this project more maintainable.

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.

5 participants