Defining the joints

As shown in the preceding representation diagram, the connections are only between the wheels and the chassis. The wheels are connected to base_link and they rotate around their y axis on their own frame of reference. Due to this, we can make use of continuous joint types. Since they're the same for all wheels, let's define them as xacro in the robot_essentials.xacro file:

<xacro:macro name="wheel_joint" params="prefix origin">
<joint name="${prefix}_wheel_joint" type="continuous">
<axis xyz="0 1 0"/>
<parent link ="base_link"/>
<child link ="${prefix}_wheel"/>
<origin rpy ="0 0 0" xyz= "${origin}"/>
</joint>
</xacro:macro>

As you can see, only the origin and the name needs to change in the preceding block of code. Hence, in our robot_base.urdf.xacro file, we'll define the wheel joints as follows:

<xacro:wheel_joint prefix="front_left" origin="0.220 0.250 0"/>
<xacro:wheel_joint prefix="front_right" origin="0.220 -0.250 0"/>
<xacro:wheel_joint prefix="rear_left" origin="-0.220 0.250 0"/>
<xacro:wheel_joint prefix="rear_right" origin="-0.220 -0.250 0"/>

Now that you have everything in your file, let's visualize this in rviz and see whether it matches our representation. You can do that by using the following commands in a new Terminal:

$ initros1
$ cd ~/chapter3_ws/
$ source devel/setup.bash
$ roscd robot_description/urdf/
$ roslaunch urdf_tutorial display.launch model:=robot_base.urdf.xacro

Add the robot model and, in the Global options, set Fixed Frame to base_link. Now, you should see our robot model if everything was successful. You can add the tf display and see whether the representation matches the Representing the robot 2D with link/coordinate system information diagram. You can also move the wheels using the sliders that were launched as a result of setting the gui argument to true.

Now, let's see what is needed to simulate the robot base.

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

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