Using macros

We define macros in this code to avoid repeatability and to make the code shorter. Here are the macros we have used in this code:

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

This is the definition of the inertial matrix macro, in which we can use mass as its parameter:

 <xacro:macro name="transmission_block" params="joint_name"> <transmission name="tran1"> <type>transmission_interface/SimpleTransmission</type> <joint name="${joint_name}"> <hardwareInterface>PositionJointInterface</hardwareInterface> </joint> <actuator name="motor1"> <hardwareInterface>PositionJointInterface</hardwareInterface> ...

Get Mastering ROS for Robotics Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.