Xacro insert_block parameter
I was hoping to use the insert_block xacro capability to insert blocks as arguments to macros. However, I can't figure out how to send blocks as parameters to xacros and there's not much documentation or examples that I can find. Here's a simple example:
<xacro:macro name="blockInserterMacro" params="*block_to_insert">
<link name="generate_link">
<xacro:insert_block name="block_to_insert"/>
</link>
</xacro:macro>
<xacro:macro name="mycallerMacro" params="x y">
<xacro:macro name="insertedBlockGenerator">
<xacro:someOtherMacroA x="${x}">
<xacro:someOtherMacroB y="${y}>
</xacro:macro>
<xacro:blockInserterMacro block_to_insert="insertedBlockGenerator"/>
</xacro:macro>
<xacro:myCallerMacro x="5" y="3"/>
I have one xacro, blockInserterMacro, that is supposed to insert whatever the contents of the bock_to_insert parameter are inside the <link> it creates. This xacro is used by another xacro, myCallerMacro, which first defines an inner macro that is supposed to generate the block to be inserted based on given parameters x and y using other macros defined elsewhere, and then passes the generated block as the block_to_insert parameter to blockInserterMacro. Finally, myCallerMacro is called with specific values for the x and y parameters.
Why would I want to do this? Basically I want to have a macro that generates a special kind of component with associated link and joint, but the physics blocks of the link (such as inertia and collision geometry) should be customizable. That way I can easily generate this component with different physics blocks.
Please let me know if there's a better way to do this.
System: Ubuntu 18.04 64-bit ROS Melodic