It is very important to understand how to place the different reference frames you will use for your robot. First, you have to decide where the <joint> elements are located in the space. In our case, we have two: one for the right wheel and one for the left wheel. Let's look at the one for the right wheel first:
<joint name="joint_right_wheel" type="continuous">
<parent link="base_link"/>
<child link="right_wheel"/>
<origin xyz="0 -0.30 0" rpy="0 0 0" />
<axis xyz="0 1 0" />
</joint>
Now, let's look at the one for the left wheel:
<joint name="joint_left_wheel" type="continuous">
<parent link="base_link"/>
<child link="left_wheel"/>
<origin xyz="0 0.30 0" rpy="0 0 0" />
<axis xyz="0 1 0" />
</joint>
Here, you can see that the <origin> tags specify the locations:
- The right joint origin is -0.30 m along the y ground axis (green axis).
- The left joint origin is +0.30 m along the y ground axis.
As in both cases, regarding the rpy="0 0 0" attribute, there is no rotation and both coordinate frames are parallel to that of the coordinate frame of the ground. We know that both <joint> tags are relative to the ground because both have base_link as the parent link, and you know that the first link of our model, base_link, is the absolute reference for the robot's overall position and orientation.
In general, <origin> is the transform from the parent link to the child link. The joint is located at the origin of the child link. The tag <axis xyz="0 1 0"> specifies the rotation axis. In this case it is y axis, since it has a value of 1, while x and z have 0 values.
The frames you can see in the following screenshot are the respective ones for base_link, right_wheel, and left_wheel. They are specified inside the <visual> tag of each link. In these three cases, in the URDF file, you will see that they follow the following pattern:
<link name="base_link">
<visual>
<origin xyz="0 0 0" rpy=".. .. .." />
xyz="0 0 0" means that they coincide with the joint reference frame:
In the case of the wheels, we have the following:
<origin xyz="0 0 0" rpy="1.570795 0 0" />
1.570795 = pi/2 = 90° is the rotation around the x axis (red). This is what ensures that the cylinders shaping the wheels are oriented vertically.