Digital I/O Gripper Control

What you will learn

You will learn how to set data store values and set position states of the Festo Gripper in EcScript. The digital I/O signal will be sent to the UR controller and you will be able to see I/O toggle on the teach pendant.

Prequisites

Set Position State

Setting the position state of the Festo gripper is an option in EcScript to get the Festo gripper to open and close in simulation. There is a total distance of 40mm when the gripper is fully open. The Extrusion Bar has a width and height of 25mm. To make the contact point of the gripper fingers to the Extrusion Bar, the gripper must close at a distance of 15mm or 7.5mm per finger. The function used to set the position state of the gripper is set_position_state. First let's get the robot to a pickable state.

  1. Go to the 3D Model Page
  2. Select Script File as CollisionMoveJoint1.ecs
  3. Put the Mode Selection in Servo
  4. Play the simulation
  5. Select Script File as CollisionExclusion1.ecs
  6. Play the simulation

If you don't have CollisionMoveJoint1.ecs or CollisionExclusion1.ecs, please refer to Collision Maps.

The robot should be in this state:

Let's take a closer look at the Festo gripper state:

It is in an open state and visually it is not touching the bar.

Note: To have meshes touch, the links must be excluded in the collision map.

Let's have the gripper grasp the bar in simulation. Go to the Scripting Page, create a New File, and paste the following:

(motion_seq
    # Gripper Manipulator Index
    (def_u32 manip_id_gripper 2)

    # Finger 1 joint position
    (def_real joint_position_finger1 7.5mm)

    # Finger 2 joint position
    (def_real joint_position_finger2 7.5mm) 

    # Close Gripper
    (set_position_state 
        manip_id_gripper
        (joint_position_finger1 joint_position_finger2)
    )
)

Save As GripperClose1.ecs

  1. Go back to the 3D Model Page
  2. Select Script File as GripperClose1.ecs
  3. Make sure the Mode Selection is in Servo
  4. Play the simulation

The gripper should close to the contact point of the Extrusion Bar:

Tip: An attach_manip function should be called to attach the bar to the gripper to perform a grasp.

Just set the joint positions to 0 to open the gripper. Go back to the Scripting Page, create a New File, and paste:

(motion_seq
    # Gripper Manipulator Index
    (def_u32 manip_id_gripper 2)

    # Finger 1 joint position
    (def_real joint_position_finger1 0.0)

    # Finger 2 joint position
    (def_real joint_position_finger2 0.0)   

    #Close Gripper
    (set_position_state 
        manip_id_gripper
        (joint_position_finger1 joint_position_finger2)
    )
)

Save As GripperOpen1.ecs

  1. Go to the 3D Model Page
  2. Select Script File as GripperOpen1.ecs
  3. Set the Mode Selection to Servo
  4. Play the simulation

The Gripper should open:

Digital IO

The robot is now able to open and close the gripper in simulation. This Festo gripper is simple to control and it is through Digital I/O pins. The gripper is connected to Digital Output 0 to close the gripper and Digital Output 1 to open the gripper. But, how do we get that to signal to a digital output on the UR controller? set_data_store_u8 must be used to communicate with the digital pins of the UR controller. It is an Actin RCF extension that provides the ability to set data store values from EcScript.

Go to the Scripting Page, create a New File, and input:

(motion_seq
    ##### Setup #####
    # Gripper Manipulator Index
    (def_u32 manip_id_gripper 2)

    # Finger 1 joint position open
    (def_real joint_position_finger_open1 0.0)

    # Finger 2 joint position open
    (def_real joint_position_finger_open2 0.0)

    # Finger 1 joint position close
    (def_real joint_position_finger_close1 7.5mm)

    # Finger 2 joint position close
    (def_real joint_position_finger_close2 7.5mm)

    # Standard digital output mask key
    (def_string key_std_digital_output_mask "STANDARD_DIGITAL_OUTPUT_MASK")

    # Standard digital output key
    (def_string key_std_digital_output "STANDARD_DIGITAL_OUTPUT")

    # RTDE path
    (def_string path_rtde "/transfer_layers/rtde")

    # Binary 1, 0000 0001
    (def_u32 binary_1 1)

    # Binary 2, 0000 0010
    (def_u32 binary_2 2)

    # Binary 3, 0000 0011
    (def_u32 binary_3 3)

    # Set digital output mask to binary 3, 0000 0011
    (set_data_store_u8
        key_std_digital_output_mask
        path_rtde
        binary_3
    )

    ##### Functions #####
    # Close Gripper
    (def_fun gripper_close ()
        # Wait 1s
        (wait 1.0)
        # Close gripper state
        (set_position_state 
            manip_id_gripper
            (joint_position_finger_close1 joint_position_finger_close2)
        )
        # Digital Output 0 - Gripper Close, binary = 1, 0000 0001
        (set_data_store_u8
            key_std_digital_output
            path_rtde
            binary_1
        )
        # Wait 1s
        (wait 1.0)
    )

    # Open Gripper
    (def_fun gripper_open ()
        # Wait 1s
        (wait 1.0)
        # Open gripper state
        (set_position_state 
            manip_id_gripper
            (joint_position_finger_open1 joint_position_finger_open2)
        )
        # Digital Output 0 - Gripper Close, binary = 1, 0000 0001
        (set_data_store_u8
            key_std_digital_output
            path_rtde
            binary_2
        )
        # Wait 1s
        (wait 1.0)
    )

    ##### Main #####
    (gripper_close)

    (gripper_open)
)