Lesson 1: Drive forward
หน้านี้ต้องใช้เบราว์เซอร์ล่าสุด (รองรับ SharedArrayBuffer) กรุณาอัปเดต Chrome, Edge, Firefox หรือ Safari เป็นเวอร์ชันล่าสุด
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.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
The goal is 600 mm in front of the robot. Drive into the green goal square and stop there.
คลิก Run เพื่อดูผลลัพธ์ที่นี่
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
This time the goal is behind the robot. Drive backwards 500 mm into the goal.
คลิก Run เพื่อดูผลลัพธ์ที่นี่