First Let’s have a look on the URDF File Documentation that is available by ROS:

https://wiki.ros.org/urdf/XML

Following the above link we will get to the URDF File Documentation and if we inspect the joint or link in the Documentation we will find the different Attributes and Elements that is applicable for either of them.

So if we go to the joint Documentation under Attributes→type, we will find the different types that can be applied. Till now we have only used fixed type but revolute type allows us to rotate links around a specified axis.

Revolute Joint Type

Let’s try to implement revolute joint type on the cylinder so that it can rotate.


Note that if we scroll down under Elements we find that it says:

<limit> (required only for revolute and prismatic joint)


The modified code is the following:

<?xml version="1.0"?>
<robot name="my_robot">

    <material name="blue">
        <color rgba="0 0 0.5 1" />
    </material>

    <material name="grey">
        <color rgba="0.5 0.5 0.5 1" />
    </material>

    <link name="base_link">
        <visual>
            <geometry>
                <box size="0.6 0.4 0.2" />
            </geometry>
            <origin xyz="0 0 0.1" rpy="0 0 0" />
            <material name="blue" />
        </visual>
    </link>

    <link name="second_link">
        <visual>
            <geometry>
                <cylinder radius="0.1" length="0.2" />
            </geometry>
            <origin xyz="0 0 0.1" rpy="0 0 0" />
            <material name="grey" />
        </visual>
    </link>

    <joint name="base_second_joint" type="revolute">
        <parent link="base_link" />
        <child link="second_link" />
        <origin xyz="0 0 0.2" rpy="0 0 0" />
        <axis xyz="0 0 1" />
        <limit lower="-1.57" upper="1.57" velocity="100" effort="100" />
    </joint>

</robot>

Explanation of the code:

<axis xyz="0 0 1" /> This line specifies the axis the rotation will take place on.

<limit lower="-1.57" upper="1.57" velocity="100" effort="100" /> This line specifies: