Lesson 1: Drive forward
Esta página precisa de um navegador recente (com suporte a SharedArrayBuffer). Por favor, atualize Chrome, Edge, Firefox ou Safari para a versão mais recente.
English
Meet the robot
- The robot drives on a playground: a square floor, 2000 mm on each side, with walls round the edge.
- You program it in Python, with the same commands as VEXcode VR (vr.vex.com). Code from here also works there.
- Press Run: the robot drives your program on the playground above the console.
Words for this lesson
| Word | Meaning |
|---|---|
| drivetrain | the wheels and motors that move the robot |
| FORWARD / REVERSE | drive to the front / drive backwards |
| mm | millimetres; 1000 mm = 1 metre |
| goal | the green square the robot must stop in |
English
Your first program
from vexcode_vr import *
def main():
drivetrain.drive_for(FORWARD, 400, MM)
vr_thread(main)
from vexcode_vr import *gives you the robot:drivetrain, its sensors and its pen.- Your commands go inside
main().vr_thread(main)starts it. VEXcode VR writes these lines for you, too. drivetrain.drive_for(FORWARD, 400, MM)drives 400 mm to the front, then stops.- Each square on the floor is 250 mm.
English
In the exam
IGCSE Computer Science (0478) often asks: what makes a machine a robot? The mark schemes give three characteristics:
| Characteristic | On your robot |
|---|---|
| a mechanical structure (a framework) | the body and the wheels |
| electrical components | motors, sensors, the brain |
| it is programmable | your Python program |
| it can move (some schemes) | drive_for |
- 0478/11/M/J/23 Q9(a): one characteristic of a robot is that it is programmable. State two other characteristics.
- 0478/11/M/J/24 Q8(b): give three characteristics of a robot.
- 0478/12/F/M/24 Q6(a): a self-driving tractor has a mechanical structure. Give one other reason why it is a robot.
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
The goal is 600 mm in front of the robot. Drive into the green goal square and stop there.
Clique em Executar para ver a saída aqui.
Dificuldade 1/5 · Moedas 100 + pequeno bônus na primeira conclusão hoje
This time the goal is behind the robot. Drive backwards 500 mm into the goal.
Clique em Executar para ver a saída aqui.