Lesson 1: Drive forward
Esta página necesita un navegador reciente (con soporte para SharedArrayBuffer). Por favor, actualiza Chrome, Edge, Firefox o Safari a la última versión.
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.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
The goal is 600 mm in front of the robot. Drive into the green goal square and stop there.
Haz clic en Ejecutar para ver la salida aquí.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
This time the goal is behind the robot. Drive backwards 500 mm into the goal.
Haz clic en Ejecutar para ver la salida aquí.