Hands and feet · Robot club · about 15 min
grip, release, holding: knowing when you have something.
[1 mark]The jaws close on nothing. What does holding() return?
[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.
while distance() > 6: forward(40); wait(0.1)stop()print("holding:", holding())gripper("close")[1 mark]A ball is 20 cm ahead. A student writes gripper("close") and then forward(40, distance=20). What goes wrong?
holding() says red as soon as the jaws close[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.
[1 mark]What does gripper("open") do underneath?
servo(0, 0) then wait(0.4)servo(0, 90) then wait(0.4)servo(1, 0) then wait(0.4)servo(0, 0) with no wait[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 mark]On the real robot, where does holding() get its answer from?
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())Plan your program here, then type it in and press Run.
distance() before and after the grip.servo(0, angle), in steps of 10 degrees with a short wait between, and print holding() at each step: at what angle does the ball get caught?