Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xacro file argument introspection #345

Open
reinzor opened this issue Jun 11, 2024 · 4 comments
Open

Xacro file argument introspection #345

reinzor opened this issue Jun 11, 2024 · 4 comments

Comments

@reinzor
Copy link

reinzor commented Jun 11, 2024

We would like to add a feature that allows a user to introspect xacro files. This way, we can query what arguments are available and prompt these to the user. We could also add additional validation to the defined arguments and some documentation. What are your thoughts about this? An example:

<xacro:arg name="argument1" default="value1" doc="Argument 1 doc" choices="value1, value2, value3" />
xacro --args test.xacro
arguments:
  - name: argument 1
  - default: value1
  - choices: [value1, value2, value3]
  - doc: Argument 1 doc
@rhaschke
Copy link
Contributor

This is generally a good idea. However, as of now, arguments don't have a choices attribute yet and I'm not sure it makes sense to introduce it. Often, arguments can take arbitrary values, such that a choices restriction doesn't make sense. Another restriction option is a range of numbers, which is difficult to express as a discrete list of choices. In both cases, the allowed parameters could be easily specified within the doc string. Of course, this makes generic validation impossible, but that's impossible anyway given the multitude of possible constraints. Note that validation is possible with corresponding code already.
Regarding the output formatting, I'd prefer a more compact format, like:

arguments:
  - argument1=default: doc
  - ...

@reinzor
Copy link
Author

reinzor commented Jun 11, 2024

Thanks; I agree with your comment on the choices attribute. I will try to prepare a PR that adds the argument introspection and the doc attribute.

@reinzor
Copy link
Author

reinzor commented Jun 11, 2024

Another thought that comes to mind, couldn't we add a validation attribute that accepts an expression as defined here: https://github.com/ros/xacro/wiki#expression-evaluation- . would this work? For example:

<arg name="arg1" validation="${xacro.arg('arg1') in ['value1', 'value2']}" />

@rhaschke
Copy link
Contributor

This would be more generic at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants