Today’s mission 5 min
Decide which missions to attempt, in what order, and what the robot does when a step goes wrong.
A WRO run lasts two minutes. You cannot do everything well in two minutes, so you must choose. Today the choice is made with numbers from your scoresheets, not with feelings.
Check this season’s General Rules. Mission points, bonuses and penalties change every season. The method in this lesson does not.
The idea — points per second, and plan B 10 min
For each mission you can do, you need three numbers:
- Points — from this season’s scoresheet.
- Seconds — measured with a
StopWatch, including the drive there. - Success rate — from your ten-run scoresheet in lesson 20.
Then work out two more:
- Expected points = points × success rate. A 40-point mission that works half the time is worth about 20.
- Points per second = expected points ÷ seconds. This is how much each second of the run earns you.
Start with the missions that earn most per second. Leave low-earning, risky missions to the end, or leave them out.
Plan B. Every risky step gets two things: a time limit, and a decision about what to do when the limit is reached. Usually that is “skip this mission and go on” or “go home now with what you have”.
Watch the whole clock too. If the run is nearly over, the robot should stop starting new missions and finish cleanly. Check this season’s rules for what scores at the end of a run.
Blocks vs Python 15 min
A fallback in both languages: drive towards a line, but give up after three seconds instead of driving for ever.
SPIKE word blocks
when program starts :: events hat reset timer :: sensors start moving (straight: 0) :: movement wait until <<(E v) reflection [< v] (30) %? :: sensors> or <(timer :: sensors) > (3)>> stop moving :: movement if <(timer :: sensors) > (3)> then write [SKIP] :: display end
Pybricks Python
from pybricks.tools import wait, StopWatch from base import hub, robot, left_eye watch = StopWatch() robot.drive(150, 0) while left_eye.reflection() > 30: if watch.time() > 3000: break wait(10) robot.stop() found = left_eye.reflection() <= 30 if not found: hub.display.text("SKIP") print("line not found: skipping")
| Block | Python | Watch out |
|---|---|---|
| wait until <A or B> | while not A: if B: break | Python checks the reflection AND the clock every time round the loop. |
| timer > 3 | watch.time() > 3000 | Seconds in SPIKE, milliseconds in Pybricks. |
| (nothing) | found = … | Keep the result. The rest of the run decides what to do next. |
SPIKE word blocks
Pybricks Python
missions = { "tower": {"points": 30, "seconds": 25, "rate": 0.9}, "cubes": {"points": 40, "seconds": 45, "rate": 0.5}, "flag": {"points": 10, "seconds": 8, "rate": 1.0}, } for name in missions: m = missions[name] expected = m["points"] * m["rate"] per_second = expected / m["seconds"] print(name, "expected", expected, "per second", round(per_second, 2))
| Block | Python | Watch out |
|---|---|---|
| (nothing) | missions["tower"]["points"] | A dictionary inside a dictionary: mission, then the number you want. |
| (nothing) | round(per_second, 2) | Two decimal places are plenty for comparing. |
These numbers are made up. Use your own points, times and success rates. This program can run on the hub or in any Python on a laptop.
Write it from scratch 20 min
- Fill in the planning dictionary with your missions and your numbers. Print the expected points and points per second for each.
- Write the run order on paper, highest points per second first. Add the total seconds. If it is over two minutes, cut from the bottom of the list.
- In your mission runner, add a time limit and a plan B to the riskiest step of every mission.
- Add a whole-run clock. Before each new mission, check how long is left. If there is not enough time for it, go home instead.
A whole-run clock
run_clock = StopWatch() RUN_LIMIT = 110000 # leave yourself a margin before 2 minutes def time_left(): return RUN_LIMIT - run_clock.time() if time_left() > 25000: tower() else: go_home()
Test and measure 15 min
- Run the full plan three times with a stopwatch. Was it inside two minutes every time? By how much?
- Make a step fail on purpose: block the line, or move an object. Does plan B start? Does the robot carry on to the next mission?
- Start the run late on purpose, so the whole-run clock is low. Does the robot go home instead of starting a mission it cannot finish?
- Score each run on this season’s scoresheet. Is the total close to the expected points you calculated?
Break it, fix it 10 min
Each program has one mistake. Only one of them gives an error message.
Bug 1
watch = StopWatch()
robot.drive(150, 0)
while left_eye.reflection() > 30:
if watch.time() > 3:
break
wait(10)
robot.stop()Bug 2
watch = StopWatch()
robot.drive(150, 0)
while left_eye.reflection() > 30:
if watch.time() > 3000:
break
wait(10)
print("line found")Bug 3
for name in missions:
m = missions[name]
per_second = m["points"] * m["rate"] / m["second"]
print(name, per_second)Bug 2 is a robot that never stops. It also prints “line found” when it gave up. Fix the stop first, then make the message tell the truth.
Solo challenge — no coach 10 min
No coach, no help. At WRO your coach may not touch the robot or the code. Close this page. You may use your own earlier programs and the Pybricks documentation, nothing else.
The lost minute. Pretend the first 60 seconds of your run are gone: a mission went badly and you restarted. You have one minute left.
- Using your numbers, choose the missions that earn most in 60 seconds.
- Make a one-minute run from your mission runner.
- Run it twice, timed, and score both runs.
Done means: both runs finish inside 60 seconds, and you can show the numbers that chose the missions.
Engineering journal 5 min
Today’s entry:
- your planning table: points, seconds, rate, expected, per second
- the full-run order, and the one-minute order
- each risky step, its time limit and its plan B
- expected points against the points you actually scored