Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Xacro filling in parameters without specifying

Hey everybody,

I came across the following strange feature. I have two seperate files. One that includes definitions of parts, another that put everything together.

First file:

  <xacro:macro name="cobot_body" params="parent_link"> 
    <xacro:body />         <!-- no parameters used in "call" here -->
  </xacro:macro>
  <xacro:macro name="body" param="parent_link">
   <link name="body_link">
      <visual>
      <origin xyz="0 0 0" rpy="0 0 ${pi/2}" />
       <geometry>
        <box size="1.0 1.0 1.0" />
       </geometry>
     </visual> 
   </link>

   <joint name="body_base_joint" type="fixed">
      <parent link="${parent_link}" />  
      <child link="body_link" />
      <origin xyz="0 0 0.045" rpy="0 0 0" />
    </joint>

  </xacro:macro>

Second file:

<?xml version="1.0"?>
<robot name="cobot_mapping" xmlns:xacro="http://ros.org/wiki/xacro">

 <xacro:include filename="$(find cobot_description)/urdf/cobot_library.urdf.xacro" />

 <cobot_body parent_link="platform_link"/>

</robot>

When I run this, the parameter of "parent_link" has the value that I specified in the second file. However, I didn't specify in the first file that this parameter should be used.

Is this intended or not?