Closed gavanderhoorn closed 2 years ago
It's currently actually the only package "in the wild" that uses things like load_yaml(..)
fi (searching for ros xacro "load_yaml"
).
I would suggest our agni_robots package as this was the trigger to all the xacro changes @rhaschke introduced in xacro in a first place, for instance
https://github.com/ubi-agni/agni_robots/blob/indigo-devel/agni_description/robots/single.urdf.xacro
we also use advanced python in xacro there https://github.com/ubi-agni/sr_common/blob/ubi-indigo-devel/sr_description/hand/xacro/tactile.ubi.xacro https://github.com/ubi-agni/sr_common/blob/ubi-indigo-devel/sr_description/hand/xacro/taxel.xacro
@rhaschke do you think we should create a new tutorial for some of the advanced xacro usage ?
I would suggest our agni_robots package as this was the trigger to all the xacro changes @rhaschke introduced in xacro in a first place
Sure, also good.
we also use advanced python in xacro there https://github.com/ubi-agni/sr_common/blob/ubi-indigo-devel/sr_description/hand/xacro/tactile.ubi.xacro https://github.com/ubi-agni/sr_common/blob/ubi-indigo-devel/sr_description/hand/xacro/taxel.xacro
Right. Is there a specific 'safe sub set' defined for the Python clauses? I seem to remember some discussion about that, but am not sure if that got implemented or not. I'm specifically thinking about circumventing the 'single-evaluation' limitation (that still exists, right?) by delegating some math to Python.
Actually, I would prefer to use the human_hand package, because it's not too complicated. All python expressions are allowed, except loading of new modules. What do you mean by "single-evaluation" limitation? An expression is only evaluated, when needed. This might be multiple time, e.g. for expressions used in macros.
All python expressions are allowed, except loading of new modules
ok, good to know. Is that explicitly stated somewhere? :)
What do you mean by "single-evaluation" limitation? An expression is only evaluated, when needed. This might be multiple time, e.g. for expressions used in macros.
Experimenting with the new features, I did this:
${some math here}
xacro:property
sIn the end, the urdf attributes contained the literal text ${some math here}
(ie: the expression), instead of the result of the evaluation. Remembering the single-eval limitation (no nested ${}
expressions) in 'old' xacro, I figured this has not changed. I'm probably not fully up-to-speed, so if this is possible right now, please do tell me.
I'm sorry for the very delayed answer, @gavanderhoorn. I don't seem to get emails from github...
Hopefully you already figured out, how to solve your issues. With new xacro, all inside ${}
is considered a python expression and evaluated as such. This means, that still nested ${}
are not allowed. However, you don't need them anymore. Within the python expression you can access all your xacro properties directly via their name. Thus you can do: ${sin(math.pi / 3)*radius}
. This is documented for a long time here: http://wiki.ros.org/xacro#Math_expressions. Do you think, this is sufficient?
@rhaschke do you think we should create a new tutorial for some of the advanced xacro usage ?
@guihomework @rhaschke Its been over an hour and I'm still trying to figure out the usage of the operators :=^|''
used in Line 16. I think an advanced tutorial would be very beneficial for and much appreciated by the ROS community!
@rwbot, you are welcome to initiate such a tutorial. I will help to fill the gaps as best as I can.
The semantics of ^
and |
is explained here.
I added this repo as an example to the xacro wiki.
Xacro has been extended quite a bit the past year with some nice features (thanks for that! :beers:). But the tutorial(s) (mostly Using Xacro to Clean Up a URDF File) seem to be lagging behind, so it can be hard to figure out the exact syntax sometimes for some of these new things.
Would it be an idea to reference this package on wiki/xacro as an (advanced?) example that shows how to use the new features?