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

Compare argument with literal question

dantenoguera opened this issue · comments

Hi! Is there a way to compare an argument with a literal, something like

<xacro:arg name="argument" default="foo"/>
<xacro:if value="${ $(arg argument) == 'foo' }">
  ...
</xacro:if>

I know I can do this:

<xacro:arg name="argument" default="foo"/>
<xacro:property="cmp_argument" value="$(arg argument)"/>

<xacro:if value="${ cmp_argument == 'foo' }">
  ...
</xacro:if>

but want to know if there is a better way.

Sure, you need to take the detour via a property:

<xacro:arg name="argument" default="foo"/>
<xacro:property name="argument" value="$(arg foo)"/>
<xacro:if value="${argument == 'foo'}">
  ...
</xacro:if>

Sorry. I didn't read your example to the end and proposed exactly what you tried before.
Up till now, there was no simpler method to do so. Take a look at #295 for an appropriate extension.