上QQ阅读APP看书,第一时间看更新
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> <mechanicalReduction>1</mechanicalReduction> </actuator> </transmission> </xacro:macro>
In the section of the code, we can see the definition using the transmission tag.
The transmission tag relates a joint to an actuator. It defines the type of transmission that we are using in a particular joint, as well as the type of motor and its parameters. It also defines the type of hardware interface we use when we interface with the ROS controllers.