Use of gripper
Adaptive gripper
1. Set gripper mode
Before using, you need to use the set_gripper_mode
interface to set the gripper mode to 0
from pymycobot import Mercury
mc = Mercury('/dev/ttyAMA1')
mc.power_on()
mc.set_gripper_mode(0)
2. Gripper control
Angle control
Use the set_gripper_value
interface to set the gripper's opening angle
from pymycobot import Mercury
import time
mc = Mercury('/dev/ttyAMA1')
mc.power_on()
mc.set_gripper_value(0, 50)
time.sleep(2)
mc.set_gripper_value(100, 50)
time.sleep(2)
IO control
Use set_digital_output
interface to realize IO control gripper opening or closing
from pymycobot import Mercury
mc = Mercury('/dev/ttyAMA1')
mc.power_on()
mc.set_digital_output(1, 0)
mc.set_digital_output(2, 1)
time.sleep(2)
mc.set_digital_output(1, 1)
mc.set_digital_output(2, 0)
time.sleep(2)
Note: By default, IO control can be used directly. If the gripper mode is set to 0, you need to set the gripper mode to 1 first, that is,
set_gripper_mode(1)
, and then use IO control. If IO control cannot be used after setting it to 1, you need to power on again.
Electric gripper
1. Initialize the gripper
Use init_electric_gripper
interface to initialize the gripper
from pymycobot import Mercury
mc = Mercury('/dev/ttyAMA1')
mc.power_on()
mc.init_electric_gripper()
2. Gripper control
Use set_electric_gripper
interface to control the opening or closing of the gripper
from pymycobot import Mercury
import time
mc = Mercury('/dev/ttyAMA1')
mc.power_on()
# Open the gripper
mc.set_electric_gripper(0)
time.sleep(2)
# Close the gripper
mc.set_electric_gripper(1)
myGripper F100 force-controlled gripper
Use the
set_pro_gripper_angle
interface to control the opening or closing of the gripper.from pymycobot import Mercury import time mc = Mercury('/dev/ttyAMA1') mc.power_on() # Open the gripper-left arm mc.set_pro_gripper_angle(14, 100) time.sleep(2) # Close the gripper-left arm mc.set_pro_gripper_angle(14, 0)
Use the
set_pro_gripper_open
andset_pro_gripper_close
interfaces to control the opening or closing of the gripper.from pymycobot import Mercury import time mc = Mercury('/dev/ttyAMA1') mc.power_on() # Open gripper - left arm mc.set_pro_gripper_open(14) time.sleep(2) # Close gripper - left arm mc.set_pro_gripper_close(14)
myGripper H100 three-finger gripper
Use set_hand_gripper_pinch_action_speed_consort
interface to control the pinching action of the gripper.
from pymycobot import Mercury
import time
mc = Mercury('/dev/ttyAMA1')
mc.power_on()
# All joints return to zero - left arm
mc.set_hand_gripper_pinch_action_speed_consort(0,5,14)
time.sleep(3)
# Index finger and thumb pinch - left arm
mc.set_hand_gripper_pinch_action_speed_consort(1,5,14)
time.sleep(3)
# Middle finger and thumb pinch - left arm
mc.set_hand_gripper_pinch_action_speed_consort(2,5,14)
time.sleep(3)
# Index finger and middle finger pinch - left arm
mc.set_hand_gripper_pinch_action_speed_consort(3,5,14)
time.sleep(3)
# Three fingers together - left arm
mc.set_hand_gripper_pinch_action_speed_consort(4,5,14)
time.sleep(3)
# All joints return to zero - left arm
mc.set_hand_gripper_pinch_action_speed_consort(0,5,14)
time.sleep(3)