ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi @Dan_RR.

First of all, to do what you want there is no need to have multiple macros since you can have params and containers (blocks) in the same macro; the key is how you declare what is a param and what is a block to insert. Take a look at the following example:

Imagine I have your blockInserterMacro to accept a container, so instead of having it like *block_to_insert it will be something like:

<xacro:macro name="blockInserterMacro" params="**block_to_insert">
    <link name="generate_link">
        <xacro:insert_block name="block_to_insert"/>
    </link>
</xacro:macro>

Please note de double *. From this you can have also parameters together with the block like params="x y **block_to_insert" but to follow your set up you will need something like:

<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>
           <block_param_1>...</block_param_1>
           <block_param_2>...</block_param_2>
           ...
        </block_to_insert>
    </xacro:blockInserterMacro>
</xacro:macro>

<xacro:myCallerMacro x="5" y="3"/>

But remember this is practically the same as having only one macro for that block inclusion:

<xacro:macro name="mycallerMacro" params="x y **block_to_insert">
    <xacro:macro name="insertedBlockGenerator">
        <xacro:someOtherMacroA x="${x}">
        <xacro:someOtherMacroB y="${y}>
    </xacro:macro>

    <link name="generate_link">
        <xacro:insert_block name="block_to_insert"/>
    </link>
</xacro:macro>

<xacro:myCallerMacro x="5" y="3">
    <block_to_insert>
        <block_param_1>...</block_param_1>
        <block_param_2>...</block_param_2>
        ...
    </block_to_insert>
<xacro:myCallerMacro/>

Hopw that helps you in with the problem.

Regards.