-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Handling arguments in included xacro files #204
Comments
I don't think that any content in tags is considered at all. It's just silently ignored. |
Thanks for the quick response. I think perhaps users assume that xacro files will behave like launch files (a reasonable assumption), and I do agree that it would be a useful feature. I'll let you know if I get any time to look at this as well. |
Did you ever figure this out @jarvisschultz ? Running into the same issue, seems like a bug since like you said I have seen this work in some scenarios. Looking at the same sawyer example and I don't see the magic they did to make it work |
I have never spent any time into digging into this feature. In my particular example, it was pretty easy to work around by using macros with args instead of xacro files with args. I.e. |
I think this issue in 2020 still contains a relevant feature request. I think having the |
This comment has been minimized.
This comment has been minimized.
Isn't that documented here already? Both args and properties are forwarded to included files. |
This comment has been minimized.
This comment has been minimized.
The key point is that |
This comment has been minimized.
This comment has been minimized.
To me it seems like you worked around this in exactly same way I described in my comment above. Basically since you can't pass values for Perhaps @rhaschke is correct that documentation improvements are really what is needed to illustrate to users the "proper" way of accomplishing this. |
|
This comment has been minimized.
This comment has been minimized.
@rhaschke This is definitely correct and an important thing for people to understand. I agree that file-local properties could still be useful, and is very much along the lines of what I was thinking when I created this issue. @rickstaa Looks like a good improvement to me. Maybe could also add a sentence explicitly helping users avoid this trap. Maybe something like:
|
There is no need to pass arguments via the macro (of course that's possible too). But, you could declare your |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I like your second proposal and added it to the docs. |
@rhaschke Amazing thanks a lot. I will hide my comments to clean up this feature request. |
Unfortunately, this means that the user of a child.macro.xacro
|
@rcywongaa, including a file within a macro, should be possible already. Also using the property ${gazebo} shouldn't be an issue. |
@rhaschke But included files inside the macro don't get the macro's parameters so it's still not possible to pass arguments to the included file from another xacro file. Using property also doesn't solve that. Note this is all assuming that The following variants of
Basically it's the same problem as the initial post. I'm merely suggesting how it would be useful and potential approaches to implementing it. |
You need to understand that xacro distinguishes two types of parameters: properties and (cmdline) arguments. |
I managed to achieve your task as follows: <?xml version="1.0"?>
<robot name="example" xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:macro name="child" params="gazebo:=false">
<xacro:arg name="gazebo" default="${str(gazebo)}" />
<xacro:include filename="child.xacro" />
</xacro:macro>
<xacro:child gazebo="true" />
</robot>
<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:if value="${gazebo}">
<link name="prop" />
</xacro:if>
<xacro:if value="$(arg gazebo)">
<link name="arg" />
</xacro:if>
</robot> However, note that you can set the (default) argument only once. The best way to go is to use properties. |
Consider the following two xacro files:
parent.xacro
child.xacro
Running
xacro --inorder parent.xacro gazebo:=true
results inI'd expect there to be only one
<link>
, but it seems that I cannot set the value of the argument in an included xacro file. I've seen a few xacro files out there trying to set arguments in includes so I thought this was possible (ex1, ex2), but I can't make it work. Is this a regression or a bug? Am I missing something?The text was updated successfully, but these errors were encountered: