# How can I use arg to add a node to a urdf.xacro?

I use the $(arg foo) syntax to change some values in a urdf.xacro file to adapt the urdf to different robots. This works fine if I just want to replace a string like a position (e.g. <origin xyz="-0.05 -0.20 -0.038" rpy="($arg rpy_joint_1)/>


but I also want to be able to a a full xml node. I'd like to have a urdf.xacro that looks like

<link name="link_foo" />
$(arg bla) <link name="link_bar" />  If an additional link is present, 'bar' would contain the whole link definition (maybe also with a joint definition), otherwise it would just be empty. Unfortunately, xacro ignores args that are not already within an xml-node (other than <robot>) Has anyone managed to get this done? edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted The$(arg bla) syntax is actually part of rospack. That's fine to use in a xacro file, but xacro has many more tools available than that. Look at the xacro:macro commands and the xacro conditionals at http://wiki.ros.org/xacro

more

I had a look at the docu, but so far, I have seen no syntax with which I could create a new node.

( 2015-06-30 11:54:50 -0600 )edit