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?
holding() is the colour of the ball in the jaws, or None when nothing is there.[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")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.
[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 closegripper("close") closes straight away. Drive to the ball first, then 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?
distance() reads very short while a ball is held.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.
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.