Hands and feet · Robot club · about 20 min
See it, approach it, grip it, bring it home.
[1 mark]Put the stages of a fetch in order.
Number the lines 1 to 5 to put them in the right order.
Stop and close the jaws once the ball is in reachSteer towards the blob, slowing as distance() fallsOpen the jawsSpin until a red blob is in viewDrive home with go_to, holding the ballSpin until a red blob is in view Steer towards the blob, slowing as distance() falls Stop and close the jaws once the ball is in reach Drive home with go_to, holding the ball Open the jaws
Find it, go to it, grip it, bring it home, let go. Each stage is something from an earlier lesson.
[1 mark]What does this program print?
def bearing_of(cx):
return (cx - 160) * 120 / 320
print(bearing_of(240))
print(bearing_of(100))30.0 -22.5
The picture is 320 pixels across a 120 degree view, centred on 160. 240 is 80 pixels right, 30 degrees; 100 is 60 pixels left, -22.5 degrees.
[1 mark]What does this program print?
for d, error in [(30, 4), (30, 25), (8, 2)]:
speed = 15 if d < 10 else (45 if abs(error) < 10 else 20)
print(d, error, speed)30 4 45 30 25 20 8 2 15
Far and centred gets 45, far but still turning gets 20, and anything under 10 cm gets 15 whatever the error.
[1 mark]Why does fetch slow to 15 for the last few centimetres?
[1 mark]Inside fetch, the jaws close but holding() is None. What happens next?
[1 mark]fetch has used all 250 ticks without holding the ball. What does it do?
stop() then return False: the caller can tell the fetch failed.[1 mark]fetch waits 0.1 s each tick for up to 250 ticks. Ignoring the time spent gripping, what is the longest it can take, in whole seconds?
Find the red ball, fetch it, and leave it in the home zone.
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.