Test FLL-style autonomous missions without a robot
Ready
Drive by hand: ↑↓←→ when no program is running
Gyro heading
0°
total turned 0°
Ultrasonic
---
Color sensor
white
reflected light 0%
Left motor
0°
power 0% · tacho
Right motor
0°
power 0% · tacho
Position x, y (cm)
0, 0
sim time 0.0 s
JavaScript with the same commands as the blocks. Robot commands take time, so put await in front of them. In your own loops, always await tick().
1
The robot
A two-wheel differential-drive robot (40 × 40 px ≈ 12 × 12 cm) with a free caster at the back. The color sensor looks down from the front bumper, and the ultrasonic sensor looks straight ahead (range 45 cm). The field is 240 × 120 cm, and 1 px = 0.3 cm.
Real-world noise makes the right motor about 3 % weaker, adds gyro drift and sensor jitter. drive(), driveUntilColor() and line following correct for it. Raw setMotors() and startDriving() don't, so watch the robot curve.
Speeds are motor power from −100 to 100 %. Angles are degrees, and right turns are positive. The gyro reads 0° in the direction the robot faced at the start.
Movement (await these)
drive(cm, speed=50)
Drive straight using the wheel encoders. Negative cm drives backward.
turn(deg, speed=30)
Spin in place using the gyro. Positive = right, negative = left.
turnTo(heading)
Turn to an absolute gyro heading.
driveUntilColor(c, speed=40)
Drive straight until the color sensor sees color c.
wait(seconds)
Do nothing for a while (the motors keep doing what they were doing).