The worksheetDownload the PDF
Answers

7.2 The gripper

Hands and feet · Robot club · about 15 min

BugBotLab

What this lesson is about

grip, release, holding: knowing when you have something.

Questions 7 marks in all

  1. [1 mark]The jaws close on nothing. What does holding() return?

    1. ANone
    2. BFalse
    3. C0
    4. D"red"
    Answer: A. holding() is the colour of the ball in the jaws, or None when nothing is there.
  2. [1 mark]Put the lines in order to drive up to a ball, stop and grab it. (The loop body is shown on one line.)

    Number the lines 1 to 4 to put them in the right order.

    1. while distance() > 6: forward(40); wait(0.1)
    2. stop()
    3. print("holding:", holding())
    4. gripper("close")
    Answer:
    while distance() > 6: forward(40); wait(0.1)
    stop()
    gripper("close")
    print("holding:", holding())

    Arrive first, stop, then close the jaws. Checking holding() only makes sense after the grip.

  3. [1 mark]A ball is 20 cm ahead. A student writes gripper("close") and then forward(40, distance=20). What goes wrong?

    1. AThe jaws shut on nothing before the robot arrives, so the ball is never held
    2. BNothing: the gripper waits until the robot reaches the ball
    3. CThe robot cannot drive while the jaws are closed
    4. Dholding() says red as soon as the jaws close
    Answer: A. gripper("close") closes straight away. Drive to the ball first, then close.
  4. [1 mark]distance() reads 7.5 cm, measured from the robot's centre, and the front of the robot is 3.5 cm from its centre. How many cm is the ball in front of the robot's front edge? Give a whole number.

    Answer: 4. 7.5 - 3.5 = 4 cm. The jaws reach about 3 cm, so creep a little closer before gripping.
  5. [1 mark]What does gripper("open") do underneath?

    1. Aservo(0, 0) then wait(0.4)
    2. Bservo(0, 90) then wait(0.4)
    3. Cservo(1, 0) then wait(0.4)
    4. Dservo(0, 0) with no wait
    Answer: A. Open is servo 0 at 0 degrees, close is servo 0 at 90, and each waits 0.4 s so the next line runs once the jaws have moved.
  6. [1 mark]The robot grips the red ball, slides left 15 cm, turns 90 degrees and reverses 10 cm. What does holding() say now?

    1. Ared, because the ball rides in the jaws until they open
    2. BNone, because turning shakes the ball loose
    3. CNone, because reversing leaves the ball behind
    4. DIt depends which way the robot is facing
    Answer: A. Once held, the ball goes wherever the robot goes: turning, strafing and reversing included.
  7. [1 mark]On the real robot, where does holding() get its answer from?

    1. AThe camera, seeing a ball filling the bottom of the picture in front of the jaws
    2. BA touch sensor inside the jaws
    3. CThe servo feeling how hard it is pushing
    4. DThe radio
    Answer: A. The gripper has no sensor of its own. For a second opinion, distance() reads very short while a ball is held.

The task: grab the ball

Drive up to the ball, grip it, and print holding: red.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

# drive forward at 50 for 20 cm, then stop
forward(50, distance=20)
print("holding:", holding())

The hint students can ask for: Drive up to the ball until it is just in front of the gripper, close the jaws with gripper("close"), and print holding: red. The jaws reach about 3 cm past the front of the robot.

A solution

from bugbot import *
connect()
while distance() > 6:
    forward(40)
    wait(0.1)
stop()
gripper("close")
print('holding:', holding())

Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.