Lesson 12: Follow the tape
Robots in a factory
- Many factory robots follow tape on the floor. People can change the route with a roll of tape, not with new code.
- The down eye under the robot sees the colour of the floor. On the tape
down_eye.detect(BLACK)isTrue. - The eye only sees the spot under the middle of the robot. So the robot cannot see a corner coming: it notices the corner when the tape is gone.
Words for this lesson
| Word | Meaning |
|---|---|
| tape | a long strip stuck on the floor |
| loading bay | the place where goods are put on a lorry |
| corner | where the tape changes direction |
| guess | try one way without knowing if it is right |
| trial and error | try, look, go back if you were wrong |
Black or not black?
from vexcode_vr import *
def main():
drivetrain.drive_for(FORWARD, 300, MM)
if down_eye.detect(BLACK):
brain.print("on the tape")
else:
brain.print("no tape here")
vr_thread(main)
- Here the floor is empty, so the robot prints
no tape here. On a task map, try it at the start of the tape.
How the robot finds a corner
- On black: drive 25 mm, then look again.
- Not black: the robot has gone past the corner. Drive back 50 mm: the eye is on the corner again.
- Turn and go on along the new piece of tape.
- Short steps are slower, but the robot can never go far off the tape.
Dificuldade 3/5 · Moedas 200 + pequeno bônus na primeira conclusão hoje
In the factory, black tape on the floor shows the way to the green loading bay. On these maps the tape only turns left. While the down eye sees black, drive 25 mm. When the robot loses the tape, it has gone past a corner: drive back 50 mm and turn left 90°.
Clique em Executar para ver a saída aqui.
Dificuldade 4/5 · Moedas 280 + pequeno bônus na primeira conclusão hoje
Now the tape turns left and right. At a corner, try left first: turn left 90° and drive 100 mm. If the eye sees black, you found the tape. If not, drive back 100 mm and turn right 180°. Reach the green bay on every map.
Clique em Executar para ver a saída aqui.