3.12. Gripper#
The gripper actuator attachment allows us to grab, hold and drag objects securely while the robot is moving. Opening and closing of the gripper jaws is controlled by a servo, which is a type of motor that holds a desired angle.
The two servo connectors onboard the Maqueen are controlled over the I2C protocol.
Note
We’ll learn how servos work in an upcoming lesson.
Warning
Watch your fingers when using the gripper!
3.12.1. Gripper Control#
The gripper can be actuated by setting an angle value between 0 and 180 degrees.
For your convenience we’ve provided some code to get started:
def servo_one(angle=0):
buf = bytearray(2)
buf[0] = 0x14
buf[1] = angle
i2c.write(0x10, buf)
You will also need to initialise the I2C interface by putting this line at the top of your script:
i2c.init()
Examples#
To completely close the gripper:
servo_one(180)
To completely open the gripper:
servo_one(0)
Hint
The actual values required will depend on how the servo is installed during assembly. You’ll need to find the sweet spot by checking when the end points are reached. In our testing we found that 130 and 65 degrees worked well.