Make a Simple Gripper


Overview

This tutorial describes how to make a simple two-bar pinching gripper by editing SDF files.

For editing models graphically, see the Model Editor tutorial.

Setup your model directory

Reference Model Database documentation and SDF documentation for this tutorial.

Make the model

  1. Create a directory for the world file.

    mkdir ~/simple_gripper_tutorial; cd ~/simple_gripper_tutorial
    
  2. We will begin with a simple empty world. Create a world file:

    gedit ~/simple_gripper_tutorial/gripper.world
    

    Copy the following SDF into gripper.world:

    <?xml version="1.0"?>
      <sdf version="1.4">
        <world name="default">
    
        <!-- A ground plane -->
        <include>
          <uri>model://ground_plane</uri>
        </include>
    
        <!-- A global light source -->
        <include>
          <uri>model://sun</uri>
        </include>
    
        <include>
          <uri>model://my_gripper</uri>
        </include>
    
        </world>
      </sdf>
    
  3. Create a model directory inside ~/.gazebo. This is where we'll put the model files:

    mkdir -p ~/.gazebo/models/my_gripper
    cd ~/.gazebo/models/my_gripper
    
  4. Let's layout the basic structure of our gripper. The easiest way to accomplish this is to make a static model and add in the links one at a time. A static model means the links will not move when the simulator starts. This will allow you to start the simulator, and visually inspect the link placement before adding joints.

  5. Create a model.config file:

    gedit model.config
    
  6. And copy the following contents:

    <?xml version="1.0"?>
    
    <model>
      <name>My Gripper</name>
      <version>1.0</version>
      <sdf version='1.4'>simple_gripper.sdf</sdf>
    
      <author>
        <name>My Name</name>
        <email>me@my.email</email>
      </author>
    
      <description>
        My awesome robot.
      </description>
    </model>
    
  7. Likewise, create a simple_gripper.sdf file:

    gedit simple_gripper.sdf
    
  8. And copy the following code into it:

    <?xml version="1.0"?>
    <sdf version="1.4">
        <model name="simple_gripper">
            <link name="riser">
                <pose>-0.15 0.0 0.5 0 0 0</pose>
                <inertial>
                    <pose>0 0 -0.5 0 0 0</pose>
                    <inertia>
                        <ixx>0.01</ixx>
                        <ixy>0</ixy>
                        <ixz>0</ixz>
                        <iyy>0.01</iyy>
                        <iyz>0</iyz>
                        <izz>0.01</izz>
                    </inertia>
                    <mass>10.0</mass>
                </inertial>
                <collision name="collision">
                    <geometry>
                        <box>
                            <size>0.2 0.2 1.0</size>
                        </box>
                    </geometry>
                </collision>
                <visual name="visual">
                    <geometry>
                        <box>
                            <size>0.2 0.2 1.0</size>
                        </box>
                    </geometry>
                    <material>
                        <script>Gazebo/Purple</script>
                    </material>
                </visual>
            </link>
            <link name="palm">
                <pose>0.0 0.0 0.05 0 0 0</pose>
                <inertial>
                    <inertia>
                        <ixx>0.01</ixx>
                        <ixy>0</ixy>
                        <ixz>0</ixz>
                        <iyy>0.01</iyy>
                        <iyz>0</iyz>
                        <izz>0.01</izz>
                    </inertia>
                    <mass>0.5</mass>
                </inertial>
                <collision name="collision">
                    <geometry>
                        <box>
                            <size>0.1 0.2 0.1</size>
                        </box>
                    </geometry>
                </collision>
                <visual name="visual">
                    <geometry>
                        <box>
                            <size>0.1 0.2 0.1</size>
                        </box>
                    </geometry>
                    <material>
                        <script>Gazebo/Red</script>
                    </material>
                </visual>
            </link>
            <link name="left_finger">
                <pose>0.1 0.2 0.05 0 0 -0.78539</pose>
                <inertial>
                    <inertia>
                        <ixx>0.01</ixx>
                        <ixy>0</ixy>
                        <ixz>0</ixz>
                        <iyy>0.01</iyy>
                        <iyz>0</iyz>
                        <izz>0.01</izz>
                    </inertia>
                    <mass>0.1</mass>
                </inertial>
                <collision name="collision">
                    <geometry>
                        <box>
                            <size>0.1 0.3 0.1</size>
                        </box>
                    </geometry>
                </collision>
                <visual name="visual">
                    <geometry>
                        <box>
                            <size>0.1 0.3 0.1</size>
                        </box>
                    </geometry>
                    <material>
                        <script>Gazebo/Blue</script>
                    </material>
                </visual>
            </link>
            <link name="left_finger_tip">
                <pose>0.336 0.3 0.05 0 0 1.5707</pose>
                <inertial>
                    <inertia>
                        <ixx>0.01</ixx>
                        <ixy>0</ixy>
                        <ixz>0</ixz>
                        <iyy>0.01</iyy>
                        <iyz>0</iyz>
                        <izz>0.01</izz>
                    </inertia>
                    <mass>0.1</mass>
                </inertial>
                <collision name="collision">
                    <geometry>
                        <box>
                            <size>0.1 0.2 0.1</size>
                        </box>
                    </geometry>
                </collision>
                <visual name="visual">
                    <geometry>
                        <box>
                            <size>0.1 0.2 0.1</size>
                        </box>
                    </geometry>
                    <material>
                        <script>Gazebo/Blue</script>
                    </material>
                </visual>
            </link>
            <link name="right_finger">
                <pose>0.1 -0.2 0.05 0 0 .78539</pose>
                <inertial>
                    <inertia>
                        <ixx>0.01</ixx>
                        <ixy>0</ixy>
                        <ixz>0</ixz>
                        <iyy>0.01</iyy>
                        <iyz>0</iyz>
                        <izz>0.01</izz>
                    </inertia>
                    <mass>0.1</mass>
                </inertial>
                <collision name="collision">
                    <geometry>
                        <box>
                            <size>0.1 0.3 0.1</size>
                        </box>
                    </geometry>
                </collision>
                <visual name="visual">
                    <geometry>
                        <box>
                            <size>0.1 0.3 0.1</size>
                        </box>
                    </geometry>
                    <material>
                        <script>Gazebo/Green</script>
                    </material>
                </visual>
            </link>
            <link name="right_finger_tip">
                <pose>0.336 -0.3 0.05 0 0 1.5707</pose>
                <inertial>
                    <inertia>
                        <ixx>0.01</ixx>
                        <ixy>0</ixy>
                        <ixz>0</ixz>
                        <iyy>0.01</iyy>
                        <iyz>0</iyz>
                        <izz>0.01</izz>
                    </inertia>
                    <mass>0.1</mass>
                </inertial>
                <collision name="collision">
                    <geometry>
                        <box>
                            <size>0.1 0.2 0.1</size>
                        </box>
                    </geometry>
                </collision>
                <visual name="visual">
                    <geometry>
                        <box>
                            <size>0.1 0.2 0.1</size>
                        </box>
                    </geometry>
                    <material>
                        <script>Gazebo/Green</script>
                    </material>
                </visual>
            </link>
            <static>true</static>
        </model>
    </sdf>
    
  9. Run the world file to visualize what we have created up to this point.

    gazebo ~/simple_gripper_tutorial/gripper.world
    

    You should see something like this:

  10. Once we are happy with the layout of the links, we can add in the joints, by copying the following code into the simple_gripper.sdf file before the </model> line.

    gedit ~/.gazebo/models/my_gripper/simple_gripper.sdf
    
            <joint name="palm_left_finger" type="revolute">
                <pose>0 -0.15 0 0 0 0</pose>
                <child>left_finger</child>
                <parent>palm</parent>
                <axis>
                    <limit>
                        <lower>-0.4</lower>
                        <upper>0.4</upper>
                    </limit>
                    <xyz>0 0 1</xyz>
                </axis>
            </joint>
            <joint name="left_finger_tip" type="revolute">
                <pose>0 0.1 0 0 0 0</pose>
                <child>left_finger_tip</child>
                <parent>left_finger</parent>
                <axis>
                    <limit>
                        <lower>-0.4</lower>
                        <upper>0.4</upper>
                    </limit>
                    <xyz>0 0 1</xyz>
                </axis>
            </joint>
            <joint name="palm_right_finger" type="revolute">
                <pose>0 0.15 0 0 0 0</pose>
                <child>right_finger</child>
                <parent>palm</parent>
                <axis>
                    <limit>
                        <lower>-0.4</lower>
                        <upper>0.4</upper>
                    </limit>
                    <xyz>0 0 1</xyz>
                </axis>
            </joint>
            <joint name="right_finger_tip" type="revolute">
                <pose>0 0.1 0 0 0 0</pose>
                <child>right_finger_tip</child>
                <parent>right_finger</parent>
                <axis>
                    <limit>
                        <lower>-0.4</lower>
                        <upper>0.4</upper>
                    </limit>
                    <xyz>0 0 1</xyz>
                </axis>
            </joint>
            <joint name="palm_riser" type="prismatic">
                <child>palm</child>
                <parent>riser</parent>
                <axis>
                    <limit>
                        <lower>0</lower>
                        <upper>0.9</upper>
                    </limit>
                    <xyz>0 0 1</xyz>
                </axis>
            </joint>
    

    And make the model non-static:

            ...
            <static>false</static>
            ...
    
  11. Start Gazebo again:

    gazebo ~/simple_gripper_tutorial/gripper.world
    
  12. Right-click on the model and select "View->Joints" and "View->Wireframe". The newly created joints will be displayed:

  13. You can also control the forces on each joint using the Joint Control widget. Click on the gripper model. Then expand this widget by clicking on the vertical handle on the right side of the GUI and dragging it to the left. The widget displays a list of sliders, one for each joint. Select the Force tab and use the sliders to apply forces to each joint, and you should see the gripper move. E.g., set the force on palm_riser to 10 (Newtons), and you should see something like:

  14. Optional:

    1. Add a small box or cylinder to the world, and position it in the gripper.
    2. Try to use the joint control GUI interface to pick up the object.

    Tip: You may need to adjust reasonable inertia to the object.

Next

Next: Attach Gripper to Robot