Using macros

One of the main features of xacro is that it supports macros. We can reduce the length complex definition using xacro to a great extent. Here is a xacro definition we used in our code for inertial:

<xacro:macro name="inertial_matrix" params="mass"> 
  <inertial> 
       <mass value="${mass}" /> 
          <inertia ixx="0.5" ixy="0.0" ixz="0.0" 
          iyy="0.5" iyz="0.0" izz="0.5" /> 
   </inertial> 
</xacro:macro> 

Here, the macro is named inertial_matrix, and its parameter is mass. The mass parameter can be used inside the inertial definition using ${mass}. We can replace each inertial code with a single line as given here:

  <xacro:inertial_matrix mass="1"/> 

The xacro definition improved the code readability and reduced the number of lines compared to urdf. Next, we can see how to convert xacro to the urdf file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.139.0