-
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
Adding support for python macros #168
Comments
I don't get the full idea yet. Where do you want to place the mesh_link function definition? Inside the .xacro? This is critical, as XML and python are not nicely syntax compatible: You need to escape special chars, care about python indentation, etc. |
The way I was imagining it the python could either be defined in an external .py file that would be specified in an attribute (either the attribute of the tag itself or perhaps in a previous tag), or it could actually be in the xacro:python block itself, but that might make reusing macros a little weird (And raises all the fun syntax compatibilities you mentioned). Maybe something like this: <xacro:python load="($find robot_description)/scripts/macros.py"/>
<xacro:python name="some_macro" some_attr="foo"/>
<xacro:python name="some_other_macro" some_other_attr="bar"/> The parser would import the python modules specified by I'll have to take another look to see if I can implement things with xacro as it is now. I recall not being able to do sines and cosines to handle rotations, but it's been a while since I looked at it. In regards to the security issue, given that the python being executed and the xacro calling for its execution are both provided by the user, I don't think there's a significant risk. Unless a user is calling python functions defined in other packages, but then theres always some risk involved in trusting a package creator. |
I'm closing this in favour of #170. |
A while back I wrote a python script that generated static xacro macros from a directory of .stls that could be imported into you main .xacro as
hardware.xacro
and significantly simplified the robot description. Unfortunately it was limited in the macros it could generate, because the support for mathematical operations in xacro is limited. We could allow for some more complex xacro macros with some kind of<xacro:python>
block that functions similarly to a macro block, but replaces the contents with the value returned by a python function, something along these lines:My mesh property calculation macro is the only concrete use case I've come up with so far, but I could imagine some other more powerful macros that further simplify the process of robot description. What do you all think?
The text was updated successfully, but these errors were encountered: