ros / xacro

Xacro is an XML macro language. With xacro, you can construct shorter and more readable XML files by using macros that expand to larger XML expressions.

Home Page:http://www.ros.org/wiki/xacro

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Macro namespace resolution

Doomerdinger opened this issue · comments

Say I have file utils.xacro:

  <xacro:macro name="make_link" params="link_name">
    <link name="${link_name}"/>
  </xacro:macro>
  
  <xacro:macro name="make_dummy_link">
    <xacro:make_link link_name="dummy_link"/>
  </xacro:macro>

And then in another file I attempt to use that, but namespaced

  <xacro:include filename="utils.xacro" ns="utils"/>
  
  <xacro:utils.make_dummy_link/>

That will error, complaining that make_link cannot be found.

I assume this is due to make_link also having the utils namespace, so the call to make_link within make_dummy_link fails.

A solution to this is to not use a macro from a different macro defined in the same file.

As a note, if I were to make a file

  <xacro:macro name="make_link" params="link_name">
    <link name="${link_name}"/>
  </xacro:macro>
  
  <xacro:make_link link_name="make_dummy_link"/>

and then include that file with a namespace, it would work fine. It seems to be specifically tied to calling a macro within a macro.

That's a very interesting issue. Obviously, we need to "activate" the namespace if a macro is called from that namespace.

#297 should fix your issue.

Thanks! I'll be sure to test this when I get a moment, quite busy right now though so it may not be for a week or so.

Fixed via #297.