Priorty between Xacro properties vs macro definition in XACRO


Case 1:

<xacro:property name="number" value="123"/>

Case 2:

<xacro:macro name="upper_leg" params="number">
content-- ${number}

<xacro:upper_leg number="456"/>

In the first case, we are using XACRO Properties to define a global variable that can be accessed globally, where as in the second case we are using parameters to assign value to number while calling it.

If we are in a situation where there is a parameter and a Xacro property of the same name,"number" in this case, which one will have priority?

That is, when we use ${number} inside the macro definition, will we have 123 or 456 as the value?

1 Like

Hello @Joseph1001 ,

You will have β€œ456” as the value since this is the value you are giving to number when you instantiate the xacro macro upper_leg (the macro is not executed until you instantiate it).

1 Like

So is it safe to say that inside the macro definition, the param value will have priority compared to a property value (global constant )with the same name?

@Joseph1001 Yes that’s it

1 Like

This topic was automatically closed after 22 hours. New replies are no longer allowed.