Competing · Robot club · about 25 min
Light Cycles, Rescue Line or Capture the Flag: how to practise one properly, and the line and gripper rehearsal.
[1 mark]Which game do you play on your own, after Module 7, using the line and the gripper at once?
[1 mark]Put the steps for getting good at a game in order.
Number the lines 1 to 5 to put them in the right order.
Change one thing at a timeThen play peoplePrint, race, readBeat one botRead the game pageRead the game page Beat one bot Print, race, read Change one thing at a time Then play people
Know the rules and what info() gives, beat the bot that beats you most, learn from your log, and only then take it to a room.
[1 mark]You change your top speed and your turning gain together, and the next race is better. What have you learned?
[1 mark]What does this program print?
for cx in [200, 160, 100]:
print(cx, round((cx - 160) * 0.35, 1))200 14.0 160 0.0 100 -21.0
The turn is how far the line is from the middle of the picture times 0.35. Right of centre gives a positive, clockwise turn; left gives a negative one.
[1 mark]In the carry-home task, when should the jaws close?
[1 mark]In the rehearsal, line() sees nothing and the robot runs drive(25, 0, 40). What is it doing?
Follow the black line to the red ball, pick it up with the gripper, and carry it into the green zone at the end without dropping it. The line bends to the right, so driving straight up the mat misses the ball by 15 cm: the line is the only way to it.
from bugbot import *
connect()
set_cv('line')
gripper("open")
# follow the line first: steer by where it is and where it is going,
# and slide sideways onto it if you drift
while position()[1] < 40:
seen = line()
if seen:
cx, angle = seen
drive(35, (cx - 160) * 0.15, (cx - 160) * 0.15 + angle * 1.5)
else:
forward(20)
wait(0.1)
stop()The hint students can ask for: The line bends to the right, and the ball is at its end, 15 cm to the side of where you start: drive straight and you miss it. Follow the line all the way, steering with where it is going as well as where it is, and slide sideways onto it if you drift. Close the gripper on the ball, then carry it into the green zone without letting go.
from bugbot import *
connect()
set_cv('line')
gripper('open')
# follow the line, using where it is going as well as where it is, until the ball is in the jaws
while not holding() and position()[1] < 56:
seen = line()
if seen:
cx, angle = seen
drive(35, (cx - 160) * 0.15, (cx - 160) * 0.15 + angle * 1.5)
else:
forward(20)
wait(0.1)
stop()
gripper('close')
wait(0.6)
# carry it home, holding the heading straight up the mat
while position()[1] < 78:
err = (0 - heading() + 180) % 360 - 180
drive(45, 0, max(-30, min(30, err * 1.5)))
wait(0.1)
stop()
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.