Defining the links

Since you're defining the robot model by parts, copy all of the following code here into the <robot> tags (that is, the space between the <robot> tags). The chassis link is as follows:

  <link name="base_link">
<visual>
<origin
xyz="0 0 0"
rpy="1.5707963267949 0 3.14" />
<geometry>
<mesh filename="package://robot_description/meshes/robot_base.stl" />
</geometry>
<material
name="">
<color
rgba="0.79216 0.81961 0.93333 1" />
</material>
</visual>
</link>

The link defines the robot geometrically and helps in visualization. The preceding is the robot chassis, which we will call base_link.

The tags are pretty straightforward. If you wish to learn about them, have a look at http://wiki.ros.org/urdf/XML/link.

Four wheels need to connect to base_link. We could reuse the same model with different names and necessary coordinate information with the help of xacro. So, let's create another file called robot_essentials.xacro and define standard macros so that we can reuse them:

<?xml version="1.0"?>
<robot xmlns:xacro="http://ros.org/wiki/xacro" name="robot_essentials" >
<xacro:macro name="robot_wheel" params="prefix">
<link name="${prefix}_wheel">
<visual>
<origin
xyz="0 0 0"
rpy="1.5707963267949 0 0" />
<geometry>
<mesh filename="package://robot_description/meshes/wheel.stl" />
</geometry>
<material
name="">
<color
rgba="0.79216 0.81961 0.93333 1" />
</material>
</visual>
</link>
</xacro:macro>
</robot>

We have created a common macro for a wheel in this file. So, all you need to do now is call this macro in your actual robot file, robot_base.urdf.xacro, as shown here:

<xacro:robot_wheel prefix="front_left"/>
<xacro:robot_wheel prefix="front_right"/>
<xacro:robot_wheel prefix="rear_left"/>
<xacro:robot_wheel prefix="rear_right"/>

That's it. Can you see how quickly you have converted that many lines of code (for a link) into just one line of code for each link? Now, let's learn how to define joints.

If you wish to find out more about xacros, have a look at http://wiki.ros.org/xacro.
..................Content has been hidden....................

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