Lesson 15: Obstacle course
このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
English
Boxes in the way
- In the warehouse some boxes fell on the floor. The robot must still reach the green strip at the top.
- The boxes are in different places on every map, so the robot has to notice a box and go round it.
- The distance sensor looks straight ahead. A box close in front means: stop, and plan a detour.
Words for this lesson
| Word | Meaning |
|---|---|
| obstacle | something in your way |
| detour | a way round something, not straight through it |
| space | free room to drive |
| heading | the direction the robot faces: 0° up, 90° right, 180° down, 270° left |
English
A detour in three moves
| Move | Code | Robot faces |
|---|---|---|
| turn to the side | turn_for(RIGHT, 90, DEGREES) |
right (90°) |
| drive past the box | drive_for(FORWARD, 450, MM) |
right (90°) |
| face up again | turn_to_heading(0, DEGREES) |
up (0°) |
- A box here is 400 mm wide. 450 mm to the side is enough to pass it, even with the robot's own width.
English
Which way is the robot facing?
from vexcode_vr import *
def main():
drivetrain.turn_for(RIGHT, 90, DEGREES)
brain.print(drivetrain.heading())
brain.new_line()
drivetrain.turn_to_heading(0, DEGREES)
brain.print(drivetrain.heading())
vr_thread(main)
- The first number is 90.0: the robot faces right. After
turn_to_heading(0, DEGREES)it faces up again: 0.0.
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Boxes fell off a shelf in the warehouse. Drive up to the green strip at the top (Y is 750 or more). Drive 50 mm at a time. When a box is closer than 80 mm, go round it: turn right, drive 450 mm, and face up again with turn_to_heading(0, DEGREES). On these maps there is always room on the right.
実行ボタンをクリックして出力を確認してください。
難易度 4/5 · 280 コイン + 今日初回達成時の小ボーナス
Now some boxes are near the right wall. Before you go round a box, look: turn right, and if there is less than 500 mm of space, turn left 180° and go round on the left side instead.
実行ボタンをクリックして出力を確認してください。