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)

results matching ""

    No results matching ""