To control the Brooks PreciseFlex grippers from a simulation, including the dual gripper, follow the steps outlined in this section.
1.Right-click your program, and add aProgram Call Instruction.
2.Enter “Gripper(gripper ID, gripper value)”。例如,爪(50)把钳子#2 of a dual gripper to 50 mm. Note that you can use Gripper(50) with a single gripper.
3.Add a Python script, rename it to “Gripper”.
4.Edit the “Gripper” Python script and paste the following:
from robodk import robolink
import sys
if len(sys.argv) < 2:
quit()
gripper_id = -1
gripper_value = int(sys.argv[1])
if len(sys.argv) > 2:
# Dual gripper
gripper_id = int(sys.argv[1])
gripper_value = float(sys.argv[2])
RDK = robolink.Robolink()
# Retrieve all available Brooks grippers
grippers = [x for x in RDK.ItemList(robolink.ITEM_TYPE_ROBOT_AXES) if len(x.Joints().tolist()) == 1 and 'Brooks' in x.Name()]
if not grippers:
RDK.ShowMessage('Unable to find a gripper!', False)
# Try to find the right gripper id (i.e. Dual Gripper 1)
gripper = grippers[0]
if gripper_id > 0:
gripper_ids = [g for g in grippers if g.Name().endswith(str(gripper_id))]
if gripper_ids:
gripper = gripper_ids[0]
gripper.MoveJ([gripper_value])
Note that this method is also compatible with the Brooks post processor.