ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Conditional block for params on macro xacro

asked 2020-04-15 04:30:35 -0500

billynugrahas gravatar image

updated 2021-09-16 13:20:41 -0500

lucasw gravatar image

I was wondering how can i use if condition in params on macro? for example:

<xacro:macro name="leg" params="prefix suffix">

I want to use if condition about the suffix:

if suffix == left so create "A", but if suffix != left so create "A"

or the concept is like if-else condition in a programming language?

The documentation on ros wiki doesn’t explain that.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2020-04-15 06:41:04 -0500

billynugrahas gravatar image

Oh it solved, i added <xacro:property name="suffix" value="left"/> when i call the macro. it give the property name suffix to the value “kanan”, so i can execute the conditional block using <xacro:if value="${suffix == 'left'}">

edit flag offensive delete link more

Comments

1

Hi, could you please format your answer to be informative for everyone?

OzzieTheHead gravatar image OzzieTheHead  ( 2021-03-30 13:21:32 -0500 )edit

<xacro:if value="${suffix == 'left'}"> code for create A </xacro:if>

<xacro:unless value="${suffix == 'left'}"> code for create B </xacro:unless>

pepelepew71 gravatar image pepelepew71  ( 2022-04-19 05:12:37 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-04-15 04:30:35 -0500

Seen: 4,143 times

Last updated: Sep 16 '21