Ask Your Question

Revision history [back]

In fact it is up to you to use xacro. You do not have to, but especially if you have a large URDF and possible duplicates.

xacro provides you some advantages with URDF. As the tutorial you linked points,

It does three things that are very helpful.

  • Constants
  • Simple Math
  • Macros

This way you can use constants throughout your URDF, therefore it will be more parametrized;

<xacro:property name="width" value=".2" />

Also you can do some simple math like;

<cylinder radius="${wheeldiam/2}" length=".1"/>

And you can use macros like;

<xacro:macro name="default_origin">
    <origin xyz="0 0 0" rpy="0 0 0"/>
</xacro:macro>
<xacro:default_origin />

For example in your case, you say that you have 3 laser range finders. Therefore possible without xacro, you are using same code block again and again with some little differences like x,y,z and r,p,y. If you use xacro at this point, you can have a macro called "laser_scanner" and you can just use it three times when you need it.

You can check PAL's repo for PMB2 in this link for such an example.

Another advantage of using xacro is that it will be interpreted and converted to URDF on run-time if you want. Therefore it will be a dynamic URDF file.

In fact it is up to you to use xacro. You do not have to, but especially if you have a large URDF and possible duplicates.duplicate codes it will be beneficial.

xacro provides you some advantages with URDF. As the tutorial you linked points,

It does three things that are very helpful.

  • Constants
  • Simple Math
  • Macros

This way you can use constants throughout your URDF, therefore it will be more parametrized;

<xacro:property name="width" value=".2" />

Also you can do some simple math like;

<cylinder radius="${wheeldiam/2}" length=".1"/>

And you can use macros like;

<xacro:macro name="default_origin">
    <origin xyz="0 0 0" rpy="0 0 0"/>
</xacro:macro>
<xacro:default_origin />

For example in your case, you say that you have 3 laser range finders. Therefore possible without xacro, you are using same code block again and again with some little differences like x,y,z and r,p,y. If you use xacro at this point, you can have a macro called "laser_scanner" and you can just use it three times when you need it.

You can check PAL's repo for PMB2 in this link for such an example.

Another advantage of using xacro is that it will be interpreted and converted to URDF on run-time if you want. Therefore it will be a dynamic URDF file.

In fact it is up to you to use xacro. You do not have to, but especially if you have a large URDF and possible duplicate codes it will be beneficial.

xacro provides you some advantages with URDF. As the tutorial you linked points,

It does three things that are very helpful.

  • Constants
  • Simple Math
  • Macros

This way you can use constants throughout your URDF, therefore it will be more parametrized;

<xacro:property name="width" value=".2" />

Also you can do some simple math like;

<cylinder radius="${wheeldiam/2}" length=".1"/>

And you can use macros like;

<xacro:macro name="default_origin">
    <origin xyz="0 0 0" rpy="0 0 0"/>
</xacro:macro>
<xacro:default_origin />

For example in your case, you say that you have 3 laser range finders. Therefore possible Therefore, possibly without xacro, you are using same code block again and again with some little differences like x,y,z and r,p,y. If you use xacro at this point, you can have a macro called "laser_scanner" and you can just use it three times when you need it.

You can check PAL's repo for PMB2 in this link for such an example.

Another advantage of using xacro is that it will be interpreted and converted to URDF on run-time if you want. Therefore it will be a dynamic URDF file.