Ask Your Question

calling xacro:macro from within xacro:macro

asked 2012-05-11 11:11:56 -0600

dsolomon gravatar image

updated 2012-05-11 11:24:47 -0600

can I include and call an xacro:macro from within an xacro:macro?

alternatively, can I pass a variable to an xacro if it is not an xacro:macro?

edit retag flag offensive close merge delete


For question2, if it is not a xacro:macro, what is it?

David Lu gravatar image David Lu  ( 2012-05-11 12:08:29 -0600 )edit

xacro:macro refers to an xacro that contains a macro. In my answer below, I include an xacro file "irb_5400_macro.xacro" that contains the macro "irb_5400". Then I call that xacro:macro from THIS file. An xacro file can also just contain a set of commands, or even constants (like an include file).

dsolomon gravatar image dsolomon  ( 2012-12-21 05:58:00 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2012-05-11 12:07:30 -0600

David Lu gravatar image

For question 1, yes you can. Recursive macros are allowed.

edit flag offensive delete link more

answered 2012-05-11 14:31:04 -0600

dsolomon gravatar image

To answer my own question #1 - Yes, macros can be recursive. My error was that I put the includes for the referenced xacro files under the xacro:macro name="..." line.

The correct way is:

<robot xmlns:xacro="">
  <include filename="$(find abb_common)/urdf/irb_5400_macro.xacro" /> 
  <xacro:macro name="generate_robot" params="robot_name" >
    <xacro:irb_5400 prefix="${robot_name}"/>

Make sure all the includes are above the macro declaration!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-05-11 11:11:56 -0600

Seen: 1,048 times

Last updated: May 11 '12