Lesson 8: Bumpers
تحتاج هذه الصفحة إلى متصفح حديث (يدعم SharedArrayBuffer). يرجى تحديث Chrome أو Edge أو Firefox أو Safari إلى أحدث إصدار.
English
Bumpers
- At the front the robot has two bumper switches, left and right.
left_bumper.pressed()isTruewhile the bumper touches something.- A bumper finds a wall by touching it, so here touching is allowed.
Words for this lesson
| Word | Meaning |
|---|---|
| bumper | a switch that is pressed when the robot touches something |
| pressed | the switch is pushed in |
| not | turns True into False and False into True |
| back up | drive backwards a little |
English
Bump and back up
from vexcode_vr import *
def main():
drivetrain.drive(FORWARD)
while not left_bumper.pressed():
wait(5, MSEC)
drivetrain.drive_for(REVERSE, 100, MM)
vr_thread(main)
while not left_bumper.pressed():keeps waiting while the bumper is not pressed.- When the robot touches the wall, the loop ends and it backs up.
الصعوبة 2/5 · 140 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Drive until the left bumper is pressed, then back up 200 mm. The wall is in a different place on each map.
اضغط تشغيل لرؤية المخرجات هنا.
الصعوبة 3/5 · 200 عملة + مكافأة صغيرة عند الإنجاز الأول اليوم
Bump the wall in front, back up 100 mm, turn right 90 degrees, then drive until you bump the next wall. Use a function bump() for "drive until a bumper is pressed".
اضغط تشغيل لرؤية المخرجات هنا.